Skip to content

Instantly share code, notes, and snippets.

@justinj
Last active December 14, 2015 20:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save justinj/5146075 to your computer and use it in GitHub Desktop.
Save justinj/5146075 to your computer and use it in GitHub Desktop.
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