[R] Lowest number in a numeric string
Jim Lemon
jim at bitwrit.com.au
Thu Jun 14 11:26:49 CEST 2012
On 06/14/2012 06:08 PM, mogwai84 wrote:
> Hi all,
>
> I've got a very long numeric string. I want to find the lowest number that
> isn't in that string.
>
> E.G
>
> String = 123456
> Therefore 7 is the lowest number not in that string
>
> E.G.2
>
> String = 1234567891011
> Therefore 13 is the lowest number not in that string.
>
> Any thoughts? p.s. I'm an R noob.
>
Hi mogwai84,
Your second example is inconsistent with the first. If the answer is not
12, then you must be counting the first two digits as a pair. However,
that can't be right, because there are several other pairs that are much
larger than 13. Are you making the assumption that all strings of digits
contain monotonically increasing integers? Without a better
specification of the problem, one can only guess at a solution.
Jim
More information about the R-help
mailing list