Add extra nushell solution for 2022 day 01
This commit is contained in:
parent
bede4baead
commit
19cd82b79d
6
2022/day-01/extra/part1.nu
Normal file
6
2022/day-01/extra/part1.nu
Normal file
@ -0,0 +1,6 @@
|
||||
source sums.nu
|
||||
|
||||
def main [path = "../inputs/puzzle.txt"] {
|
||||
sums $path
|
||||
| math max
|
||||
}
|
8
2022/day-01/extra/part2.nu
Normal file
8
2022/day-01/extra/part2.nu
Normal file
@ -0,0 +1,8 @@
|
||||
source sums.nu
|
||||
|
||||
def main [path = "../inputs/puzzle.txt"] {
|
||||
sums $path
|
||||
| sort -r
|
||||
| take 3
|
||||
| math sum
|
||||
}
|
9
2022/day-01/extra/sums.nu
Normal file
9
2022/day-01/extra/sums.nu
Normal file
@ -0,0 +1,9 @@
|
||||
def sums [path: string] {
|
||||
open $path
|
||||
| split row "\n\n"
|
||||
| each {
|
||||
split row "\n"
|
||||
| into int
|
||||
| math sum
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user