2025/2: nushell part 1

This commit is contained in:
2026-04-03 22:45:25 +02:00
parent cf64d5950e
commit 87457e0a92

26
2025/2/nu/main.nu Executable file
View File

@@ -0,0 +1,26 @@
#!/usr/bin/env nu
def part-1 [parsed] {
$parsed
| each -f {
|row| where {|x| into string
| split chars
| take (($in | length) // 2)
| ($in | str join) + ($in | str join)
| try {into int} catch {0}
| $in == $x
}
} | math sum
}
let input = open input
let parsed = $input
| str trim
| lines
| str join
| split row ','
| split column '-'
| rename l u
| into int l u
| each {|row| $row.l..$row.u}
timeit {print (part-1 $parsed)}