Oct. 30, 2014, 5:10 p.m. |
+ 1 |
for Comment
veky: Only few things... Names starting with uppercase are usually not used locally. In line 4, look at th...
|
Sept. 3, 2014, 5:46 p.m. |
+ 1 |
for Comment
krzychusan: Theoretically speaking I would suggest to handle empty list case. Currently this will go into infini...
|
Sept. 3, 2014, 5:46 p.m. |
+ 1 |
for Comment
nickie: Some of what I'll say has already been discussed, but let me add my two cents. There are several way...
|
Sept. 3, 2014, 5:40 p.m. |
+ 1 |
for Comment
veky: Much more pythonic is: def checkio(data): try: return data[0] + checkio(data[1:]) except IndexError:...
|
Aug. 27, 2014, 8:29 p.m. |
+ 1 |
for Comment
bunnychai: how about assert shot((0, 0), (1, 1), (3, 3), (2, 2)) == 0, "shot in butt of wall" ?
|
Aug. 15, 2014, 8:31 p.m. |
+ 1 |
for Comment
veky: Best reinventing the wheel ever. :-P
|
Aug. 15, 2014, 8:30 p.m. |
+ 1 |
for Comment
artemrudenko: You can use getattr(hashlib, algorithm) instead of if here. In any case - cool.
|
Aug. 15, 2014, 8:29 p.m. |
+ 1 |
for Comment
veky: I don't get it, why don't you just import hashlib directly??
|
Aug. 15, 2014, 7:10 p.m. |
+ 1 |
for Comment
Cjkjvfnby: It can be more cute and clever with string format: return eval('%c%c%c(%s)' % (115, 117, 109, x))
|
Aug. 15, 2014, 7:10 p.m. |
+ 1 |
for Comment
aotus: This is in the "clear" category? It's cute. It's clever. It's cheating! :^)
|
Aug. 13, 2014, 4:28 p.m. |
+ 1 |
for Comment
Lijantropique: Hello Gyahun_dash, Do you mind explaining to me why you use "c:'sides'" in line 9? I tried your code...
|
Aug. 13, 2014, 4:27 p.m. |
+ 1 |
for Comment
aotus: My solution was essentially the same, except that I defined my equivalent to area_function globally....
|
Aug. 11, 2014, 6:01 p.m. |
+ 1 |
for Comment
SimonMontford: '<' and '>' are excluded from the problem in a 'more real' situation, you would trip up on '[(4 + 5)...
|
Aug. 11, 2014, 6 p.m. |
+ 1 |
for Comment
Tiktin: OPEN_BRACKETS = {a for a, _ in BRACKET_PAIRS} Why did you use a set (curly brackets) instead of a li...
|
Aug. 11, 2014, 5:59 p.m. |
+ 1 |
for Comment
Tiktin: BRACKET_PAIRS = ['()', '{}', '[]', '<>'] Lines 3-5 can be replaced by explicitly defining just the C...
|
Aug. 6, 2014, 6:02 p.m. |
+ 1 |
for Comment
Cjkjvfnby: please read about python naming convention and code style. legacy.python.org/dev/peps/pep-0008/ you ...
|
Aug. 4, 2014, 5:33 p.m. |
+ 1 |
for Comment
guido: def min_diff(self, stones): What should the answer be if stones is an empty list? I think it should ...
|
Aug. 4, 2014, 5:33 p.m. |
+ 1 |
for Comment
guido: best = None If you initialize best to a large enough value you won't need to special-case "best is N...
|
Aug. 4, 2014, 5:32 p.m. |
+ 1 |
for Comment
guido: max_size = math.ceil(len(stones) / 2) Use the // operator ("floor division") to do integer division ...
|
Aug. 4, 2014, 5:31 p.m. |
+ 1 |
for Comment
guido: best = diff At this point you can actually stop if best == 0: if best == 0: return
|
Aug. 4, 2014, 5:31 p.m. |
+ 1 |
for Comment
guido: return total * len(stones) / 2 See note about constants and big Oh notation below.
|
Aug. 4, 2014, 5:31 p.m. |
+ 1 |
for Comment
guido: y_size = math.floor(total / 2) + 1 Again, I think you can use // and avoid using the math module:
|
Aug. 4, 2014, 5:31 p.m. |
+ 1 |
for Comment
guido: return x + x_size * y It's clear that you really want a two-dimensional list; then you could just wr...
|
Aug. 4, 2014, 5:30 p.m. |
+ 1 |
for Comment
guido: for x, s in enumerate(stones, 1): Your choice to start x at 1 seems odd -- in the code below, "x - 1...
|
Aug. 4, 2014, 5:30 p.m. |
+ 1 |
for Comment
guido: table[index(x, y)] = v PS. I'm not going to verify that this actually works; I'd get a headache. I t...
|
Aug. 4, 2014, 5:29 p.m. |
+ 1 |
for Comment
guido: approach = min(ALGORITHMS, key=lambda algorithm: algorithm.time(stones)) This is cute, but you don't...
|
Aug. 4, 2014, 5:29 p.m. |
+ 1 |
for Comment
guido: return approach.min_diff(stones) For extra points, you could run both solutions in parallel threads ...
|
Aug. 4, 2014, 5:28 p.m. |
+ 1 |
for Comment
guido: return 1 << (len(stones) - 1) This is probably better written as 2 ** (len(stones) - 1), so the read...
|
Aug. 4, 2014, 4:38 p.m. |
+ 1 |
for Comment
gyahun_dash: # Appendix (but longer than code) In this approach, numbers are converted to 2-D coordinates (x, y) ...
|
Aug. 4, 2014, 4:05 p.m. |
+ 1 |
for Comment
gyahun_dash: return '{:.0f}'.replace('0', str(decimals)).format(number) + powers[e] + suffix You can use nested b...
|
July 30, 2014, 6 p.m. |
+ 1 |
for Comment
veky: "len(stack) != 0" is more simply written as just "stack" inside conditionals. Sequences can bool. :-...
|
July 30, 2014, 6 p.m. |
+ 1 |
for Comment
okiyama: if commands[i][1]=='U' is not very good readability. You're a lot better off with something like if ...
|
July 30, 2014, 5:59 p.m. |
+ 1 |
for Comment
Talim42: elif 'POP' in cmd.upper() and len(stack) can be rewritten shorter: elif 'POP' in cmd and stack
|
July 1, 2014, 7:22 p.m. |
+ 1 |
for Comment
Amachua: Python 3.x way :) P.S. Why use tuple here? It works fine without it :)
|
June 30, 2014, 6:13 p.m. |
+ 1 |
for Comment
odwl: Interesting way to get 0. Still very readable.
|
June 26, 2014, 5:33 p.m. |
+ 1 |
for Comment
Cjkjvfnby: You can get alphabet : **from string import ascii_lowercase** No need to c.lower() it is already in ...
|
June 23, 2014, 3:05 p.m. |
+ 1 |
for Comment
atrioom: i like "c.isalpha()" had to import "re" for this...
|
June 23, 2014, 3:04 p.m. |
+ 1 |
for Comment
martinbetz: I like how you make sure that you get the first letter when two letters have the same occurance with...
|
June 20, 2014, 4:29 p.m. |
+ 1 |
for Comment
badbird: if the password is '+++++++++++',it also return True, but it is a wrong answer.
|
June 20, 2014, 4:28 p.m. |
+ 1 |
for Comment
DanielDou: This is very clever code. :) Gave you a thumbs up! But the flaw in it seems you can bypass those con...
|
June 20, 2014, 4:27 p.m. |
+ 1 |
for Comment
bryukh: This is original and interesting solution, but is not "Clear" for newbies. I would give you thumbsUp...
|
June 18, 2014, 4:25 p.m. |
+ 1 |
for Comment
macfreek: I just might have gotten a bit carried away here in my desire to solve this in linear time instead o...
|
June 18, 2014, 4:22 p.m. |
+ 1 |
for Comment
Cjkjvfnby: no: **if len(args) == 0:** yes: **if not args:** You handle conner cases and raises exception, but d...
|
June 17, 2014, 6:01 p.m. |
+ 1 |
for Comment
maderilo: proper naming is really important!
|
June 17, 2014, 6:01 p.m. |
+ 1 |
for Comment
Cjkjvfnby: If you change names to normal, most comments can be omitted. It is hard find code inside comments. D...
|
June 17, 2014, 6:01 p.m. |
+ 1 |
for Comment
oduvan: Thank you for all comments you did
|
June 17, 2014, 5:58 p.m. |
+ 1 |
for Comment
Cjkjvfnby: You can rename function argument to wheat and ommit line 2.
|
June 17, 2014, 5:58 p.m. |
+ 1 |
for Comment
odwl: This actually incorrect for large input. Use itertools.count() instead of range(0, 1000)
|