m-chrzan.xyz
aboutsummaryrefslogtreecommitdiff
path: root/10/a.rb
diff options
context:
space:
mode:
authorMarcin Chrzanowski <marcin.j.chrzanowski@gmail.com>2020-12-25 15:26:01 +0100
committerMarcin Chrzanowski <marcin.j.chrzanowski@gmail.com>2020-12-25 15:26:01 +0100
commit5a28775f19a8a48b67fc41e048c2a3958afa1e42 (patch)
tree8cababf438ee509ccb51a2023430891876cc2d88 /10/a.rb
parent15c6d8d79d9ec00a7abb14f90bd65547893c76f2 (diff)
Add day 10
Diffstat (limited to '10/a.rb')
-rw-r--r--10/a.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/10/a.rb b/10/a.rb
new file mode 100644
index 0000000..34336ef
--- /dev/null
+++ b/10/a.rb
@@ -0,0 +1,10 @@
+lines = File.readlines('input.txt').map { |l| l.to_i }
+lines.sort!
+lines.unshift(0)
+lines.push(lines.last + 3)
+diffs = Hash.new 0
+lines.each_cons 2 do |chargers|
+ diffs[chargers[1] - chargers[0]] += 1
+end
+
+puts diffs[1] * diffs[3]