## Introduction

MathsJam is a good time to get to solve interesting puzzles with other people.

While the name suggests it is mostly focused on pure math, I prefer to approach the problems in a more pragmatic way, usually with the help of computer programs.

It’s funny because coming to the solution this way always makes the others raise eyebrows: “Nah it doesn’t really solve the problem, does it?” or “It’s not proper math”.

I came across this video by James Grime the other day, and found it amusing because this is exactly what he and Matt Parker talked about.

Anyway, here are two puzzles with some kind of math aspect. For both of them, Python in conjunction with the Jupyter Notebook turned out to be **incredibly powerful tools!**

## Investigating Pancakes Stacks

A stack of different sized pancakes can be sorted into size order by repeatedly inserting a spatula underneath one of the pancakes, and flipping the top section over.

- What’s the most flips you might need to sort a stack of four different sized pancakes?
- With 6 pancakes, exactly two stacks exist that need 7 flips. Can you find one?

Sure many people have already worked on this since it is quite famous. Even Bill Gates has apparently done some research on it.

We imagined the problem as a **graph**, and the number of flips as **distances between nodes**. So we used the great networkx library to facilitate graph creation and shortest paths calculations. Again, a super useful tool!

Here is a notebook detailing the different steps, with the Python code and some explanations: Investigating pancake stacks Notebook

## Triangle Fraction

The original problem was found on Twitter, posted by @math8_teacher, and looks like this:

Three equilateral triangles. Which fraction is shaded?

While it’s possible to solve it by hand with some time and geometry skills, it’s even more fun to state the problem and let Python do the calcultations. The other good thing about using a program is that it makes it easier to extend to four, five or more triangles.

Again, here is the notebook: Triangle Fractions Notebook

## Questions?

The notebooks are concise but hopefully cover the main point. There might even be more extensions to these problems that will make them even more interesting.

So if after looking at the notebooks you have questions, suggestions or bug fixes, feel free to let me know!