about summary refs log tree commit diff
path: root/day05.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 /day05.rb
parent05050c3b5e20d5d475894788df6c31f867d2c51a (diff)
downloadadventofcode2018-master.tar.gz
adventofcode2018-master.tar.xz
adventofcode2018-master.zip
add rest HEAD master
Diffstat (limited to 'day05.rb')
-rw-r--r--day05.rb21
1 files changed, 21 insertions, 0 deletions
diff --git a/day05.rb b/day05.rb
new file mode 100644
index 0000000..ce5fd2e
--- /dev/null
+++ b/day05.rb
@@ -0,0 +1,21 @@
+t = s = File.read("day05").chomp
+
+v = ('a'..'z').map { |l| ["#{l}#{l.upcase}", "#{l.upcase}#{l}"] }.flatten
+r = Regexp.union v
+
+p r
+
+while s.gsub!(r, '')
+end
+
+p s.size
+
+# 9687 too high
+
+p ('a'..'z').map { |l|
+  s = t.delete "#{l}#{l.upcase}"
+  while s.gsub!(r, '')
+  end
+  p [l, s.size]
+  s.size
+}.min