Is there any general algorithm to solve this kind of puzzle?
https://i.stack.imgur.com/PNH5Q.jpg
Any sub O(N^3) solution will be greatly appreciated <3
Is there any general algorithm to solve this kind of puzzle?
https://i.stack.imgur.com/PNH5Q.jpg
Any sub O(N^3) solution will be greatly appreciated <3
Sounds like https://en.wikipedia.org/wiki/Constraint_satisfaction to me - you pose the problem as a set of arithmetical equations, typically with small integer unknowns, and build a data-structure that works out when you know enough about some of the unknowns in one of the equations to deduce others. Then you start a tree search over the possible solutions, using the data structure to work out enough of the unknowns from the assumptions so far to make the tree search feasible and/or to rule out partial solutions that can't possibly work early.
Some time ago I worked in the same office as a group using ILOG Solver for scheduling, and noticed that its manual had a number of examples of using it to solve simple logical/numerical problems - I think https://en.wikipedia.org/wiki/Verbal_arithmetic was one. (They eventually gave up on the scheduling in favour of a much simpler approach. The stated reason was that the ILOG Solver scheduling was not transparent enough for users to see why unsatisfiable schedules were unsatisfiable and thereby work out what constraints needed to be relaxed).
It is assumed that each cell in the pyramid is the sum of the two immediately below it.
Theorem
For any sub-pyramid
P
, let the arrayr
be any row inP
of lengthn+1
. Then the sumis constant for each row of
P
. (C(i,j)
is the binomial coefficient.)For example, let
P
be the whole pyramid. For the top row, we have:For the bottom row, we have:
where
x
is the unknown value in the bottom row.Applying the above theorem:
from which it follows that
x = 15
.As a demonstration for the consistency of this theorem, one can take
P'
as the 3-row sub-pyramid whose peak is60
. Thenfrom which it again follows that
x = 15
.Once one row is completely known, all rows above it follow directly.