Created
June 2, 2012 05:10
-
-
Save willnet/2856690 to your computer and use it in GitHub Desktop.
minato-amida
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
#!/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