All problems

Problem 839

Positions of Large Groups

Easy · 10 pts · String

Problem

In a string of lowercase letters, a group is a maximal run of the same letter, like xxxx in abbxxxxzyy. A group is large if it has 3 or more characters. Print the start and end positions (0-based, inclusive) of every large group, one group per line in order of position, or NONE if there are no large groups. Scan once, and whenever a run ends, check its length.

Input

A single string S of lowercase letters.

Output

Print one line 'start end' per large group, or NONE.

Constraints

1 <= |S| <= 1000

Example input

abbxxxxzzy

Example output

3 6

Explanation

In abbxxxxzzy, the only group of length 3 or more is xxxx, which runs from index 3 to index 6. So the answer is 3 6.

Every problem here can be used in a RelayTrixCode team match. Create a room.

Previous: Count Substrings That Differ by One Character Next: Check if Word Equals Summation of Two Words