用户:QWERTY770/沙盒

QWERTY770留言 | 贡献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