This question already has an answer here:
- Generate Pascal's triangle 47 answers
the contest is already finished, so I don't think it's cheating to ask: I am trying to optimize this small contest: pascal triangle I started with 4.72 and worked myself up to 7.48. The best made a 9.05 but in perl, python2 best score is 8.25. Unfortunately they don't let you look at what others did. My current solution is the following:
l= print 1 while(len(l)<31): print' '.join(map(str,l+)) l=+map(lambda x,y:x+y,l,l[1:]+)
Now I tried to get rid of the loop in using list comprehension, but I am too new to python to get this done. Can anyone give me a hint for nested list comprehension shortening this code further down?
Thank you for your audience.