Skip to content

Instantly share code, notes, and snippets.

@tdtds
Forked from ymorimo/amida.rb
Created June 2, 2012 05:48
Show Gist options
  • Save tdtds/2856826 to your computer and use it in GitHub Desktop.
Save tdtds/2856826 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(/1+/){|a| ([1]+[0]*(a.size-1)).shuffle.join}
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