started at ; stage 2 at ; ended at
paying with cash is too complicated, so please work out change for me in either python, rust, lua, or bash.
you get a target N and two lists (really multisets) of denominations, always positive integers. the first is the money you have and the second is the money the vendor has. just return a subset of each input such that the money you give minus the change you get back equals N. that's all. if it's impossible, don't worry about it.
APIs:
def entry(target: int, mine: list[int], theirs: list[int]) -> tuple[list[int], list[int]]
pub fn entry(target: u32, mine: &[u32], theirs: &[u32]) -> (Vec<u32>, Vec<u32>)
entry
that takes a number and two arrays of numbers and returns two arrays of numbersentry
that takes a numeric string followed by 4 namerefs to arrays of numeric strings. the first two are mine
and theirs
, and the other two are corresponding outparams.you can download all the entries
written by LyricLy
submitted at
1 like
1 2 3 4 5 6 7 | def entry(n, x, y): # put all the money in a big pile # solve it l = x + y ; p = n + sum(y); r = []; o = y[:]; [l.remove(e := __import__("random").choice(l)) or (o.remove(e) if e in o else r.append(e)) or (p := p - e) for _ in iter(lambda: p > 0, False)]; return entry(n, x, y) if p else (r, o) # burn it del l[:] # return ashes return l, l |
:3
hi
post a comment