57
Awesome Team
Vedran Čačić
https://web.math.hr/~veky
Last seen 21 hours ago
Member for 11 years, 6 months, 6 days
Difficulty Advanced
We shall not cease from exploration, and the end of all our exploring will be to arrive where we started and know the place for the first time.
re is obviously an overkill here. With the necessary escaping it is even longer than ordinary index (or my approach:). And you don't even use IGNORECASE.
Nice use of bisect.insort. :-)
That ugly offset calculating can be completely removed, if only you replace "enumerate" with "reversed" in li
More
Why is `check` a separate function? Considering the context, name is not really very semantical.
And if you really want a function,
for c in filter(check, message)
would probably be nicer.
More
Nice and straightforward. In fact the same algorithm as my solution:-). But function check is really confusing. Line 13 should be just
if x*3 in flat:
Don't you agree?
More
Nice and straightforward. bools can be used arithmetically in total +=
(p>e) - (pMore
Namespace dicts are usually initialized via kwargs.
dict(e=1, a=1, i=1, ...)
[Of course, you might argue whether VALUES _is_ a namespace dict, but I think the readability gain is positive anyway.:]
---
Otherwise, as opposed to many solutions that are claimed to be clear and Pythonic, this on
More
Much clearer: define min_max with its true signature (reverse:bool, *args, key=None) and say
min = functools.partial(min_max, False)
max = functools.partial(min_max, True)
More
Nice UF. But of course you don't need a class.
Line 44: You don't need `list()`. In fact you don't need `set()` either. ;-]
Line 45: `sorted(eggs, key=spam)[-1]` is also known as `max(eggs, key=spam)`. Timsort _is_ damn fast, but max is linear. :-)
Line 19: see `dict.fromkeys`. Very useful and fe
More
* jackdied: Does your class have two methods, one of which is `__init__`?
* veky: errrm... no? :-)
([context](https://youtu.be/o9pEzgHorH0?t=180))
More
@oduvan: Much improvement. I usually solve your missions with just one import from stdlib, now I had to use three. :-D
More
Cool. Not really general, but here is a nice hack someone might find amusing: you can replace max(0, x - 1) with x - bool(x). ;-)
More
int(round(bla,0)) is just round(bla).
Also, see "Always use a def statement instead of an assignment statement that binds a lambda expression directly to a name." (new version of PEP8).
Otherwise, nice solution.
More
Next time someone tells me Python is a functional programming language, I'll show them this. :-DD
More
Putting obvious solution aside, here is your algorithm written in Python, not in some Lisp-Java mix you've written. ;-)
def checkio(str_number, radix):
import string
result, value = 0, (string.digits + string.ascii_uppercase).index
for exponent, digit in enumerate(r
More
Cool. Especially the - grid[row][col] part. ;-)
In slicing, max is unfortunately necessary, since -1 has a different meaning. But min isn't necessary.
r[max(0, col-1):col+2]
works fine.
More
Could be simpler, cleaner, _and_ use less memory if you removed the brackets.
''.join(letter for letter in text if letter.isupper())
BTW .istitle is not exactly the same. It is used when the desired output has only first letter of word emphasized by case. Although the test example gives exactl
More
Nice, but can be compressed much further. First, you don't need twice as long items in ALPHABETS, just say text.upper() at end of line 4.
Second, once you know that only \w are in your words (and BTW you don't need []s), you only need one item in ALPHABETS, another one can be deduced with [A-Z] a
More
You're aware that you wrote the same thing three times? :-)
More
chain(*map(f, l))
is what you're probably looking for. ;-)
(And it has nothing to do with ChainMap.:)
More