Code Golf
I spend way too much time playing Clash of Code on CodinGame as you can see in the “featured image” above. I still haven’t caught up with Haskell, and I struggle to stay above Allis. Both are really strong, and seem to know Ruby very well!
My favorite mode is “Shortest”. The goal is to write a program against a given specification within 15 minutes. But, unlike the “Fastest” and “Reverse” modes, the main criterion is the number of characters in the submitted code.
So, if the problem is to write a program that asks for an integer n and then prints n! (the factorial of n), you are not going to submit the following snippet (69 characters):
from math import factorial
n = int(input())
f = factorial(n)
print(f)
At the very least, you are going to remove the extraneous spaces and avoid unnecessary declarations (47 characters):
import math
print(math.factorial(int(input())))
Or you might notice that importing a module and calling a method with a long name costs you many characters and that you are better off implementing it yourself (45 characters):
n=int(input())
p=1
while n:p*=n;n-=1
print(p)
This is less read