@@ -26,14 +26,16 @@ void CrateMover9001(Move move) {
26
26
CrateMover9000 ( move with { source = helper } ) ;
27
27
}
28
28
29
- string MoveCrates ( string input , Action < Move > crateMover ) {
29
+ string MoveCrates ( string input , Action < Move > crateMover ) {
30
30
var parts = input . Split ( "\n \n " ) ;
31
31
32
32
var stackDefs = parts [ 0 ] . Split ( "\n " ) ;
33
33
34
34
// process each line by 4 character wide columns
35
35
// 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
+
37
39
// bottom-up: push the next element to the the correspoing stack;
38
40
// ' ' means no more elements.
39
41
foreach ( var line in stackDefs . Reverse ( ) . Skip ( 1 ) ) {
@@ -51,10 +53,15 @@ string MoveCrates(string input, Action<Move> crateMover) {
51
53
var count = int . Parse ( m . Groups [ 1 ] . Value ) ;
52
54
var from = int . Parse ( m . Groups [ 2 ] . Value ) - 1 ;
53
55
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
+ ) ) ;
55
61
}
56
62
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:
58
65
return string . Join ( "" , stacks . Select ( stack => stack . Pop ( ) ) ) ;
59
66
}
60
67
}
0 commit comments