spacemacs

ARTS Week 4

十年热恋 提交于 2019-12-06 08:41:39
Nov 18, 2019 ~ Nov 24, 2019 Algorithm 深入优先搜索-马遍历棋盘 要求:给定一个 n * m 的棋盘,左上角为(0, 0),马的初始位置为(x, y),找到所有方案使得马不重复地遍历棋盘,输出所有方案 思路 马走‘日’字,因此有八种移动方案,分别为: dir = [[-2,1], [-1,2], [1,2], [2,1], [2,-1], [1,-2], [-1,-2], [-2,-1]] 坐标 (x, y) 移动一步后的结果为 (x+dir[i][0], y+dir[i][1]) 马的移动需要受到以下两个条件的约束: 移动后的点仍要在棋盘上,即 $ 0 \leq x+dir[i][0] \leq n-1 $ $ 0 \leq y+dir[i][1] \leq m-1 $ 移动后的点是要为访问过的,即 $ visited[x+dir[i][0]][y+dir[i][1]] $ 实现 Python的实现代码如下: def draw(): print('第', ans,'种方案:',history) def horse(x, y, step): if step == num: global ans, found ans = ans + 1 found = True draw() else: for i in range(8): x_temp = x

Extract the second level headline

六眼飞鱼酱① 提交于 2019-12-06 08:08:24
For my global TODO list, I am showing breadcrumbs as suggested here : (concat \"[ \"(org-format-outline-path (org-get-outline-path)) \" ]\") ") to produce following: I would like to show only the second level of project breadcrumb. So in this case, I would only display [Project A] . I think if I can make a function that can extract the second level, I just need to prepend with %? so that [Tasks] does not appear for Tasks, but only project names would appear for Projects. What would be an ideal way of extracting the second level? All you have to do to get the second element of (org-get-outline