下面是内存溢出 jb51.cc 通过网络收集整理的代码片段。
内存溢出小编现在分享给大家,也给大家做个参考。
#!/usr/bin/python"""---------------------------------------------------------------------------------------------------2015.07.23 Grey***************************************************************************************************Counter all the triangles in a picture---------------------------------------------------------------------------------------------------"""import itertools,stringdef CounterTriangle(): print "All the triangles we can find in the picture are as follows:" triangle_number = 0 sIDes_match_List = ['abh','acgi','adfj','aek','bcde','efgh','hijk'] dot_List = [] i = 0 while i < 26: dot_List.append(string.lowercase[i]) if string.lowercase[i] == 'k': break else: i += 1 for each_combination in itertools.combinations(dot_List,3): triangle_flag = True for each_dot_combination in itertools.combinations(each_combination,2): for each_sIDe in sIDes_match_List: if each_dot_combination[0] in each_sIDe and each_dot_combination[1] in each_sIDe: triangle_flag = True break else: triangle_flag = False else: triangle_flag = False break line_flag = False for each_sIDe in sIDes_match_List: if each_combination[0] in each_sIDe and each_combination[1] in each_sIDe and each_combination[2] in each_sIDe: line_flag = True if triangle_flag == True and line_flag == False: triangle_number += 1 print "%d : %s" % (triangle_number,each_combination) print "The number of triangles in the picture is : %d" % triangle_numberCounterTriangle()
以上是内存溢出(jb51.cc)为你收集整理的全部代码内容,希望文章能够帮你解决所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
总结以上是内存溢出为你收集整理的计算一个图形中的三角形数目全部内容,希望文章能够帮你解决计算一个图形中的三角形数目所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)