diff options
author | Oscar Najera <hi@oscarnajera.com> | 2023-01-28 03:46:12 +0100 |
---|---|---|
committer | Oscar Najera <hi@oscarnajera.com> | 2023-01-28 03:46:12 +0100 |
commit | 84ec86b63ac38423ce021448e379b87094f7d4ac (patch) | |
tree | 6574d8b2b5aef30845f38e279a4c389d9fa8897e /AoC2022/04 | |
parent | 497dc1ea9de502761c00ead6de62abe6eeea67d6 (diff) | |
download | scratch-84ec86b63ac38423ce021448e379b87094f7d4ac.tar.gz scratch-84ec86b63ac38423ce021448e379b87094f7d4ac.tar.bz2 scratch-84ec86b63ac38423ce021448e379b87094f7d4ac.zip |
more julia and formatted
Diffstat (limited to 'AoC2022/04')
-rw-r--r-- | AoC2022/04/solver.jl | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/AoC2022/04/solver.jl b/AoC2022/04/solver.jl index 0f512ae..31cabce 100644 --- a/AoC2022/04/solver.jl +++ b/AoC2022/04/solver.jl @@ -1,15 +1,15 @@ using Test -subinterval(a0, a1, b0, b1) = a0<= b0 && a1 >= b1 +subinterval(a0, a1, b0, b1) = a0 <= b0 && a1 >= b1 subcontained(a0, a1, b0, b1) = subinterval(a0, a1, b0, b1) || subinterval(b0, b1, a0, a1) overlap(a0, a1, b0, b1) = a0 <= b1 && b0 <= a1 data = open("input") do f - map(l-> parse.(Int, l), eachsplit.(eachsplit(read(f,String)), r"[,-]")) + map(l -> parse.(Int, l), eachsplit.(eachsplit(read(f, String)), r"[,-]")) end @testset "solutions" begin - @test map(l-> subcontained(l...) ,data) |>sum == 515 - @test map(l-> overlap(l...) ,data) |>sum == 883 + @test map(l -> subcontained(l...), data) |> sum == 515 + @test map(l -> overlap(l...), data) |> sum == 883 end |