#K13841. Consecutive Repeating Digit Finder

    ID: 24002 Type: Default 1000ms 256MiB

Consecutive Repeating Digit Finder

Consecutive Repeating Digit Finder

Given a string consisting of digits and a single non-digit character (or possibly no non-digit character), your task is to extract the substring consisting only of digits that appears before the first non-digit character. Then, from this substring, find the first digit that appears consecutively (i.e. a digit that is immediately repeated). If such a digit exists, output that digit; otherwise, output (None).

For example, if the input string is 2314555x42, the digit-only substring is 2314555 and the first occurrence of consecutive repeated digits is 5 (since the two 5's in positions 5 and 6 repeat), so the answer is 5.

inputFormat

Input is a single line string provided via standard input. The string consists of digits followed by at most one non-digit character. In the case there is no non-digit character, consider the entire string.

outputFormat

Output the first digit (as a single character) that is repeated consecutively in the extracted digit substring. If no such digit exists, output (None) (without quotes).## sample

2314555x42
5