15
Last seen 9 years ago
Member for 9 years, 10 months, 26 days
Difficulty Normal
Very clean code, I like it!
If you cared about how quickly your code ran, editing strings is very slow because Python has to make an entire new string anytime something is changed- it can't just change them in place. For example,
result = ""
...
result += letter
could be
More
Nice code, I like comparing the lower-case string to the original to find capitals. I have a few suggestions though.
- The input is already a string, line 2 is not needed.
- The try/except blocks will only ever catch an IndexError if len(texte)==0. You can avoid this by using a for loop instead
More
Very well organized code :-)
Is there a reason to use
a*a/c/c
instead of
a**2/c**2
or is it just preference?
More
This code would be easier to understand if the variables 'b' and 'i' were renamed something more informative. B is the number of pigeons arriving in 1 minute and i is the index of the current pigeon, maybe "Arriving_Birds" and "Bird_Index"?
Instead of :
pigeons.extend([0 for d in range(b+1
More
Hello! Very nice code. Why do you make a copy of the set of computers under attack at line 8? The set 'infected' is not altered in that for loop.
More
I'm not a fan of the 7-deep nested blocks, and re-iterating over every character so many times.
More
Is there any particular reason you squished everything into one return statement?
More
You can eliminate line #3 by changing line #1 to:
def checkio(feed):
Overall this is very clear and concise.
More
Well I feel silly.
def Parse_Friendship(String):
return String.split('-')
Does the same thing much more nicely.
Also, the recursive mapping could be stopped as soon as the second name was found to make it run more quickly.
More
I have a few ideas for you.
Good job naming 'number' something more intuitive :-). Line #4 could be eliminated if you changed line #1 to:
def checkio(food):
What you call the function arguments doesn't matter to the website's checker.
When you want to increase/decrease a number, line
More
Very nice! If you want to save yourself a little typing,
roman_numerals = anhyeuem[i][rest] + roman_numerals
could be replaced by
roman_numerals += anhyeuem[i][rest]
More
Very cool method. It doesn't affect the game result, it just rotates the board, but do r0, r1, and r2 hold columns as oriented from game_result?
More
Hello, I have a few suggestions to make your code look a little nicer :-).
Integers are automatically converted to floats by Python if you divide by a float, that's why you need the int() part in line #4. But because of this, line #4 can be simplified to
median = (lst[int(len(lst)
More
Very concise, nice.
If you didn't want to use range() with a guess at what the maximum number of arriving pigeons was, you could use itertoosl.count, which would make it able to handle any number of pigeons.
from itertools import count
def checkio(data):
num_pigeon = 0
f
More