# Hackerrank – Separate the Numbers

## Hackerrank – Problem Statement

A description of the problem can be found on Hackerrank.

## Solution

I explain my solution with following examples:

Example `1234`
I start with a beginning of a string, which would be one digit number – `1` and try to examine a rest of the given string `234`.

Next, I check the greater number than `1` in the rest of the string `234`.
The next number to examine is `2` which should follow.
It is at the beginning of the rest `234`. The next rest is `34`.
The next number should be `3`. It is at the beginning of the rest.
Then the next rest is `4`. And the next number should be `4` because it is an increment of previous number `3`.
The number and the rest are the same. The number `1234` is beautiful

Example `101103`
I start with a beginning of a string, which would be one digit number – `1` and try to examine a rest of the given string `01103`.
The next number should be `2`. But the rest of the string does not start with `2`.
I need to examine two digit numbers.

If I start with `10`, the rest of the string is `1103`.
The next number should be `11` and it is at the beginning, my next rest is `03`.
The next number should be `12` but it is not equal to the rest `03`

Last, I try with `101` and the rest is `103`.
The next should be `102`, but is is not. That means that `101103` is not beautiful.

Javascript solution does not work for a number 9007199254740992.

I created solution in:

All solutions are also available on my GitHub profile.