Merge: doc: fixed some typos and other misc. corrections
[nit.git] / tests / test_rubix_cube.nit
1 # This file is part of NIT ( http://www.nitlanguage.org ).
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 # http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14
15 import rubix
16 import combinations
17
18 var commands = ["U", "L", "F", "R", "B", "D", "M", "E", "S", "u", "l", "r", "b", "d", "X", "Y", "Z"]
19
20 for iters in [1 .. commands.length[ do
21 var ref_rubix = new RubixCube.solved
22 #alt1 ref_rubix = new RubixCube.scrambled
23 var combin = new CombinationCollection[String](commands, iters)
24 combin.are_sorted = true
25 combin.are_unique = true
26 for cmd in combin do
27 var rubix = new RubixCube.solved
28 #alt1 rubix = new RubixCube.scrambled
29 var revcmd = new Array[String].with_capacity(cmd.length * 2)
30 for i in cmd do revcmd.add i
31 for i in cmd.reverse_iterator do revcmd.add("{i}'")
32 print "Trying combination {revcmd}"
33 for i in revcmd do rubix.do_cmd(i)
34 assert rubix == ref_rubix
35 print "Combination {revcmd} is OK."
36 end
37 end