• 博客园logo
  • 会员
  • 周边
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • YouClaw
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
近知
博客园 | 首页 | 新随笔 | 新文章 | 联系 | 订阅 订阅 | 管理

随笔分类 -  算法

算法
 
通用排列
摘要:''' 这个程序不是很有效率,程序中的’if f not in e:‘会产生许多的开销,不是很好,也较难扩展到当L中有重复元素的情况 ''' def permutation_1(L,k): def product2(R,L): R1=[] if R==[[]]: for e in L:R1.appe 阅读全文
posted @ 2021-11-27 11:04 近知 阅读(46) 评论(0) 推荐(0)
组合问题
摘要:def combination_2(L,k): def product2(R,L): R1=[] if R==[[]]: for e in L:R1.append([e]) else: for e in R: for f in L: if f not in e and f >e[-1]: R1.ap 阅读全文
posted @ 2021-11-27 11:02 近知 阅读(119) 评论(0) 推荐(0)
全排列问题
摘要:def permutation_all_1(L): if len(L) <= 1: return [L] T = permutation_all_1(L[1:]) R = [] # 循环方式一: for i in range(len(L)): for t in T: # 循环方式二: # for t 阅读全文
posted @ 2021-11-27 10:58 近知 阅读(58) 评论(0) 推荐(0)
雪花图形绘制
摘要:from turtle import * # 雪花图形 def draw(s, size): for i in s: if i == 's': p.left(60) elif i == 'f': p.forward(size) else: # p.left(-120) p.right(120) de 阅读全文
posted @ 2021-11-18 19:47 近知 阅读(103) 评论(0) 推荐(0)
 

公告


博客园  ©  2004-2026
浙公网安备 33010602011771号 浙ICP备2021040463号-3