aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xday3.rb50
1 files changed, 0 insertions, 50 deletions
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}"