diff options
| author | Yigit Sever | 2021-12-13 10:40:39 +0300 |
|---|---|---|
| committer | Yigit Sever | 2021-12-13 10:40:39 +0300 |
| commit | bf16b19b1f6deffd1983efca059db576f3b60ee5 (patch) | |
| tree | 1262f68d8eb2c326684d395aebcd5a1cc0b0f748 /2019/day1 | |
| parent | 74b27ccca31bb757c737dd7fdc02f513f57561b2 (diff) | |
| download | aoc-bf16b19b1f6deffd1983efca059db576f3b60ee5.tar.gz aoc-bf16b19b1f6deffd1983efca059db576f3b60ee5.tar.bz2 aoc-bf16b19b1f6deffd1983efca059db576f3b60ee5.zip | |
2019, tracking
Diffstat (limited to '2019/day1')
| -rw-r--r-- | 2019/day1/README.md | 5 | ||||
| -rw-r--r-- | 2019/day1/part1.in | 100 | ||||
| -rw-r--r-- | 2019/day1/part2.in | 100 | ||||
| -rw-r--r-- | 2019/day1/rec_fuel.py | 23 |
4 files changed, 228 insertions, 0 deletions
diff --git a/2019/day1/README.md b/2019/day1/README.md new file mode 100644 index 0000000..af0b60e --- /dev/null +++ b/2019/day1/README.md | |||
| @@ -0,0 +1,5 @@ | |||
| 1 | I realized part 1 can be solved with a perl one liner; | ||
| 2 | |||
| 3 | ```bash | ||
| 4 | perl -ne '$c += int ($_ / 3) - 2;END {print $c}' < part1.in | ||
| 5 | ``` | ||
diff --git a/2019/day1/part1.in b/2019/day1/part1.in new file mode 100644 index 0000000..63d0a1a --- /dev/null +++ b/2019/day1/part1.in | |||
| @@ -0,0 +1,100 @@ | |||
| 1 | 93912 | ||
| 2 | 138996 | ||
| 3 | 112824 | ||
| 4 | 110011 | ||
| 5 | 139024 | ||
| 6 | 132292 | ||
| 7 | 74029 | ||
| 8 | 81664 | ||
| 9 | 138077 | ||
| 10 | 109614 | ||
| 11 | 121056 | ||
| 12 | 136338 | ||
| 13 | 132771 | ||
| 14 | 86611 | ||
| 15 | 131526 | ||
| 16 | 123101 | ||
| 17 | 61315 | ||
| 18 | 93900 | ||
| 19 | 62070 | ||
| 20 | 97957 | ||
| 21 | 67168 | ||
| 22 | 119464 | ||
| 23 | 119066 | ||
| 24 | 111076 | ||
| 25 | 56856 | ||
| 26 | 144203 | ||
| 27 | 109400 | ||
| 28 | 120187 | ||
| 29 | 57915 | ||
| 30 | 143353 | ||
| 31 | 71308 | ||
| 32 | 67695 | ||
| 33 | 141275 | ||
| 34 | 106552 | ||
| 35 | 136209 | ||
| 36 | 86990 | ||
| 37 | 98969 | ||
| 38 | 57207 | ||
| 39 | 99103 | ||
| 40 | 71940 | ||
| 41 | 63145 | ||
| 42 | 91765 | ||
| 43 | 121095 | ||
| 44 | 139700 | ||
| 45 | 128851 | ||
| 46 | 77138 | ||
| 47 | 66712 | ||
| 48 | 91318 | ||
| 49 | 96924 | ||
| 50 | 132235 | ||
| 51 | 99897 | ||
| 52 | 67479 | ||
| 53 | 87996 | ||
| 54 | 121100 | ||
| 55 | 55411 | ||
| 56 | 61715 | ||
| 57 | 130658 | ||
| 58 | 121030 | ||
| 59 | 141445 | ||
| 60 | 83939 | ||
| 61 | 90402 | ||
| 62 | 121107 | ||
| 63 | 59618 | ||
| 64 | 120112 | ||
| 65 | 58140 | ||
| 66 | 103514 | ||
| 67 | 90538 | ||
| 68 | 55552 | ||
| 69 | 142739 | ||
| 70 | 61770 | ||
| 71 | 147374 | ||
| 72 | 80038 | ||
| 73 | 128830 | ||
| 74 | 93328 | ||
| 75 | 52369 | ||
| 76 | 71801 | ||
| 77 | 144536 | ||
| 78 | 147140 | ||
| 79 | 118213 | ||
| 80 | 128056 | ||
| 81 | 92155 | ||
| 82 | 114384 | ||
| 83 | 89234 | ||
| 84 | 124451 | ||
| 85 | 94214 | ||
| 86 | 79174 | ||
| 87 | 108427 | ||
| 88 | 111041 | ||
| 89 | 96715 | ||
| 90 | 128414 | ||
| 91 | 62521 | ||
| 92 | 93897 | ||
| 93 | 107428 | ||
| 94 | 90637 | ||
| 95 | 126176 | ||
| 96 | 78676 | ||
| 97 | 69504 | ||
| 98 | 93663 | ||
| 99 | 80869 | ||
| 100 | 124230 | ||
diff --git a/2019/day1/part2.in b/2019/day1/part2.in new file mode 100644 index 0000000..63d0a1a --- /dev/null +++ b/2019/day1/part2.in | |||
| @@ -0,0 +1,100 @@ | |||
| 1 | 93912 | ||
| 2 | 138996 | ||
| 3 | 112824 | ||
| 4 | 110011 | ||
| 5 | 139024 | ||
| 6 | 132292 | ||
| 7 | 74029 | ||
| 8 | 81664 | ||
| 9 | 138077 | ||
| 10 | 109614 | ||
| 11 | 121056 | ||
| 12 | 136338 | ||
| 13 | 132771 | ||
| 14 | 86611 | ||
| 15 | 131526 | ||
| 16 | 123101 | ||
| 17 | 61315 | ||
| 18 | 93900 | ||
| 19 | 62070 | ||
| 20 | 97957 | ||
| 21 | 67168 | ||
| 22 | 119464 | ||
| 23 | 119066 | ||
| 24 | 111076 | ||
| 25 | 56856 | ||
| 26 | 144203 | ||
| 27 | 109400 | ||
| 28 | 120187 | ||
| 29 | 57915 | ||
| 30 | 143353 | ||
| 31 | 71308 | ||
| 32 | 67695 | ||
| 33 | 141275 | ||
| 34 | 106552 | ||
| 35 | 136209 | ||
| 36 | 86990 | ||
| 37 | 98969 | ||
| 38 | 57207 | ||
| 39 | 99103 | ||
| 40 | 71940 | ||
| 41 | 63145 | ||
| 42 | 91765 | ||
| 43 | 121095 | ||
| 44 | 139700 | ||
| 45 | 128851 | ||
| 46 | 77138 | ||
| 47 | 66712 | ||
| 48 | 91318 | ||
| 49 | 96924 | ||
| 50 | 132235 | ||
| 51 | 99897 | ||
| 52 | 67479 | ||
| 53 | 87996 | ||
| 54 | 121100 | ||
| 55 | 55411 | ||
| 56 | 61715 | ||
| 57 | 130658 | ||
| 58 | 121030 | ||
| 59 | 141445 | ||
| 60 | 83939 | ||
| 61 | 90402 | ||
| 62 | 121107 | ||
| 63 | 59618 | ||
| 64 | 120112 | ||
| 65 | 58140 | ||
| 66 | 103514 | ||
| 67 | 90538 | ||
| 68 | 55552 | ||
| 69 | 142739 | ||
| 70 | 61770 | ||
| 71 | 147374 | ||
| 72 | 80038 | ||
| 73 | 128830 | ||
| 74 | 93328 | ||
| 75 | 52369 | ||
| 76 | 71801 | ||
| 77 | 144536 | ||
| 78 | 147140 | ||
| 79 | 118213 | ||
| 80 | 128056 | ||
| 81 | 92155 | ||
| 82 | 114384 | ||
| 83 | 89234 | ||
| 84 | 124451 | ||
| 85 | 94214 | ||
| 86 | 79174 | ||
| 87 | 108427 | ||
| 88 | 111041 | ||
| 89 | 96715 | ||
| 90 | 128414 | ||
| 91 | 62521 | ||
| 92 | 93897 | ||
| 93 | 107428 | ||
| 94 | 90637 | ||
| 95 | 126176 | ||
| 96 | 78676 | ||
| 97 | 69504 | ||
| 98 | 93663 | ||
| 99 | 80869 | ||
| 100 | 124230 | ||
diff --git a/2019/day1/rec_fuel.py b/2019/day1/rec_fuel.py new file mode 100644 index 0000000..d837202 --- /dev/null +++ b/2019/day1/rec_fuel.py | |||
| @@ -0,0 +1,23 @@ | |||
| 1 | import sys | ||
| 2 | |||
| 3 | |||
| 4 | def recfuel(mass): | ||
| 5 | """Calculate the fuel required for the module | ||
| 6 | use the new weight of the fuel recursively | ||
| 7 | r(M) = r(M / 3 - 2) | ||
| 8 | """ | ||
| 9 | M = mass // 3 - 2 | ||
| 10 | |||
| 11 | if M < 0: | ||
| 12 | return 0 | ||
| 13 | else: | ||
| 14 | return M + recfuel(M) | ||
| 15 | |||
| 16 | |||
| 17 | total = 0 | ||
| 18 | |||
| 19 | for mass in sys.stdin: | ||
| 20 | ret = recfuel(int(mass)) | ||
| 21 | total += ret | ||
| 22 | |||
| 23 | print(total) | ||
