Skip to content

Commit 7a3e42b

Browse files
committed
2022/25 comment
1 parent 4382115 commit 7a3e42b

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

2022/Day25/Solution.cs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System.Linq;
2+
using System;
23

34
namespace AdventOfCode.Y2022.Day25;
45

@@ -13,9 +14,9 @@ public object PartOne(string input) =>
1314
.Sum()
1415
);
1516

17+
// This is just string to number conversion in base 5
18+
// with the two special digits that worth -2 and -1.
1619
long SnafuToLong(string snafu) {
17-
// This is just string to number conversion in base 5
18-
// with the two special digits that worth -2 and -1.
1920
long res = 0L;
2021
foreach (var digit in snafu) {
2122
res = res * 5;
@@ -30,11 +31,11 @@ long SnafuToLong(string snafu) {
3031
return res;
3132
}
3233

34+
// Snafu numbers have digits -2, -1, 0, 1 and 2, so this is almost
35+
// standard base 5 conversion, but when dealing with digits 3 and 4 we
36+
// need to increment the higher decimal place so that we have
37+
// something to subtract 2 and 1 from.
3338
string LongToSnafu(long d) {
34-
// Almost standard base conversion, but when dealing with digits 3
35-
// and 4 we need to increment the higher decimal place so that we have
36-
// something to subtract 2 and 1 from.
37-
3839
var res = "";
3940
while (d > 0) {
4041
switch (d % 5) {

0 commit comments

Comments
 (0)