Adapt the tester for permutations
Uses the bool return value now
This commit is contained in:
parent
1ae4d535cd
commit
03db4d2930
1 changed files with 13 additions and 11 deletions
|
|
@ -1,17 +1,19 @@
|
||||||
discard """
|
discard """
|
||||||
output: '''@[0, 1, 2, 3, 4, 5, 6, 7, 9, 8]
|
output: '''@[0, 2, 1]
|
||||||
@[0, 1, 2, 3, 4, 5, 6, 8, 7, 9]
|
@[1, 0, 2]
|
||||||
@[0, 1, 2, 3, 4, 5, 6, 8, 9, 7]
|
@[1, 2, 0]
|
||||||
@[0, 1, 2, 3, 4, 5, 6, 8, 7, 9]
|
@[2, 0, 1]
|
||||||
@[0, 1, 2, 3, 4, 5, 6, 7, 9, 8]
|
@[2, 1, 0]
|
||||||
@[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]'''
|
@[2, 0, 1]
|
||||||
|
@[1, 2, 0]
|
||||||
|
@[1, 0, 2]
|
||||||
|
@[0, 2, 1]
|
||||||
|
@[0, 1, 2]'''
|
||||||
"""
|
"""
|
||||||
import algorithm
|
import algorithm
|
||||||
|
|
||||||
var v = @[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
|
var v = @[0, 1, 2]
|
||||||
for i in 1..3:
|
while v.nextPermutation():
|
||||||
v.nextPermutation()
|
|
||||||
echo v
|
echo v
|
||||||
for i in 1..3:
|
while v.prevPermutation():
|
||||||
v.prevPermutation()
|
|
||||||
echo v
|
echo v
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue