**New here?**Learn about Bountify and follow @bountify to get notified of new bounties! Follow @bountify x

we have this code

https://repl.it/repls/CompatibleZanyScience

we would like to get it modified to have a distance value next to each computed outcome that tells us how many substitutions were needed to calculate it.

next we want to dedup the list - the item that should remain is the one with the fewest transforms needed. for example

suppose we have these outcomes

`abc: 1`

`abe: 2`

`abc: 3`

`abe: 4`

we would want the final output to just have

`abc: 1`

`abe: 2`

to make things easier i think the order of operations should be

- compute variants as it does today
- include transform distance when coming up with the value
- dedup as a final operation

note: we think representing the distance and value should be like this

"distance:value" whereas today we just have "value"

Please fork my repl.it codebase.

## 1 Solution

Here's your current solution with distance and deduping: https://repl.it/repls/InbornVapidMetric

`const len = Math.pow(arr.length, 2);`

to

`const len = Math.pow(2, arr.length);`

at line 54.

The mistake originates from the original solution.

`getPermutations`

function already accepts`maxDistance`

argument. And the output can be remapped to whichever format you like.