The best challenge (please read!)
Hiya guys,
I came across this pretty little problem a while ago, and I was wondering if anyone here wanted to give it a crack.
It was invented by a guy called Cedric beust, so here it is:
Quote:
Here is an interesting coding challenge: write a counter function that counts from 1 to max but only returns numbers whose digits don’t repeat.
For example, part of the output would be:
8, 9, 10, 12 (11 is not valid)
98, 102, 103 (99, 100 and 101 are not valid)
5432, 5436, 5437 (5433, 5434 and 5435 are not valid)
Also:
Display the biggest jump (in the sequences above, it’s 4: 98 -> 102)
Display the total count of numbers
Give these two values for max=10000
Anyone want a shot?
Bernie