# The Story of Math Academy’s Eurisko Sequence

*Note: This is the preamble to the textbook Introduction to Algorithms and Machine Learning.*

This book was written to support Eurisko, an advanced math and computer science elective course sequence within the Math Academy program at Pasadena High School. During its operation from 2020 to 2023, Eurisko was one of the most advanced high school math/CS sequences in the USA. (“Eurisko” is Greek for “I discover,” and is the namesake of an AI system from the 1980s that won a particular game competition twice in a row, even when the rules were changed in attempt to handicap it.)

Eurisko’s courses were presented at a level of intensity comparable to those offered at elite technical universities, and students wrote all their code from scratch before they were allowed to import external libraries. This was possible because students had already learned a large amount of college-level math through Math Academy including multivariable calculus, linear algebra, and differential equations by the end of 10th grade.

The first Eurisko course was inspired by MIT’s Introduction to Computer Science and went far beyond it. In addition to implementing canonical data structures and algorithms (sorting, searching, graph traversals), students wrote their own machine learning algorithms from scratch (polynomial and logistic regression, k-nearest neighbors, k-means clustering, parameter fitting via gradient descent).

In subsequent courses, students implemented more advanced machine learning algorithms such as decision trees and neural networks. They also reproduced academic research papers in artificial intelligence leading up to Blondie24, an AI computer program that taught itself to play checkers. At the same time, they worked together to implement Space Empires, an extremely complex board game that pushed their large-scale project skills (object-oriented design, version control, etc) to the limit. The ultimate goal was to create artificially intelligent Space Empires players, drawing inspiration from techniques used in Blondie24.

This book would not have been written if the Eurisko program had not existed, and Eurisko would not have been possible without the collaboration of Jason Roberts, founder of Math Academy.

Eurisko started in June 2020 when Jason asked me to teach his 15-year-old son Colby some computer science. Colby was just finishing up his 10th grade year in App Academy, a computer science program at Pasadena High School, but Jason felt that the curriculum was not geared towards students who had a strong aptitude in the subject, and that Colby could and should be learning a lot more. Plus, many extracurriculars had been shut down due to the pandemic.

As I’ve come to expect with Jason, that initial idea grew quickly: he pulled in some of Colby’s buddies who had the necessary mathematical background, and we put together a summer computer science group that met virtually on Mondays, Wednesdays, and Fridays with about 10 hours of problem sets each week.

All problem sets consisted of the kids writing code individually, from scratch, in Python. They weren’t allowed to use external libraries. Instead, they had to build everything themselves. They were allowed to collaborate at a high level, discussing different approaches to solving the problems, but every student had to write up every problem set on their own.

To our surprise, the kids progressed even faster than we could have possibly expected:

- At the start of June, they didn't know how to write helper functions. Even something as simple as checking if a string was a palindrome was not trivial to them.
- By the start of July, they had built a matrix class and a gradient descent optimizer from scratch. The matrix class included methods for matrix arithmetic as well as standard linear algebra procedures like row reduction, determinants, and inverses.
- By the start of August, they had built a regression library on top of their matrix class and gradient descent optimizer. The library included polynomial, logistic, and multiple linear regressors with interaction terms.
- On top of all this, they also implemented standard algorithms for sorting arrays and traversing graphs. And per Jason's suggestion, to get some systems programming experience, they also created a simple version of the Space Empires board game that they could play by programming and submitting autonomous strategies.

At the end of the summer, Eurisko was fortunate to receive funding for an official high school class through a partnership with App Academy. Jason recruited a second cohort of incoming 10th graders, and – through an extreme feat of class management – I managed to continue supporting Colby’s 11th grade crew while simultaneously launching the second cohort within the same class period.

The class setup during the 2020-21 year was incredibly tricky. School was fully remote due to the pandemic, and each cohort only had 2 hours of Zoom time each week. If a student got stuck, they had to ask for help by posting a message on Slack, and the message had to be descriptive enough that I or another classmate could quickly understand their reply with a suggestion without burning time. This setup would be a steep learning curve for any junior developer, much less a high school underclassman with little to no prior coding experience – but we made do, and those students who muscled through it emerged with an incredible amount of self-sufficiency and debugging ability. (Not to mention, we did all this on school-issued Chromebooks using free online development environments like Replit and Gitpod.)

Later years became significantly smoother as I refined the curriculum and school returned to in-person classes. During the 2021-22 year, most of problem sets contained written tutorials descriptive enough that I only had to round up everyone for a traditional lesson once per week. Over summer 2022 I further refined and organized these tutorials into book chapters, and during the 2022-23 year, the Eurisko classes were almost entirely self-service. Students would read the chapter and do the problems on their own. There was no need for traditional lessons; students just worked on the problems during class and asked for help once in a while if they didn’t understand something or hit a wall while debugging their code.

At some point in 2021, Jason shared a wild idea to have Eurisko students reproduce the Blondie24 research papers and use that as inspiration to create artificially intelligent Space Empires players. This became our vision for the ultimate capstone project. The first Eurisko cohort came within striking distance but ultimately ran out of time (it was a bit of a reach given that they only had two full years of Eurisko instead of three). However, the second Eurisko cohort managed to achieve this goal in their final year, 2022-23, which also happened to be the final year of the Eurisko program as a whole due to my relocation.

All together, there were 16 students who stayed for the duration of the program.

*Cohort 1 (Summer 2020 - Spring 2022):*Colby, David, Elijah, George, Riley*Cohort 2 (Fall 2020 - Spring 2023):*Anton, Cayden, Charlie, Justin, Maia, William*Cohort 3 (Fall 2021 - Spring 2023):*Ben, Celeste, Elias, Jeff*Cohort 4 (Fall 2022 - Spring 2023):*Matteo

Finally, a sincere thank you to Sanjana Kulkarni for her thoughtful suggestions and diligent proofreading of this book.