Skip to content

Instantly share code, notes, and snippets.

@underhilllabs
Created December 2, 2015 03:48
Show Gist options
  • Save underhilllabs/dcf5d2521a0674ece165 to your computer and use it in GitHub Desktop.
Save underhilllabs/dcf5d2521a0674ece165 to your computer and use it in GitHub Desktop.
santa map
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}"
@underhilllabs
Copy link
Author

(reduce + 
         (map #(if (= (str %) "(" ) 
                   1 
                   -1) 
                  (slurp "./santas_map_input.txt")))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment