Last active
December 14, 2015 20:48
-
-
Save justinj/5146075 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def valid_move_1?(scramble, move) | |
if scramble.empty? | |
true | |
elsif same_face?(scramble[-1], move) | |
false | |
elsif scramble.count == 1 | |
true | |
elsif same_axis?(scramble[-1], scramble[-2], move) | |
false | |
else | |
true | |
end | |
end | |
##### | |
def valid_move_2?(scramble, move) | |
return true if scramble.count == 0 | |
return false if same_face?(scramble[-1], move) | |
return true if scramble.count == 1 | |
return false if same_axis?(scramble[-1], scramble[-2], move) | |
return true | |
end | |
##### | |
def valid_move_3?(scramble, move) | |
!invalid_move?(scramble, move) | |
end | |
def invalid_move?(scramble, move) | |
case scramble.count | |
when 0 | |
false | |
when 1 | |
same_face?(scramble[-1], move) | |
else | |
same_axis?(scramble[-1], scramble[-2], move) || same_face?(scramble[-1], move) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment