Hacker News new | ask | show | jobs
by daddyo 3260 days ago
High school diploma solution:

There are increasingly more ways to distribute wealth unevenly, than evenly.

Reduce the problem to the simplest case of 3 persons: `a`, `b`, and `c`. Person `a` has decision to give to either `b` or `c`. Then use combinatorics:

    from itertools import product

    decisions_a = ['ab', 'ac']
    decisions_b = ['ba', 'bc'] 
    decisions_c = ['ca', 'cb']

    for combination in product(decisions_a, decisions_b, decisions_c):
        print combination

    >>> ('ab', 'ba', 'ca') # uneven
    >>> ('ab', 'ba', 'cb') # uneven
    >>> ('ab', 'bc', 'ca') # even
    >>> ('ab', 'bc', 'cb') # uneven
    >>> ('ac', 'ba', 'ca') # uneven
    >>> ('ac', 'ba', 'cb') # even
    >>> ('ac', 'bc', 'ca') # uneven
    >>> ('ac', 'bc', 'cb') # uneven