is.solved {rcube}R Documentation

Testing if cube is solved

Description

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

Usage

is.solved(cube)

Arguments

cube

- cube object to be tested

Value

TRUE/FALSE

Examples

## 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

[Package rcube version 0.5 Index]