Python-Project Euler 41
2014-01-18 16:35
363 查看
from isPrime import *
ans=[]
f=[]
def check():
global f
s=''
for i in range(len(f)):
s+=str(f[i])
if isPrime(s)==True:
return True
else:
return False
def go(k,n):
global f
for i in range(n,0,-1):
if i not in f:
f.append(i)
if (len(f)==n and check()==True):
ans[:]=f[:]
print(len(f),' ',len(ans),' ',ans)
go(k+1,n)
f.pop()
go(1,7)
print(ans)
ans=[]
f=[]
def check():
global f
s=''
for i in range(len(f)):
s+=str(f[i])
if isPrime(s)==True:
return True
else:
return False
def go(k,n):
global f
for i in range(n,0,-1):
if i not in f:
f.append(i)
if (len(f)==n and check()==True):
ans[:]=f[:]
print(len(f),' ',len(ans),' ',ans)
go(k+1,n)
f.pop()
go(1,7)
print(ans)
相关文章推荐
- [Project Euler] Problem 18 & Problem 67 Python解答
- Python 3基础教程41-多线程不一定效率就高
- Python-Project Euler 30
- Python-Project Euler 39
- Python-Project Euler 50
- 41. First Missing Positive Leetcode Python
- python经典100例(41-60)
- 笨办法学Python-习题41-44
- Python实现Project Euler 5
- Selenium2+python自动化41-绕过验证码(add_cookie)
- Python3 笨方法 练习41(面向对象)详解及运行结果
- Python-Project Euler 22
- Python-Project Euler 81
- Python-Project Euler 52
- python手记(41)
- PHP 和 Python实现Project Euler 1、2题
- 笨方法学Python(41-45)
- Python-Project Euler 42
- Learn Python The Hard Way exercise 41 note
- 笨办法学 Python · 续 练习 41:SQL 更新