Skip to content

Instantly share code, notes, and snippets.

@rhowe
Created February 20, 2020 17:14
Show Gist options
  • Save rhowe/e3981f73554ca8a6ed35d95c31a25016 to your computer and use it in GitHub Desktop.
Save rhowe/e3981f73554ca8a6ed35d95c31a25016 to your computer and use it in GitHub Desktop.
AOC2019day1part2
#!/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