Next highest int from digits: Difference between revisions

Content added Content deleted
m (→‎{{header|Factor}}: change a word)
Line 60: Line 60:


=={{header|Factor}}==
=={{header|Factor}}==
This uses the <code>next-permutation</code> word from the <code>math.combinatorics</code> vocabulary. <code>next-permutation</code> wraps around and returns the smallest permutation after the largest one, so the only thing we have to do is check if we're at the largest permutation and return zero if so. See the implementation of <code>next-permutation</code> [https://docs.factorcode.org/content/word-next-permutation%2Cmath.combinatorics.html here].
This uses the <code>next-permutation</code> word from the <code>math.combinatorics</code> vocabulary. <code>next-permutation</code> wraps around and returns the smallest lexicographic permutation after the largest one, so the only thing we have to do is check if we're at the largest permutation and return zero if so. See the implementation of <code>next-permutation</code> [https://docs.factorcode.org/content/word-next-permutation%2Cmath.combinatorics.html here].
{{works with|Factor|0.99 2020-01-23}}
{{works with|Factor|0.99 2020-01-23}}
<lang factor>USING: formatting grouping kernel math math.combinatorics
<lang factor>USING: formatting grouping kernel math math.combinatorics