I'm genuinely fascinated every day by the way your brain is working, it's impressive, especially if taking into account you deal with it all in less than 10min from scratch
@jb318427 күн бұрын
I had a nice NumPy version of this to check the corners using offset views of the main grid. Been beating my head on the desk for why my counts were too high. Turns out I didn't pay enough attention to the requirement that the 'M' and 'S' corners must be adjacent. 🤬
@vegeta39937 күн бұрын
I checked substrings in the rows for part one, in part two I did a 3x3 grid search. Could've it based on every A but I used the same condition as you for the final X-MAS check
@mairex38037 күн бұрын
Nice solutions! For the second part i just checked whether both diagonals sum of unicode values was equal to ord('S') + ord('M').
@hyper-neutrino7 күн бұрын
that's a very interesting way to do it! i'm surprised that works given that that could hit false positives like T+L unless you checked that they were all equal to S or M first. i probably would've done like, set(diagonals) = {"S", "M"} since that ignores order. or sorted.
@galactic_fx8 күн бұрын
i hard coded this one 😭😭😭😭
@ybertold68827 күн бұрын
How so?
@galactic_fx6 күн бұрын
@ manual position checks with indices instead of looping through arrays
@hyperbolia-440318 күн бұрын
For part 2, I just checked all 3x3 squares for desired patterns lmao
@oldmajor52408 күн бұрын
Nice! For the second part, I just counted how many times the A-tiles got covered and add one to the result for every A-tile that got covered twice.
@DarkNobody20118 күн бұрын
Clever!
@vegeta39937 күн бұрын
What do you mean by a tile being 'covered' and 'covered twice'?
@oldmajor52407 күн бұрын
@@vegeta3993 You run the algorithm from part1 except, that now you only allow diagonal words. Now if you find a word, I will say that that word "covers" its letter-tiles. So if an A-tile is covered twice, it means that there are two diagonal words that covered it.
@DeviantFox8 күн бұрын
I had the right idea, just fumbled getting through it very very badly.
@RickMMarina8 күн бұрын
Nice approach, more or less like mine. For second part I just checked corners for all 'A' points this way: First, checking if all corners are inside bounds, then comparing total 'M' and total 'S' corners with 2, and finally checking if just two diagonal corners are different. List corners = [q1, q2, q3, q4]; if (corners.All(x=> InBounds(x)) && corners.Count(p=> map[p.y][p.x] == 'M') == 2 && corners.Count(p=> map[p.y][p.x] == 'S') == 2 && map[q1.y][q1.x] != map[q3.y][q3.x]) { return 1; }
@abroy778 күн бұрын
you're back!! awesome!
@supernenechi7 күн бұрын
Spent the entire day on this puzzle! And this man cracks it out like it's nothing. And I know it's nothing, but it still makes me feel a bit pathetic. I guess as a DevOps engineer rather than an actual developer, at least I'm a better YAML engineer than programmer, but still.
@hyper-neutrino7 күн бұрын
don't get discouraged! this wasn't a trivial problem and i messed it up in my first attempt and had to retry it. also correction, i'm a woman not a man jsyk :) good luck with the later problems! you'll improve and there's no shame taking a while to figure something out
@rexsybimatrimawahyu32927 күн бұрын
i genuinely want to learn more how you can handle these aoc questions, what book or sources you reading to get where you want to this day????? cos i know programming and know how to build app but im suck at algorithm question like this :)
@hyper-neutrino7 күн бұрын
hard to say. i wish i could recommend resources but it's been a long time since i referred to specific resources and i've been coding for over a decade so it is mostly just extensive experience at this point
@SlickMona7 күн бұрын
For P2 I just went with Diagonal1 in ("MS", "SM") and Diagonal2 in ("MS", "SM"). Seems a little simpler than doing all four at once?
@hyper-neutrino6 күн бұрын
i'd say they're about the same. being able to do set(d1) == set(d2) == set("SM") would make this approach better though
@Andres-it2du7 күн бұрын
I did something similar for part 2, but for part 1 I just got all the strings for lines, columns and diagonals and looked for /XMAS|SAMX/ occurrences in each on of those strings. If it’s stupid and it works it ain’t stupid, right?😅
@shell11_7 күн бұрын
how did you get the diagonals?
@hyper-neutrino7 күн бұрын
that's what i tried first. getting the diagonals is something i am apparently very terrible at and that is why i got such a bad time
@Andres-it2du7 күн бұрын
@@hyper-neutrino yeah, same, it took me like an hour of trial and error, I was too stubborn to quit at that point lol
@bartomiejbigda32888 күн бұрын
I had the same solution for part 1. For part 2, I considered that the “X” could also be formed using vertical and horizontal lines instead of just diagonals. After solving part 1, where we checked every direction, it felt natural for me to think this way. That said, I did take a quick look at the AoC subreddit for memes as hints, and the first meme I saw gave it away.
@vikingthedude7 күн бұрын
i didn't know about the subreddit. Thanks had a good laugh and i'll be sure to avoid it while i haven't solved the problem yet!