aboutsummaryrefslogtreecommitdiff
path: root/2025/src
diff options
context:
space:
mode:
authorThomas Schmucker <ts@its1.de>2025-12-09 08:50:50 +0100
committerThomas Schmucker <ts@its1.de>2025-12-09 08:50:50 +0100
commitd89b7d7fcf5a42bc5a7e0eef1304c73a09929611 (patch)
tree6965aa06ec6be701d91946b0163aef11233c07f8 /2025/src
parent5f41cc49734c7d1ef304be37b60e19349b314193 (diff)
downloadadvent-of-code-d89b7d7fcf5a42bc5a7e0eef1304c73a09929611.tar.gz
advent-of-code-d89b7d7fcf5a42bc5a7e0eef1304c73a09929611.tar.bz2
advent-of-code-d89b7d7fcf5a42bc5a7e0eef1304c73a09929611.zip
aoc 2025, day 9, part 1
Diffstat (limited to '2025/src')
-rw-r--r--2025/src/day09.cpp56
1 files changed, 56 insertions, 0 deletions
diff --git a/2025/src/day09.cpp b/2025/src/day09.cpp
new file mode 100644
index 0000000..f46112a
--- /dev/null
+++ b/2025/src/day09.cpp
@@ -0,0 +1,56 @@
1#include <filesystem>
2#include <fstream>
3#include <iostream>
4#include <tuple>
5#include <vector>
6
7using namespace std;
8
9namespace {
10
11using Pos = tuple<long, long>;
12
13vector<Pos>
14read_file(const filesystem::path& filename)
15{
16 ifstream file{ filename };
17
18 vector<Pos> data;
19
20 long x{};
21 long y{};
22 char skip{};
23
24 while ( file >> x >> skip >> y ) {
25 data.emplace_back(x, y);
26 }
27 return data;
28}
29
30void
31part1(const vector<Pos>& data)
32{
33 auto area = numeric_limits<long>::min();
34
35 for ( size_t i = 0; i != data.size(); ++i ) {
36 for ( size_t j = i + 1; j != data.size(); ++j ) {
37 const auto [x1, y1] = data[i];
38 const auto [x2, y2] = data[j];
39
40 const auto width = abs(x1 - x2) + 1;
41 const auto height = abs(y1 - y2) + 1;
42
43 area = max(area, width * height);
44 }
45 }
46 cout << "Part 1: " << area << '\n';
47}
48
49} // namespace
50
51int
52main()
53{
54 auto data = read_file("data/day09.txt");
55 part1(data);
56}