Ad
  • Custom User Avatar

    check for mod 256
    Its even in details.

  • Custom User Avatar

    You need to work with the digits of the number, if you use 1 for the first digit, then you should use 2 for the second one and so on.

  • Default User Avatar

    Hi, and welcome to Codewars!

    You can "use loops" - but you have to make sure you understand what exactly your algorithm is doing to understand its actual complexity.

    It is a common mistake to only think of stuff like for x in list.. as being "a loop" (because you can actually see the word "for" in it), but in fact in your code the line if x in list is also a loop - when this line is reached, your code is actually going to loop through every element in list until it finds x.

    This is why your approach is timing out, it has complexity O(n^2) even though this is "hidden" by the above fact.