---
title: 'Dartboard Problem'
url: 'https://blog.recursiveprocess.com/2011/06/20/dartboard-problem'
markdown: 'https://blog.recursiveprocess.com/2011/06/20/dartboard-problem.md'
date: '2011-06-20'
description: "From Infinigons, etc: Putting myself in kids’ shoes You have a square dartboard. What is the probability that a randomly-thrown dart will land closer to the center of the dartboard than to an edge? Superb\_problem. I took the lazy route. I made a python program to run 100,000 trials, and graph…"
taxonomy:
  category:
    - blog
---

# Dartboard Problem

### [Dartboard Problem](https://blog.recursiveprocess.com/2011/06/20/dartboard-problem)

   June 20, 2011, 12:00 am  

[From Infinigons, etc: Putting myself in kids’ shoes](http://infinigons.blogspot.com/2011/06/putting-myself-in-my-kids-shoes.html)

> You have a square dartboard. What is the probability that a randomly-thrown dart will land closer to the center of the dartboard than to an edge?

Superb problem.

I took the lazy route. I made a python program to run 100,000 trials, and graph those trials on a coordinate plane.

Visual result:
[![](https://blog.recursiveprocess.com/wp-content/uploads/2011/06/2011-06-20-09h20_37.jpg "2011-06-20 09h20_37")](https://blog.recursiveprocess.com/wp-content/uploads/2011/06/2011-06-20-09h20_37.jpg)

And the numerical result:

```
closer to center 21939
closer to edge 78061
ratio is 0.21939
```

After 1,000,000 trials, the ratio is:

```
closer to center 219148
closer to edge 780852
ratio is 0.219148
```

The code for the vpython simulation is found [here](http://dl.dropbox.com/u/3646828/dartboard.py) (and pasted below).

```
from math import sqrt
import random
from visual import *

#Distance Formula
def distance(xa,ya,xb,yb):
    return sqrt((xa-xb)**2+(ya-yb)**2)

totalthrows = 0
closertoedge = 0
closertocenter = 0

#Creates the White points at the boundries of the screen
points(pos=[(-500,-500,0),(500,-500,0),(500,500,0),(-500,500,0)],size=5, color=color.white)

while (totalthrows < 100000):

    #All the random point coordinates are in the range:
    # 0 <= (x or y coordinate) < 1
    #They are multipled later for display purposes
    xcoord = random.random()
    ycoord = random.random()

    #The min distance to edge is simply the coordinate closest 0 or to 1
    mindistancetoedge = min(xcoord,ycoord,(1-xcoord),(1-ycoord))

    if (mindistancetoedge > distance(xcoord,ycoord,0.5,0.5)):
        #Random point is closest to center
        closertocenter += 1
        points(pos=[(int(1000*xcoord)-500,int(1000*ycoord)-500,0)], size=1, color=color.red)
    else:
        #Random point is closest to edge
        closertoedge += 1
        points(pos=[(int(1000*xcoord)-500,int(1000*ycoord)-500,0)], size=1, color=color.yellow)
    totalthrows+=1

print "closer to center " + str(closertocenter)
print "closer to edge " + str(closertoedge)
print "ratio is " + str(float(closertocenter)/(float(closertoedge+closertocenter)))
```

Update: Btw, several people have REAL solutions (bravo): [@infinignons](http://infinigons.blogspot.com/2011/06/putting-myself-in-my-kids-shoes.html?showComment=1308504795935#c291882900168119453) and [Ms. Cookie](http://infinigons.blogspot.com/2011/06/putting-myself-in-my-kids-shoes.html?showComment=1308528361436#c5239288016911753004)

 [ Next Post](https://blog.recursiveprocess.com/2011/06/22/math-notebook-questions) [Previous Post ](https://blog.recursiveprocess.com/2011/06/16/sbg-a-small-tweak-and-a-feedback-inequality)

#### SimpleSearch

Bootstrap Theme for [Grav](http://getgrav.org)

---

## Navigation

- Parent: [A Recursive Process](https://blog.recursiveprocess.com/index.md)
- Previous: [Math Notebook Questions](https://blog.recursiveprocess.com/2011/06/22/math-notebook-questions.md)
- Next: [SBG: A Small Tweak and a Feedback Inequality](https://blog.recursiveprocess.com/2011/06/16/sbg-a-small-tweak-and-a-feedback-inequality.md)
