From a6702d7d72a293694d6d7180c446596cda08808c Mon Sep 17 00:00:00 2001 From: Nathan Lasseter Date: Fri, 4 Dec 2015 16:05:10 +0000 Subject: Lose the Ruby. --- day3.rb | 50 -------------------------------------------------- 1 file changed, 50 deletions(-) delete mode 100755 day3.rb diff --git a/day3.rb b/day3.rb deleted file mode 100755 index 17fd0ca..0000000 --- a/day3.rb +++ /dev/null @@ -1,50 +0,0 @@ -#!/usr/bin/env ruby - -map = {:onlysanta => Hash.new(0), :robosanta => Hash.new(0)} -map[:onlysanta][[0,0]] += 1 -map[:robosanta][[0,0]] += 1 - -onlysanta = {:northing => 0, :easting => 0} -santa = {:northing => 0, :easting => 0} -robosanta = {:northing => 0, :easting => 0} - -input = STDIN.readlines.map(&:chomp).join - -input.chars.each_with_index do |ch, idx| - case ch - when '<' - onlysanta[:easting] -= 1 - if idx.odd? then - santa[:easting] -= 1 - else - robosanta[:easting] -= 1 - end - when '>' - onlysanta[:easting] += 1 - if idx.odd? then - santa[:easting] += 1 - else - robosanta[:easting] += 1 - end - when 'v' - onlysanta[:northing] -= 1 - if idx.odd? then - santa[:northing] -= 1 - else - robosanta[:northing] -= 1 - end - when '^' - onlysanta[:northing] += 1 - if idx.odd? then - santa[:northing] += 1 - else - robosanta[:northing] += 1 - end - end - map[:onlysanta][[onlysanta[:easting], onlysanta[:northing]]] += 1 - map[:robosanta][[santa[:easting], santa[:northing]]] += 1 - map[:robosanta][[robosanta[:easting], robosanta[:northing]]] += 1 -end - -puts "Santa only: #{map[:onlysanta].length}" -puts "Robosanta: #{map[:robosanta].length}" -- cgit v1.2.1