Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for How Much Gold by martin_b
# gold + tin + iron + copper = 1
# 3 pairs of equations x + y = fraction
# if gold is not in the pair, convert it to gold + z = 1 - fraction
# set of equations:
# A: 1 1 1 1 1
# B: 1 1 0 0 f1
# C: 1 0 1 0 f2
# D: 1 0 0 1 f3
# then A-B-C-D gives -2gold = 1 - f1 - f2 - f3
# that is gold = (1 - (f1 + f2 + f3)) / -2
checkio = lambda a: (1 - sum(f if 'gold' in p else 1 - f for p, f in a.items())) / -2
June 15, 2019