diff options
Diffstat (limited to 'day12.rb')
-rw-r--r-- | day12.rb | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/day12.rb b/day12.rb new file mode 100644 index 0000000..288d34f --- /dev/null +++ b/day12.rb @@ -0,0 +1,79 @@ +s="#..#.#..##......###...###" + +t = { +"...##"=>"#", +"..#.."=>"#", +".#..."=>"#", +".#.#."=>"#", +".#.##"=>"#", +".##.."=>"#", +".####"=>"#", +"#.#.#"=>"#", +"#.###"=>"#", +"##.#."=>"#", +"##.##"=>"#", +"###.."=>"#", +"###.#"=>"#", +"####."=>"#", +} + +s="##.####..####...#.####..##.#..##..#####.##.#..#...#.###.###....####.###...##..#...##.#.#...##.##.." + +t={ +"##.##"=>"#", +"....#"=>".", +".#.#."=>"#", +"..###"=>".", +"##..."=>"#", +"#####"=>".", +"###.#"=>"#", +".##.."=>".", +"..##."=>".", +"...##"=>"#", +"####."=>".", +"###.."=>".", +".####"=>"#", +"#...#"=>"#", +"....."=>".", +"..#.."=>".", +"#..##"=>".", +"#.#.#"=>"#", +".#.##"=>"#", +".###."=>".", +"##..#"=>".", +".#..."=>"#", +".#..#"=>"#", +"...#."=>".", +"#.#.."=>".", +"#...."=>".", +"##.#."=>".", +"#.###"=>".", +".##.#"=>".", +"#..#."=>"#", +"..#.#"=>".", +"#.##."=>"#", +} + +s = ("."*1000) + s + (".")*1000 + +r = 0 +(1..1000).each { |i| + s = "..#{s}..".chars.each_cons(5).map { |c| + t[c.join] || "." + }.join + + if i == 20 || i == 500 || i == 1000 + r = 0 + s.chars.each_with_index { |c, i| + if c == "#" + # p i-10 + r += i-1000 + end + } + + p [i,r] + end +} + +# 1000..2000 adds up to 32000 +p r + ((50000000000/1000)-1)*32000 # 1600000032081 |