Skip to content

Commit 94e3a64

Browse files
committed
2022/06 comment
1 parent 20f67ff commit 94e3a64

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

2022/Day06/Solution.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ class Solution : Solver {
88

99
public object PartOne(string input) => StartOfBlock(input, 4);
1010
public object PartTwo(string input) => StartOfBlock(input, 14);
11+
12+
// Slides a window of length l over the input and finds the first position
13+
// where each character is different. Returns the right of the window.
1114
int StartOfBlock(string input, int l) =>
1215
Enumerable.Range(l, input.Length)
13-
.First(i => input.Substring(i-l, l).ToHashSet().Count == l);
16+
.First(i => input.Substring(i - l, l).ToHashSet().Count == l);
1417
}

0 commit comments

Comments
 (0)