Ad
  • Custom User Avatar
  • Default User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    You're very welcome! Party on.

  • Custom User Avatar

    It's a lot of code to find max_freq, but it's good that you filter most_feq_elements simply. Much of the first half can be simplified by compounding multiple statements, such as

    v = freq_dict.values()
    max_freq = max(v)
    

    into the one-liner

    max_freq = max(freq_dict.values())
    

    Always try to eliminate unnecessary variables, in this case v. Usually it is good to have explicit variable names to make your code more readable, but sometimes doing more in each line can make things more readable by reducing the numbers of steps and variables.

  • Custom User Avatar

    Thank you! It is a nice way of one-lining the solution without any imports. However, swk000@gmail.com is right in saying (in the comment on kgashock's fork) that it is very inefficient. Re-calculating the max for every x delivers N^2 complexity. This would we terrible except for the fact that it's on one line which nullifies any optimization complaints. I mean, look at it, it's adorable...