39
Awesome Team
Олександр Зозуля
Last seen 9 hours ago
Member for 9 years, 12 months, 3 days
Difficulty Easy
Notice a few moments to improve the solution:
1) no need to use `list()` on `sorted()` since `sorted()` returns `list` object;
2) since `bool` value may be interpreted as `int`, `k != v` is enough to get 1 or 0;
3) `sum()` can take list comprehension as argument, so no need in `[]`.
More
Your solution is wrong, because it does not allow case "Characters in String B are allowed to correspond to multiple character values in String A."
For the test isometric_strings('abba', 'cccc') it returns False, though True is correct.
More
I am totally sure you know, that "if group" is enough to check emptiness)
More
Haven't seen your solution before solving, just think quite the same way)
More
Olmost the same as mine) But dont you think its better to make res and dvs arrays global and with each call do operations inside loop not with all atts (again and again with the same information) but only once with last!)
More
Notice, that you don't actually need `elif` when every branch ends with `return`. It may be organized just as a bunch of `if`'s.
More
No need to use join here.
newtext.append("".join(word[::-1]))
More
I've used ChatGPT to generate comments and exlanation for this solution.
The "remove_brackets" function is the entry point of the solution. It initializes a global variable "result" to store valid bracket combinations and then calls the "remove_spare" function to start the removal of unnecessary br
More
Will not work if string starts with ' '. To follow your strategy you use lstrip() before loop. Besides, you don't need variable count, because 'i' is doing the same job, range doesn't need '0', as well as text slicing in return. Hm...you don't need break as well, you may return you result write ther
More
You may replase
lst = []
for num in values:
lst.append(abs(one-num))
with list comprehension
lst = [abs(one-num) for num in values] # or lst = list(...the same)
In a lot of cases it's even better to use [generator expressions](https://peps.python.org/pep-0289/)
lst = (ab
More
The idea is cool, but I guess the solution needs improvement.
You don't catch a case, when `typed` ends _before_ `text`.
Check correct `assert long_pressed("abc", "aabb") == False`
The cure could be something like:
`...`
`while(text and typed):`
`...`
`return typed == text == ""`
More
def longest_palindromic(a):
for x in xrange(len(a)-1, -1, -1):
for y in xrange(len(a)-x):
s = a[y:1+x+y]
if s == s[::-1]:
return s
More
Your solution returns True for this example, which is wrong:
goes_after('world', 'a', 'r')
More
Your solution returns True for this example, which is wrong:
goes_after('abbaz', 'a', 'z')
More
Your code could be cleaner:
def checkio(number):
if not number % 3:
if not number % 5:
return "Fizz Buzz"
return "Fizz"
if not number % 5:
return "Buzz"
return str(number)
More