mirror of
https://github.com/fredrikr79/advent_of_code.git
synced 2026-04-15 22:40:43 +02:00
2025/2: nushell part 1
This commit is contained in:
26
2025/2/nu/main.nu
Executable file
26
2025/2/nu/main.nu
Executable 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)}
|
||||
Reference in New Issue
Block a user