Skip to content

Commit 20f67ff

Browse files
committed
2022/05 comment
1 parent 5e2806b commit 20f67ff

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

2022/Day05/Solution.cs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,16 @@ void CrateMover9001(Move move) {
2626
CrateMover9000(move with {source=helper});
2727
}
2828

29-
string MoveCrates(string input, Action<Move> crateMover) {
29+
string MoveCrates(string input, Action<Move> crateMover) {
3030
var parts = input.Split("\n\n");
3131

3232
var stackDefs = parts[0].Split("\n");
3333

3434
// process each line by 4 character wide columns
3535
// last line defines the number of stacks:
36-
var stacks = stackDefs.Last().Chunk(4).Select(i => new Stack<char>()).ToArray();
36+
var stacks =
37+
stackDefs.Last().Chunk(4).Select(i => new Stack<char>()).ToArray();
38+
3739
// bottom-up: push the next element to the the correspoing stack;
3840
// ' ' means no more elements.
3941
foreach (var line in stackDefs.Reverse().Skip(1)) {
@@ -51,10 +53,15 @@ string MoveCrates(string input, Action<Move> crateMover) {
5153
var count = int.Parse(m.Groups[1].Value);
5254
var from = int.Parse(m.Groups[2].Value) - 1;
5355
var to = int.Parse(m.Groups[3].Value) - 1;
54-
crateMover(new Move(count:count, source: stacks[from], target: stacks[to]));
56+
crateMover(
57+
new Move(
58+
count:count,
59+
source: stacks[from], target: stacks[to]
60+
));
5561
}
5662

57-
// assuming that the stacks are not empty at the end, concatenate the top of each:
63+
// assuming that the stacks are not empty at the end, concatenate the
64+
// top of each:
5865
return string.Join("", stacks.Select(stack => stack.Pop()));
5966
}
6067
}

0 commit comments

Comments
 (0)