Skip to content

Instantly share code, notes, and snippets.

@mankyKitty
Last active January 3, 2024 13:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mankyKitty/e46e80480ac13fd99ab4149107bf6ed5 to your computer and use it in GitHub Desktop.
Save mankyKitty/e46e80480ac13fd99ab4149107bf6ed5 to your computer and use it in GitHub Desktop.
x ← ⊜□ ≠@\n.&fras "aoc_inputs/day1"
# remove all the non-numeric characters
# take first and last
# parse to number
# sum them all
# DayOnePartOne ← /+∵(⋕⊂⊃⊢(⊢⇌)▽<@a.°□)
# DayOnePartOne x
Wrd ← {"one" "two" "three" "four" "five" "six" "seven" "eight" "nine"}
# find start positions of number words and 0-index of which word
v ← ⊚⊞⊐⌕Wrd
# on a copy, find the min and max positions
# select the number word indices using the above
# these are 0-indices so add one to each to get the numeric value of each.
# now I'm stuck because this only works for strings with multiple valid
# number words.. not sure how to handle single number strings.
g ← ≡↙1⊝+1⊏⊂⊃(⊗/↧.)(⊗/↥.)≡↘1.
i ← ⊢x
y ← ⊢↘3x
g v i
g v y
―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
╭─
╷ 6
╭─
╷ 4
2
―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment