about summary refs log tree commit diff
path: root/day23.rb
diff options
context:
space:
mode:
Diffstat (limited to 'day23.rb')
-rw-r--r--day23.rb21
1 files changed, 21 insertions, 0 deletions
diff --git a/day23.rb b/day23.rb
new file mode 100644
index 0000000..d946376
--- /dev/null
+++ b/day23.rb
@@ -0,0 +1,21 @@
+file = File.read("day23")
+
+bots = file.lines.map { |l|
+  l.scan(/<(-?\d+),(-?\d+),(-?\d+)>.*r=(-?\d+)/).first.map(&:to_i)
+}
+
+strongest = bots.max_by { |x,y,z,w| w }
+
+p bots.count { |x,y,z,w|
+  ((x-strongest[0]).abs +
+   (y-strongest[1]).abs +
+   (z-strongest[2]).abs) <= strongest[3]
+}  # 577
+
+
+p bots.map { |b| b[0] }.sum 
+p bots.map { |b| b[1] }.sum
+p bots.map { |b| b[2] }.sum
+
+#  16933511,19092135,15403726
+# 51429372