laurencevs
  • Member for 7 years, 4 months
  • Last seen more than a week ago
  • Cambridge, United Kingdom
Sort a list and write some English!
25 votes

Python 2 & 3 Unfortunately, the employees of today just can't stop using hashtags all over the place... #WritingALetter #Business Dear Boss, #SecondLine I found this scrap of paper on the ...

View answer
Shrinking numbers
4 votes

Python 2, 72 68 63 56 55 Obviously not as concise as other answers, but anyway: x=input() m=min(x) print[(i*1.-m)/(max(x)-m)for i in x] Sample run: [1,100,25,8,0] #input [0.01, 1.0, ...

View answer
Calculate a check digit using the Damm algorithm
3 votes

Python 3, 149 141 138 characters import re l="" for c in"ĽᝢႮ⏿ዿၮ∉᜝Ꮺൢ៫Njẜ᳼╭᛭ᰡඡᆸߡⓞ᠜ȍ῏᪆":l+="%04d"%ord(c) def D(b): a="0" for i in re.sub("\D","&...

View answer
Tetrahedron Surface Area
3 votes

Python 3, 308 298 292 279 258 254 from itertools import* def a(t,u,v):w=(t+u+v)/2;return(w*(w-t)*(w-u)*(w-v))**.5 z,x,c,v,b,n=((lambda i,j:(sum((i[x]-j[x])**2for x in[0,1,2]))**.5)(x[0],x[1])for*x,in ...

View answer
Draw an ASCII Checkerboard
2 votes

Python 3, 114 108 100 def f(n): for i in range(3*n+1):print(("|##| "*n+"|")[::i//3%2*2-1][:3*n+1]if i%3 else"+--"*n+"+") Previous solutions 108 def f(n): for i in range(3*n+1): a=("|##| "*n+"...

View answer
Make a one sequence
2 votes

Python, 138 from itertools import* def f(n,s): for i in[list(accumulate(x))for x in product([-1,1],repeat=n-1)]: if sum(i)==s:return[0]+i return[]

View answer
Creating Distinct Sums
1 votes

Python 3, 29 27 Edit: doesn't meet the requirement in the 2nd "Details" bullet point Bonus: it works from -99998 to 99998 inclusive lambda n:[99999*n,-99998*n] This creates an anonymous ...

View answer
Remove common leading spaces
1 votes

Python 3, 100 def f(s):t=s.split("\n");return"\n".join([c[min([len(c)-len(c.lstrip(" "))for c in t]):]for c in t])

View answer
Knight's tour game (7x7)
1 votes

Python 3 - 241 chars This will work most of the time, if you live long enough to see the result... It works by randomly reordering a list of all coordinates until it gets the right answer. If it takes ...

View answer
Piem validator programme
1 votes

Python - 130 127 116 - 17 digits of pi As in @flawr 's answer, Law ' s fine and Law's fine both return True. Thanks to @Emil for removing 12 characters from the program. import re f=lambda x:all(j==...

View answer
Counting Fountains
0 votes

Python 3, 88 bytes f=lambda n,p:sum([f(n-p,q)for q in range(1,p+2)])if p<n else int(p==n) t=lambda n:f(n,1)

View answer
Sort by custom alphabet
0 votes

Python, 131 w,a=input().split() print(",".join(sorted(w.split(","),key=lambda s:"".join(["abcdefghijklmnopqrstuvwxyz"[a.find(c)]for c in s])))) There should be ...

View answer