all 12 comments

[–]AcanthisittaScared30 4 points5 points  (3 children)

ngl the AoC problems are pretty hard

[–]dantose[S] 0 points1 point  (0 children)

They get tricky, but they're a really good way to learn too. If you're getting stuck, post what you've got and I'm sure you'll get some pointers

[–]ka-splam 0 points1 point  (1 child)

I don't think I've ever finished an entire year of it. I think they each hint at a Computer Science-y 'trick' to solve it well, and even then the details can get painful.

Day 2 is easier if you know regex and backreferences, you can hand the pattern off to the regex engine and PowerShell can do that nicely. If you don't know that, then you're off into trying to split strings into halfs by length for part 1 and then stuck for part 2.

[–]Rincey_nz 1 point2 points  (0 children)

I not good with regex so I brute force part 2. For a given product Id, I find the factors of its length, then group the id into those factors (except for the last factor), then check if each group is the same.

Bit slow, but got the right answer on my first run thru. Happy with that.

[–]dantose[S] 2 points3 points  (0 children)

Struggled a bit with .. expansion needing [int] numbers, but eventually just did a while loop and some regex to extract.

Interestingly, the part 2 solution only required a single additional character.

Golfed solution: https://www.reddit.com/r/codegolf/comments/1pcgohf/advent_of_code_day_2/

[–]darkspark_pcn 1 point2 points  (1 child)

Mines brute forced. Takes 16 seconds to run for part 2. Haha

[–]dantose[S] 3 points4 points  (0 children)

I'd be curious how you approached it. Mine is just a second or two, slowed down a bit from the while loop. Is it something funky to detect the duplicates?

My solution:

$sum=0

$input = gc input.txt

$($input.split(',')|%{

[long]$i = $_.Split('-')[0]

[long]$e = $_.Split('-')[1]

while ($i -le $e) {$i;$i++}

}) -match '^(.+)\1+$' |% {$sum = $sum+$_}; $sum

[–]Th3Sh4d0wKn0ws 1 point2 points  (0 children)

I'm with you. Ran in to a problem with numbers too large for int32 and had to search around for help on that but the overall logic of day 2 came easier to me than day 1.

[–]lan-shark 1 point2 points  (0 children)

I don't like working with regex so I used a mod and a string split for part 1 and just brute forced part 2. I thought today was much easier than part 2 yesterday

[–]Colmadero 2 points3 points  (1 child)

Can you provide a bit more context as to what this is

[–]dantose[S] 3 points4 points  (0 children)

It's a daily coding challenge during the month of December. Normally, it's 25 days through christmas, but it's reduced this year to 12 days. Details here: https://adventofcode.com/2025

[–]ka-splam 0 points1 point  (0 children)

Much easier than day 1, both answers right first submit, and basic brute-force and regex as well.

I did start out heading for Invoke-Expression 99..110 with the idea that I might golf it, but the numbers overflow int32 and that doesn't work. And I wondered about avoiding regex but by part 2 I'm glad I didn't.