m = {1 => ""}\x0d r = 1\x0d p = ''\x0d (1..100).each { |c|\x0d mof = c % 5 == 0\x0d mot = c % 3 == 0\x0d done = mot && !mof && (c + 1) % 5 != 0 && (c + 2) % 5 != 0\x0d if mot && !mof \x0d c.to_s.length.times { m[r] << " "} unless done\x0d r += 1\x0d if m[r].nil? #newline\x0d m[r] = ""\x0d (m[r-1].to_s.length - c.to_s.length).times { m[r] << " " }\x0d end\x0d elsif mof && !mot\x0d c.to_s.length.times { m[r] << " "} \x0d r -= 1\x0d end\x0d \x0d c.to_s.length.times { m[r-1] << " " } if r != 1 && !mot \x0d c.to_s.length.times { m[r+1] << " " } if !m[r+1].nil? && !mof\x0d \x0d m[r] << c.to_s\x0d p += m[r-1] + "\n" if done\x0d }\x0d puts p + m[r] + "\n" + m[r+1]
Note that non-ascii characters in the above source code will be escaped (such as \x9f).