|
发表于 2022-3-8 00:07:13
|
显示全部楼层
如果只是 6元、13元、15元、20元,零用錢 35元整
代碼:- from itertools import permutati**
- toys = [6, 13, 15, 20]
- buy = [[list(price) for price in permutati**(toys, i) if sum(price) == 35] for i in range(len(toys))]
- res = []
- for i in buy:
- if i:
- for j in i:
- if sorted(j) not in res:
- res.append(j[:])
- print(*res)
复制代码 |
|