about summary refs log tree commit diff
path: root/day12.rb
diff options
context:
space:
mode:
authorLeah Neukirchen <leah@vuxu.org>2019-11-28 17:38:10 +0100
committerLeah Neukirchen <leah@vuxu.org>2019-11-28 17:38:10 +0100
commite12436c99bb04897d6344b6351d0336e4c627573 (patch)
tree74f8afb9de5d2a466e5fe6225df3661e1280519e /day12.rb
parent05050c3b5e20d5d475894788df6c31f867d2c51a (diff)
downloadadventofcode2018-e12436c99bb04897d6344b6351d0336e4c627573.tar.gz
adventofcode2018-e12436c99bb04897d6344b6351d0336e4c627573.tar.xz
adventofcode2018-e12436c99bb04897d6344b6351d0336e4c627573.zip
add rest HEAD master
Diffstat (limited to 'day12.rb')
-rw-r--r--day12.rb79
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