We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 20f67ff commit 94e3a64Copy full SHA for 94e3a64
2022/Day06/Solution.cs
@@ -8,7 +8,10 @@ class Solution : Solver {
8
9
public object PartOne(string input) => StartOfBlock(input, 4);
10
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.
14
int StartOfBlock(string input, int l) =>
15
Enumerable.Range(l, input.Length)
- .First(i => input.Substring(i-l, l).ToHashSet().Count == l);
16
+ .First(i => input.Substring(i - l, l).ToHashSet().Count == l);
17
}
0 commit comments