Compare commits

..

2 commits

Author SHA1 Message Date
eriedaberrie 4f20bfde3b 2024 day 20 2024-12-19 22:02:11 -08:00
eriedaberrie 7f1556b52d Remove nearby and add units to util file 2024-12-19 22:01:51 -08:00
3 changed files with 22 additions and 11 deletions

View file

@ -2,6 +2,13 @@
#include <bits/stdc++.h>
using namespace std;
const array<icoord, 4> directions = {
icoord(-1, 0),
icoord(1, 0),
icoord(0, -1),
icoord(0, 1),
};
void rec(icoord c, unordered_map<icoord, int> &m, int score) {
if (!m.contains(c)) {
return;
@ -13,7 +20,7 @@ void rec(icoord c, unordered_map<icoord, int> &m, int score) {
}
s = score;
for (auto dir : icoord::units()) {
for (auto dir : directions) {
rec(c + dir, m, score + 1);
}
}

View file

@ -2,6 +2,13 @@
#include <bits/stdc++.h>
using namespace std;
const array<icoord, 4> directions = {
icoord(-1, 0),
icoord(1, 0),
icoord(0, -1),
icoord(0, 1),
};
void rec(icoord c, unordered_map<icoord, int> &m, int score) {
if (!m.contains(c)) {
return;
@ -13,7 +20,7 @@ void rec(icoord c, unordered_map<icoord, int> &m, int score) {
}
s = score;
for (auto dir : icoord::units()) {
for (auto dir : directions) {
rec(c + dir, m, score + 1);
}
}

View file

@ -1,7 +1,6 @@
#pragma once
#include <array>
#include <functional>
typedef long long ll;
typedef unsigned long long ull;
@ -16,14 +15,12 @@ template <typename T> struct Coord {
this->y = y;
}
static inline const std::array<Coord<T>, 4> units() {
return {
static inline const std::array<Coord<T>, 4> units = {
Coord<T>(0, 1),
Coord<T>(1, 0),
Coord<T>(0, -1),
Coord<T>(-1, 0),
};
}
Coord<T> operator-() { return {-this->x, -this->y}; }