Word with greatest repeat of letters Recently there was a question on Stack Overflow where the OP was trying to write a function to find the word in a string that has the most repeated letters. It is of course not hard to write one up in seconds, and I wrote one in Javascript as short as I can for fun. But I'm not an expert in code golfing, so I wonder how much shorter can this simple program be!



Challenge

Write a program or function that takes in a string of words and return or print the word with the most repeating single letters.

Rules:


Choose the word with the greatest number of repeating single letters (see examples below)
If no word has repeating letters, return -1.
If two words have the same maximum number of repeating letters, choose the one closer to the start of the string.
The shortest submission in bytes wins.


Input

Take as input a string consisting of one or more space-delimited words. Input can be from STDIN (or closest alternative), command line parameters, or function arguments.

Output

Print the output to STDOUT to return it.

Examples

Consider the string aaabbb cccc. This contains two words: aaabbb and cccc. The word aaabbb has 3 a's and 3 b's, and cccc has 4 c's. So the maximum number of repeated letters in aaabbb is 3 and the maximum in cccc is 4. We want to choose the word with the maximum number of repeated single letters, so the output for aaabbb cccc should be cccc.

Other test cases:

Today, is the greatest day ever!  --&gt; greatest
This is a great day               --&gt; -1
aaabbb cccc                       --&gt; cccc
C - GCC - 159 145 135 Bytes
x=0,w=0,i,j,c;main(int _,char**z){while(--_)for(j=i=0;_[z][i];j=++i,x=c&gt;x?w=_,c:x)for(c=0;j--;)c+=z[_][i]==z[_][j];puts(x?z[w]:&quot;-1&quot;);}

Will update when I can truncate it a bit
How to compile:         gcc -w cg.c
How to run:             ./a.out word1 word2 aass ddaaa ssdddd
Output:                 ssdddd
No-Output/No-match:     -1
First off, I cheated a bit, by taking in the words as program arguments, but getting GCC to parse the words and give me a word count for free was too much reward to pass up.
How does it work?
We have 3 nested loops. The first incrementing through each word, the next two are mimicking a bubble sort to compare values. The first letter is never compared with itself, and each subsequent letter is compared to each previous letter. Whenever a word has more same letters than a previous word, the word is stored in x, and the count of how many same letters is also stored.
GCC Abuse
We use implicit global auto int delcarations for our integers. We allow argv to be an int instead of a char (currently a char, this is a TODO). We make use of default functions such as puts and getchar. We also make use of the comma operator to overload our trinary (conditional) operator.
Want 2 less bytes?
Replace &quot;-1&quot; with *z and name the file -1
Program unobfuscated and untested:
int main(int argc, char * argv[])
{
    int word = 0           // Current most repeat letters word
    int count = 0;        // Current most repeat letters
    int i, j, increment; // Counter variables

    while(--argc != 0) // While we have words from program parameters
    {
        for(j = i = 0; argv[argc][i] != '\0'; j = ++i) // Iterate through each letter until end of word
        {
            for(increment = 0; j &gt; 0; j--) // Iterative backwards through each letter
            {
                if(argv[argc][i] == argv[argc][j])
                {
                    increment++;
                }
            }
            if(increment &gt; count) // New greatest lettered word
            {
                word = argc;
                count = increment;
            }
        }
    }

    if(word == 0)
    {
        puts(&quot;-1&quot;);
    }
    else
    {
        puts(argv[word]);
    }

    return 0;
}