Skip to content

Instantly share code, notes, and snippets.

View zaz's full-sized avatar

Zaz Brown zaz

View GitHub Profile
@zaz
zaz / example-1.rb
Last active August 29, 2015 14:07 — forked from thatrubylove/example-1.rb
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