Skip to content

Instantly share code, notes, and snippets.

@willnet
Created Jun 2, 2012
Embed
What would you like to do?
minato-amida
#!/usr/bin/env ruby
number = ARGV[0]
number = number.to_i
raise if number == 0
ary = []
9.times do
ary << Array.new(number - 1, 0)
end
ary.map! do |a|
previous = false
a.map do |i|
if rand(2) > 0 && !previous
previous = true
1
else
previous = false
0
end
end
end
result = ''
ary.each do |a|
result += '|' + a.map { |i| i == 0 ? ' ' : '---' }.join('|') + "|\n"
end
(['A'] * number).map.each_with_index do |s, i|
i.times { |j| s.succ! }
end
titles = []
(['A'] * number).each_with_index do |s, i|
str = s.dup
i.times { |j| str.succ! }
titles << str
end
atari = Array.new(number, 0)
atari[rand(number + 1)] = 1
atari.map! {|a| a == 0 ? ' ' : '!!!'}
puts titles.join(' ') + "\n" + result + "\n" + atari.join
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment