Challenge: Fancy a Game of Darts?

 

This challenge is all about finding the number of possible ways to achieve a particular score in the game of darts.

Consider a normal dartboard which has 20 main sectors numbered 1 to 20. It also has the double, triple, bull and bull's eye but we will be ignoring these for this particular challenge.

What you need to do is to find all of the possible ways to achieve a particular score. 

You may wish to break this task down and simplify it to start with by considering a dartboard with a reduced number of sectors e.g. one with 4 sectors.

The other consideration is that it does not matter which order the individual score is achieved for each dart. For example, there is only one way to score a total of 1 with 3 darts.  The first dart could be 1 and the other two darts could miss the board. However, this is the same as a 0 on the first dart (you missed the board), a 1 on the second dart and a 0 on the third part.  In the same way it could be 0, 0, 1.  We consider these three variations to be the same end result so the total number of ways to score a 1 with three darts is 1.

The table below may help explain:

DART 1 DART 2 DART 3 TOTAL
1 0 0 1
1 1 0 2
2 0 0 2
1 1 1 3
2 1 0 3
3 0 0 3
1 1 2 4
1 3 0 4
2 2 0 4
4 0 0 4

This table could be increased for the remaning possibilities all the way to the maximum possible score of 12 with 3 darts on 4 sectors.

As you can see above, there are 4 possible ways to score a total of 4 points with 3 darts on 4 sectors.

The idea of the challenge is to produce either a table or graph of the total number of possibilities.

The following video explains the challenge and provides some visualisation of the possible results.

 

This challenge is part of the PHP for Beginners series of courses. If you wish to enrol then visit the membership page.

Would you like the solution to this challenge?

The full video solution together with downloadable code is available in the PHP for Beginners course.

This course is taught by Patrick Morrow, a national award-winning teacher, who is very active in the course and who provides full support.

To enrol in the course click here.