@@ -56,9 +56,9 @@ long activeCubesAfterCmd(int icmd, Region region) {
56
56
return activeCubesAfterCmd (
57
57
cmds . Length - 1 ,
58
58
new Region (
59
- new Section ( - size , size ) ,
60
- new Section ( - size , size ) ,
61
- new Section ( - size , size ) ) ) ;
59
+ new Segment ( - size , size ) ,
60
+ new Segment ( - size , size ) ,
61
+ new Segment ( - size , size ) ) ) ;
62
62
}
63
63
64
64
Cmd [ ] Parse ( string input ) {
@@ -67,23 +67,23 @@ Cmd[] Parse(string input) {
67
67
var on = line . StartsWith ( "on" ) ;
68
68
// get all the numbers with a regexp:
69
69
var m = Regex . Matches ( line , "-?[0-9]+" ) . Select ( m => int . Parse ( m . Value ) ) . ToArray ( ) ;
70
- res . Add ( new Cmd ( on , new Region ( new Section ( m [ 0 ] , m [ 1 ] ) , new Section ( m [ 2 ] , m [ 3 ] ) , new Section ( m [ 4 ] , m [ 5 ] ) ) ) ) ;
70
+ res . Add ( new Cmd ( on , new Region ( new Segment ( m [ 0 ] , m [ 1 ] ) , new Segment ( m [ 2 ] , m [ 3 ] ) , new Segment ( m [ 4 ] , m [ 5 ] ) ) ) ) ;
71
71
}
72
72
return res . ToArray ( ) ;
73
73
}
74
74
}
75
75
76
76
record Cmd ( bool on , Region region ) ;
77
77
78
- record Section ( int from , int to ) {
78
+ record Segment ( int from , int to ) {
79
79
public bool IsEmpty => from > to ;
80
80
public long Length => IsEmpty ? 0 : to - from + 1 ;
81
81
82
- public Section Intersect ( Section that ) =>
83
- new Section ( Math . Max ( this . from , that . from ) , Math . Min ( this . to , that . to ) ) ;
82
+ public Segment Intersect ( Segment that ) =>
83
+ new Segment ( Math . Max ( this . from , that . from ) , Math . Min ( this . to , that . to ) ) ;
84
84
}
85
85
86
- record Region ( Section x , Section y , Section z ) {
86
+ record Region ( Segment x , Segment y , Segment z ) {
87
87
public bool IsEmpty => x . IsEmpty || y . IsEmpty || z . IsEmpty ;
88
88
public long Volume => x . Length * y . Length * z . Length ;
89
89
0 commit comments