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.
check for mod 256
Its even in details.
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.
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 lineif x in list
is also a loop - when this line is reached, your code is actually going to loop through every element inlist
until it findsx
.This is why your approach is timing out, it has complexity O(n^2) even though this is "hidden" by the above fact.