用户:QWERTY770/沙盒:修订间差异
(// Edit via Wikiplus) |
小无编辑摘要 |
||
| (未显示3个用户的7个中间版本) | |||
| 第1行: | 第1行: | ||
<pre>from collections import Counter | |||
a = [1] | |||
s = 1 | |||
l = 1 | |||
n = 0 | |||
m = 0 | |||
def check(): | |||
c = Counter(a) | |||
if c[1] >= 2 and c[2] >= 1 and c[3] >= 1 and c[4] >= 1 and c[5] >= 1: | |||
if s - 16 <= 7: | |||
return True | |||
return False | |||
while l > 0: | |||
if check(): | |||
n += 6 ** (13 - l) | |||
if n > m: | |||
print(a, l, n) | |||
m = n + 1000000 | |||
while a[-1] == 6: | |||
a.pop() | |||
l -= 1 | |||
s -= 6 | |||
if l > 0: | |||
a[-1] += 1 | |||
s += 1 | |||
continue | |||
if l < 13: | |||
a.append(1) | |||
l += 1 | |||
s += 1 | |||
else: | |||
while a[-1] == 6: | |||
a.pop() | |||
l -= 1 | |||
s -= 6 | |||
if l > 0: | |||
a[-1] += 1 | |||
s += 1 | |||
</pre> | |||
2025年3月12日 (三) 16:46的最新版本
from collections import Counter
a = [1]
s = 1
l = 1
n = 0
m = 0
def check():
c = Counter(a)
if c[1] >= 2 and c[2] >= 1 and c[3] >= 1 and c[4] >= 1 and c[5] >= 1:
if s - 16 <= 7:
return True
return False
while l > 0:
if check():
n += 6 ** (13 - l)
if n > m:
print(a, l, n)
m = n + 1000000
while a[-1] == 6:
a.pop()
l -= 1
s -= 6
if l > 0:
a[-1] += 1
s += 1
continue
if l < 13:
a.append(1)
l += 1
s += 1
else:
while a[-1] == 6:
a.pop()
l -= 1
s -= 6
if l > 0:
a[-1] += 1
s += 1