From 2e15fbd3a5baaefbd325453f965eb58c7b56be76 Mon Sep 17 00:00:00 2001 From: Nat Lasseter Date: Fri, 1 Dec 2017 11:57:19 +0000 Subject: Initial commit, day01 --- day01/part2 | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100755 day01/part2 (limited to 'day01/part2') diff --git a/day01/part2 b/day01/part2 new file mode 100755 index 0000000..c8356df --- /dev/null +++ b/day01/part2 @@ -0,0 +1,13 @@ +#!/usr/bin/env ruby + +input = gets.chomp.chars.map(&:to_i) +l = input.length +r = l / 2 + +sum = 0 + +(0...l).each do |i| + sum += input[i] if input[i] == input[(i + r) % l] +end + +puts sum -- cgit v1.2.3