Python Quiz of the Week - #1 を Squeak Smalltalk で

Find the longest words in a dictionary of legal words that can be constructed from a given list of letters.

Your solution should take as its first argument the name of a dictionary file, which will be plain text with one word per line. The remaining arguments define the list of legal letters.

Note that each letter may be used only as many times as it occurs in the list of legal letters.

Here's an example of how it should work:

scrabble.py ospd.txt i g h l p r a ['argil', 'glair', 'grail', 'graph', 'hilar', 'laigh', 'phial', 'pilar', 'ralph']

I'm using the scrabble dictionary I found here: http://www.puzzlers.org/pub/wordlists/ospd.txt

Python Quiz of the Week - #1 : Python
| letters results |
letters := 'ighlpra'.
results := Array streamContents: [:ss |
   FileStream fileNamed: 'ospd.txt' do: [:file |
      [file atEnd] whileFalse: [
         | word |
         word := file nextLine.
         (word asBag removeAllFoundIn: letters; yourself) ifEmpty: [ss nextPut: word]]]].
(results groupBy: #size having: #notEmpty) associations max
=> 5->an OrderedCollection('argil' 'glair' 'grail' 'graph' 'hilar' 'laigh' 'phial' 'pilar' 'ralph')