m-chrzan.xyz
aboutsummaryrefslogtreecommitdiff
path: root/10/b.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/b.rb
parent15c6d8d79d9ec00a7abb14f90bd65547893c76f2 (diff)
Add day 10
Diffstat (limited to '10/b.rb')
-rw-r--r--10/b.rb7
1 files changed, 7 insertions, 0 deletions
diff --git a/10/b.rb b/10/b.rb
new file mode 100644
index 0000000..d27f1ab
--- /dev/null
+++ b/10/b.rb
@@ -0,0 +1,7 @@
+lines = File.readlines('input.txt').map { |l| l.to_i }.unshift(0).sort!
+arrs = Hash.new 0
+arrs[0] = 1
+lines.slice(1, lines.size).each do |line|
+ arrs[line] += arrs[line - 1] + arrs[line - 2] + arrs[line - 3]
+end
+puts arrs[lines.last]