Add solution for "Day 20: Race Condition", part 2

This commit is contained in:
2025-06-04 23:29:27 +02:00
parent 43f1798343
commit e1eb8fbe2b
6 changed files with 80 additions and 37 deletions

View File

@@ -15,7 +15,8 @@
#pragma once
#include <aoc/common/Grid.hpp>
#include <vector>
#include <aoc/framework/LinesSolver.hpp>
class RaceCondition
@@ -29,9 +30,9 @@ class RaceCondition
private:
static constexpr char getStartChar();
static constexpr char getWallChar();
static constexpr int getCheatLength();
const std::array<Point2, 8> doubleSteps_{ Point2::down * 2, Point2::downRight, Point2::right * 2,
Point2::upRight, Point2::up * 2, Point2::upLeft, Point2::left * 2, Point2::downLeft };
static constexpr int getPart1CheatLength();
static constexpr int getPart2CheatLength();
int threshold_;
void checkCheat(const Point2& position, Grid<int>& times);
bool tryFindNextPathPosition(std::vector<Point2>& path);
void checkCheat(const std::vector<Point2>& path);
};

View File

@@ -36,6 +36,7 @@ class Point2
int x, y;
Point2();
Point2(const int x, const int y);
int calcManhattanDistance(const Point2& other) const;
bool operator==(const Point2& rhs) const;
bool operator!=(const Point2& rhs) const;
bool operator<(const Point2& rhs) const;