Adapt the tester for permutations

Uses the bool return value now
This commit is contained in:
def
2015-02-02 08:06:19 +01:00
parent 1ae4d535cd
commit 03db4d2930

View File

@@ -1,17 +1,19 @@
discard """
output: '''@[0, 1, 2, 3, 4, 5, 6, 7, 9, 8]
@[0, 1, 2, 3, 4, 5, 6, 8, 7, 9]
@[0, 1, 2, 3, 4, 5, 6, 8, 9, 7]
@[0, 1, 2, 3, 4, 5, 6, 8, 7, 9]
@[0, 1, 2, 3, 4, 5, 6, 7, 9, 8]
@[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]'''
output: '''@[0, 2, 1]
@[1, 0, 2]
@[1, 2, 0]
@[2, 0, 1]
@[2, 1, 0]
@[2, 0, 1]
@[1, 2, 0]
@[1, 0, 2]
@[0, 2, 1]
@[0, 1, 2]'''
"""
import algorithm
var v = @[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
for i in 1..3:
v.nextPermutation()
var v = @[0, 1, 2]
while v.nextPermutation():
echo v
for i in 1..3:
v.prevPermutation()
while v.prevPermutation():
echo v