#include "IdanStringLib.h"
#include "IdanLib.h"
#include <stdio.h>

#define STRING_MAX_SIZE 256

unsigned short HighestSequence(char vec[])
{
    unsigned short place = ZERO;
    unsigned short counter = ZERO;
    unsigned short counter_max = ZERO;
    while(vec[place])
    {
        counter = (vec[place] == vec[place + ONE]) ? ++counter : ZERO;
        counter_max = (counter_max > counter) ? counter : counter_max;
    }

    return counter_max + 1;
}

//---------------------------------------------------------------------------------------
//                                              Exercise 4
//                                              ----------
//
// General : The program checks how many substring can u build with the string that you
//			  get in the main string you got.
//
// Input   : string.
//
// Process : The program checks if there is a char like the start (char start) that the
//			 program got, if there is it will check how many ends (char end) and just
//			 add it too the counter.
//
// Output  : How many substring can you build.
//
//---------------------------------------------------------------------------------------
// Programmer : Cohen Idan
// Student No : 211675038
// Date       : 04.11.2019
//---------------------------------------------------------------------------------------
void main(void)
{
    typedef char string[STRING_MAX_SIZE];
    string str_arr[TEN];

    unsigned short counter;
    unsigned short max;
    unsigned short max_offset;

    for(counter = ZERO; counter < TEN; counter++)
    {
        scanf("%s", str_arr[counter]);
    }

    max = HighestSequence(str_arr[ZERO]);
    max_offset = ZERO;
    for (counter = ONE; counter < TEN; counter++)
    {
        if(max < HighestSequence(str_arr[counter]))
        {
            max = HighestSequence(str_arr[counter]);
            max_offset = counter;
        }
    }
    printf("%s  %hu\n",str_arr[max_offset], max_offset + ONE);

    scanf("%hu",&counter);
}