diff options
| author | Gustav Sörnäs <gusso230@student.liu.se> | 2019-12-17 20:54:35 +0100 |
|---|---|---|
| committer | Gustav Sörnäs <gusso230@student.liu.se> | 2019-12-17 20:54:35 +0100 |
| commit | ee96aa7c6ab8f0148e814630e77a726bf61530c0 (patch) | |
| tree | 444376bc3ecfc235118558cace0de96f3aafd790 /solutions/py/d01.py | |
| parent | ca4d3b189da7793ce8744246617c793c8640ce71 (diff) | |
| download | aoc-ee96aa7c6ab8f0148e814630e77a726bf61530c0.tar.gz | |
Rename 2019
Diffstat (limited to 'solutions/py/d01.py')
| -rw-r--r-- | solutions/py/d01.py | 28 |
1 files changed, 0 insertions, 28 deletions
diff --git a/solutions/py/d01.py b/solutions/py/d01.py deleted file mode 100644 index d1c57c8..0000000 --- a/solutions/py/d01.py +++ /dev/null @@ -1,28 +0,0 @@ -import math -import sys - -def get_fuel(mass): - fuel = math.floor(mass / 3) - 2 - return 0 if fuel <= 0 else fuel + get_fuel(fuel) - -def pt1(_in): - s = 0 - for line in _in: - mass = int(line) - if mass == 0: - break - fuel = math.floor(mass / 3) - 2 - s += fuel - return s - -def pt2(input): - return sum([get_fuel(int(line)) for line in input]) - -if __name__ == "__main__": - import cProfile - - input = open("../input/01", "r").readlines() - cProfile.run("pt1(input)") - cProfile.run("pt2(input)") - print(pt1(input)) - print(pt2(input)) |
