Skip to content

Commit b36962d

Browse files
committed
Tidy
1 parent 6b11e5f commit b36962d

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/main/scala/AdventOfCode2022/Day25.scala

+8-8
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ object Day25:
1111
5 * total + digit
1212
}
1313

14-
def toSnafu(i: Long, s: String = ""): String = if i == 0 then s else
15-
val (digit, prefix) = i % 5 match
16-
case 0 => (0, "0")
17-
case 1 => (1, "1")
18-
case 2 => (2, "2")
19-
case 3 => (-2, "=")
20-
case 4 => (-1, "-")
21-
toSnafu((i - digit) / 5, prefix + s)
14+
def toSnafu(i: Long): String = if i == 0 then "" else
15+
val suffix = i % 5 match
16+
case 0 => "0"
17+
case 1 => "1"
18+
case 2 => "2"
19+
case 3 => "="
20+
case 4 => "-"
21+
toSnafu((i + 2) / 5) + suffix
2222

2323
def part1(input: Seq[String]): String = toSnafu(input.map(fromSnafu).sum)
2424

0 commit comments

Comments
 (0)