Skip to content

Instantly share code, notes, and snippets.

@thefotios
Last active December 2, 2015 15:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thefotios/a0c96ceb8ba4e212171f to your computer and use it in GitHub Desktop.
Save thefotios/a0c96ceb8ba4e212171f to your computer and use it in GitHub Desktop.
Advent of Code 2015
# 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