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...
|
Oct. 13, 2014, 6:48 p.m. |
+ 1 |
for Comment
emnkugler: In the [comments on another solution](http://www.checkio.org/mission/humpty-dumpty/publications/htam...
|
Sept. 16, 2014, 5:03 p.m. |
+ 1 |
for Comment
rupadhya: Awesome visualizer for interactive python code. Checkout recursions. http://pythontutor.com/ .
|
Sept. 16, 2014, 4:59 p.m. |
+ 1 |
for Comment
veky: Here is a resource. Whenever you see lambda args: expression replace it with tempfunc, where in the ...
|
Sept. 10, 2014, 2:50 p.m. |
+ 1 |
for Comment
bukebuer: You're right. I underestimate the complexity of all possible maps. Need to find some other algorithm...
|
Sept. 5, 2014, 10:08 p.m. |
+ 1 |
for Comment
ale1ster: You mean: def boolean(x, y, op): return eval(op)(x, y) ?
|
Sept. 3, 2014, 5:47 p.m. |
+ 1 |
for Comment
veky: Many. :-) EAFP. Read [this](http://www.checkio.org/mission/number-radix/publications/tdietert/python...
|
Sept. 3, 2014, 5:47 p.m. |
+ 1 |
for Comment
veky: Python's len is always constant time. BDFL's dictum. :-) That's why, e.g. you can't take len of a ge...
|
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:45 p.m. |
+ 1 |
for Comment
veky: I don't know what rule are you talking about. :-) But EAFP is just a "rule of the thumb", not some h...
|
Sept. 3, 2014, 5:44 p.m. |
+ 1 |
for Comment
ichaleynbin: I quoted it by rereading it... and yeah I couldn't find EAFP in any of the PEPs. I do know it's basi...
|
Sept. 3, 2014, 5:43 p.m. |
+ 1 |
for Comment
ichaleynbin: Not denying that it's EAFP. Heh I just recommended to somebody the other day to read the zen of pyth...
|
Sept. 3, 2014, 5:43 p.m. |
+ 1 |
for Comment
veky: Do re-read it. You might be surprised that EAFP is not there. ;-] It was not Python's idea, it's a g...
|
Sept. 3, 2014, 5:42 p.m. |
+ 1 |
for Comment
veky: > Lots of things can get lost in try:except, though at least you specified an error, which helps to ...
|
Sept. 3, 2014, 5:41 p.m. |
+ 1 |
for Comment
ichaleynbin: I don't think I'd have caught that until I caught a recursion limit reached error. I disagree about ...
|
Sept. 3, 2014, 5:41 p.m. |
+ 1 |
for Comment
veky: My comments were not about speed, but about clarity, bug avoiding (you don't have to think about pre...
|
Sept. 3, 2014, 5:40 p.m. |
+ 1 |
for Comment
ichaleynbin: Good call. You're right, for anything longer than a list of two, try:except will be faster, and at t...
|
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:...
|
Sept. 3, 2014, 5:38 p.m. |
+ 1 |
for Comment
veky: > I hope to not replicate something similar to this in the future! Don't be afraid to make mistakes....
|
Sept. 3, 2014, 3:55 p.m. |
+ 1 |
for Comment
magdre: yes yes ,that i just want,but i forgot before published.
|
Sept. 2, 2014, 4:58 p.m. |
+ 1 |
for Comment
vinc: Correct url for '**Are Annotations the Future?**': [http://sdtimes.com/python-creator-proposes-type-...
|
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. 27, 2014, 8:29 p.m. |
+ 1 |
for Comment
bukebuer: I remember such case was included in the old version of the task and solved it. However, when solvin...
|
Aug. 25, 2014, 4:22 p.m. |
+ 1 |
for Comment
veky: Yes, kind of. In fact p = lambda x: x > 10. And of course there can _be_ suitable x in the sequence,...
|
Aug. 25, 2014, 4:21 p.m. |
+ 1 |
for Comment
veky: Ok, let's try this way. You kno de Morgan laws? Even if you don't, try saying in Python "no x in c s...
|
Aug. 25, 2014, 4:21 p.m. |
+ 1 |
for Comment
veky: > If any(data) is False how can be all(data) True? Exactly when data is empty. Of course. > It seems...
|
Aug. 25, 2014, 4:20 p.m. |
+ 1 |
for Comment
hanpari: Thank you, at least it seems to me pretty tricky.
|
Aug. 25, 2014, 4:20 p.m. |
+ 1 |
for Comment
coells: Not seeing a *logic* does not mean there is not one. :-) all(iterable) -> bool Return True if bool(x...
|
Aug. 25, 2014, 4:19 p.m. |
+ 1 |
for Comment
bryukh: But this is written in "help" all(...) all(iterable) -> bool Return True if bool(x) is True for all ...
|
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, 8:29 p.m. |
+ 1 |
for Comment
Wei5: Because you could not do that. You can do it now because this problem is too difficult for beginners...
|
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. 14, 2014, 6:47 p.m. |
+ 1 |
for Comment
tihenko: Understanding code written by another person? This is not for newbies! :о)
|
Aug. 14, 2014, 6:47 p.m. |
+ 1 |
for Comment
ale1ster: I think that is the whole point...
|
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:28 p.m. |
+ 1 |
for Comment
bryukh: Did you try this in py3?
|
Aug. 13, 2014, 4:28 p.m. |
+ 1 |
for Comment
Lijantropique: Hello Bryukh, I use normally 2.7 and I didn't realize this code was P3 (my bad). However, this morni...
|
Aug. 13, 2014, 4:28 p.m. |
+ 1 |
for Comment
gyahun_dash: It is **annotation** introduced in py3. Let's try it.
|
Aug. 13, 2014, 4:28 p.m. |
+ 1 |
for Comment
bryukh: I had tried this code in pythontutor and didn't get an error.
|
Aug. 13, 2014, 4:28 p.m. |
+ 1 |
for Comment
Lijantropique: Hello Bryukh, That was my point. The program runs **without** errors but nothing special happened (I...
|
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. 13, 2014, 4:27 p.m. |
+ 1 |
for Comment
gyahun_dash: As you say, the dictionary is re-defined. If we need more speed, it should be defined globally like ...
|
Aug. 13, 2014, 4:27 p.m. |
+ 1 |
for Comment
aotus: Pardon the strange formatting in my message. It appears that the underscore character is interpreted...
|
Aug. 13, 2014, 4:27 p.m. |
+ 1 |
for Comment
gyahun_dash: When you use underscores in comments, you may insert \ in front of them.
|
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, 6 p.m. |
+ 1 |
for Comment
PositronicLlama: OPEN_BRACKETS = {a for a, _ in BRACKET_PAIRS} I did use a set for efficiency. A set uses more memory...
|
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. 11, 2014, 5:59 p.m. |
+ 1 |
for Comment
PositronicLlama: Lines 3-5 are certainly unnecessary, but they are potentially worthwhile as an optimization. Looking...
|
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. 6, 2014, 5:48 p.m. |
+ 1 |
for Comment
pohmelie: Okay… maybe this is idea for new task. Something like "maximum count of disjoint words". Cause in de...
|
Aug. 6, 2014, 5:48 p.m. |
+ 1 |
for Comment
bryukh: It's just for fun. Of course you can make the new task :-) It will be great.
|
Aug. 6, 2014, 5:47 p.m. |
+ 1 |
for Comment
pohmelie: What about case when text = "abcd" and words = {"abc", "bcd"}? I think words can't intersects, but s...
|
Aug. 6, 2014, 5:47 p.m. |
+ 1 |
for Comment
bryukh: > You should count how many words are included in the given text. "abs" is included, "bcd" is includ...
|
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, 5:28 p.m. |
+ 1 |
for Comment
PositronicLlama: return 1 << (len(stones) - 1) Thanks for all the code review feedback! I appreciate the time you put...
|
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:38 p.m. |
+ 1 |
for Comment
gyahun_dash: Incorrect: def saturate(signal, threshold): # threshold = period / 4 return max(-threshold, min(thre...
|
Aug. 4, 2014, 4:05 p.m. |
+ 1 |
for Comment
Sim0000: Thank you. I wanted to know it!
|
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, 6 p.m. |
+ 1 |
for Comment
Martin.N.Menendez: Thanks my friend. I cant use if "PUSH" in commands[i] because we send "PUSH i" with i=0,1,2,... I th...
|
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 :)
|
July 1, 2014, 7:22 p.m. |
+ 1 |
for Comment
Cjkjvfnby: Simple is better than complex.
|
July 1, 2014, 7:22 p.m. |
+ 1 |
for Comment
bryukh: "The list or tuple" I had tossed a coin and chose the tuple :-)
|
July 1, 2014, 7:21 p.m. |
+ 1 |
for Comment
bryukh: The coin does not think so ;-)
|
June 30, 2014, 6:13 p.m. |
+ 1 |
for Comment
odwl: Interesting way to get 0. Still very readable.
|
June 27, 2014, 9:29 p.m. |
+ 1 |
for Comment
peter_parada: Thanks for advice, I appreciate it. Yeah I know about .join but maybe I am too lazy too use advanced...
|
June 26, 2014, 5:36 p.m. |
+ 1 |
for Comment
Sim0000: Thank you!
|
June 26, 2014, 5:36 p.m. |
+ 1 |
for Comment
veky: Cool bool. :-D
|
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 26, 2014, 5:27 p.m. |
+ 1 |
for Comment
bryukh: Because precondition is using for the advanced users, when they complain "wrong" solutions :-)
|
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
Renelvon: I agree it is not correct (for a correct solution, see my code snippet in the comments). I disagree ...
|
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: No problem. :)
|
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:28 p.m. |
+ 1 |
for Comment
Renelvon: Indeed! I need to filter symbols out before applying the test, but I need to reintroduce them when c...
|
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
bryukh: It's an interesting reading. Thank you for the solution (I saved it for weekend) and for this commen...
|
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
macfreek: Thanks, good feedback. The reason to add these corner cases, even though they are not required is th...
|