is.solved: Testing if cube is solved

Description Usage Arguments Value Examples

Description

Function returns TRUE if cube is solved (each side contains exactly one colour) and FALSE otherwise.

Usage

1
is.solved(cube)

Arguments

cube

- cube object to be tested

Value

TRUE/FALSE

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
## Create new cube:
cube <- createCube(3)
## And it is solved:
is.solved(cube) # TRUE
## Now, test how many times repeating LFRB moves will bring back initial state:
cube <- twistCube(cube,'LFRB')
i <- 1
while(!is.solved(cube))
{
cube <- twistCube(cube,'LFRB')
i <- i + 1
}
print(i) # 315
## Check one more time if this is a solution:
is.solved(twistCube(cube,'LFRB',315)) # TRUE
## Check if really 314 moves and 316 moves don't give solution:
is.solved(twistCube(cube,'LFRB',314)) || is.solved(twistCube(cube,'LFRB',316)) # FALSE

Example output

[1] TRUE
[1] 315
[1] TRUE
[1] FALSE

rcube documentation built on May 15, 2019, 5:09 p.m.