Skip to content

Instantly share code, notes, and snippets.

from functools import cache, cmp_to_key
from itertools import permutations as it_permutations
from typing import Final, Generator, Iterable, Self
Allocation = tuple[int, ...]
class Permutation:
def __init__(self, perm: Iterable[int]) -> None:
self.perm: Final = tuple(perm)
#!/usr/bin/env python3
# https://www.reddit.com/r/math/comments/8b1z6h/interview_question/
from statistics import mean
from functools import lru_cache
memoize = lru_cache(None)
rolls = tuple((min(i, j), max(i, j))
for i in range(1, 7) for j in range(1, 7) if i+j <= 9)