Apex Skills

Code-Breaking Strategy: Learn From Every Guess

Use exact and misplaced matches to narrow a four-digit code without wasting guesses.

4 min read

Published by Apex Ascend Group, LLC Methodology · Editorial policy

Read the feedback as constraints

In Code Breaker, the secret contains four different digits. A guess reports exact matches, where the digit and position are both correct, plus misplaced matches, where the digit belongs in the code but occupies another position. The feedback does not identify which digit earned which mark, so each reply narrows the candidates without revealing the answer.

Because leading zeroes are allowed, treat 0 as an ordinary digit. A secret such as 0472 is valid. Every guess must also use four distinct digits, so a repeated-digit probe such as 0012 cannot be submitted.

For every row, write two facts: the total matches, calculated as exact plus misplaced, and the positions ruled out for any digits you already know are present. This prevents a later guess from contradicting an earlier clue.

Open with a membership test

Start with four distinct digits, such as 0123. A reply of zero exact and zero misplaced eliminates all four digits. A reply totaling two means exactly two of 0, 1, 2, and 3 occur in the secret, although you do not yet know which two.

A second guess should have a declared purpose. Replacing two old digits with two new ones tests membership. Keeping known digits and changing their slots tests position. Changing every digit and every position at once can produce a clue, but it is harder to connect that clue to one hypothesis.

  • Membership question: which digits occur anywhere in the secret?
  • Position question: where can a digit already known to occur be placed?
  • Consistency question: which candidate codes satisfy every earlier row?

Worked example: the match total cannot change on a rotation

Use the secret 0472 as a visible teaching example. The guess 0123 returns 1 exact and 1 misplaced: 0 is exact in the first slot, 2 is present in the secret but sits in the guess's third slot instead of the secret's fourth slot, and 1 and 3 are absent. The total is two matching digits.

Now rotate the same four guessed digits to 1230. Against 0472, this returns 0 exact and 2 misplaced: both 2 and 0 occur, but both occupy the wrong slots. The exact count changed from one to zero and the misplaced count changed from one to two; the total stayed two.

That invariant always holds when you only reorder the same guessed digits. Exact plus misplaced counts how many guessed digits occur in the secret, and reordering does not change membership. A rotation can teach you about placement, but it can never make the total rise or fall. To learn about new digit membership, at least one digit in the guess must change.

Carry the example forward

After 0123 gives a total of two, try 0456. Against the teaching secret, that guess returns 2 exact and 0 misplaced. The valid deduction is limited: exactly two of 0, 4, 5, and 6 occur, and both occupy the positions shown in 0456. Combined with the first row, you still cannot claim that 0 is present, that 1 and 3 are absent, or that 2 is present. You only know that exactly two of 0, 1, 2, and 3 occur and exactly two of 0, 4, 5, and 6 occur.

A controlled next probe is 0478: keep the possible 0 and 4 in the same slots, replace 5 and 6, and test 7 and 8. Against 0472 it returns 3 exact and 0 misplaced. Following with 4078 swaps only 0 and 4 and returns 1 exact and 2 misplaced. Because those two guesses contain the same digits, their total stays three; the split shows that 0 and 4 were exact before the swap. Now the first row proves exactly one of 1, 2, and 3 is present, while the 0478 row proves exactly one of 7 and 8 is present in its shown slot. A probe such as 0427 can test those remaining candidates and positions without discarding the established 0 and 4 placements.

The point is not to memorize this path. State only what every clue proves, preserve unresolved alternatives, and make the next guess distinguish between them.

Practice protocol and review

Play one game with no guess limit pressure: before submitting, say whether the row tests membership, position, or consistency. After feedback, write the new fact in plain language. On a second game, mark any guess that changed more than one idea at once. On a third, try to reduce those ambiguous guesses while keeping the notes.

After an unsolved game, reveal the code and replay each row against it. Check that every exact and misplaced count now makes sense, then identify the first inference you ignored or failed to record. This is a logic puzzle and a lesson in constraint tracking, not a measure of general intelligence or a security tool.

Frequently asked questions

How is Code Breaker scored?

You have eight valid guesses. A win earns 9 minus the number of guesses used; an unsolved code scores zero.

Can the code begin with zero?

Yes. The secret uses four unique digits from 0 through 9, and zero may be first.

Put It Into Practice

Code Breaker

Code Breaker

Free code breaker puzzle. Deduce a four-digit code from exact and misplaced-digit clues, with eight guesses and personal bests.

FocusMedium2–4 min