49
Awesome Team
Philippe Cholet
https://github.com/Philippe-Cholet
Last seen 7 hours ago
Member for 6 years, 3 months, 18 days
Difficulty Advanced
I was a math teacher in France for two years. I'm currently reconverting to IT, I'm here to improve my Python skills, and practice English.
Coming back to it 19 months later, I still understand it clearly. It makes me happy. ✨
And the only thing I would really change is:
No need of the variable "okay" in the "possible_words" function: the "else" clause would do the job.
changes = []
for rc, letter in z
More
`items[begin:end]` and `items[end:]` are already sorted, you just need to reverse them so
result += items[begin:end][::-1] # may be possible with one slicing but I'm incomfortable with reversed slices.
result.extend(reversed(items[begin:end]))
a = items[begin:end]; a.reverse(); result
More
Note that `for each,i in zip(str1, range(len(str1)))` and `for i,each in enumerate(str1)` are equivalent.
More
You don't need to iterate on the text. You're almost lucky it even works.
def correct_sentence(text: str) -> str:
text = text[0].upper()+text[1:]
if text[-1] != ".":
text += "."
return text
More
More creative than clear IMO.
No need of parenthesis around `float` or around no rounded result: `round((...), 2)` -> `round(..., 2)`.
More
I think the "checkio" function should receive only one “step info” each time and process it, instead of giving the entire history, and a coroutine is a good way to do just that. Plus, it's a rare occasion to use `typing.Generator` in a meaningful way.
More
Use global variables is usually a bad idea, like here. Honestly it should NOT have pass tests. You only pass them because of "check" part work, and little tests did not warn you about it.
assert isometric_strings('add', 'egg') == True
dict == {'a': 'e', 'd': 'g'}
assert isometric_strin
More
You could use `float('inf')` or `from math import inf` for min_cost.
And global variable are tricky to use. You can define a function into another. Then you won't have to use a global variable.
def cheapest_flights():
min_cost = float('inf')
def cost_calc():
# cost_
More
I would use "for/else" instead of "flag". What do you think?
for i in range(1, 101):
for j in range(4):
if i % prime[j] != attempts[j + 1][0]:
break
else:
return [2, i]
More
def cheapest_flight(costs: List, a: str, b: str) -> int:
return min((get_weigth(l, costs) for l in find_all_paths(gen_dict(costs), a, b)),
default = 0)
default value is returned when the iterable is empty.
min([], default=0) == 0
def get_weigth(route, t):
More
All tests in a quarter of a second on my computer. Fast enough for me.
More
Great use of numpy and scipy! I like the simplicity that these modules offer to your code, except lines 24-31, I would like a function similar to `pad` to reduce the matrix. :-) Or apply pad function only if it's necessary.
More
If the iterable is not necessarily a "list of lists of ... of ints/floats", but an "iterable of iterables of ... of not iterables".
def how_deep(iterable) -> int:
try:
return 1 + max(map(how_deep, iterable), default=0)
except TypeError: # not an iterable anymore, re
More
I really like the fact you use **corners** (so +2). I thought about it too, but my solution worked without this kind of deduction.
Line 54: `for v in range(1, 100):` or `for v in count(1):` itertools count, it's great.
I like to see exceptions raised, but you should create your own exception to be
More
`num%2==0` is already a boolean True or False, you can return it.
def is_even(num: int) -> bool:
return num%2 == 0
More
Note that when I published this I could not put it in **creative** category where it clearly belongs.
More