Added older advents
This commit is contained in:
parent
8db2505049
commit
9cf858b860
78 changed files with 13807 additions and 0 deletions
100
advent_of_code_2019/day1/input.txt
Normal file
100
advent_of_code_2019/day1/input.txt
Normal file
|
|
@ -0,0 +1,100 @@
|
|||
84242
|
||||
87800
|
||||
131272
|
||||
84629
|
||||
105398
|
||||
91086
|
||||
99863
|
||||
146591
|
||||
58757
|
||||
51370
|
||||
108422
|
||||
95689
|
||||
91513
|
||||
113692
|
||||
79189
|
||||
113603
|
||||
52750
|
||||
123562
|
||||
147710
|
||||
145313
|
||||
98785
|
||||
86959
|
||||
89755
|
||||
97093
|
||||
62048
|
||||
98872
|
||||
145829
|
||||
76682
|
||||
65788
|
||||
119356
|
||||
124600
|
||||
69459
|
||||
80167
|
||||
56122
|
||||
117390
|
||||
72303
|
||||
141896
|
||||
140568
|
||||
82565
|
||||
75431
|
||||
54613
|
||||
124106
|
||||
104628
|
||||
78531
|
||||
63748
|
||||
139285
|
||||
111926
|
||||
101999
|
||||
53435
|
||||
57906
|
||||
58120
|
||||
146795
|
||||
147754
|
||||
79892
|
||||
65395
|
||||
121551
|
||||
50577
|
||||
122520
|
||||
66441
|
||||
86009
|
||||
121899
|
||||
71715
|
||||
112666
|
||||
112863
|
||||
140695
|
||||
54016
|
||||
78041
|
||||
91757
|
||||
130007
|
||||
89595
|
||||
142289
|
||||
149842
|
||||
136738
|
||||
70046
|
||||
89586
|
||||
142234
|
||||
142090
|
||||
147759
|
||||
85957
|
||||
136288
|
||||
86895
|
||||
131370
|
||||
71565
|
||||
128290
|
||||
95531
|
||||
110317
|
||||
115170
|
||||
56454
|
||||
71468
|
||||
113938
|
||||
64193
|
||||
115562
|
||||
73585
|
||||
81194
|
||||
92754
|
||||
105826
|
||||
104739
|
||||
137106
|
||||
104467
|
||||
120320
|
||||
25
advent_of_code_2019/day1/main1.cc
Normal file
25
advent_of_code_2019/day1/main1.cc
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
#include <iostream>
|
||||
|
||||
using namespace std;
|
||||
|
||||
int required_fuel(int mass)
|
||||
{
|
||||
return (mass / 3) - 2;
|
||||
}
|
||||
|
||||
int main(int argv, char **argc)
|
||||
{
|
||||
int sum = 0;
|
||||
|
||||
while (!cin.eof())
|
||||
{
|
||||
int mass;
|
||||
cin >> mass;
|
||||
|
||||
cout << mass << " requires " << required_fuel(mass) << "\n";
|
||||
|
||||
sum += required_fuel(mass);
|
||||
}
|
||||
|
||||
cout << "Total required fuel: " << sum << "\n";
|
||||
}
|
||||
29
advent_of_code_2019/day1/main2.cc
Normal file
29
advent_of_code_2019/day1/main2.cc
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
#include <iostream>
|
||||
|
||||
using namespace std;
|
||||
|
||||
int required_fuel(int mass)
|
||||
{
|
||||
int fuel = (mass / 3) - 2;
|
||||
|
||||
if (fuel <= 0)
|
||||
return 0;
|
||||
|
||||
return fuel + required_fuel(fuel);
|
||||
}
|
||||
|
||||
int main(int argv, char **argc)
|
||||
{
|
||||
int sum = 0;
|
||||
|
||||
while (!cin.eof())
|
||||
{
|
||||
int mass;
|
||||
cin >> mass;
|
||||
sum += required_fuel(mass);
|
||||
// cout << mass << " requires " << required_fuel(mass) << "\n";
|
||||
|
||||
}
|
||||
|
||||
cout << "Total required fuel: " << sum << "\n";
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue