Countdown
Your goal for this code-golf challenge is to count down and meanwhile recycle numbers. Let me explain.
First your application reads a number, either as program argument or using stdin.
Next you'll simply need to count down like this:
10 9 8 7 6
(in descending order)
But wait, there is more!
Recycling
There are situations where we can print every number, but don't list every number, we can do recycling! Let me give a quick example:
Input: 110
Output: 11091081071061051041031021010099... etc
Recycled: 10 1
We've now still listed all the numbers, 110, 109, 108, but we've recycled a 0 and a 1.
Another example:
Input: 9900
Output: 9900989989897989698959894... etc
Recycled: 9 98
Code-golf challenge
- Read a number (argument or stdin)
- Output the countdown in descending order while recycling all possible numbers (to stdout or file)
- Stop when you reach 1 OR the moment you've recycled 0 to 9 (whatever happens first)
Simple example (until 1 reached):
Input: 15
Output: 15141312110987654321
(Notice the 110 instead of 1110)
More advanced example (all recycled):
Input: 110
Output: 110910810710610510410310210100998979695949392919089887868584838281807978776757473727170696867665646362616059585756554535251504948474645443424140393837363534332313029282726252423221
Recycled: 10 9 8 7 6 5 4 3 2
(We've recycled all 0-9)