57
Awesome Team
Vedran Čačić
https://web.math.hr/~veky
Last seen 3 hours ago
Member for 11 years, 6 months, 7 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.
You could have written list(list(list([a,b]))), the effect would be the same. :-P
More
";" might be funny if everything else was in C style, but "sum" surely doesn't fit there. :-]
More
Nice reducing to addition of natural numbers. :-) pattern can be much nicer written using list comprehension: [i in range(b) for i in range(a)]. ;-)
More
Straightforward. A hint: function tri can be declared as def tri(a,b,c), and called as tri(*act). That way you don't need line 2. This is not Perl, you can actually tell what your arguments are. ;-)
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
Sorry, but popping empty stack is not your only problem.
Appending at end is much smarter than inserting at beginning all the time, your dic is "backwards" (aestetics, true, but doesn't it just look wrong to you?:), and those parentheses are duplicated in three places in the code. And oh, that "T
More
If you like using external stuff, those little lambdas are already there:
change "lambda x, y: y/abs(y) * x" to "math.copysign"
change "lambda x, y: x * y" to "operator.mul"
Batteries included. ;-)
More
LOL. This is the reason why I don't comment my code. :-] There would be more comments than code. :-)
More
32?? LOL. You might have as well put 53 there. :-P
Python(3) int is not fixed size, this is not C.
More
We have a very similar solution. :-)
BTW, I ROTFLed at 'Aaaaaaarrrrgghhhhh!'. :-D Wasn't it better to raise some appropriate exception? (PermissionError sounds very appropriate.:))
More