You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

18 lines
300 B
Chapel

use IO;
config const numChars = 4;
var theBytes: bytes;
stdin.read(theBytes);
var indices: [0..<26] int = -numChars;
for (char, idx) in zip(theBytes.these() - b"a"[0], 0..) do {
indices[char] = idx;
if + reduce (indices > idx - numChars) == numChars {
writeln(idx + 1);
break;
}
}