This commit is contained in:
shu 2019-12-01 09:02:57 +01:00
parent d03d580749
commit 4e58ab46eb
2 changed files with 114 additions and 0 deletions

14
2019/day1/day1.hs Normal file
View File

@ -0,0 +1,14 @@
main = do
content <- readFile "input"
let input = lines content
print (day11 input)
print (day12 input)
day11 :: [String] -> Int
day11 xs = sum $ map ((subtract 2) . floor . (/ 3) . read) xs
day12 :: [String] -> Int
day12 xs = (sum $ map (f . read) xs) - (sum $ map read xs) where
f x | x>0=x+f (((subtract 2) . floor . (/ 3) . fromIntegral) x)
| otherwise = 0

100
2019/day1/input Normal file
View File

@ -0,0 +1,100 @@
50962
126857
127476
136169
62054
116866
123235
147126
146767
140795
54110
106452
98413
114925
141914
54864
120093
118166
81996
143924
145941
96950
126488
85764
111438
63278
147558
128982
123857
58646
80757
98260
97143
136609
99349
63167
142129
144645
97212
70162
98044
125931
103859
67890
67797
79263
134255
130303
73367
103091
97315
74892
82311
51157
79802
138401
108423
63111
61441
102862
53184
125543
147413
117762
106771
115805
66424
85851
53101
82736
136768
130745
140135
101770
55349
143419
60108
84990
91544
75240
92709
134369
140901
59910
63641
54966
104671
71950
60358
127289
147362
70799
82870
108630
53450
106888
129843
53227
58758
137751