Spellathon solver in Java
The explanation for slowness is simple: you're doing a slow operation (reading a file) many many times (due to combinatorial explosion).

How many permutations of "hello" are there? For 5 items, there are 5!, or 120 permutations. However, two of the letters are indistinguishable, so it's actually \$\frac{5!}{2!}\$, or 60. Add the 12 permutations of "hell", 24 permutations of "helo", and 12 permutations of "hllo", and we have about a hundred.

Of those, I would expect only maybe a dozen to be valid English words.

Then, for each permutation, you are opening the file and reading every line to see if the candidate is a word. File IO involves the operating system and the disk — both very expensive.



Generating all permutations of something is costly. In contrast, checking whether two given words are permutations of each other is a simple matter of counting.

A smarter approach, therefore, would be to go through the dictionary once, and check whether each word meets the acceptance criteria.