File tree Expand file tree Collapse file tree 1 file changed +4
-7
lines changed Expand file tree Collapse file tree 1 file changed +4
-7
lines changed Original file line number Diff line number Diff line change @@ -79,17 +79,14 @@ record Section(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
- this . from > that . from ? that . Intersect ( this ) : // switch order
84
- that . to < this . from ? new Section ( 0 , - 1 ) : // empty
85
- new Section ( that . from , Math . Min ( this . to , that . to ) ) ;
82
+ public Section Intersect ( Section that ) =>
83
+ new Section ( Math . Max ( this . from , that . from ) , Math . Min ( this . to , that . to ) ) ;
86
84
}
87
85
88
86
record Region ( Section x , Section y , Section z ) {
89
87
public bool IsEmpty => x . IsEmpty || y . IsEmpty || z . IsEmpty ;
90
88
public long Volume => x . Length * y . Length * z . Length ;
91
89
92
- public Region Intersect ( Region that ) {
93
- return new Region ( this . x . Intersect ( that . x ) , this . y . Intersect ( that . y ) , this . z . Intersect ( that . z ) ) ;
94
- }
90
+ public Region Intersect ( Region that ) =>
91
+ new Region ( this . x . Intersect ( that . x ) , this . y . Intersect ( that . y ) , this . z . Intersect ( that . z ) ) ;
95
92
}
You can’t perform that action at this time.
0 commit comments