Jules Olléon
  • Member for 10 years, 7 months
  • Last seen more than 1 year ago
  • Sunnyvale, CA
Palindromic palindrome checker
26 votes

Python without comment "a\";w=]1-::[w trinp;)(tupni_war=w;";w=raw_input();print w[::-1]==w;"\a" I'm surprised that no one found that trick yet, it should work in most languages!

View answer
The strange life of a beehive
5 votes

Python, 171 169 158 chars w=300 s=w*w x=[0]*297 h=[1,1,0]+x+[1,0,1,1]+x+[1]+x*s exec('h=[1<sum(h[(i+x)%s]for x in[-1,-w-1,-w,1,w+1,w])<5-h[i]for i in range(s)];'*input()) print sum(h) I model ...

View answer
Generating guitar tabs?
4 votes

Since shorter solutions have been given already (damn you GolfScript!), here is mine: Python, 229 chars s=[("E EmF FmF#GbG GmG#AbA AmA#BbB BmC CmC#DbD DmD#Eb".find("%-02s"%s[:2])/4,s[-1]!='m')for s ...

View answer
Code-Golf: Permutations
2 votes

Python - 58 chars Slightly shorter than ugoren's, by taking a set as input: p=lambda x:x and[[y]+l for y in x for l in p(x-{y})]or[[]]

View answer
Shortest, lexicographically smallest generating string
2 votes

Python, 121 137 129 chars s=raw_input() n=len(s) l=[(s+s)[i/n:i/n+i%n+1]for i in range(n*n)] print min(filter(lambda x:(x*len(s)).find(s)+1,sorted(l)),key=len) EDIT: fixed the bug spotted by JiminP

View answer