4 ms·
Now try BQN (Advent of Code 2020 Problem 2): Split ←((⊢-˜+`׬)∘=⊔⊢) input2←' 'Split¨•file.Lines "../202
by satvikpendem 2y ago
Now try BQN (Advent of Code 2020 Problem 2):
Split ←((⊢-˜+`׬)∘=⊔⊢)
input2←' 'Split¨•file.Lines "../2020/2.txt" # change string to your file location
Day2←{
f←⊑{(⊑)+↕1+|-´}‿{-1} # Select the [I]ndex generator [F]unction
I←{F •BQN¨ '-' Split ⊑} # [I]ndices used to determine if the
C←{⊑1⊑} # [C]haracter appears in the
P←{⊑⌽} # [P]assword either
Part1←(I∊˜·+´C= P)¨ # a given number of times
Part2←(1= ·+´C=I⊏P)¨ # or at one of a pair of indices
⊑+´◶Part1‿Part2
}
•Show { Day2 input2}¨↕2
- LtdJorge 2y agoOr Brainfuck https://github.com/nicuveo/advent-of-code/blob/main/2022/brainfuck/01-A.bf https://github.com/nicuveo/advent-of-code/blob/main/2022/bra...