Assignment Of The Year
My boys attend a terrific extracurricular math program called Spirit of Math. One of their more challenging assignments is to make 100 math equations using the four digits of a given year, with a different equation for all the numbers from one to one hundred.
After putting in a respectable number of hours writing out all the possible equations for the year 1846, Alex realized it would be much more efficient to write a program that randomly generates these equations for us. He described the program in about three minutes, and we wrote this together with Processing over two evenings.
Please don’t use this program to cheat on your assignment! But if you’ve done the bulk of the work by hand and you’re absolutely out of ideas, maybe this can help. The slider bars at the top allow you to adjust the year. The ‘Do In Order’ button at the bottom of the screen is a modifier for the advanced version of the assignment in which you have to generate all your equations with the digits in the order that they appear in the year. The ‘Print Answers’ button outputs all the answers that have been found so far in a format that can be copied and pasted into a separate window.
Note, this program does not account for order of operations! It calculates the numbers sequentially, so you’ll have to add brackets to make the numbers work according to the rules of math. If anyone wants to add this to the code, please let me know.
e.g., (((a + b) + c) + d)
I haven’t actually seen the program find more than 81 equations for any given year. This may be due to the lack of order of operations, or it can be that it gets more and more difficult to find new equations past a certain threshold. If anyone manages to find a year that can produce 100 equations, let me know!