Last active
August 29, 2015 14:16
-
-
Save hagiyat/7a7bae5de7eee0e82e09 to your computer and use it in GitHub Desktop.
generate bingo card
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
class Bingo | |
def self.generate | |
[*1..75] | |
.each_slice(15) | |
.map { |v| v.sample(5) } | |
.tap { |a| | |
a[2][2] = nil # (´;ω;`) | |
break a.unshift('BINGO'.chars) | |
} | |
.map { |v| | |
v.map { |s| | |
s.to_s.rjust(2) | |
}.join(' | ') | |
} | |
.join("\n") | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment