Golfing

I spent a few hours today round Code Golf and here's a neat thing I did.I think this is python's shortest possible factorial:

f=lambda x:x<2or x*f(x-1)

You may say it's not correct, because f(1) returns True, but int(True) is 1, so it's almost there ;-)

And here's a surprisingly readable (as long as you know pascal's triangle) and not too long answer to their choose challenge:

n,k=input()
a,c=1,0
while c<k:a*=n-c;c+=1;a/=c
print a

Comments

Comments powered by Disqus