Skip to content

Instantly share code, notes, and snippets.

@nemrow
Created January 23, 2016 20:42
Show Gist options
  • Select an option

  • Save nemrow/9d5fd15dbca32f1979b5 to your computer and use it in GitHub Desktop.

Select an option

Save nemrow/9d5fd15dbca32f1979b5 to your computer and use it in GitHub Desktop.
def farked?(dice_array)
puts "farked" if has_3_of_kind?(dice_array) || has_1?(dice_array) || has_5(dice_array)
end
def has_1?(dice_array)
dice_array.include?(1)
end
def has_5?(dice_array)
dice_array.include?(1)
end
def has_3_of_kind?(dice_array)
(1..6).each do |num|
return true if dice_array.find(num).length >= 3
end
end
# not farked
farked? [1,2,3,4,4,4]
# farked
farked? [3,3,2,2,6,6]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment