66
12
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 o
(4)
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".
Problem
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.
Input
The file contain newline separated sentences:
hello
i love cat
i love dog
i love mommy
mommy loves daddy
Output
Provide back sorted list of letters, where each letter appears only as many times to be sufficient to write any sentence:
acdddeghillmmmoostvyy
(thanks, isaacg!)
Winner
Shortest implementation (code)
UPDATED: Testing
I have created an extra test and tried with various answers here:
May we assume all uppercase input? Does the output have to be sorted? – Titus – 2018-12-14T08:56:21.683
2There should be a letter
v
in the output ;) – Antonio Ragagnin – 2014-04-10T06:35:59.5331I believe the correct output is: acdddeghillmmmoostvyy – isaacg – 2014-04-10T06:49:55.230
1Damnit, I accidentally bought one pack with lowercase letters too... – PlasmaHH – 2014-04-10T08:41:25.530
40Are we allowed / required to substitute an upside-down
M
for aW
, or a sidewaysN
for aZ
? ;-) – Ilmari Karonen – 2014-04-10T11:42:35.0804Basically you can construct any letter using
I
s. – swish – 2014-04-10T11:53:49.3537More seriously, when you say "ignore cases", do you mean that we can assume that the input is already all in the same case, or that we must convert it all into the same case? Also, is it OK for the output to include some leading spaces? – Ilmari Karonen – 2014-04-10T12:01:58.920
2@swish Try making a
G
out ofI
s :P Or anS
– Doorknob – 2014-04-10T13:09:34.9403@Doorknob:
_\¯
– Ilmari Karonen – 2014-04-10T13:37:56.047@IlmariKaronen looks more like a backwards Z – Tim Seguine – 2014-04-11T15:33:37.527
@swish or you can use
m
's as pixels, as they're the closest thing to a filled in square – Cruncher – 2014-04-11T15:56:14.490Lordy you guys want to bring back 1337 5p33|< ? – Carl Witthoft – 2014-04-12T12:54:28.753