Zum Hauptinhalt springen
tsecurity.de LIVE
Echtzeit-Radar & Feeds
Alle RSS Feeds
👥 Community & Social
Web Security TippsIntroducing the new Confluence integration with Google Chat(22.09.2026 um 19:40 Uhr)
Web Security TippsQuick notes in Take notes for me(22.09.2026 um 21:31 Uhr)
Sichere ProgrammierungSecurity improvements for SSH(22.09.2026 um 16:11 Uhr)
Sichere ProgrammierungKI-Akzeptanz: Wie Rewe digital einfach nur den Chatbot umbenannte(22.09.2026 um 18:00 Uhr)
Sichere ProgrammierungClaude Opus 5.5: Keeping safety ahead of capabilities(22.09.2026 um 20:59 Uhr)
Sichere ProgrammierungYour Terraform Monolith Isn't Too Big. It's Tightly Coupled.(22.09.2026 um 21:00 Uhr)
Sichere ProgrammierungMy PR got merged into Mike — OSS Legal AI Platform 🎉(22.09.2026 um 21:34 Uhr)
Sichere ProgrammierungStop Writing JavaScript To Fix `100vh` On Mobile(22.09.2026 um 21:35 Uhr)
Sichere ProgrammierungNext.js proxy.ts Explained (with Cheat Sheet)(22.09.2026 um 21:36 Uhr)
Web Security TippsIntroducing the new Confluence integration with Google Chat(22.09.2026 um 19:40 Uhr)
Web Security TippsQuick notes in Take notes for me(22.09.2026 um 21:31 Uhr)
Sichere ProgrammierungSecurity improvements for SSH(22.09.2026 um 16:11 Uhr)
Sichere ProgrammierungKI-Akzeptanz: Wie Rewe digital einfach nur den Chatbot umbenannte(22.09.2026 um 18:00 Uhr)
Sichere ProgrammierungClaude Opus 5.5: Keeping safety ahead of capabilities(22.09.2026 um 20:59 Uhr)
Sichere ProgrammierungYour Terraform Monolith Isn't Too Big. It's Tightly Coupled.(22.09.2026 um 21:00 Uhr)
Sichere ProgrammierungMy PR got merged into Mike — OSS Legal AI Platform 🎉(22.09.2026 um 21:34 Uhr)
Sichere ProgrammierungStop Writing JavaScript To Fix `100vh` On Mobile(22.09.2026 um 21:35 Uhr)
Sichere ProgrammierungNext.js proxy.ts Explained (with Cheat Sheet)(22.09.2026 um 21:36 Uhr)
Intelligence View
⚡ tsecurity.de Intelligence

Advent of Code 2025 - December 10th

In this series, I'll share my progress with the 2025 version of Advent of Code. Check the first post for a short intro to this series. You can also follow my progress on GitHub. December 10th The puzzle of day 10 was fun for…

0
↗ Quelle (dev.to)
Reagiere als Erste:r — dein Feedback zählt!

In this series, I'll share my progress with the 2025 version of Advent of Code.



Check the first post for a short intro to this series.



You can also follow my progress on GitHub.






December 10th



The puzzle of day 10 was fun for part one, and very disappointing for part two. Part two requires much more time than what I have available, and perhaps also a third-party library. I only completed part one for this day 😢



My pitfall for this puzzle: Although the code for part two works for the sample input, it does not terminate for the puzzle input. From what I've peeked at solutions for this day on Reddit, most people apply Gaussian Elimination, and most use a library for it.




Solution here, do not click if you want to solve the puzzle first yourself




#include <cassert>
#include
<fstream>
#include
<iostream>
#include
<sstream>

typedef std::vector<std::vector<int>> Wiring;

struct Machine {
Wiring wiring;
std::string startLights;
std::string endLights;
std::vector<int> startJoltage;
std::vector<int> endJoltage;
};

std::vector<Machine> loadInput(const std::string &filename) {
std::vector<Machine> result;
std::ifstream file(filename);
std::string line;
while (std::getline(file, line)) {
auto rSquareIndex = line.find(']');
std::string endLights = line.substr(1, rSquareIndex - 1);
bool inWiring = false;
bool injoltage = false;
std::string numberBuffer;
Wiring wiring;
std::vector<int> currentWiring;
std::vector<int> endJoltage;
for (auto i = rSquareIndex + 1; i < line.length(); ++i) {
if (line[i] == ')') {
inWiring = false;
currentWiring.push_back(std::stoi(numberBuffer));
numberBuffer.clear();
wiring.push_back(currentWiring);
} else if (line[i] == '(') {
inWiring = true;
currentWiring.clear();
} else if (inWiring) {
if (line[i] == ',') {
currentWiring.push_back(std::stoi(numberBuffer));
numberBuffer.clear();
} else {
numberBuffer += line[i];
}
} else if (line[i] == '{') {
injoltage = true;
} else if (line[i] == '}') {
injoltage = false;
endJoltage.push_back(std::stoi(numberBuffer));
numberBuffer.clear();
} else if (injoltage) {
if (line[i] == ',') {
endJoltage.push_back(std::stoi(numberBuffer));
numberBuffer.clear();
} else {
numberBuffer += line[i];
}
}
}
result.emplace_back(Machine{wiring, std::string(endLights.length(), '.'), endLights,
std::vector<int>(endJoltage.size(), 0), endJoltage});
}
return result;
}

std::string doMove(const std::string &current, const std::vector<int> &move) {
std::string next = current;
for (int i : move) {
next[i] = current[i] == '.' ? '#' : '.';
}
return next;
}

int calcSteps(const Machine &m) {
std::vector<std::string> states;
states.push_back(m.startLights);
int step = 1;
while (true) {
std::vector<std::string> nextStates;
for (const auto &state : states) {
for (const auto &move : m.wiring) {
auto nextState = doMove(state, move);
if (nextState == m.endLights) {
return step;
}
nextStates.push_back(nextState);
}
}
step++;
states = nextStates;
}
}

std::vector<int> doMovePartTwo(const std::vector<int> &current, const std::vector<int> &move) {
std::vector<int> next = current;
for (int i : move) {
next[i] = current[i] - 1;
}
return next;
}

std::vector<int> minElementIndices(const std::vector<int> &v) {
std::vector<int> result;
auto minElement = 0;
for (int i : v) {
if (minElement == 0) {
minElement = i;
} else if (i > 0 && i < minElement) {
minElement = i;
}
}
for (int i = 0; i < v.size(); ++i) {
if (v[i] == minElement) {
result.push_back(i);
}
}
return result;
}

bool contains(const std::vector<int> &v, std::vector<int> values) {
for (auto value : values) {
if (std::find(v.begin(), v.end(), value) != v.end()) {
return true;
}
}
return false;
}

int calcStepsPartTwo(const Machine &m) {
std::vector<std::vector<int>> states;
states.push_back(m.endJoltage);
int step = 1;
while (true) {
std::vector<std::vector<int>> nextStates;
for (const auto &s : states) {
auto indices = minElementIndices(s);
for (const auto &w : m.wiring) {
if (!contains(w, indices)) {
continue;
}
auto nextState = doMovePartTwo(s, w);
if (nextState == m.startJoltage) {
return step;
}
if (*std::min_element(nextState.begin(), nextState.end()) < 0) {
continue;
}
if (std::find(nextStates.begin(), nextStates.end(), nextState) == nextStates.end()) {
nextStates.push_back(nextState);
}
}
}
step++;
states = nextStates;
}
}

void partOne() {
const auto machines = loadInput("/Users/rob/projects/robvanderleek/adventofcode/2025/10/input.txt");
long result = 0;
for (const auto &m : machines) {
result += calcSteps(m);
}
std::cout << result << std::endl;
assert(result == 558);
}

void partTwo() {
const auto machines = loadInput("/Users/rob/projects/robvanderleek/adventofcode/2025/10/input-small.txt");
long result = 0;
for (int i = 0; i < machines.size(); ++i) {
std::cout << "Processing machine " << i + 1 << " of " << machines.size() << std::endl;
result += calcStepsPartTwo(machines[i]);
}
std::cout << result << std::endl;
assert(result == 0);
}

int main() {
partOne();
partTwo();
return 0;
}









That's it! See you again tomorrow!

Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten Advent of Code 2025 - December 10th

Thematisch verwandte Begriffe: Advent, Code, 2025, December · 6 Treffer

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Zum Aktualisieren ziehen
ZERO-DAY CVE-2026-77259 | MCP Atlassian is a Model Context Protocol (MCP) server for Atlassian pro…
Advisory →
TTS Reader • tsecurity.de Voice
tsecurity.de Icon
tsecurity.de App
Offline-Lesen, Eilmeldungen & 0ms Ladezeit

Installiere tsecurity.de direkt auf deinen Home-Bildschirm für das ultimative Vollbild-Magazinerlebnis ohne Browser-Leisten.

Nächster Beitrag
Themen-Radar & Intelligence Matrix
Echtzeit-Taxonomie nach Angriffsvektoren & Plattformen

tsecurity.de Live Threat Radar

🔴 LIVE RADAR
MONITORING
AKTIV
CVE-DATENBANK
LIVE
🔍
Community Radar & Live Chat
Sentinel Bot online • Live-Stream
Dein Cluster: Security Explorer
Match:
lädt…
Verbindung zum Community-Stream wird aufgebaut...
Bearbeitungsmodus — Senden überschreibt deine Nachricht
Community-Puls — was gerade passiert
lädt…
Aktivitäten deiner Analysten
lädt…
Neues Thema oder Eilmeldung einreichen

Reiche interessante Links, Zero-Days oder Debatten ein. Die Community entscheidet per Upvote über die Veröffentlichung.

Heiß diskutierte Einreichungen
🔖 Gespeicherte Artikel
📂 Keine gespeicherten Artikel vorhanden.
Zurück Ziehen Vor
Links: vorheriger Artikel Rechts: nächster Artikel unten: schließen
News NIS-2 Frühwarnung Tier-1 Intel ⏱️ 3 Min vor 10 Min
Artikeldaten werden geladen...

Zurück: vorheriger Vor: nächster
↗ Original-Quelle
Social Reaktionen Deine Reaktion zählt
Einstufung & Relevanz-Poll 0 Stimmen
In sozialen Netzwerken teilen 1-Klick