Clever way to do it with absolute values, I like it. For the record though, a compound conditional with comparisons would be more readable/maintainable.
This is calld "cleverness beyond any boundaries". 👏👏👏
it's the same as n = n // 2.
n = n // 2
Could someone ELI5 what //= does here?
Funny eh :)
Not bad, I don't understand how it works, but not bad
@fadetogether Glad to see you've been enlightened! This (indexing a const list) is useful often to retrieve one of a common few values.
sorry no, I meant this structure of a tuple followed by a list, I thought it was some weird ternary operation but I realized after posting it's literally just indexing a tuple with the calculation lol! very clever
what is this kind of operation called? I haven't seen it before
yep, u r right too :)
P.s. Python 3.6+
I doubt it is best solution (see forks).