Advent of Code 2022 - Day 15

preview_player
Показать описание
Today was the most I've struggled so far... but then I had an epiphany!

===== Chapters =====
0:00 Intro
0:08 Reading Part 1
3:35 Part 1
28:29 Reading Part 2
30:17 Part 2
47:45 Part 1&2 Solution Explanation

===== Music =====
Audionautix - Carol Of The Bells
Audionautix - Joy To The World
DJ Williams - Jingle Bells
E's Jammy Jams - Deck the Halls (Instrumental Jazz)
Jingle Punks - Deck the Halls (Instrumental)
Jingle Punks - O Christmas Tree (Instrumental)
Twin Musicom - Hip Hop Christmas
Lake George - William Rosati
Рекомендации по теме
Комментарии
Автор

Helloo turkey I’m back, and as normal my god your content still amazing

Danishdostuff
Автор

43:37 had the exact same 🤣 though mine happened @ 1:50:29 (sad I can't link to the exact spot in my video so you can just click it, but YT will pretty much hide any comment that has a link) 😅

NKCSS
Автор

I have done a cleaned up version. There were a few variables you didn't need.

public int solve(String input) {
List<InputLine> inputLines = setup(input);
int lineToFind =
Set<Integer> invalidPoints = new HashSet<>();
for(InputLine inputLine : inputLines) {
int remaining = getRemainingOnLine(inputLine, lineToFind);
if(remaining < 0)
continue;
for(int i = 0; i <= remaining; i++) {
+ i);
- i);
}
}
return invalidPoints.size() - 1;
}

long solveTwo(String input) {
List<InputLine> inputLines = setup(input);
int max =
for(int i = 0; i < max; i++) {
for(int x = 0; x <= max;) {
int newX = x;
for(InputLine il : inputLines) {
newX = skipOverLine(il, x, i);
if(x != newX)
break;
}
if(newX == x) return ((long) x * max) + i;
x = newX;
}
}
return -1;
}

BenjaminKane-rs
Автор

Getting that first star in less than 30 minutes is still way faster than me; took me 75 minutes 😅 wasted 30 minutes on debugging myself 😅

NKCSS
Автор

this puzzle straight hit my trauma of last year's day 19.

kathi.puzzles
Автор

Wow, today was not your day 😅Felt like this on day 13 and 9 😅wished I was there in the livestream, me yelling at the screen "you're comparing X with Y" and "compare manhattan distance between target Y and your sensor against your distance value" does nothing 😅😅

Curious to see how this continues; at 20:00 in the video now. We all have these moments, so I feel for ya 😅

NKCSS
Автор

Thanks for your solution! :) Helped me al lot.
I found a small mistake in your github code that probably happened while tidying up your code in line 86:
return dist - il.sy > y ? (il.sy - y) : (y - il.sy);
has to be
return dist - (il.sy > y ? (il.sy - y) : (y - il.sy));

sakenova