I think that n%3 mean that a number divide by 3 and what you want is the remainder. n//3%3 mean that you are diving the number dirst and rounding it down, then you are doinging another division and looking for it's remainder. Same with n//9%3 This just mean that you are dividing by 9 first and rounding down, then you divide by 3 and get the remainder.
5%3 would have a remainder of 2.
5//3%3 would be 1.66 and round down would have 1, then you find the remainder which is 1.
12//9%3 would be 1.33 and round down you get 1, then you find the remainder of 1/3 which is 1.
I mean how you are calculating the exact hands by dividing. I could think of three nested(one for each person ) for loops that gives me array of numbers, but I was failing to stop the 3 nested at exact hands given as input
In the table given in the kata description, observe that P1, P2, P3 are simply counting in ternary. So this kata is an exercise in converting a decimal integer to ternary.
Can you please explain this solution
What if the string = '0.1' ?
Named values are clearer than tuples IMHO : convert ad convert, which one is a in a*x + b ?. Actually, NamedTuple would be even better
Here the goal was to show how you can work with lambda and other python chips, so that newcomers learn something new.
It is bad practice to assign a lambda to a variable. PEP8 states that its an Anti-Pattern.
Just declare a normal function if you want to use it more than once.
See also: https://docs.quantifiedcode.com/python-anti-patterns/correctness/assigning_a_lambda_to_a_variable.html
Why bad practice? If this needs to be done, let's say in the key= or somewhere else like that. Here's an awkward example: arr = [(1,4),(2,3),(1,3)]; sorted(arr, key = lambda e: sum([*range(*e)]))
Bad practice, but clever :)
Would this not potentially turn <original_string>?? into <original_string>?
nice! I was trying to figure out how to convert my two for loops into list comprehension but couldn't figure out the summation trick.