Next highest int from digits: Difference between revisions
Content added Content deleted
(→{{header|Go}}: Removed superfluous import.) |
m (→Python: Generator: Fix for a premature generator depletion - corrected output) |
||
Line 447: | Line 447: | ||
<lang python>'''Digit-shuffle successors''' |
<lang python>'''Digit-shuffle successors''' |
||
from itertools import chain, islice, permutations |
from itertools import chain, islice, permutations, tee |
||
Line 471: | Line 471: | ||
def showSuccs(n): |
def showSuccs(n): |
||
def go(xs): |
def go(xs): |
||
ys, zs = tee(xs) |
|||
harvest = take(5)(ys) |
|||
return ( |
return ( |
||
repr(len(harvest)) + ' of ' + repr(len(list( |
repr(len(harvest)) + ' of ' + repr(len(list(zs))) + ': ' |
||
).rjust(12, ' ') + repr(harvest) |
).rjust(12, ' ') + repr(harvest) |
||
return lambda xs: go(xs) |
return lambda xs: go(xs) |
||
Line 545: | Line 546: | ||
0 -> 0 of 0: [] |
0 -> 0 of 0: [] |
||
9 -> 0 of 0: [] |
9 -> 0 of 0: [] |
||
12 -> 1 of |
12 -> 1 of 1: [21] |
||
21 -> 0 of 0: [] |
21 -> 0 of 0: [] |
||
12453 -> 5 of |
12453 -> 5 of 116: [12534, 12543, 13245, 13254, 13425] |
||
738440 -> 5 of |
738440 -> 5 of 96: [740348, 740384, 740438, 740483, 740834] |
||
45072010 -> 5 of |
45072010 -> 5 of 1861: [45072100, 45100027, 45100072, 45100207, 45100270] |
||
95322020 -> 1 of |
95322020 -> 1 of 1: [95322200]</pre> |
||
=={{header|REXX}}== |
=={{header|REXX}}== |