The following steps demonstrate how a full match might be played. We begin by creating a match.
-
POST /deduceMatch/createMatch
We will now use the match id 57d0d10d85770e0319119843 for all subsequent actions on this match. For the next step, let's see what letter exists at index 0.
-
GET /deduceMatch/57d0d10d85770e0319119843/letterAtIndex/0
Note that the letter at index 0 is C. This means both letters A and B are in the secret word. We now know 2 of the five letters in the word. Since five letters have been removed from the alphabet, there are 21 letters in the subset. So our known picture of the subset is as below.
0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 |
C | | | | | | | | | | | | | | | | | | | |
An algorithmic client can begin applying logic to the words list using the two known letters to narrow the possible solutions down. But for now, let's just assume interactive play and try a different index inquiry. Lets try index 10.
-
GET /deduceMatch/57d0d10d85770e0319119843/letterAtIndex/10
If you start with letter C on index 0, and count forward to index 10, you find that letter M is the expected value. This means that none of the letters between C and M are in the secret word. This deductive conclusion allows us to fill in much of the known subset, making the word much easier to guess.
0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 |
C | D | E | F | G | H | I | J | K | L | M | | | | | | | | | |
Now let's check on index 15.
-
GET /deduceMatch/57d0d10d85770e0319119843/letterAtIndex/15
Interesting. The letter at index 15 is U. The letter U is eight places past the letter M in the full alphabet. This means that three of those seven in-between letters are in our secret word. We already know two of the letters in the word, so this tells us quite a bit. First let's fill in our known subset table. Because we know the remaining three letters all exist between M and U, then none of the letters after U are in the secret word.
0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 |
C | D | E | F | G | H | I | J | K | L | M | ? | ? | ? | ? | U | V | W | X | Y | Z |
So the letters in our secret word could be expressed as A, B, [N|O|P|Q|R|S|T], [N|O|P|Q|R|S|T], [N|O|P|Q|R|S|T]. Perhaps a regular expression could help? Wait, we're doing this with our minds, so we'll carry on and try zeroing in on some letters. Let's look at index 12.
-
GET /deduceMatch/57d0d10d85770e0319119843/letterAtIndex/12
The letter at index 12 is P. Since index 10 is M, this means that either N or O is in our secret word. This also lets us fill in the table a bit more.
0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 |
C | D | E | F | G | H | I | J | K | L | M | ? | P | ? | ? | U | V | W | X | Y | Z |
This means our letters list looks a bit different: A, B, [N|O], [Q|R|S|T], [Q|R|S|T]. We're getting closer! Lets look at index 14.
-
GET /deduceMatch/57d0d10d85770e0319119843/letterAtIndex/14
Ah ha! Index 14 is S. This gives us even more information. Lets look at the table.
0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 |
C | D | E | F | G | H | I | J | K | L | M | ? | P | ? | S | U | V | W | X | Y | Z |
Index 14 is S and index 15 is U. So now we know the letter T is in our word. So now our known letters list look like this: A, B, [N|O], [Q|R|S], T.
Maybe the word is BOAST!
- PUT /deduceMatch/57d0d10d85770e0319119843/solve/BOAST
The word is not BOAST! But lets look at the results of that solution attempt. You see it has each of the actions we have performed so far in the match details. This lets us count our steps to see how efficient we are. So far we've taken 6 steps, and our table only has two empty spots left. Thus is the power of deduction. We could continue to make subsequent guesses, but the game rules require us to make an index query prior to more solution attempts. So, lets pick one of the two remaining unknown indexes, lets try 11.
-
GET /deduceMatch/57d0d10d85770e0319119843/letterAtIndex/11
So the letter at index 11 is N. Because we know index 12 is P, this tells us that the letter O is in our word. But more importantly, it allows us to make another solution attempt. We probably don't need the table as much anymore, at this point we know the letters are A, B, O, [Q|R|S], T. Is the word ABORT?
- PUT /deduceMatch/57d0d10d85770e0319119843/solve/ABORT
Success! We solved the puzzle in eight steps. Less than half the minimum number of steps required by the brute-force algorithmic reference client.
Hopefully after this exercise you understand how to use the deduce-api service, and feel inspired to write interesting client implementations in your favorite programming languages.