Tricks learned in CodeWars —— Python
A string’s reverse
How to reverse a string as quickly as possible?
The answer is
>>> string = '1234567890' >>> string[::-1] '0987654321'
Prefill an Array
Prefill an Array with a fixed value without loop.
def prefill(n,v=None): try: return [v]*int(n) except Exception as e: raise TypeError('%s is invalid' % n)
True without return
This is easy.
solve = lambda : True
Waiting for new stuff…