r/PowerShell • u/dantose • Dec 04 '25
Advent of code day 3 and 4
Got a bit busy yesterday. I'm currently working on day 3 part 2. How's everyone else coming?
If you don't know what' I'm talking about, it's a coding challenge that runs every december.
11
Upvotes
2
u/Future-Remote-4630 Dec 04 '25
Day 4 has taken me for a spin. So many wrong answers, finally got through it, after removing all semblances of elegance from my attempts.
1
u/dantose Dec 04 '25 edited Dec 05 '25
My very ugly part 1.
And part 2:
1
u/dantose Dec 09 '25 edited Dec 09 '25
Day 4 part 1:
Part 2, which takes a little while.
4
u/pandiculator Dec 04 '25
I've managed to complete them all so far (eight gold stars) and I'm enjoying the challenge.
But I don't think my scripts would win any prizes. I've reverted to programming techniques, rather than PowerShell techniques for all my answers: Lots of
whileloops,forloops and counters rather than cmdlets and pipelines.I've been impressed by how neat and concise some of the solutions are compared to my hacky (but working!) attempts.
1
u/ka-splam Dec 07 '25 edited Dec 07 '25
Day 3 part 1 done. And kinda stuck on part 2.
Day 4 Part 1, literally a brute-force loop for each row and column position, if it has a roll, check the 8 surrounding positions:
Day 4 Part 2 looks very similar, just changed the rows into arrays so I could replace '@' with '.' and wrapped it in a loop until the output stops changing:
Runtime is about 5 seconds in PS 5.1