39
Axel
Last seen 1 month ago
Member for 2 years, 9 months, 4 days
Difficulty Normal
it's possible to make an one-line solution)
and some optimization to make this possible:
- start from a.replace('\\', '')
- for x in filter(None, a.splitlines()):
- map(str.strip, x.split(':'))
- long if-else construction
More
some optimization:
- you may first calculate ans, then control sun visibility with one condition like x <= ans <= y
- abs(min) looks superfluous
More
Great abstraction and polymorphism using!
But for my solution I economize with volume(). I made it non-abstract with 0 result )
More
Btw! It was list with first 2 zeros [0, 0, 1, ...]
It's results for lst = list(range(20))
return items == sorted(items) and len(items) == len(set(items)) # 0.75
return all(map(lambda a, b: a < b, items, items[1:])) # 1.31
return all(a < b for a, b in zip(items, items[
More
An ideas for optimization:
- you can compare self with shifted iterable. And take an elements different with shifted
- zip maybe useful for this
More
you can use this for alpha shift (need no string module and try-except):
chr(97 + (ord(s) - 97 + delta) % 26)
and next step looks like pack it all to one line )
More
Looks like my first solution...
Btw max(..., key=...) could help to improve code :)
More
good solution! but it isn't speedy )
you may use all + (comprehension + zip or comprehension + range)
More
Are you sure it works for files like "one.two.three.ext" and templates like "name.so*me.ext"?
More
some optimzation:
- count digits in the word
- compare it with 0 and length of word
- try to use expression like "x < y > z"
More
Clearness is inconceivable! Btw try to use 'any' for one-line solution
More
Great!
Do you think about itertools.combinations?
something about
tr1 = sorted(map(f_norm, combinations(coords_1)))
More
some optimization for solution
- it isn't necessary test for len(password)>9 in cycle, you may test it once in final 'if'
- it's possible to use any(map(str.isdigit, password)) instead of num = False + cycle
- if 'num==True and let==True' looks worse than 'if num and let'
More
it's still possible to make one-line solution using hints from previous tasks :)
More
You may use hints from previous tasks and sets for unique symbols count to make one-line solution possible :)
More
you can replace
sorted(data)
L=[x for x in sorted(data)]
with L = sorted(data), or simply use data.sort() and omit using L
More
first you may use this instead of binar_morze(). In addition you may remove 'bm = '.'*(nums[i] - len(bm)) + bm'
def binar_morze(n):
return f'{1:04b}'.replace('0', '.').replace('1', '-')
second you may to parse source data to 6 variables (it is possible in one line)
then use f-string t
More