Last active
December 2, 2015 15:37
-
-
Save thefotios/a0c96ceb8ba4e212171f to your computer and use it in GitHub Desktop.
Advent of Code 2015
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
# Part 1 | |
awk 'BEGIN{ FS = ""} {for(i = 1; i <= NF; i++) if($i ~ /\(/){ floors++}else{floors--} } END { print floors}' | |
# Part 2 | |
awk 'BEGIN{ FS = ""} {for(i = 1; i <= NF; i++){ if($i ~ /\(/){ floors++}else{floors--}; if(floors < 0){print i; break}}} END { print floors}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment