- 117 words -
See also my Javascript golf page
Useful code to copy/paste in codingame "fastest" challenges:
def log(*args): import sys; print(*args, file=sys.stderr)
To call create an input from calling the same function several times:
[input() for i in range(8)]
[i() for i in [input]*8]
[input() for _ in "1"*8]
Note that the list comprehension might be better in some cases. Example with The Descent where we need to read a list of integers and return the index of the highest value:
while m:=[input()for _ in "1"*8]:print(m.index(max(m)))
while 1:print(max([(input(),i)for i in range(8)])[1])
The list comprehension allows to create tuples with the value and the index. Iterating on "1"*8
would not give us the incrementing index.
Posts in the same category: [codegolf]