Tiles Still Needed

Python for AIMedium+10 XP+10

Tiles Still Needed

In a word game, you hold some letter tiles and want to spell a word. Each tile can only be used once.

Task: write missing_letters(tiles, word) that returns a dictionary of the letters you are still short of, with how many more of each you need.

  • tiles and word are both text. Ignore capitals: treat everything as small letters.
  • Only include letters you actually need more of. Don't include letters with a count of 0.
  • If you can already spell the word, return {}.
  • Return a plain dictionary.

You have one n but need two, and two as but need three. The b is covered.

Examples

tiles = "bnaa"
word = "banana"
returns {'a': 1, 'n': 1}
tiles = "tacx"
word = "cat"
returns {}

Hints

Solve it to unlock the solution

Once your code passes every test, a reference solution shows up here so you can compare it with yours.

solution.py
CtrlEnterto run