-
Notifications
You must be signed in to change notification settings - Fork 1
/
sol_01.aes
31 lines (25 loc) · 1.18 KB
/
sol_01.aes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
include "List.aes"
contract Day1 =
entrypoint solve_1() =
List.sum(List.map(fuel, input()))
entrypoint solve_2() =
List.sum(List.map(fuel_2, input()))
entrypoint fuel(m : int) =
m / 3 - 2
entrypoint fuel_2(m : int) =
let f = fuel(m)
fuel_2'(f, f)
function fuel_2'(acc : int, f : int) =
let fx = fuel(f)
if(fx > 0) fuel_2'(acc + fx, fx)
else acc
function input() =
[100152, 121802, 140047, 92337, 101891, 122051, 50384, 53628, 139979, 57959, 90354, 119201,
53941, 74563, 140320, 69972, 90954, 85414, 52999, 69869, 65511, 91084, 146614, 120976,
145517, 121313, 99155, 144062, 53343, 60992, 81324, 109565, 83665, 100255, 116562, 71967,
66486, 76844, 83233, 129089, 98787, 118848, 120030, 123908, 144800, 113563, 74763, 80902,
58740, 115929, 57926, 61739, 118481, 111540, 55259, 90161, 110745, 85103, 92616, 126402,
71906, 137282, 76811, 124470, 140723, 89796, 98126, 127274, 104925, 120395, 134417, 105281,
140414, 52683, 149260, 123259, 125238, 68860, 103545, 90308, 118854, 121111, 72989, 62993,
96615, 145935, 75078, 96752, 118779, 68090, 95136, 82132, 149426, 51496, 70123, 129725,
63022, 74422, 143216, 139349]