Skip to content

Instantly share code, notes, and snippets.

@hagiyat
Last active August 29, 2015 14:16
Show Gist options
  • Save hagiyat/7a7bae5de7eee0e82e09 to your computer and use it in GitHub Desktop.
Save hagiyat/7a7bae5de7eee0e82e09 to your computer and use it in GitHub Desktop.
generate bingo card
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