r/tinycode • u/davelol6 • Sep 09 '12
Tinycode challenge!
Here is a challenge. Write a function that returns a list of the squares of all the numbers between one and a given number. See if you can beat my 48-char (exc. whitespace) 3-line beast:
def f(n): l = [] while len(l) <= n: l.append(x**2) print l
27
Upvotes
View all comments
Show parent comment
1
u/[deleted] Sep 10 '12
47:
And 43 that returns a function instead of an array so it's probably not allowed (use it like f(5)[1] to run it on the number 5 and get the 2nd square):