Ad
  • Default User Avatar

    Thanks for the reply -- good thoughts, I agree there is a balance between optimization, readability, development time, etc!

  • Default User Avatar

    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.)

  • Default User Avatar

    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.)

  • Default User Avatar

    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 point Cluster 2: (4, 3)?

  • Default User Avatar

    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.