Skip to content

Instantly share code, notes, and snippets.

@kibibites
Last active March 27, 2025 20:38
Show Gist options
  • Save kibibites/eb78e2c247ece93bf72d0e1985e18da4 to your computer and use it in GitHub Desktop.
Save kibibites/eb78e2c247ece93bf72d0e1985e18da4 to your computer and use it in GitHub Desktop.
code advent 2024 solutions in uiua

here are my solutions (partially) in uiua for advent of code 2024.

there is an explained version with filename ending in _long and a minimized version ending in _short for each part in each day.

i might explain more for each one on my website here so yea :3

&fras "day1.txt"
⊜(⊜⋕⊸≠@\s)⊸≠@\n
# transpose to get columns
# sort each column
≡⍆
# pop the two columns into stacks
♭:°⊂
# find the Δ
⌵-
# sum
/+
&fras "day1.txt"
⊜(⊜⋕⊸≠@\s)⊸≠@\n
/+⌵-♭:°⊂≡⍆⍉
&fras "day2.txt"
⊜(□⊜⋕⊸≠@\s)⊸≠@\n
# for each row
≡(
# unbox
°□
# get Δ for each num
↘¯1-↻₁.
# Δ should be either only increasing or decreasing
=1⧻◴±.
# for all Δ; 1≤Δ≤3
× ≤3: ≥1.⌵:
# logical and
×
)
# sum
/+
&fras "day2.txt"
⊜(□⊜⋕⊸≠@\s)⊸≠@\n
/+≡(×/××≤3:≥1.⌵:=1⧻◴±.↘¯1-↻₁.°□)
&fras "input"
# regex parse string
regex"mul\\((\\d+),(\\d+)\\)"
# drop the first string in each row
≡↘₁
# parse the numbers
≡⋕
# multiply
≡(/×)
# sum
/+
&fras "input"
/+≡(/×)≡⋕≡↘₁regex"mul\\((\\d+),(\\d+)\\)"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment