Last active
January 3, 2024 13:22
-
-
Save mankyKitty/e46e80480ac13fd99ab4149107bf6ed5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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