Saturday, 24 November 2012

The Chessboard Equation


This equation is a way of working out how many squares there is in a chessboard; for example not each square but the four squares that make up a square and the sixteen squares that make up that. The equation is:

(n(n+1)(2n+1))/6
(Or for a spread sheet program, =(A2*(A2+1)*((A2*2)+1))/6)

In a spread sheet program like Excel (I have used Google Docs), you can add the formula above to have this outcome.












If you want to plot a significant amount of data, using a spread sheet program can be difficult, so I wrote my own python program to export data into a .csv file witch can be opened in a spread sheet program. Here is the outcome:

Chessboard Effect by Monty Anderson
This program displays the results and then exports that into a .csv file
Display results from 1 to 5

1X1, 1
2X2, 5
3X3, 14
4X4, 30
5X5, 55

Export complete, named 'Chessboard.csv'
Press enter to close...

If I then open up ‘Chessboard.csv’, I get a simple spread sheet with the data outputted from the program.









Download the Python program

Download the Excel document

No comments:

Post a Comment