twiddling

This commit is contained in:
rhiannon morris 2022-01-25 22:45:33 +01:00
parent 4682fe282f
commit f665be0180
1 changed files with 13 additions and 16 deletions

29
aoc.bqn
View File

@ -112,30 +112,27 @@ aoc9 ⇐ {
################################################################################ ################################################################################
Fst {0 𝕩? @; 𝕩} At {1 ( 𝕩˙)¨/ 𝕨} # use ⎊ for default
At {1 ( 𝕩˙)¨/ 𝕨} # use ⎊ for default
aoc10 { aoc10 {
BadScore1 ')'3,']'57,'}'1197,'>'25137At0 BadScore1 ')'3,']'57,'}'1197,'>'25137At
BadScore BadScore1 {'!'c: c; @} BadScore {'!'c: BadScore1 c; 0}
pairs Words "() [] {} <>"
Step { Step {
'!' Fst 𝕨? 𝕨; '!' @ 𝕩? 𝕩;
𝕨 𝕊 ')': '(' = Fst 𝕨? 1𝕨; 𝕨 = pairs At@ 𝕩? 1𝕩;
𝕨 𝕊 ']': '[' = Fst 𝕨? 1𝕨; 𝕨 ¨pairs? 𝕨𝕩;
𝕨 𝕊 '}': '{' = Fst 𝕨? 1𝕨; '!'𝕨
𝕨 𝕊 '>': '<' = Fst 𝕨? 1𝕨;
𝕩"([{<"? 𝕩𝕨;
'!'𝕩
} }
Find ""(Step˜´) Find ""(Step´)
GoodScore1 '('1,'['2,'{'3,'<'4At GoodScore1 '('1,'['2,'{'3,'<'4At
GoodScoreN {0 ((GoodScore1 ) + (5× ))´ 𝕩} GoodScore {'!' 𝕩? 0 ((GoodScore1 ) + (5× ))´ 𝕩; 0}
GoodScore GoodScoreN {'!' Fst 𝕩? ""; 𝕩}
Middle ((÷2) ) (0¨/) Middle ((÷2) ) (0¨/)
A +´ (BadScoreFind¨) •FLines A +´ BadScoreFind¨ •FLines
B Middle (GoodScoreFind¨) •FLines B Middle GoodScoreFind¨ •FLines
} }