duckhunt.png
Photo taken from Nintendo game “Duck Hunt”

Duck Hunt from Nintendo always brings back fond memories for me. This post is a semi-tribute to the popular Nintendo game, but more than anything reflects my fascination for interesting puzzles/riddles. An interesting mathematical problem that I ran across a couple of years ago when I was browsing the web involves a bunch of duck hunters. Click here for the original link.

The Problem Statement

  • Montana duck hunters have 100% accuracy.
  • Ten Montana hunters are in a duck blind when 10 ducks fly over.
  • All 10 hunters pick a duck at random to shoot at, and all 10 hunters fire at the same time.
  • Thus, it is possible for 2 hunters to shoot at the same duck. In fact, its possible for all 10 hunters to shoot at the same duck as well!
  • How many ducks could be expected to escape, on average, if this experiment were repeated a large number of times?

How to Solve this Problem

You’d have to have a pretty solid understanding or probability to tackle this problem. To be honest, I don’t think I was ever able to solve it analytically as it involves the use of binomial probability and some rugged counting techniques. If you click on the link I provided above, there’s a pretty good analytical approach/solution to this problem. But since this is a website dedicated mostly to Matlab, let’s use Matlab to help us solve this problem!

Hunting Ducks with Matlab

Matlab Logo

  1. Using Matlab to solve this problem might be a little easier than you would expect. My approach was to first write a functon that would simulate one single event of 10 hunters shooting at 10 ducks. I saved this function as an m-file.

    function numAlive = duckHunt
     
    %create a vector with 10 entries, all entries are 1's
    %0 = dead, 1 = alive
    ducks = ones(1,10); 
     
    %let's set aside a number from 1 to 10 for each duck
    %create a vector with 10 entries.  each entry is between 1 and 10
    %for example, we might get a vector [1,5,6,7,1,2,3,9,10,8], this
    %means that hunter 1 shoots at duck #1, hunter 2 shoots at duck #5
    %hunter 3 shoots at duck #6 . . . and so on
    hunter = ceil(rand(1,10)*10);
     
    %each hunter shoots at a random duck
    %it is possible for two hunters to shoot at the same duck!
    %any duck that was targeted goes from a 1 (alive) to a 0 (dead)
    ducks(hunter) = 0;
     
    %sums up the number of ducks still alive
    numAlive = sum(ducks);
  2. So now we have a function that will simulate one event. But we need to take many samples in order to get the average. Lets use a sample size of 10,000 events. I used the following code at the command prompt to call the function that I just wrote multiple times. After the FOR loop is done running, I took the average of the number of ducks that escaped.

    total = 0;
    for x= 1:10000
    total = total + duckHunt;
    end
    averageDucksAlive = total/10000

The Answer!

The theoretical answer for this problem is 9^10 / 10^9 = 3.4867.

How close did my simulation get? The answer I got was 3.4854. Not quite the exact answer, but pretty darn close!

How Would You Solve This Problem?

Did any of you guys have a different idea on how to solve this? I would love to hear how you guys went about solving this problem. Whether you used analytical methods or used a computer program, I’m always interested in how problems can be approached from different angles.