previndexinfonext

code guessing, round #36 (completed)

started at ; stage 2 at ; ended at

specification

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:

results

  1. LyricLy +0 -0 = 0

    entries

    you can download all the entries

    entry #1

    written by LyricLy
    submitted at
    1 like

    guesses
    comments 3
    Olive

    :3



    essaie

    Cute£


    post a comment


    sss.py ASCII text, with very long lines (500)
    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