Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
Thanks for the reply -- good thoughts, I agree there is a balance between optimization, readability, development time, etc!
When you set up your dicts, you iterate through (and re-compute count() for) every character in every string. The strings could be very long. Iterating through each possible letter in the lowercase alphabet would have a fixed number of iterations regardless of the length of the input strings.
(I saw other solutions using set() to potentially limit the iteration to the subset of the alphabet actually appearing in the input strings.)
When you set up your dicts, you iterate through (and re-compute count() for) every character in every string. The strings could be very long. Iterating through each possible letter in the lowercase alphabet would have a fixed number of iterations regardless of the length of the input strings.
(I saw other solutions using set() to potentially limit the iteration to the subset of the alphabet actually appearing in the input strings.)
In the description of the distance metric
Distance = (sqrt((0-4)^2 + (0-3)^2) + sqrt((0-4)^2 + (1-2)^2)) / 2
should the
(1-2)
near the end actually be(1-3)
to match the example pointCluster 2: (4, 3)
?OK, but what if the original song contained the consecutive characters "WUB" somewhere? I don't believe that could be decrypted successfully once encrypted based on the description here.