Day 9 Question 1

This commit is contained in:
2025-12-10 05:33:34 +02:00
parent 67f590a7b0
commit 6b70d4955c
3 changed files with 541 additions and 0 deletions

496
Day9/Question1/input Normal file
View File

@@ -0,0 +1,496 @@
97879,50255
97879,51476
98119,51476
98119,52688
97950,52688
97950,53875
97529,53875
97529,55132
97929,55132
97929,56306
97494,56306
97494,57451
96963,57451
96963,58720
97201,58720
97201,59834
96591,59834
96591,61124
96800,61124
96800,62207
96129,62207
96129,63575
96504,63575
96504,64587
95637,64587
95637,65638
94964,65638
94964,66855
94774,66855
94774,68128
94689,68128
94689,69307
94336,69307
94336,70438
93863,70438
93863,71358
92959,71358
92959,72316
92171,72316
92171,73553
91905,73553
91905,74570
91233,74570
91233,75641
90653,75641
90653,76890
90330,76890
90330,77596
89199,77596
89199,78654
88588,78654
88588,79604
87826,79604
87826,80510
87012,80510
87012,81578
86389,81578
86389,82346
85420,82346
85420,83260
84617,83260
84617,84193
83829,84193
83829,85218
83121,85218
83121,85917
82103,85917
82103,86673
81144,86673
81144,87457
80210,87457
80210,88035
79118,88035
79118,88917
78258,88917
78258,89576
77233,89576
77233,90457
76354,90457
76354,90788
75121,90788
75121,91302
74017,91302
74017,92487
73286,92487
73286,93058
72199,93058
72199,93622
71109,93622
71109,93276
69605,93276
69605,94305
68733,94305
68733,94990
67693,94990
67693,94691
66280,94691
66280,95163
65168,95163
65168,96343
64268,96343
64268,95866
62859,95866
62859,96388
61746,96388
61746,96664
60566,96664
60566,97466
59490,97466
59490,97533
58257,97533
58257,97764
57056,97764
57056,98095
55864,98095
55864,97968
54619,97968
54619,98186
53410,98186
53410,97508
52154,97508
52154,97757
50954,97757
50954,97930
49743,97930
49743,98386
48515,98386
48515,98075
47304,98075
47304,97773
46105,97773
46105,97820
44878,97820
44878,97758
43657,97758
43657,97194
42511,97194
42511,97593
41207,97593
41207,96568
40170,96568
40170,97034
38820,97034
38820,96444
37709,96444
37709,95729
36650,95729
36650,95790
35363,95790
35363,95655
34121,95655
34121,95147
33004,95147
33004,94454
31966,94454
31966,93899
30882,93899
30882,93934
29528,93934
29528,92759
28741,92759
28741,92532
27492,92532
27492,92198
26282,92198
26282,91073
25525,91073
25525,90820
24252,90820
24252,90106
23259,90106
23259,88943
22584,88943
22584,88330
21537,88330
21537,88000
20259,88000
20259,86871
19605,86871
19605,86393
18417,86393
18417,85076
17967,85076
17967,84433
16916,84433
16916,83905
15730,83905
15730,82613
15321,82613
15321,82207
13965,82207
13965,80753
13787,80753
13787,80180
12580,80180
12580,79089
12001,79089
12001,78374
10923,78374
10923,77039
10704,77039
10704,76352
9545,76352
9545,74935
9513,74935
9513,73948
8816,73948
8816,73282
7520,73282
7520,72224
6894,72224
6894,70936
6733,70936
6733,69694
6525,69694
6525,68803
5529,68803
5529,67739
4890,67739
4890,66502
4700,66502
4700,65429
4059,65429
4059,64150
4040,64150
4040,62863
4117,62863
4117,61771
3512,61771
3512,60652
2953,60652
2953,59489
2540,59489
2540,58163
3005,58163
3005,57037
2361,57037
2361,55790
2508,55790
2508,54568
2561,54568
2561,53361
2509,53361
2509,52189
1725,52189
1725,50965
1730,50965
1730,50238
94710,50238
94710,48527
2008,48527
2008,47334
2470,47334
2470,46083
1968,46083
1968,44893
2312,44893
2312,43651
2190,43651
2190,42452
2429,42452
2429,41199
2368,41199
2368,40026
2749,40026
2749,38886
3242,38886
3242,37706
3543,37706
3543,36597
4089,36597
4089,35276
3937,35276
3937,34256
4732,34256
4732,33240
5478,33240
5478,32019
5674,32019
5674,30830
5979,30830
5979,29701
6437,29701
6437,28818
7395,28818
7395,27470
7426,27470
7426,26669
8491,26669
8491,25328
8597,25328
8597,24462
9511,24462
9511,23575
10367,23575
10367,22427
10833,22427
10833,21645
11815,21645
11815,20285
12032,20285
12032,19390
12867,19390
12867,18347
13525,18347
13525,17934
14887,17934
14887,17059
15715,17059
15715,15912
16274,15912
16274,14908
16998,14908
16998,14243
18040,14243
18040,13199
18747,13199
18747,12890
20069,12890
20069,11697
20677,11697
20677,11143
21785,11143
21785,10561
22861,10561
22861,9729
23767,9729
23767,9459
25030,9459
25030,8609
25931,8609
25931,7548
26733,7548
26733,6944
27801,6944
27801,7053
29217,7053
29217,6536
30310,6536
30310,5830
31324,5830
31324,5100
32342,5100
32342,5289
33712,5289
33712,4724
34793,4724
34793,4140
35880,4140
35880,4230
37167,4230
37167,3850
38313,3850
38313,3559
39484,3559
39484,2961
40594,2961
40594,2866
41811,2866
41811,2665
43007,2665
43007,2673
44229,2673
44229,2019
45379,2019
45379,1884
46594,1884
46594,2331
47837,2331
47837,2370
49047,2370
49047,1793
50257,1793
50257,2068
51470,2068
51470,2017
52690,2017
52690,2255
53892,2255
53892,1858
55155,1858
55155,2246
56341,2246
56341,2382
57555,2382
57555,2505
58774,2505
58774,2981
59924,2981
59924,3138
61138,3138
61138,3390
62334,3390
62334,3948
63443,3948
63443,3927
64726,3927
64726,4430
65848,4430
65848,4842
66999,4842
66999,5522
68042,5522
68042,6382
68994,6382
68994,6554
70243,6554
70243,7145
71305,7145
71305,7190
72653,7190
72653,7923
73649,7923
73649,8468
74747,8468
74747,9274
75687,9274
75687,9844
76773,9844
76773,10937
77499,10937
77499,11607
78509,11607
78509,11828
79874,11828
79874,13085
80429,13085
80429,13451
81717,13451
81717,14603
82325,14603
82325,15645
83007,15645
83007,16216
84146,16216
84146,17157
84922,17157
84922,18145
85639,18145
85639,18713
86841,18713
86841,19815
87424,19815
87424,20793
88150,20793
88150,21779
88865,21779
88865,23051
89162,23051
89162,23531
90632,23531
90632,24992
90602,24992
90602,26074
91145,26074
91145,26872
92196,26872
92196,27775
93106,27775
93106,28983
93431,28983
93431,30347
93380,30347
93380,31489
93778,31489
93778,32537
94403,32537
94403,33430
95484,33430
95484,34757
95383,34757
95383,35985
95518,35985
95518,37079
96085,37079
96085,38096
97007,38096
97007,39477
96468,39477
96468,40593
97045,40593
97045,41800
97196,41800
97196,42987
97469,42987
97469,44139
98064,44139
98064,45367
98104,45367
98104,46630
97599,46630
97599,47812
98231,47812
98231,49047
97644,49047
97644,50255

8
Day9/Question1/inputTest Normal file
View File

@@ -0,0 +1,8 @@
7,1
11,1
11,7
9,7
9,5
2,5
2,3
7,3

37
Day9/Question1/main.cpp Normal file
View File

@@ -0,0 +1,37 @@
#include <cmath>
#include <cstdint>
#include <cstdlib>
#include <fstream>
#include <iostream>
#include <string>
#include <vector>
struct Vector2D {
int64_t x, y;
};
int main() {
std::fstream input("input");
std::string currentLine = "";
std::vector<Vector2D> points{};
int64_t password = 0;
while (std::getline(input, currentLine, '\n')) {
uint16_t positionOfTheComma = currentLine.find(',');
points.push_back({std::stoll(currentLine.substr(0, positionOfTheComma)),
std::stoll(currentLine.substr(positionOfTheComma + 1))});
}
uint64_t count = 0, pointsSize = points.size();
for (Vector2D &point : points) {
for (uint64_t index = ++count; index < pointsSize; index++) {
Vector2D *position1 = &point, *position2 = &points[index];
int64_t area = (std::abs(position2->x - position1->x) + 1) *
(std::abs(position2->y - position1->y) + 1);
if (area > password) {
password = area;
}
}
}
std::cout << password << std::endl;
}