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