enigma
enigma copied to clipboard
Sorting twice?
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.
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! :)