Prime Substrings by undergroundmonorail

def p(n):
 n=int(n);a=n<2
 for i in range(2,n):a+=n%i<1
 return'01'[a<1]
def u(s):r=range(len(s)+1);return[s[x:y]for y in r for x in r if s[x:y]]
while 1:print''.join(map(p,sorted(u(`input()`),key=len)))

Note that non-ascii characters in the above source code will be escaped (such as \x9f).

download

return to the top page