Next highest int from digits: Difference between revisions

Content added Content deleted
m (→‎Python: Generator: Fix for a premature generator depletion - corrected output)
m (→‎{{header|Haskell}}: (a where in lieu of two lets))
Line 240: Line 240:
digitShuffleSuccessors :: Integer -> [Integer]
digitShuffleSuccessors :: Integer -> [Integer]
digitShuffleSuccessors n =
digitShuffleSuccessors n =
(fmap . (+) <*> (nub . sort . concatMap go . permutations . show)) n
let go ds =
where
let delta = (read ds :: Integer) - n
go ds =
in bool [delta] [] (0 >= delta)
in (+ n) <$> (nub $ sort (permutations (show n) >>= go))
let delta = (read ds :: Integer) - n
in bool [delta] [] (0 >= delta)


---------------------------TEST----------------------------
---------------------------TEST----------------------------
Line 283: Line 284:
45072010 -> 5 of 1861: [45072100,45100027,45100072,45100207,45100270]
45072010 -> 5 of 1861: [45072100,45100027,45100072,45100207,45100270]
95322020 -> 1 of 1: [95322200]</pre>
95322020 -> 1 of 1: [95322200]</pre>



=={{header|Perl 6}}==
=={{header|Perl 6}}==