Jumbles Map

Home Jumbles

Background

This was an extra-credit assignment, the goal of which was to see if we could re-do the original Jumbles assignment using Map/Set instead of just ArrayList.

Ideally, this implementation would be much faster. For more information on the original assignment, follow the Jumbles link above.

A leaderboard (which was ranked based on runtime) was once again created to encourage students to write fast/efficient code to accomplish the task.

Implementation

With this implementation, I was able to implement more filters and massively simplify the code. For one, I created a HashSet that contained lengths of jumbles, which greatly decreased the amount of dictionary words that were processed (as dictionary words of lengths that weren’t found in the set weren’t processed). The length (lines) of the logic was reduced to less than half the size.

Additionally, the canonicalize() method came in very handy, as it allowed for words whose characters (naturally ordered) didn’t match a word in the jumblesMap (which mapped a canonicalized version of the jumble to the original jumble) to not be processed at all.

To accomplish this task, in the most efficient manner (that I could come up with at the time, while satisfying the assignment requirements), this is the solution that I came up with:

The complexity is O(Nlog(N))

Solution (full class)