-
-
Save zaz/826255d0b871d5809215 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
numbers = [1,3,5,8,10,54,99] | |
cards = [5,3,4,6,2] | |
# get only the values where the distance is greater than 10 | |
numbers.each_cons(2).select {|a,b| b-a>10 } #=> [[10, 54], [54, 99]] | |
# determine if the hand is a straight | |
cards.sort.each_cons(5).all? do |series| | |
series.last - series.first == 4 | |
end #=> true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment