Duck
Game
(Divide-and-Conquer)
🦆

In this game, your goal is to get the highest score possible! You have to choose a set of ducks that are in a row to spray with the hose.
There are 3 levels, then a free play mode where you can pick the number of ducks (with a max of 16).

You choose the ducks by clicking on the duck at the start and at the end of the selection you want to make.
You may deselect a duck at the start or end of your selection by clicking on those ducks.

If you think you have chosen the best set of ducks, click the button that says "Spray"

Have you figured out a pattern to always get the highest score?
What if there were more ducks, maybe 100, 1,000, or even 1,000,000? Do you think you could still find a solution?
See how you could solve this with a divide-and-conquer method below.



We've put together this video which explains the divide-and-conquer method for this problem.

This algorithm works very cleanly for arrays with a number of elements equal to some power of two. The process is the same for less convenient numbers, but the math isn't as beautiful.


Feel free to experiment with different values of n! Once you get to level 8 (where the number of ducks = n = 8), you are free to type in any number between 1 and 16 inclusive and try out your algorithmic understanding.

If you'd like a more detailed explanation, we recommend this video!

Feedback Form