This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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) |