First repeated occurrence of either’a’ or ’b’ or ’c’ or ’d’

Implement a program such that, given a sequence of characters from
{a,b,c,d}, tells which one is the first character that is found repeated
when we read them from the beginning, and on what position this first
repetition takes place (positions are assumed to be indexed starting
from 0).

It is guaranteed that there will be at least one repetition.

Input

The input contains only one line with a sequence of consecutive
characters from {a,b,c,d}. It is guaranteed that at least one character
occurs twice or more in the input sequence.

Output

The output contains the first character which occurs twice or more in
the input, and the position of the first repetition (indexing positions
from 0). These data must be printed on one line and separated by a white
space.

Observation

Do not use strings nor any other massive data storage method. Read and
treat the input character by character. Please, try to avoid carrying on
reading the input when that is no longer necessary.

Problem information

Author: PRO1

Generation: 2026-01-25T21:38:35.012Z

© Jutge.org, 2006–2026.
https://jutge.org
