r/codegolf • • Dec 02 '25

Advent of Code: Day 2

What do you guys have?

7 Upvotes

9 comments sorted by

View all comments

Show parent comment

2

u/surfingoldelephant Dec 03 '25 edited Dec 03 '25

Yep, you're right. |measure -su for it to be version-agnostic. -join'+'|iex also works instead.

Down to 99:

(gc input.txt|% sp* `,|%{for([long]$i,$e=$_|% sp* -;$i-le$e){($i++)}})-match'^(.+)\1$'-join'+'|iex

I've been trying to remove the $i type-constraint. It doesn't have to be a [long] (unless it's being type-constrained); it just needs to be a numeric value before the first ++.

Edit:

Also 99:

(gc input.txt|% sp* `,|%{for($i,$e=$_|% sp* -;$i-$e-1){$i-=0;($i++)}})-match'^(.+)\1$'-join'+'|iex

96:

(gc input.txt|% sp* `,|%{for($i,$e=$_|% sp* -;$i-$e-1){$i;$i-=-1}})-match'^(.+)\1$'-join'+'|iex