mirror of
https://github.com/fredrikr79/advent_of_code.git
synced 2026-04-24 02:36:10 +02:00
Compare commits
2 Commits
cf64d5950e
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 16684fea02 | |||
| 87457e0a92 |
Executable
+26
@@ -0,0 +1,26 @@
|
||||
#!/usr/bin/env nu
|
||||
def part-1 [parsed] {
|
||||
$parsed
|
||||
| par-each {
|
||||
|row| where {|x| into string
|
||||
| split chars
|
||||
| take (($in | length) // 2)
|
||||
| ($in | str join) + ($in | str join)
|
||||
| try {into int} catch {0}
|
||||
| $in == $x
|
||||
}
|
||||
} | flatten | 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