Skip to content

Commit dd89072

Browse files
committed
day 22 cleanup
1 parent df680c2 commit dd89072

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

2021/Day22/Solution.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,9 @@ long activeCubesAfterCmd(int icmd, Region region) {
5656
return activeCubesAfterCmd(
5757
cmds.Length - 1,
5858
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)));
6262
}
6363

6464
Cmd[] Parse(string input) {
@@ -67,23 +67,23 @@ Cmd[] Parse(string input) {
6767
var on = line.StartsWith("on");
6868
// get all the numbers with a regexp:
6969
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]))));
7171
}
7272
return res.ToArray();
7373
}
7474
}
7575

7676
record Cmd(bool on, Region region);
7777

78-
record Section(int from, int to) {
78+
record Segment(int from, int to) {
7979
public bool IsEmpty => from > to;
8080
public long Length => IsEmpty ? 0 : to - from + 1;
8181

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));
8484
}
8585

86-
record Region(Section x, Section y, Section z) {
86+
record Region(Segment x, Segment y, Segment z) {
8787
public bool IsEmpty => x.IsEmpty || y.IsEmpty || z.IsEmpty;
8888
public long Volume => x.Length * y.Length * z.Length;
8989

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy