Created
January 23, 2016 20:42
-
-
Save nemrow/9d5fd15dbca32f1979b5 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 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