Skip to content

Instantly share code, notes, and snippets.

@fjkz
fjkz / minimal_wallet.py
Created August 13, 2022 04:47
minimal wallet problem -- how much we should pay for minimizing the number of coins in wallet
from copy import copy
coin_kind = [1, 5, 10, 50, 100, 500]
def minimal_coin_set(value):
# greedy algorithm
ret = {}
for coin in sorted(coin_kind, reverse=True):
ret[coin] = value // coin
value %= coin
@fjkz
fjkz / pentomino.py
Created August 14, 2022 04:09
pentomino solver
import string
from copy import deepcopy
from random import shuffle
PENTO = 5
_ = None
# O to Z
piece_labels = string.ascii_uppercase[-12:]