aboutsummaryrefslogtreecommitdiffstats
path: root/AoC2022/02/solver.jl
diff options
context:
space:
mode:
authorOscar Najera <hi@oscarnajera.com>2023-01-28 03:46:12 +0100
committerOscar Najera <hi@oscarnajera.com>2023-01-28 03:46:12 +0100
commit84ec86b63ac38423ce021448e379b87094f7d4ac (patch)
tree6574d8b2b5aef30845f38e279a4c389d9fa8897e /AoC2022/02/solver.jl
parent497dc1ea9de502761c00ead6de62abe6eeea67d6 (diff)
downloadscratch-84ec86b63ac38423ce021448e379b87094f7d4ac.tar.gz
scratch-84ec86b63ac38423ce021448e379b87094f7d4ac.tar.bz2
scratch-84ec86b63ac38423ce021448e379b87094f7d4ac.zip
more julia and formatted
Diffstat (limited to 'AoC2022/02/solver.jl')
-rw-r--r--AoC2022/02/solver.jl10
1 files changed, 5 insertions, 5 deletions
diff --git a/AoC2022/02/solver.jl b/AoC2022/02/solver.jl
index b93a88f..0516fc7 100644
--- a/AoC2022/02/solver.jl
+++ b/AoC2022/02/solver.jl
@@ -2,7 +2,7 @@ using Match
using Test
plays = open("input") do f
- split.(eachsplit(read(f, String),"\n", keepempty=false))
+ split.(eachsplit(read(f, String), "\n", keepempty = false))
end
translate(play) = @match play begin
@@ -11,7 +11,7 @@ translate(play) = @match play begin
"C" || "Z" => :scissors
end
-weigth(play)= @match play begin
+weigth(play) = @match play begin
:rock => 1
:paper => 2
:scissors => 3
@@ -58,12 +58,12 @@ function reactive_play(oponent, my)
"Y" => oponent_hand
"Z" => looses(oponent_hand) # I win
_ => error("Invalid input")
- end
+ end
points(my_hand, oponent_hand) + weigth(my_hand)
end
@testset "solutions" begin
- @test map(((op, my),) -> fixed_play(op,my), plays) |> sum == 12535
- @test map(((op, my),) -> reactive_play(op,my), plays) |> sum == 15457
+ @test map(((op, my),) -> fixed_play(op, my), plays) |> sum == 12535
+ @test map(((op, my),) -> reactive_play(op, my), plays) |> sum == 15457
end