How to approach a number guessing game (with a twist) algorithm?

We’ll combine graph-theory and probability:

On the 1st day, build a set of all feasible solutions. Lets denote the solutions set as A1={a1(1), a1(2),…,a1(n)}.

On the second day you can again build the solutions set A2.

Now, for each element in A2, you’ll need to check if it can be reached from each element of A1 (given x% tolerance). If so – connect A2(n) to A1(m). If it can’t be reached from any node in A1(m) – you can delete this node.

Basically we are building a connected directed acyclic graph.

All paths in the graph are equally likely. You can find an exact solution only when there is a single edge from Am to Am+1 (from a node in Am to a node in Am+1).

Sure, some nodes appear in more paths than other nodes. The probability for each node can be directly deduced based on the number of paths that contains this node.

By assigning a weight to each node, which equals to the number of paths that leads to this node, there is no need to keep all history, but only the previous day.

Also, have a look at non-negative-values linear diphantine equations – A question I asked a while ago. The accepted answer is a great way to enumarte all combos in each step.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)