main
Araozu 2023-10-31 21:53:42 -05:00
parent 2102e35083
commit 2dcca0e720
3 changed files with 36 additions and 41 deletions

View File

@ -21,7 +21,6 @@ object Day01 extends Solution:
current_sum = 0 current_sum = 0
"part 1: " + max_calories_amount.toString() "part 1: " + max_calories_amount.toString()
override def part_02() = override def part_02() =
@ -44,10 +43,8 @@ object Day01 extends Solution:
else if current_sum > max2 then else if current_sum > max2 then
max3 = max2 max3 = max2
max2 = current_sum max2 = current_sum
else if current_sum > max3 then else if current_sum > max3 then max3 = current_sum
max3 = current_sum
current_sum = 0 current_sum = 0
"part 2: " + (max1 + max2 + max3).toString() "part 2: " + (max1 + max2 + max3).toString()

View File

@ -14,7 +14,6 @@ enum RPS:
case (Rock, Rock) | (Paper, Paper) | (Scissor, Scissor) => 3 case (Rock, Rock) | (Paper, Paper) | (Scissor, Scissor) => 3
case _ => 0 case _ => 0
enum Outcome: enum Outcome:
case Win, Draw, Lose case Win, Draw, Lose
@ -24,8 +23,6 @@ enum Outcome:
case (Win, RPS.Scissor) | (Lose, RPS.Paper) => RPS.Rock case (Win, RPS.Scissor) | (Lose, RPS.Paper) => RPS.Rock
case (Draw, _) => opponent_choice case (Draw, _) => opponent_choice
object Day02 extends Solution: object Day02 extends Solution:
override def part_01() = override def part_01() =
val file = read_input("02") match val file = read_input("02") match
@ -50,7 +47,9 @@ object Day02 extends Solution:
case _ => return "Unexpected char found (pos 2)" case _ => return "Unexpected char found (pos 2)"
) )
score += self_choice.get_score() + self_choice.get_match_score(opponent_choice) score += self_choice.get_score() + self_choice.get_match_score(
opponent_choice
)
s"part 2: $score" s"part 2: $score"
@ -79,7 +78,8 @@ object Day02 extends Solution:
val self_choice = outcome.get_choice(opponent_choice) val self_choice = outcome.get_choice(opponent_choice)
score += self_choice.get_score() + self_choice.get_match_score(opponent_choice) score += self_choice.get_score() + self_choice.get_match_score(
opponent_choice
)
s"part 2: $score" s"part 2: $score"

View File

@ -6,5 +6,3 @@ import scala.util.Random
println("Advent of code 2022 with Scala") println("Advent of code 2022 with Scala")
println(Day02.part_01()) println(Day02.part_01())
println(Day02.part_02()) println(Day02.part_02())