Skip to content

Instantly share code, notes, and snippets.

@ymorimo
Created June 2, 2012 05:29
Show Gist options
  • Save ymorimo/2856767 to your computer and use it in GitHub Desktop.
Save ymorimo/2856767 to your computer and use it in GitHub Desktop.
#minatork01
#!/usr/bin/env ruby
cols = (ARGV[0] || 5).to_i - 1
rows = (ARGV[1] || 9).to_i
begin
table = (0...rows).map do |i|
(0...cols).map { rand(2) }.join
end
end until table.join =~ /1/
table.map! do |r|
r.gsub /11/, '10'
end
name = 'A'
(0..cols).each do
print name + (' ' * (4 - name.length))
name.succ!
end
puts
table.each do |r|
puts "|" + r.gsub(/1/, "---|").gsub(/0/, " |")
end
atari = rand(cols+1) * 4
puts " " * atari + '!'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment