Back
Close

The longest hill

Statement
You are given a string composed of only {{1}} and {{0}} where {{1}} represents a hill, and {{0}} the ground. Consecutive {{1}} represents the same hill. Find the index (considering 1st character is at index 1) and the length of the longest hill. Example for the string {{110001111}}: the longest hill is at index 6 and its length is 4 => The output expected is: "6 4" If there are many solutions, return the first longest hill found.

Input description
<<Line 1:>> A string [[s]] with only {{1}} and {{0}}, where {{1}} represents a hill, and {{0}} the ground.

Output description
Index and the length of the longest hill separated by a space. 1st character is at index 1. If there are many solutions, output the first longest hill found.

Constraints
1 ≤ length of [[s]] ≤ 256 Only {{0}} and {{1}} in the string [[s]] At least one {{1}} in the string [[s]]

Game modes
FastestShortest

Test cases
Test 1 Test
Input
11111
Output
1 5

Validator 1 Validator
Input
111
Output
1 3

Test 2 Test
Input
00011
Output
4 2

Validator 2 Validator
Input
0000111
Output
5 3

Test 3 Test
Input
0111100110111
Output
2 4

Validator 3 Validator
Input
0011101011
Output
3 3

Test 4 Test
Input
01011100010101010101010101010101
Output
4 3

Validator 4 Validator
Input
01001101010101010101010101010101
Output
5 2

Test 5 Test
Input
01011010110011011
Output
4 2

Validator 5 Validator
Input
0110101011011011
Output
2 2

Test 6 Test
Input
110011101010101010101010
Output
5 3

Validator 6 Validator
Input
111000111110101010101010
Output
7 5

Test 7 Test
Input
11001
Output
1 2

Validator 7 Validator
Input
111001101001011
Output
1 3

Test 8 Test
Input
10110111
Output
6 3

Validator 8 Validator
Input
10101101111
Output
8 4

Test 9 Test
Input
1011011011
Output
3 2

Validator 9 Validator
Input
1011101110111
Output
3 3

Test 10 Test
Input
10101010101
Output
1 1

Validator 10 Validator
Input
110101011011010110101011
Output
1 2

Solution language

Solution

Stub generator input
codingame x discord
Join the CodinGame community on Discord to chat about puzzle contributions, challenges, streams, blog articles - all that good stuff!
JOIN US ON DISCORD
Online Participants