57
Awesome Team
Vedran Čačić
https://web.math.hr/~veky
Last seen 12 hours ago
Member for 11 years, 6 months, 6 days
Difficulty Advanced
We shall not cease from exploration, and the end of all our exploring will be to arrive where we started and know the place for the first time.
Just a tip: matrix doesn't need to be singular if s[i][i]==0. Pivot can be somewhere below in that column, so by reordering equations, you can find it. (These tests are worthless, so you're ok here. Just thought you'd like to know generally.)
More
You're reinventing the wheel. See Counter in collections module (standard library).
More
If you're trying to see how it works: just print(r) between lines 5 and 6. I'm sure you'll see what r is, and then the rest is pretty obvious. (Of course, if there are any questions, just ask.)
More
Nice usage of pop, but the variable s is used in a really weird way here. (With "nonlocal" it would be funnier.:) Those "+=" are in fact just "=", and "initialization" to 0 isn't needed. Also, pop could be used in both branches (or better, before "if"), so condition could be simplified.
Also, I h
More
This is just to show various methods your system can be cheated. Fix these, and I'll find new ones. :-P
More
Doesn't work on empty list.
checkio=f=lambda x:x.pop()+f(x)if x else 0
would be better. ;-)
More
Meh. You could do much better if you were a bit bolder. :-D Maybe even find a closed formula. ;-P
More
Yes, cool. While I was obsessed with canonical representation of lines, you rightly saw that all that was needed was \_\_eq\_\_ on them.
More
LOL. This is the reason why I don't comment my code. :-] There would be more comments than code. :-)
More
Last line is just
return s*(n == 1)
And yes, you could have get rid of that special case (given your hate for special cases) in line 2. For example,
return (s + (not s))*(n == 1)
Here you do need parentheses around not, since it is special in grammar. But "not" being special enab
More
Again, no parentheses around "not s" are needed. You never need them when you use it as a logical condition, only as an arithmetical expression.
BTW sentinel really could have helped here (to reduce number of cases:). See mine. ;-)
More
Nice usage of Zeckendorf's theorem. ;-)
BTW it would be more scary without that friendly looking boo-ghost. ;-D
More