aboutsummaryrefslogtreecommitdiff
path: root/2024/01/day01b.cpp
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano@tronto.net>2024-12-01 09:40:19 +0100
committerSebastiano Tronto <sebastiano@tronto.net>2024-12-01 09:40:19 +0100
commit0aefd410a18acf826af5187cdb038fd9b4f25fc5 (patch)
treef24d69d83567079412924bf6ce06e058673171b7 /2024/01/day01b.cpp
parent6c5fe99d41a3d63975deb08911ebb0e162684a43 (diff)
downloadaoc-0aefd410a18acf826af5187cdb038fd9b4f25fc5.tar.gz
aoc-0aefd410a18acf826af5187cdb038fd9b4f25fc5.zip
Started 2024 + day 1
Diffstat (limited to '2024/01/day01b.cpp')
-rw-r--r--2024/01/day01b.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/2024/01/day01b.cpp b/2024/01/day01b.cpp
new file mode 100644
index 0000000..91ef0db
--- /dev/null
+++ b/2024/01/day01b.cpp
@@ -0,0 +1,21 @@
1#include <iostream>
2#include <algorithm>
3#include <vector>
4using namespace std;
5
6int main() {
7 int x, y, tot;
8 vector<int> v, w;
9
10 while (cin >> x >> y) {
11 v.push_back(x);
12 w.push_back(y);
13 }
14
15 tot = 0;
16 for (unsigned i = 0; i < v.size(); i++)
17 tot += v[i] * count(w.begin(), w.end(), v[i]);
18
19 cout << tot << endl;
20 return 0;
21}

Generated with cgit - Back to sebastiano.tronto.net