enigma icon indicating copy to clipboard operation
enigma copied to clipboard

Sorting twice?

Open PavloMcBlister opened this issue 3 years ago • 1 comments

At the end of findRotorConfiguration, the keySet is sorted in reverse order, then when the keySet.stream() is returned, it is also sorted in reverse order. It doesn't seem like the .sorted() would be needed on the returned stream() since the keySet is already sorted.

FYI: On my M1 Mac mini with 8 cores, the optimized version runs in about 4.3 seconds.

PavloMcBlister avatar Jan 10 '22 20:01 PavloMcBlister

Good spot! Feel free to put in a pull request if you'd like, or I can fix it. Sorry for the slow response, teaching and stuff! :)

mikepound avatar Apr 09 '22 21:04 mikepound