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.
here's a little hack,
i&1==0 and i%2==0 are equivalent but i&1 is faster because it uses a bit operator & (AND)
we care about lsb (least binary digit, ex. 101 is 1 and 1000 is 0) when checking for parity
odd numbers have lsb=1, even numbers have lsb=0.
all numbers either end with lsb=1 or 0, therefore we can check parity by equating them to either 1 or 0. we say
"is lsb of a number equals 1 or 0? if equals 1, then it is odd. if not then even"
there are other ways.. int(bin(i)[-1]), simply i&1 or bool(i&1), (a^b)&1 returns 1 if a and b dont have same parity
goodluck :)
the numbers is string type. you need to transver it to int type.
try ===
This comment is hidden because it contains spoiler information about the solution
You can not iterate through a loop numbers, in your case the variable "numbers" is a string.
Therefore, you should make a statement under the for loop statement that estabilishes that the variable "num" is an integer.
You do that by typing:
num=int(num)
and then you continue with your if statement.
i'm an idiot. that wasn't my 8kyu level, though dunno why i got a fail when even numbers are the outliers (they are mentioned first in code).
what could i actually use?
currently using .split() for getting a list, int(), .index().
anything recommended?
u got a string type here.
i use int(num) - it changes type to int. though, most likely not the best option.
I keep getting a 'TypeError: not all arguments converted during string formatting' when I do
Does anyone know what I did wrong?