# I need an equation for this

**URL:** <https://boards.straightdope.com/t/i-need-an-equation-for-this/429918>\
**Category:** Factual Questions\
**Created:** [December 13, 2007, 10:29pm UTC](https://boards.straightdope.com/t/i-need-an-equation-for-this/429918 "2007-12-13T22:29:05Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![selego](https://avatars.discourse-cdn.com/v4/letter/s/f05b48/32.png) [@selego](https://boards.straightdope.com/u/selego)\
**Post date:** [December 13, 2007, 10:29pm UTC](https://boards.straightdope.com/t/i-need-an-equation-for-this/429918/1 "2007-12-13T22:29:05Z")

</div>

My friend and I are quite addicted to the MSN game known as Minesweeper Flags. If any of you are familiar

---

<div class="post-metadata">

**Author:** ![selego](https://avatars.discourse-cdn.com/v4/letter/s/f05b48/32.png) [@selego](https://boards.straightdope.com/u/selego)\
**Post date:** [December 13, 2007, 10:34pm UTC](https://boards.straightdope.com/t/i-need-an-equation-for-this/429918/2 "2007-12-13T22:34:23Z")

</div>

Ah, damn enter button…

Anyway, if any of you are familiar with this game, you know that you must be the first person to reach 26 mines before your opponent. There are a total of 51 mines randomly laid out on a 16x16 grid. The game is set up a lot like regular minesweeper, except you want to get the mines. Now, we were trying to find out the odds of hitting a mine at the start of a new game, where no numbers have been uncovered. One time at the beginning of a game I hit 6 mines without any numbered boxes coming up.

So I need an equation for this. The odds of hitting one of the 51 mines in a 16x16 grid is about 19.92%. How would an equation be set up for each subsequent mine, when there are 50 mines left, on 255 grids, 49 on 254, etc.

---

<div class="post-metadata">

**Author:** ![RickG](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/rickg/32/5174_2.png) [@RickG](https://boards.straightdope.com/u/RickG)\
**Post date:** [December 13, 2007, 11:14pm UTC](https://boards.straightdope.com/t/i-need-an-equation-for-this/429918/3 "2007-12-13T23:14:49Z")

</div>

Each subsequent selection is an independent event, so just multiply one probability by the next to get the probablility of a particular sequence. If you want the probability of hitting _n_ mines in a row at the beginning, it ends up being:

P(n) = (256-n)!51!/(256!(51-n)!)

Where the exclamation point denotes the factorial function.

-Rick

---

<div class="post-metadata">

**Author:** ![selego](https://avatars.discourse-cdn.com/v4/letter/s/f05b48/32.png) [@selego](https://boards.straightdope.com/u/selego)\
**Post date:** [December 14, 2007, 3:55am UTC](https://boards.straightdope.com/t/i-need-an-equation-for-this/429918/4 "2007-12-14T03:55:27Z")

</div>

The factorial functions cause a huge overflow. The probability of getting 4 or 5 is not that intense, so is there any other way to set this up?

Sorry, math was never one of my strong points 😛

---

<div class="post-metadata">

**Author:** ![ultrafilter](https://avatars.discourse-cdn.com/v4/letter/u/3d9bf3/32.png) [@ultrafilter](https://boards.straightdope.com/u/ultrafilter)\
**Post date:** [December 14, 2007, 4:05am UTC](https://boards.straightdope.com/t/i-need-an-equation-for-this/429918/5 "2007-12-14T04:05:36Z")

</div>

You have to be a bit clever about how you calculate the probabilities. For n = 4, you have 252!/256! \* 51!/47!. This reduces to 51_50_49_48/(253_254_255_256). If you rewrite that as 51/253 \* 50/254 \* 49/255 \* 48/256, you don’t have to worry about overflow.

This can be done algorithmically, but I’ll leave it to you to figure out the details.

---

<div class="post-metadata">

**Author:** ![MikeS](https://avatars.discourse-cdn.com/v4/letter/m/919ad9/32.png) [@MikeS](https://boards.straightdope.com/u/MikeS)\
**Post date:** [December 14, 2007, 4:12am UTC](https://boards.straightdope.com/t/i-need-an-equation-for-this/429918/6 "2007-12-14T04:12:39Z")

</div>

The factorials cancel out in large part; you end up with

(51/256)_(50/255)_(49/254)\*…

where you multiply _n_ terms following that pattern to find the probability of getting _n_ mines right off the bat.

These probabilities work out to:[ol][_]51/256, or about 1 in 5,[_]5/128, or about 1 in 26,[_]245/32,512, or about 1 in 130,[_]735/514,096, or about 1 in 700,[_]About 1 in 3800, and[_]About 1 in 20,000.[/ol]

---

<div class="post-metadata">

**Author:** ![J\_Cubed](https://avatars.discourse-cdn.com/v4/letter/j/c6cbf5/32.png) [@J\_Cubed](https://boards.straightdope.com/u/J_Cubed)\
**Post date:** [December 14, 2007, 4:54am UTC](https://boards.straightdope.com/t/i-need-an-equation-for-this/429918/7 "2007-12-14T04:54:57Z")

</div>

In original Minesweeper, the probability of getting on mine on the first click is zero. So, keep in mind that the game may not adhere to the perfectly random model.

---

<div class="post-metadata">

**Author:** ![Frylock](https://avatars.discourse-cdn.com/v4/letter/f/ce7236/32.png) [@Frylock](https://boards.straightdope.com/u/Frylock)\
**Post date:** [December 14, 2007, 6:57am UTC](https://boards.straightdope.com/t/i-need-an-equation-for-this/429918/8 "2007-12-14T06:57:21Z")

</div>

[QUOTE=J Cubed]  
In original Minesweeper, the probability of getting on mine on the first click is zero. So, keep in mind that the game may not adhere to the perfectly random model.  
[/QUOTE]

I hit a mine on the first click plenty of times.

Maybe mine’s not the original version? It’s the one that comes packaged with WinXP.

-FrL-

---

<div class="post-metadata">

**Author:** ![Frylock](https://avatars.discourse-cdn.com/v4/letter/f/ce7236/32.png) [@Frylock](https://boards.straightdope.com/u/Frylock)\
**Post date:** [December 14, 2007, 7:01am UTC](https://boards.straightdope.com/t/i-need-an-equation-for-this/429918/9 "2007-12-14T07:01:06Z")

</div>

[QUOTE=Frylock]  
I hit a mine on the first click plenty of times.

Maybe mine’s not the original version? It’s the one that comes packaged with WinXP.

-FrL-  
[/QUOTE]

Okay.

Dammit.

You don’t hit a mine on the first try on WinXP. I have proven this to myself as conclusively as I required.

I _swear_ I’ve hit a mine on the first try, many times, in the past. I remember it so clearly.

Guess not on my present computer though, or something.

-FrL-

---

<div class="post-metadata">

**Author:** ![Bryan\_Ekers](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/bryan_ekers/32/183_2.png) [@Bryan\_Ekers](https://boards.straightdope.com/u/Bryan_Ekers)\
**Post date:** [December 14, 2007, 7:30am UTC](https://boards.straightdope.com/t/i-need-an-equation-for-this/429918/10 "2007-12-14T07:30:37Z")

</div>

[Relevant Documentary](http://www.collegehumor.com/video:1770138)
