Created
December 2, 2015 03:48
-
-
Save underhilllabs/dcf5d2521a0674ece165 to your computer and use it in GitHub Desktop.
santa map
This file contains hidden or 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
basement = [] | |
floor = 0 | |
f = File.read("./santas_map_input.txt") | |
f.chars.each_with_index do |f, idx| | |
if f=='(' | |
floor += 1 | |
else | |
floor -= 1 | |
end | |
basement << (idx+1) if floor == -1 | |
end | |
puts "ends on floor #{floor}" | |
puts "first time in basement #{basement.first}" |
Author
underhilllabs
commented
Dec 2, 2015
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment