AdventOfCode/Nu/2015/01.nu
2024-10-22 01:27:29 +02:00

10 lines
222 B
Text

use std
def main [input] {
open --raw $input
| split chars
| each { match $in { '(' => 1, ')' => -1 } }
| std iter scan 0 {|it, acc| $it + $acc }
| tee { last | print }
| std iter find-index {|x| $x == -1 }
}