28
Alex Mahotin
Last seen 31 minutes ago
Member for 6 years, 1 month, 8 days
Difficulty Normal
Engineer (3D modelling, 3D printing).
Very clean solution.
It's also possible to replace .format() method with f-string in line 14:
return f"{total.numerator//total.denominator} and {total.numerator % total.denominator}/{total.denominator}"
I'm not sure it'd be very readable though.
More
It's not a proper way to handle data parsing. Precondition says that 0 < xi, yi, r < 10, but it doesn't say xi, yi and r must be integers. For this particular quiz input data had been simplified, but a better way is to think ahead. What if xi is a float? What if it's negative? To make your solution
More
Why not just
[[line[i] for line in data] for i in range(len(data[0]))]
? I also used your approach. I tried to recall without look up how's it to use zip, but failed, u2? =)
HNY by the way.
More
It's also possible to not specify a delimeter for .split() method (just write words.split() instead).
This way for this task the result would be the same, but the procedure would be a bit different, read [here](https://docs.python.org/3.7/library/stdtypes.html?highlight=split#str.split) for more i
More
Your approach is very good.
I also don't like loopings are placed in places they aren't needed in.
More
But overdocumented though. There is no need to comment imported modules, there's python documentation existed for those who want to dig into. Your code is quite clear, superfluous comments make it cluttered.
For lines 40-43 you could use this snippet:
return sorted([alpha, beta, gamma]) if
More
List comprehension works faster than invocation of append through the loop. You may fold this part
result = els[:2]
for i in range(len(els[2:])):
result.append(sorted(els[i:i+3])[1])
return result
into this line:
return els[:2] + [sorted(els[i-2:i+1])[1] for i in range(2,
More
Banned "sum"? Pfff, hold my beer!
*Typing "s" + "um" instead of "sum".
Oh, I like it!
More
You could write one line.
[Ax, Ay, Bx, By, Cx, Cy] = map(int, [data[1], data[3], data[7], data[9], data[13], data[15]])
And it's better to use any more general approach to parse strings.
For example, this one below gives you the list with all of the numbers from a string.
re.findall(r"\d
More
You used a good approach to solve this task.
However, here is how you could improve your solution.
Take lines 4-6. You may use list comprehension idiom:
res = sum([Fraction(i,j) for i, j in fracts])
Further, line №10. You may f-strings. They are more readable than concatenation and a
More
Looks neat. Why not use enumerate for iteration though? I think your solution might look even a bit better:
def checkio(text, word):
matrix = text.lower().replace(' ', '').split('\n')
for row, line in enumerate(matrix):
try:
start_col = line.index(word)
excep
More
Hi!
I am looking at your solution via rand.solution, so my review may be late. Anyway.
1. Solution is clear and understandable.
2. You could improve readability if you had written _from math import acos, degrees_. This way line 6 is reduced to
_alpha = round(degrees(acos((b^2 + c^2 - a^2) /
More
Very well. Looks neat.
I didn't use regexes for solving this task because I didn't know about them at the time I was solving it.
But then I learned python docs [HOWTO](https://docs.python.org/3.7/howto/regex.html) for regexes.
There is "Common Problems" section at the end. Among other things
More
Hi. This solution looks very neat, but apparently lines 14, 15
schema = [list(line) for line in schema.split()]
schema = [line for line in schema if '#' in line]
could be replaced with one line:
schema = [list(line) for line in schema.split() if "#" in line]
More
I like your solution itself, it's very accurate IMO.
Can't say so about the comments. I understand your intention to make it clear for newbies but it works in reverse, leaving your code unclean.
Have a look at the lines 6, 7 or 3, 4 e.g.
Is there a need for such a comment? Code and comments ha
More