diff options
author | Leah Neukirchen <leah@vuxu.org> | 2019-11-28 17:38:10 +0100 |
---|---|---|
committer | Leah Neukirchen <leah@vuxu.org> | 2019-11-28 17:38:10 +0100 |
commit | e12436c99bb04897d6344b6351d0336e4c627573 (patch) | |
tree | 74f8afb9de5d2a466e5fe6225df3661e1280519e /day23.rb | |
parent | 05050c3b5e20d5d475894788df6c31f867d2c51a (diff) | |
download | adventofcode2018-e12436c99bb04897d6344b6351d0336e4c627573.tar.gz adventofcode2018-e12436c99bb04897d6344b6351d0336e4c627573.tar.xz adventofcode2018-e12436c99bb04897d6344b6351d0336e4c627573.zip |
Diffstat (limited to 'day23.rb')
-rw-r--r-- | day23.rb | 21 |
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 |