a few more

This commit is contained in:
rhiannon morris 2022-01-25 22:04:31 +01:00
parent 4bee69d8b1
commit 4682fe282f
1 changed files with 49 additions and 3 deletions

52
aoc.bqn
View File

@ -33,6 +33,7 @@ aoc3 ⇐ {
Gamma Most˘ BitFile
A ¬(×FromBin) Gamma
B {"nah"!0, 𝕩}
}
################################################################################
@ -74,8 +75,8 @@ aoc5 ⇐ {
################################################################################
aoc6 {
FishFile /CSVInt•FLines
Step ( × (/68)˙) +(9) «
FishFile 9 / CSVInt •FLines
Step ( × (/68)˙) + «
Fishies {+´ Step𝕨 FishFile 𝕩}
A 80Fishies, B 256Fishies
}
@ -83,7 +84,7 @@ aoc6 ⇐ {
################################################################################
aoc7 {
CrabFile CSVInt•FLines
CrabFile CSVInt •FLines
Range {l + (´𝕩)¬(l´𝕩)}
@ -93,3 +94,48 @@ aoc7 ⇐ {
_Go {´ ps𝔽¨ Range psCrabFile 𝕩}
A FuelA _Go, B FuelB _Go
}
################################################################################
aoc8 {AB{"maybe later"!0, 𝕩}}
################################################################################
aoc9 {
SmokeFile > -'0' •FLines
Adj {<1 > «˘𝕩, »˘𝕩, «˘𝕩, »˘𝕩}
Lowest ´¨ <Adj
Risk 1+ × Lowest
A +´ Risk SmokeFile
B {"nah"!0, 𝕩}
}
################################################################################
Fst {0 𝕩? @; 𝕩}
At {1 ( 𝕩˙)¨/ 𝕨} # use ⎊ for default
aoc10 {
BadScore1 ')'3,']'57,'}'1197,'>'25137At0
BadScore BadScore1 {'!'c: c; @}
Step {
'!' Fst 𝕨? 𝕨;
𝕨 𝕊 ')': '(' = Fst 𝕨? 1𝕨;
𝕨 𝕊 ']': '[' = Fst 𝕨? 1𝕨;
𝕨 𝕊 '}': '{' = Fst 𝕨? 1𝕨;
𝕨 𝕊 '>': '<' = Fst 𝕨? 1𝕨;
𝕩"([{<"? 𝕩𝕨;
'!'𝕩
}
Find ""(Step˜´)
GoodScore1 '('1,'['2,'{'3,'<'4At
GoodScoreN {0 ((GoodScore1 ) + (5× ))´ 𝕩}
GoodScore GoodScoreN {'!' Fst 𝕩? ""; 𝕩}
Middle ((÷2) ) (0¨/)
A +´ (BadScoreFind¨) •FLines
B Middle (GoodScoreFind¨) •FLines
}