31
Last seen 2 months ago
Member for 5 years, 4 months, 6 days
Difficulty Normal
## [::(-1)**row] - it's great!!
How many wondrous revelations
The spirit of enlightment hides!
And practice, son of hard mistakes,
And genius, friend of paradox,
Sorry, no rhyme. An attempt to translate A.S.Pushkin.
More
try
assert fuzzy_string_match("apple", "apples", 0) == False
assert fuzzy_string_match("apple", "apxles", 1) == False
Use zip_longest instead zip
More
clear
Instead of this line:
for a, b in [(cakes[i], cakes[k]) for i in range(len(cakes)) for k in range(i + 1, len(cakes))]
you could use a combinations from itertools :
for a, b in combinations(cakes, 2)
More
try
assert fuzzy_string_match("apple", "apples", 2) == True
condition needs to be changed
cnt <= threshold
More
Nice and **short**.
IMHO, in one style is better:
def money(self):
return f'{self.working_years*self.salary*12:,}'.replace(',', ' ')
More
try
assert fuzzy_string_match("apple", "apples", 0) == False
assert fuzzy_string_match("apple", "apxles", 1) == False
Use zip_longest instead zip
More
exactly like my solution ))
I just didn't use math.ceil()
minutes[date] = minutes.get(date, 0) + int(sec)//60 + bool(int(sec)%60)
More
the solution will not pass on the test
assert is_all_upper('1 23') == False
that's right:
def is_all_upper(text):
if text := text.strip():
if subset := set(text) - set(string.digits + ' '):
return not subset - set(string.ascii_uppercase)
re
More
You don't need to convert the string to a list. A string is a sequence that can be manipulated directly. You can shorten your code:
def backward_string(val: str) -> str:
arr = reversed(val)
newval = ''.join(map(str, arr))
return newval
But an easy way to use slices
More
try:
assert unix_match('name2.txt', 'name[].txt') == False
And if you change re.search to re.match (because you need match the filename, not search part of the filename) then try again extra test:
assert unix_match('[!]check.txt', '[!]check.txt') == True
More