Created
February 20, 2020 17:14
-
-
Save rhowe/e3981f73554ca8a6ed35d95c31a25016 to your computer and use it in GitHub Desktop.
AOC2019day1part2
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
#!/bin/sh | |
set -eu | |
total=0 | |
while read -r val; do | |
xtra=$((val / 3 - 2)) | |
while [ "$xtra" -gt 0 ]; do | |
total=$((total + xtra)) | |
xtra=$((xtra / 3 - 2)) | |
done | |
done | |
echo $total |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment