本帖最后由 wanghan519 于 2023-9-7 09:29 编辑
python最简单,因为有itertools,- import itertools
- s = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'
- with open(r'a.txt','w') as f:
- for i in range(1, 5):
- for j in itertools.permutations(s, i):
- f.write(''.join(j)+'\n')
复制代码 前两天刚提过的nushell可以方便的写sql,似乎sql写递归也很方便- with recursive c as (
- select x, 1 n from t
- union all
- select c.x || t.x, c.n + 1
- from c join t
- where c.n < 4 and c.x not like '%' || t.x || '%'
- )
- select x from c;
复制代码 或者就像上面那样再试试awk递归怎么写,上面那是列出所有组合,没考虑全排列 |