Use Clojure to Move Drugs – A Programming Challenge

You are a drug trafficker. Every day you meet with a different nice old lady (the mule) and find out how much weight she can carry in her handbag. You then meet with your supplier who has packed various drugs into a myriad of collectible porcelain dolls. Once packed with drugs, each of the precious dolls has a unique combination of weight and street value. Sometimes your supplier has more dolls than grandma can carry, though space in her handbag is never an issue. Your job is to choose which dolls the nice old lady will carry, maximizing street value, while not going over her weight restriction.

Write a program in Clojure that chooses the optimal set of drug-packed porcelain dolls from a set where each has a unique weight and value combination, while staying within a given weight restriction, W, that maximizes the street value of drugs delivered by the grandma, including a set of executable high-level tests for your solution.

Fork this repo on Github to share your solution!

  • Michael Mol says:

    This the bounded variant of the Knapsack problem.

    Spoilers here. (Although there isn’t a Clojure solution there yet, there is a PicoLisp solution which is probably trivial to translate)

  • Phil Kirkham says:

    Next Weeks Challenge: Write an undercover watcher program in Erlang to optimise surveillance time of these dodgy characters

  • […] a range of different opportunities to sell themselves to us: resumès, writing samples, portfolios, programming challenges, interviews, […]

  • Comments are closed.