This game was originally inspired by the video (A Number Pyramid Puzzle) solved by the excellent Dr. Barker on YouTube. I was nerdsniped by this problem and found it oddly satisfying, so I felt the urge to turn it into a game.
As far as I can tell, addition pyramids with unique entries aren't exactly hot mathematics, so I was very fortunate to have stumbled into A028307 on OEIS.org, which gives the minimum value for the apex of the addition pyramid with unique entries. There does not appear to be a known closed form for this, so I appreciate Mauro Fiorentini crunching the numbers on this Soviet competition problem (401) from 1985. I needed these values to make the game work, and this saved me from having to brute force sizes > 7.
Scores are calculated using three factors which encourage real engagement with the puzzle: time to solve, the difficulty of the puzzle, and a factor called "cope".
Values in the center of the base row have larger effects on the apex of the pyramid (compared to values at the edges of the base row) due to binomial effects from repeated addition. Values in the center of the base row also impact more cells, making them more likely to create duplicate values. Often, it is possible to spike a value at the edge of the base row to meet the target value. This makes the puzzle too easy and must be discouraged. To encourage the use of center rows and reduce the total input values by relying on binomial effects, we create a factor called "cope".
Let \(n\) be the number of cells in the base row and let \(v_1, ..., v_n\) be the input values. We define the cope factor as the weighted sum of input values, minus an (lowest possible but invalid) minimum value, \(n\). The inverse binomial weights encourage heavier use of values in the center. $$\text{cope} = \sum_{k=0}^n \frac{v_k}{\binom{n}{k}} - n$$
Because solutions with low cope take more time to find, our unadjusted score takes both cope and time to solve into account. The ideal unadjusted score is between \(S_{min}=1\) and \(S_{max}=1000\), and should decrease asymptotically with higher values of cope or time to solve. A direct product of both cope and time to solve was considered, but the score decreased too rapidly. Instead, the logarithm of the product was chosen as the variable used to decrease the score.
Let time to solve be \(\Delta_t\). The unadjusted score is then: $$\text{unadjustedScore} = S_{min} + \frac{S_{max} - S_{min}}{\max\{\log_{10}(\text{cope} * \Delta_t),1\}}$$
To account for the size of the problem, we multiply the unadjusted score by the number of total cells: $$\text{score} = \text{unadjustedScore} * \frac{n (n+1)}{2}$$ This means that a given score is at most \(S_{max} * \frac{n (n+1)}{2}\).
Puzzles with lower values in target cells have far fewer solutions, and are therefore more challenging. I'm doing some research to see how to accurately account for this fact