Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def solve(n = 1)
- return true if n == @cubes.length
- rotationCount = 0
- solved = false
- while not solved
- solved = true
- n.times do |i|
- if @cubes[n] == @cubes[i]
- solved = false
- break
- end
- end
- if solved and (solved = solve(n + 1))
- return true
- else
- @cubes[n].rotate
- rotationCount += 1
- if rotationCount > 3
- return false
- end
- end
- end
- end
Add Comment
Please, Sign In to add comment