Anonymous user
Scrabble challenge: Difference between revisions
→Step 2: get the rack
(4 intermediate revisions by 4 users not shown) | |||
Line 16:
Write a Python script that takes a Scrabble rack as a command-line argument and prints all valid Scrabble words that can be constructed from that rack, along with their Scrabble scores, sorted by score. An example invocation and output:
<pre>[[Media:]]
$ python scrabble.py ZAEFIEE
17 feeze
Line 73:
Write the code to get the Scrabble rack (the letters available to make words) from the command line argument passed to your script. For example if your script were called `scrabble_cheater.py`, if you ran <tt>python scrabble_cheater.py RSTLNEI</tt>, <tt>RSTLNEI</tt> would be the rack.
Handle the case where a user forgets to supply a rack; in this case, print an error message saying they need to supply some letters, and then exit the program using the <code>exit()</code> function. Make sure you are consistent about capitalization▼
▲a user forgets to supply a rack; in this case, print an error message saying they need to supply some letters, and then exit the program using the <code>exit()</code> function. Make sure you are consistent about capitalization
<b>Step 2 resources</b>:
Line 89 ⟶ 88:
====Step 3: find valid words====
Write the code to find all words from the word list that are made of letters that are a subset of the rack letters. There are many ways to do this, but here's one way that is easy to reason about and is fast enough for our purposes: go through every word in the word
<b>Step 3 resources</b>:
Line 100 ⟶ 99:
</li>
</ul>
====Step 4: scoring====
Line 138:
2,ea
2,ai
2,aa
2,ae
</pre>
Line 143 ⟶ 144:
===Bonus challenge===
===
You've implemented a substantial, useful script in Python from scratch that is perfect for cheating at Scrabble or Words with Friends. Keep practicing!
[[File:Fireworks.png|150px]]
[[File:
|