A Market With No Market Maker

Easy data structure and algorithm practice puzzle.

A decentralized exchange has no order book. A pool holds reserves of two tokens, and one rule sets every price: the two reserves multiplied together must never go down. You put amountIn of one token into the pool and take out as much of the other as the rule allows. The pool keeps a 0.3 percent fee, so only 997 parts in 1000 of what you put in count. Return the whole number of tokens you receive, rounded down.

Solve it three ways: snap the jigsaw pieces together, fill in the blanks, or type it from scratch against the tests. This one is free to play, with no account.

Every line of the solution comes with a note explaining why it is there, and a step by step replay shows the code running. At level 3, where you type it yourself, you can ask for an AI mock interview on this problem that ends with a hiring manager's scorecard.

Then grow it into a real project with the Software Engineer button: this puzzle becomes the Trade Forecaster, a pipeline you can run and download. See every Software Engineer project.

More Business Admin puzzles

All 21 Business Admin practice problems

Browse all 676 puzzles