Skip to content

Instantly share code, notes, and snippets.

@hitode909
Created July 5, 2009 16:33
Show Gist options
  • Save hitode909/141026 to your computer and use it in GitHub Desktop.
Save hitode909/141026 to your computer and use it in GitHub Desktop.
# -*- coding: utf-8 -*-
def getnewline(line, rule)
(0..(line.size-1)).map { |i|
rule[line[i-1..i+1].join.to_i(2)] # 端がおかしくなりそう
}
end
token = ARGV.first.to_i || raise
rule = (0..7).map{|i| token[i]}
line = Array.new(80, 0)
line[40] = 1
40.times do
puts line.map{|i| [' ', '*'][i]}.join(' ') + '|'
line = getnewline(line, rule)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment