Created
January 23, 2014 20:46
-
-
Save gstark/8586425 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class String | |
def py_slice(start, step = 1) | |
start.step(step < 0 ? 0 : self.length, step).map { |index| self[index] } | |
end | |
end | |
input = ARGF.readlines | |
for i in Range.new(0,input.size).step(4) | |
northLasers, conveyorBelt, southLasers = input[i,3] | |
x = conveyorBelt.index('X') | |
west = (northLasers.py_slice(x,-2) + southLasers.py_slice(x-1,-2)).count('|') | |
east = (northLasers.py_slice(x, 2) + southLasers.py_slice(x+1, 2)).count('|') | |
puts east < west ? "GO EAST" : "GO WEST" | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment