# coding:GBK
# 解题:填入数字1~9,使它们之间关系成立
#
# ○>○<○
# V ^ V
# ○<○>○
# ^ V ^
# ○>○<○
#
# trees_peng@hotmail.com
import os
import time
counter=0
def SearchBuf(src,dat):
global counter
if len(src)==0:
#dat满,检查是否符合题目规则
if dat[0]>dat[1] and dat[1]<dat[2] \
and dat[0]>dat[3] and dat[1]<dat[4] and dat[2]>dat[5] \
and dat[3]<dat[4] and dat[4]>dat[5] \
and dat[3]<dat[6] and dat[4]>dat[7] and dat[5]<dat[8] \
and dat[6]>dat[7] and dat[7]<dat[8]:
#符合规则,打印出结果
print 'Result:'
print ' %d %d %d'%(dat[0],dat[1],dat[2])
print ' %d %d %d'%(dat[3],dat[4],dat[5])
print ' %d %d %d'%(dat[6],dat[7],dat[8])
counter=counter+1
else:
#src中仍有内容,分别提取后递归检查
for m in src:
n=src.index(m)
src.remove(m)
dat.append(m)
SearchBuf(src,dat)
dat.pop()
src.insert(n,m)
print 'Searching...'
timer1 = time.time()
SearchBuf([1,2,3,4,5,6,7,8,9],[])
timer2 = time.time()
print 'Done!'
print '%s results'%counter
print '%.3f seconds elapsed'%(timer2-timer1)
os.system('pause')
maths_games_fill_in_blanks.zip_Maths.h_games_math python
版权申诉
190 浏览量
2022-09-24
01:24:25
上传
评论
收藏 2KB ZIP 举报
四散
- 粉丝: 49
- 资源: 1万+
最新资源
- 基于MIC+NE555光敏电阻的声光控电路Multisim仿真原理图
- python tkinter-08-盒子模型.ev4.rar
- Doozy UI Manager 2023
- 基于matlab实现夜间车牌识别程序(1).rar
- 基于matlab实现无线传感器网络无需测距定位算法matlab源代码 包括apit,dv-hop,amorphous在内的共7个
- 基于python的yolov5实现的旋转目标检测
- 基于matlab实现无线传感器网络 CAB定位仿真程序 这是无线传感器节点定位CAB算法的仿真程序,由matlab完成.rar
- 基于matlab实现图像处理,本程序使用背景差分法对来往车辆进行检测和跟踪.rar
- 基于matlab实现视频监控中车型识别代码,自己写的,希望和大家多多交流.rar
- springcodespringcodespringcodespringcode
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈