On Thu, Jul 17, 2008 at 3:44 PM, Robert D. [email protected]
true while restricted_numbers.include?(n+=1)
I think there is a typo in here
Did you mean
42 while restricted_numbers.include?( n+= 1 )
of course you did.
Now to add injustice to injury
n = ([*n.succ…rn.max.succ]-rn).min || n.succ
This will be about 10 times slower than David’s beautiful code.
However in some extreme cases, e.g. very densely populated rn arrays
this functional approach becomes more interesting.
If rn is [*1…1_000] the functional code runs 50 times faster, and if
you have to jump over an restricted
numbers array of [*1…10_000] the functional code runs 500 times faster.
So maybe just in case you can afford the extra runtime for the
“normal” case you can assure nice performance in edge cases by the
AALST (n.) One who changes his name to be further to the front
D.Adams; The Meaning of LIFF