36
Colin McNicholl
Last seen 7 months ago
Member for 6 years, 9 months, 11 days
Difficulty Normal
Really tidy and clean layout makes you code the kind I am happy to spend time looking at more closely.
Not only that but overall I believe it is possibly the most efficient from a sample of solutions posted by other community members.
Some results from timeit module assessment I made below:
More
Not sure how random these random reviews are. This code is no doubt
created by someone with much more coding experience than I have.
Nevertheless, I will give it my review.
It is readable, being sparse helps in this respect.
It is explicit in that it is obvious, given the clear variable names what
More
Really nice solution.
Many others have shown skill in creating comprehensions which whilst fairly compact are, I think not as readable, as an indented loop or your even shorter yet easier to understand solution.
I had not used islice before so thanks for the lesson.
More
Nice solution, avoiding import of re module.
The else on line 19 looked out of place but after studying your code for a while I understood.
More
Very good.
I would not have deduced from reading the python docs for unicode module that category(c) 'Mn' ("Non-spacing mark") contains every accent.
Your comments are useful.
Triple quotes are more appropriate for comments below the function definition.
More
You have expertly made the code very sparse.
A very minor observation would be that in cases were weights is a very long
sequence with mirror image either side of central fulcrum
It seems a little wasteful to have a for loop over the full length of
weights
in cases such as [1,1,1,9,1,1,1].
My code:
More
You did well to have the patience to read and understand the long description for this mission.
Line 2: Block comments. The first word should be capitalized, unless it is an identifier that begins with a lowercase letter. Also comments should be complete sentences. See PEP8.
Your use of '_' as
More
Fantastic piece of code.
Certainly convinces me that this mission merits using re module.
I have not noticed 'escape' in module re before.
More
is_exist function does not cover all conditions:
CHANNELS = ["BBC", "Discovery", "TV1000"]
controller = VoiceCommand(CHANNELS)
assert controller.is_exist(4) == "No"
assert controller.is_exist(3) == "Yes" # AssertionError: code returns 'No'
More
Good code. I like the methods for name, work, money and home.
Possible improvements would be:
line 6: the __init__ ends at column 120. Break this into 2 lines, e.g.:
class Person:
def __init__(self, first_name, last_name, birth_date, job,
working_years,
salary, country, city,
More
Nice code.
You could have avoided the nasty looking indices with the following:
return chain.from_iterable(range(start, stop + 1) for (start, stop) in
items)
Virus-free.
www.avast.com
<
More
Good code. Your code works and is fairly short.
I could be missing something but it is not clear to me why your function is
called 'extractOne' ? It reduces the length of the list 'numbers' but not
necessarily by one.
This maybe as I rarely use reduce. I find the line:
candidates = reduce
More
Very good compact and also clear.
IMO code would look better if you leave a single space either side of any operator, e.g. the '*' in line 2. You did this with the '%' operator on line 4.
Line 3 could have been:
data = [ord(x) - 48 for x in reversed(data) if x.isalnum()]
More
A nice demonstration of how it can be done in one line.
Satisfies sparse is better than dense and flat is better than nested.
Not exactly beautiful.
Variable names are too short to be informative.
A bit on the long side at 86 characters in length.
A return after say "sorted(" would make the code a l
More
Good effort and well done on successfully solving the mission.
It would be worth you going back over this mission.
Instead of lines 4 and 5:
kinds = ["golden coin", "silver coin", "ruby"]
weights = [info[kind]["weight"] for kind in kinds]
you could have:
weights = [v['weight'] for v in info.valu
More
A lot of features packed into this code.
First line and we have lambda function, * unpacking operator and keyword arguments on show.
Line 3 and the decorator is being used to customise the buttons function.
Good choice of variable names, e.g. nb_rows, nb_cols. These mean that the compact lambda
More
line 20: The thought process seems strange to me for a function named
fight. While unit_1.health or unit_2.health would be true for all cases
except if both were False. So it is a bit like if one of the units has
health, i.e. is_alive and the other has 0 health, i.e. is dead, do stuff,
i.e. have
More