diff options
author | def <dennis@felsin9.de> | 2015-02-02 08:06:19 +0100 |
---|---|---|
committer | def <dennis@felsin9.de> | 2015-02-02 08:06:19 +0100 |
commit | 03db4d2930bb5265da1d966cd32d7f5faccb6056 (patch) | |
tree | 796af38b464176b8ef2917dcfc46b5be46e4d70f /tests | |
parent | 1ae4d535cd8ed6b797cf0525eaab9e0c889e0c6d (diff) | |
download | Nim-03db4d2930bb5265da1d966cd32d7f5faccb6056.tar.gz |
Adapt the tester for permutations
Uses the bool return value now
Diffstat (limited to 'tests')
-rw-r--r-- | tests/stdlib/tpermutations.nim | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/tests/stdlib/tpermutations.nim b/tests/stdlib/tpermutations.nim index 99bc424cd..a6e07ded6 100644 --- a/tests/stdlib/tpermutations.nim +++ b/tests/stdlib/tpermutations.nim @@ -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 |