m-chrzan.xyz
aboutsummaryrefslogtreecommitdiff
path: root/10/b.rb
diff options
context:
space:
mode:
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]