Skip to content

Commit

Permalink
advent of code 2024 day 1 problem 2
Browse files Browse the repository at this point in the history
  • Loading branch information
Vicfred committed Dec 5, 2024
1 parent 6e855d5 commit dc163fd
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
File renamed without changes.
27 changes: 27 additions & 0 deletions aoc/aoc2024day01historianhysteria2.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import std.algorithm;
import std.stdio;

long abs(long x) {
if(x < 0) {
return -x;
}
return x;
}

void main() {
long MAXN = 1000;
auto input = File("input.txt");
long[1000] u;
long[1000000] v;
long answer = 0;
for(long i = 0; i < MAXN; ++i) {
long x, y;
readf("%d %d\n", &x, &y);
u[i] = x;
v[y] += 1;
}
for(long i = 0; i < MAXN; ++i) {
answer += u[i]*v[u[i]];
}
answer.writeln;
}

0 comments on commit dc163fd

Please sign in to comment.