mirror of
https://github.com/nim-lang/Nim.git
synced 2025-12-28 17:04:41 +00:00
Adapt the tester for permutations
Uses the bool return value now
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user