The other day we were writing sentences with my daughter with a fridge magnet letter. While we were able to make some(
I love cat), we didn't have enough letters to make the others (
I love you too) due to an insufficient amount of letters
I then found out that while one set included 3
e letters it had only 2
o letters. Probably inspired by http://en.wikipedia.org/wiki/Letter_frequency this would still not reflect the actual situation "on the fridge".
Given the text file where each line contains a "sample sentence" one would want to write on the fridge, propose an alphabet set with minimum amount of letters but still sufficient to write each sentence individually.
Note: ignore cases, all magnet letters are capitals anyway.
The file contain newline separated sentences:
hello i love cat i love dog i love mommy mommy loves daddy
Provide back sorted list of letters, where each letter appears only as many times to be sufficient to write any sentence:
Shortest implementation (code)
I have created an extra test and tried with various answers here: