Code breaker

Printable code breaker puzzles with answers

Each puzzle is a locked code and a few old guesses, with a note on how close each guess came. Find the one code that fits every clue. Print the set for a class or a quiet evening, or check your answers right here.

Printing gives you all 20 puzzles without the answers, and the answer key on a page of its own. On screen, type your answer under a puzzle and press Check, or open the step by step answer.

How the clues work

Every puzzle hides a code with no repeated digits. A code can start with 0. Each clue shows a guess and tells you two things about it: how many of its digits are in the code at all, and how many of those sit in the right place.

  • "Exactly 1 digit is correct and in the correct position." One digit of the guess is in the code, in that exact spot. The others aren't in the code.
  • "Exactly 1 digit is in the code but in a different position." One digit is in the code, somewhere else. The others aren't in the code.
  • "None of these digits is in the code." Cross all of them out. This is usually the best place to start.

Clues with bigger numbers work the same way, just with more digits. Every puzzle here has exactly one code that fits all its clues, and you can always reach it by reasoning, without trying codes at random.

Lock riddles, 3 digits

The kind you've seen on a padlock picture: three digits and a handful of clues. A good warm up.

  1. B1 3 digits, 4 clues

    GuessClue
    028None of these digits is in the code.
    941Exactly 1 digit is in the code but in a different position.
    675Exactly 2 digits are in the code but in different positions.
    146Exactly 2 digits are correct and in the correct positions.

    Code:

    Answer to B1

    The code is 156. Step by step:

    1. Clue 1 says none of its digits is in the code. 0, 2 and 8 aren't in the code.
    2. Clue 2 has no digit in the right slot. 1 isn't in slot 3; 4 isn't in slot 2; 9 isn't in slot 1.
    3. Clue 3 has no digit in the right slot. 5 isn't in slot 3; 6 isn't in slot 1; 7 isn't in slot 2.
    4. Clue 4 needs 2 digits in the right slot, and only 1 and 6 can still be there. 1 goes in slot 1; 6 goes in slot 3.
    5. 4 has no slot left where it could go. 4 isn't in the code.
    6. 7 has no slot left where it could go. 7 isn't in the code.
    7. Clue 2 has 2 digits that aren't in the code, and only 9 and 4 can still be missing. 9 isn't in the code.
    8. Clue 3 has 1 digit that isn't in the code, and 7 is already that one. 5 is in the code.
    9. The code has 3 digits, and you already know 1, 5 and 6 are in it. 3 isn't in the code.
  2. B2 3 digits, 4 clues

    GuessClue
    092Exactly 1 digit is correct and in the correct position.
    172Exactly 1 digit is in the code but in a different position.
    327Exactly 2 digits are correct and in the correct positions.
    016None of these digits is in the code.

    Code:

    Answer to B2

    The code is 397. Step by step:

    1. Clue 4 says none of its digits is in the code. 0, 1 and 6 aren't in the code.
    2. Clue 1 has no correct digit in a different slot. 2 isn't in slots 1 or 2; 9 isn't in slots 1 or 3.
    3. Clue 2 has no digit in the right slot. 2 isn't in slot 3; 7 isn't in slot 2.
    4. 2 has no slot left where it could go. 2 isn't in the code.
    5. Clue 1 needs 1 digit in the right slot, and only 9 can still be there. 9 goes in slot 2.
    6. Clue 2 has 2 digits that aren't in the code, and 1 and 2 are already those. 7 is in the code.
    7. Clue 3 needs 2 digits in the right slot, and only 3 and 7 can still be there. 3 goes in slot 1; 7 goes in slot 3.
  3. B3 3 digits, 4 clues

    GuessClue
    420Exactly 2 digits are in the code but in different positions.
    539Exactly 1 digit is in the code but in a different position.
    957None of these digits is in the code.
    643Exactly 1 digit is in the code but in a different position.

    Code:

    Answer to B3

    The code is 302. Step by step:

    1. Clue 3 says none of its digits is in the code. 9, 5 and 7 aren't in the code.
    2. Clue 1 has no digit in the right slot. 0 isn't in slot 3; 2 isn't in slot 2; 4 isn't in slot 1.
    3. Clue 2 has no digit in the right slot. 3 isn't in slot 2.
    4. Clue 2 has 2 digits that aren't in the code, and 5 and 9 are already those. 3 is in the code.
    5. Clue 4 has no digit in the right slot. 3 isn't in slot 3; 4 isn't in slot 2; 6 isn't in slot 1.
    6. Clue 4 has 2 digits that aren't in the code, and only 6 and 4 can still be missing. 6 and 4 aren't in the code.
    7. Clue 1 has 1 digit that isn't in the code, and 4 is already that one. 2 and 0 are in the code.
    8. The code has 3 digits, and you already know 0, 2 and 3 are in it. 1 and 8 aren't in the code.
    9. Only 0 can still go in slot 2. 0 goes in slot 2.
    10. Only 2 can still go in slot 3. 2 goes in slot 3.
  4. B4 3 digits, 4 clues

    GuessClue
    691Exactly 1 digit is in the code but in a different position.
    670Exactly 1 digit is in the code but in a different position.
    192Exactly 2 digits are correct and in the correct positions.
    679None of these digits is in the code.

    Code:

    Answer to B4

    The code is 102. Step by step:

    1. Clue 4 says none of its digits is in the code. 6, 7 and 9 aren't in the code.
    2. Clue 1 has no digit in the right slot. 1 isn't in slot 3.
    3. Clue 1 has 2 digits that aren't in the code, and 6 and 9 are already those. 1 is in the code.
    4. Clue 2 has no digit in the right slot. 0 isn't in slot 3.
    5. Clue 2 has 2 digits that aren't in the code, and 6 and 7 are already those. 0 is in the code.
    6. Clue 3 needs 2 digits in the right slot, and only 1 and 2 can still be there. 1 goes in slot 1; 2 goes in slot 3.
    7. The code has 3 digits, and you already know 0, 1 and 2 are in it. 3, 4, 5 and 8 aren't in the code.
  5. B5 3 digits, 4 clues

    GuessClue
    184Exactly 1 digit is correct and in the correct position.
    802None of these digits is in the code.
    367Exactly 2 digits are in the code but in different positions.
    137Exactly 1 digit is in the code but in a different position.

    Code:

    Answer to B5

    The code is 674. Step by step:

    1. Clue 2 says none of its digits is in the code. 8, 0 and 2 aren't in the code.
    2. Clue 1 has no correct digit in a different slot. 1 isn't in slots 2 or 3; 4 isn't in slots 1 or 2.
    3. Clue 3 has no digit in the right slot. 3 isn't in slot 1; 6 isn't in slot 2; 7 isn't in slot 3.
    4. Clue 4 has no digit in the right slot. 1 isn't in slot 1; 3 isn't in slot 2.
    5. 1 has no slot left where it could go. 1 isn't in the code.
    6. Clue 1 needs 1 digit in the right slot, and only 4 can still be there. 4 goes in slot 3.
    7. 3 has no slot left where it could go. 3 isn't in the code.
    8. Clue 3 has 1 digit that isn't in the code, and 3 is already that one. 6 and 7 are in the code.
    9. The code has 3 digits, and you already know 4, 6 and 7 are in it. 5 and 9 aren't in the code.
    10. Only 7 can still go in slot 2. 7 goes in slot 2.
  6. B6 3 digits, 5 clues

    GuessClue
    038Exactly 1 digit is correct and in the correct position.
    609Exactly 1 digit is in the code but in a different position.
    980Exactly 1 digit is correct and in the correct position.
    201None of these digits is in the code.
    416Exactly 1 digit is in the code but in a different position.

    Code:

    Answer to B6

    The code is 934. Step by step:

    1. Clue 4 says none of its digits is in the code. 2, 0 and 1 aren't in the code.
    2. Clue 1 has no correct digit in a different slot. 3 isn't in slots 1 or 3; 8 isn't in slots 1 or 2.
    3. Clue 2 has no digit in the right slot. 6 isn't in slot 1; 9 isn't in slot 3.
    4. Clue 3 needs 1 digit in the right slot, and only 9 can still be there. 9 goes in slot 1.
    5. Clue 2 has 2 digits that aren't in the code, and only 6 and 0 can still be missing. 6 isn't in the code.
    6. Clue 3 has 2 digits that aren't in the code, and only 8 and 0 can still be missing. 8 isn't in the code.
    7. Clue 1 needs 1 digit in the right slot, and only 3 can still be there. 3 goes in slot 2.
    8. Clue 5 has 2 digits that aren't in the code, and 1 and 6 are already those. 4 is in the code.
    9. The code has 3 digits, and you already know 3, 4 and 9 are in it. 5 and 7 aren't in the code.

4 digits

One more digit, and clues where some digits are right and some are only in the code.

  1. M1 4 digits, 6 clues

    GuessClue
    2490Exactly 2 digits are correct in total, of which 1 is in the correct position.
    9238Exactly 2 digits are in the code but in different positions.
    8217Exactly 1 digit is in the code but in a different position.
    7981None of these digits is in the code.
    4096Exactly 1 digit is correct and in the correct position.
    6284Exactly 1 digit is in the code but in a different position.

    Code:

    Answer to M1

    The code is 2053. Step by step:

    1. Clue 4 says none of its digits is in the code. 7, 9, 8 and 1 aren't in the code.
    2. Clue 2 has no digit in the right slot. 2 isn't in slot 2; 3 isn't in slot 3.
    3. Clue 2 has 2 digits that aren't in the code, and 9 and 8 are already those. 2 and 3 are in the code.
    4. Clue 5 has no correct digit in a different slot. 0 isn't in slots 1, 3 or 4; 4 isn't in slots 2, 3 or 4; 6 isn't in slots 1, 2 or 3.
    5. Clue 1 needs 1 digit in the right slot, and only 2 can still be there. 2 goes in slot 1.
    6. Only 5 can still go in slot 3. 5 goes in slot 3.
    7. 4 has no slot left where it could go. 4 isn't in the code.
    8. Clue 1 has 2 digits that aren't in the code, and 4 and 9 are already those. 0 is in the code.
    9. Clue 5 has 1 digit in the right slot, and 0 is already that one. 6 isn't in slot 4.
    10. Only 3 can still go in slot 4. 3 goes in slot 4.
  2. M2 4 digits, 6 clues

    GuessClue
    5762Exactly 1 digit is in the code but in a different position.
    3594Exactly 1 digit is correct and in the correct position.
    7438None of these digits is in the code.
    6275Exactly 1 digit is correct and in the correct position.
    3761Exactly 1 digit is in the code but in a different position.
    4967Exactly 1 digit is in the code but in a different position.

    Code:

    Answer to M2

    The code is 1290. Step by step:

    1. Clue 3 says none of its digits is in the code. 7, 4, 3 and 8 aren't in the code.
    2. Clue 1 has no digit in the right slot. 2 isn't in slot 4; 5 isn't in slot 1; 6 isn't in slot 3.
    3. Clue 2 has no correct digit in a different slot. 5 isn't in slots 3 or 4; 9 isn't in slots 1, 2 or 4.
    4. Clue 4 has no correct digit in a different slot. 2 isn't in slots 1 or 3; 5 isn't in slot 2; 6 isn't in slots 2 or 4.
    5. 5 has no slot left where it could go. 5 isn't in the code.
    6. Clue 2 needs 1 digit in the right slot, and only 9 can still be there. 9 goes in slot 3.
    7. Clue 5 has no digit in the right slot. 1 isn't in slot 4.
    8. Only 0 can still go in slot 4. 0 goes in slot 4.
    9. Clue 6 has 3 digits that aren't in the code, and only 4, 6 and 7 can still be missing. 6 isn't in the code.
    10. Only 1 can still go in slot 1. 1 goes in slot 1.
    11. Only 2 can still go in slot 2. 2 goes in slot 2.
  3. M3 4 digits, 6 clues

    GuessClue
    3862Exactly 1 digit is correct and in the correct position.
    4165Exactly 2 digits are correct in total, of which 1 is in the correct position.
    9576Exactly 1 digit is in the code but in a different position.
    6037Exactly 1 digit is in the code but in a different position.
    9174Exactly 1 digit is in the code but in a different position.
    7125Exactly 1 digit is correct and in the correct position.

    Code:

    Answer to M3

    The code is 0845. Step by step:

    1. Clue 1 has no correct digit in a different slot. 2 isn't in slots 1, 2 or 3; 3 isn't in slots 2, 3 or 4; 6 isn't in slots 1, 2 or 4; 8 isn't in slots 1, 3 or 4.
    2. Clue 3 has no digit in the right slot. 5 isn't in slot 2; 7 isn't in slot 3; 9 isn't in slot 1.
    3. Clue 4 has no digit in the right slot. 0 isn't in slot 2; 7 isn't in slot 4.
    4. Clue 5 has no digit in the right slot. 1 isn't in slot 2; 4 isn't in slot 4.
    5. Clue 6 has no correct digit in a different slot. 1 isn't in slots 1, 3 or 4; 2 isn't in slot 4; 5 isn't in slots 1 or 3; 7 isn't in slot 2.
    6. 1 has no slot left where it could go. 1 isn't in the code.
    7. 2 has no slot left where it could go. 2 isn't in the code.
    8. Clue 2 needs 1 correct digit in a different slot, and only 4 can still be that one. 4 is in the code; 4 isn't in slot 1.
    9. Clue 5 has 3 digits that aren't in the code, and only 9, 1 and 7 can still be missing. 9 and 7 aren't in the code.
    10. Clue 6 needs 1 digit in the right slot, and only 5 can still be there. 5 goes in slot 4.
    11. Clue 2 has 1 digit in the right slot, and 5 is already that one. 6 isn't in slot 3.
    12. 6 has no slot left where it could go. 6 isn't in the code.
    13. Suppose 0 goes in slot 3. Then clue 4 can't be true anymore. 0 isn't in slot 3.
    14. Only 4 can still go in slot 3. 4 goes in slot 3.
    15. Only 8 can still go in slot 2. 8 goes in slot 2.
    16. Clue 1 has 1 digit in the right slot, and 8 is already that one. 3 isn't in slot 1.
    17. Only 0 can still go in slot 1. 0 goes in slot 1.
  4. M4 4 digits, 6 clues

    GuessClue
    9145Exactly 1 digit is in the code but in a different position.
    5384Exactly 2 digits are in the code but in different positions.
    1258Exactly 2 digits are correct in total, of which 1 is in the correct position.
    7634Exactly 1 digit is correct and in the correct position.
    8763Exactly 2 digits are correct in total, of which 1 is in the correct position.
    3169Exactly 1 digit is in the code but in a different position.

    Code:

    Answer to M4

    The code is 8650. Step by step:

    1. Clue 1 has no digit in the right slot. 1 isn't in slot 2; 4 isn't in slot 3; 5 isn't in slot 4; 9 isn't in slot 1.
    2. Clue 2 has no digit in the right slot. 3 isn't in slot 2; 4 isn't in slot 4; 5 isn't in slot 1; 8 isn't in slot 3.
    3. Clue 4 has no correct digit in a different slot. 3 isn't in slots 1 or 4; 4 isn't in slots 1 or 2; 6 isn't in slots 1, 3 or 4; 7 isn't in slots 2, 3 or 4.
    4. 4 has no slot left where it could go. 4 isn't in the code.
    5. Clue 5 needs 1 digit in the right slot, and only 8 can still be there. 8 goes in slot 1.
    6. 7 has no slot left where it could go. 7 isn't in the code.
    7. Clue 3 has 1 correct digit in a different slot, and 8 is already that one. 1 isn't in slots 3 or 4; 2 isn't in slots 3 or 4; 5 isn't in slot 2.
    8. 1 has no slot left where it could go. 1 isn't in the code.
    9. Clue 6 has no digit in the right slot. 9 isn't in slot 4.
    10. Only 0 can still go in slot 4. 0 goes in slot 4.
    11. Suppose 9 goes in slot 3. Then clue 2 can't be true anymore. 9 isn't in slot 3.
    12. Suppose 3 is in the code. Then clue 6 can't be true anymore. 3 isn't in the code.
    13. Only 5 can still go in slot 3. 5 goes in slot 3.
    14. Clue 1 has 3 digits that aren't in the code, and only 9, 1 and 4 can still be missing. 9 isn't in the code.
    15. Clue 3 has 1 digit in the right slot, and 5 is already that one. 2 isn't in slot 2.
    16. Only 6 can still go in slot 2. 6 goes in slot 2.
  5. M5 4 digits, 5 clues

    GuessClue
    5231Exactly 3 digits are correct in total, of which 1 is in the correct position.
    8361Exactly 2 digits are in the code but in different positions.
    7935Exactly 2 digits are correct and in the correct positions.
    4596None of these digits is in the code.
    4386Exactly 1 digit is in the code but in a different position.

    Code:

    Answer to M5

    The code is 7132. Step by step:

    1. Clue 4 says none of its digits is in the code. 4, 5, 9 and 6 aren't in the code.
    2. Clue 1 has 1 digit that isn't in the code, and 5 is already that one. 2, 3 and 1 are in the code.
    3. Clue 2 has no digit in the right slot. 1 isn't in slot 4; 3 isn't in slot 2; 8 isn't in slot 1.
    4. Clue 2 has 2 digits that aren't in the code, and only 8 and 6 can still be missing. 8 isn't in the code.
    5. Clue 3 needs 2 digits in the right slot, and only 7 and 3 can still be there. 7 goes in slot 1; 3 goes in slot 3.
    6. Clue 1 has 1 digit in the right slot, and 3 is already that one. 2 isn't in slot 2.
    7. The code has 4 digits, and you already know 1, 2, 3 and 7 are in it. 0 isn't in the code.
  6. M6 4 digits, 5 clues

    GuessClue
    2716None of these digits is in the code.
    8634Exactly 3 digits are correct in total, of which 2 are in the correct positions.
    5931Exactly 2 digits are in the code but in different positions.
    7402Exactly 1 digit is in the code but in a different position.
    9742Exactly 1 digit is in the code but in a different position.

    Code:

    Answer to M6

    The code is 8354. Step by step:

    1. Clue 1 says none of its digits is in the code. 2, 7, 1 and 6 aren't in the code.
    2. Clue 2 has 1 digit that isn't in the code, and 6 is already that one. 8, 3 and 4 are in the code.
    3. Clue 3 has no digit in the right slot. 3 isn't in slot 3; 5 isn't in slot 1; 9 isn't in slot 2.
    4. Clue 2 needs 2 digits in the right slot, and only 8 and 4 can still be there. 8 goes in slot 1; 4 goes in slot 4.
    5. Clue 4 has no digit in the right slot. 0 isn't in slot 3.
    6. Clue 4 has 3 digits that aren't in the code, and only 7, 0 and 2 can still be missing. 0 isn't in the code.
    7. Clue 5 has 3 digits that aren't in the code, and only 9, 7 and 2 can still be missing. 9 isn't in the code.
    8. Only 5 can still go in slot 3. 5 goes in slot 3.

4 digits, harder

These need at least one "what if" step: suppose a digit is in the code, follow it through, and see it break a clue.

  1. H1 4 digits, 5 clues

    GuessClue
    2394Exactly 2 digits are in the code but in different positions.
    9328Exactly 2 digits are correct in total, of which 1 is in the correct position.
    9325Exactly 2 digits are correct in total, of which 1 is in the correct position.
    7896Exactly 1 digit is correct and in the correct position.
    5178Exactly 1 digit is in the code but in a different position.

    Code:

    Answer to H1

    The code is 7023. Step by step:

    1. Clue 1 has no digit in the right slot. 2 isn't in slot 1; 3 isn't in slot 2; 4 isn't in slot 4; 9 isn't in slot 3.
    2. Clue 4 has no correct digit in a different slot. 6 isn't in slots 1, 2 or 3; 7 isn't in slots 2, 3 or 4; 8 isn't in slots 1, 3 or 4; 9 isn't in slots 1, 2 or 4.
    3. 9 has no slot left where it could go. 9 isn't in the code.
    4. Clue 2 needs 1 digit in the right slot, and only 2 can still be there. 2 goes in slot 3.
    5. Clue 3 has 1 digit in the right slot, and 2 is already that one. 5 isn't in slot 4.
    6. Clue 5 has no digit in the right slot. 1 isn't in slot 2; 5 isn't in slot 1.
    7. Suppose 1 goes in slot 4. Then clue 4 can't be true anymore. 1 isn't in slot 4.
    8. Suppose 5 goes in slot 2. Then clue 3 can't be true anymore. 5 isn't in slot 2.
    9. 5 has no slot left where it could go. 5 isn't in the code.
    10. Clue 3 has 2 digits that aren't in the code, and 9 and 5 are already those. 3 is in the code.
    11. Clue 1 has 2 digits that aren't in the code, and only 9 and 4 can still be missing. 4 isn't in the code.
    12. Clue 2 has 2 digits that aren't in the code, and only 9 and 8 can still be missing. 8 isn't in the code.
    13. Only 0 can still go in slot 2. 0 goes in slot 2.
    14. Suppose 3 goes in slot 1. Then clue 5 can't be true anymore. 3 isn't in slot 1.
    15. Suppose 6 is in the code. Then slot 4 would have no digit left. 6 isn't in the code.
    16. Clue 4 needs 1 digit in the right slot, and only 7 can still be there. 7 goes in slot 1.
  2. H2 4 digits, 7 clues

    GuessClue
    8530Exactly 1 digit is correct and in the correct position.
    2740Exactly 1 digit is in the code but in a different position.
    5316Exactly 2 digits are in the code but in different positions.
    1574Exactly 2 digits are in the code but in different positions.
    7916Exactly 3 digits are correct in total, of which 1 is in the correct position.
    4708Exactly 1 digit is in the code but in a different position.
    8523Exactly 1 digit is in the code but in a different position.

    Code:

    Answer to H2

    The code is 7139. Step by step:

    1. Clue 1 has no correct digit in a different slot. 0 isn't in slots 1, 2 or 3; 3 isn't in slots 1, 2 or 4; 5 isn't in slots 1, 3 or 4; 8 isn't in slots 2, 3 or 4.
    2. Clue 2 has no digit in the right slot. 0 isn't in slot 4; 2 isn't in slot 1; 4 isn't in slot 3; 7 isn't in slot 2.
    3. 0 has no slot left where it could go. 0 isn't in the code.
    4. Clue 3 has no digit in the right slot. 1 isn't in slot 3; 6 isn't in slot 4.
    5. Clue 4 has no digit in the right slot. 1 isn't in slot 1; 4 isn't in slot 4; 5 isn't in slot 2; 7 isn't in slot 3.
    6. 5 has no slot left where it could go. 5 isn't in the code.
    7. Clue 6 has no digit in the right slot. 4 isn't in slot 1.
    8. Clue 7 has no digit in the right slot. 2 isn't in slot 3; 8 isn't in slot 1.
    9. 8 has no slot left where it could go. 8 isn't in the code.
    10. Clue 1 needs 1 digit in the right slot, and only 3 can still be there. 3 goes in slot 3.
    11. Clue 7 has 3 digits that aren't in the code, and only 8, 5 and 2 can still be missing. 2 isn't in the code.
    12. Suppose 9 goes in slot 1. Then clue 5 can't be true anymore. 9 isn't in slot 1.
    13. Suppose 1 goes in slot 4. Then clue 5 can't be true anymore. 1 isn't in slot 4.
    14. Suppose 6 goes in slot 2. Then clue 4 can't be true anymore. 6 isn't in slot 2.
    15. Suppose 9 goes in slot 2. Then clue 4 can't be true anymore. 9 isn't in slot 2.
    16. Clue 5 needs 1 digit in the right slot, and only 7 can still be there. 7 goes in slot 1.
    17. Only 9 can still go in slot 4. 9 goes in slot 4.
    18. 6 has no slot left where it could go. 6 isn't in the code.
    19. Clue 2 has 3 digits that aren't in the code, and only 2, 4 and 0 can still be missing. 4 isn't in the code.
    20. Only 1 can still go in slot 2. 1 goes in slot 2.
  3. H3 4 digits, 8 clues

    GuessClue
    7609Exactly 2 digits are correct in total, of which 1 is in the correct position.
    6378Exactly 2 digits are in the code but in different positions.
    4305Exactly 2 digits are correct in total, of which 1 is in the correct position.
    2538Exactly 1 digit is in the code but in a different position.
    9653Exactly 2 digits are in the code but in different positions.
    3825Exactly 1 digit is correct and in the correct position.
    2806Exactly 1 digit is in the code but in a different position.
    0976Exactly 2 digits are in the code but in different positions.

    Code:

    Answer to H3

    The code is 7465. Step by step:

    1. Clue 2 has no digit in the right slot. 3 isn't in slot 2; 6 isn't in slot 1; 7 isn't in slot 3; 8 isn't in slot 4.
    2. Clue 4 has no digit in the right slot. 2 isn't in slot 1; 3 isn't in slot 3; 5 isn't in slot 2.
    3. Clue 5 has no digit in the right slot. 3 isn't in slot 4; 5 isn't in slot 3; 6 isn't in slot 2; 9 isn't in slot 1.
    4. Clue 6 has no correct digit in a different slot. 2 isn't in slots 2 or 4; 5 isn't in slot 1; 8 isn't in slots 1 or 3.
    5. Clue 7 has no digit in the right slot. 0 isn't in slot 3; 6 isn't in slot 4; 8 isn't in slot 2.
    6. 8 has no slot left where it could go. 8 isn't in the code.
    7. Clue 8 has no digit in the right slot. 0 isn't in slot 1; 9 isn't in slot 2.
    8. Suppose 4 goes in slot 4. Then clue 3 can't be true anymore. 4 isn't in slot 4.
    9. Suppose 7 goes in slot 4. Then clue 1 can't be true anymore. 7 isn't in slot 4.
    10. Suppose 3 goes in slot 1. Then clue 3 can't be true anymore. 3 isn't in slot 1.
    11. 3 has no slot left where it could go. 3 isn't in the code.
    12. Clue 2 has 2 digits that aren't in the code, and 3 and 8 are already those. 6 and 7 are in the code.
    13. Clue 1 has 2 digits that aren't in the code, and only 0 and 9 can still be missing. 0 and 9 aren't in the code.
    14. Clue 1 needs 1 digit in the right slot, and only 7 can still be there. 7 goes in slot 1.
    15. Clue 3 needs 1 digit in the right slot, and only 5 can still be there. 5 goes in slot 4.
    16. Clue 3 has 2 digits that aren't in the code, and 3 and 0 are already those. 4 is in the code.
    17. Clue 4 has 3 digits that aren't in the code, and only 2, 3 and 8 can still be missing. 2 isn't in the code.
    18. The code has 4 digits, and you already know 4, 5, 6 and 7 are in it. 1 isn't in the code.
    19. Only 4 can still go in slot 2. 4 goes in slot 2.
  4. H4 4 digits, 6 clues

    GuessClue
    0657Exactly 3 digits are correct in total, of which 1 is in the correct position.
    0695Exactly 2 digits are in the code but in different positions.
    7430Exactly 3 digits are in the code but in different positions.
    9486Exactly 1 digit is in the code but in a different position.
    1560Exactly 2 digits are correct in total, of which 1 is in the correct position.
    2973Exactly 1 digit is in the code but in a different position.

    Code:

    Answer to H4

    The code is 4507. Step by step:

    1. Clue 2 has no digit in the right slot. 0 isn't in slot 1; 5 isn't in slot 4; 6 isn't in slot 2; 9 isn't in slot 3.
    2. Clue 3 has no digit in the right slot. 0 isn't in slot 4; 3 isn't in slot 3; 4 isn't in slot 2; 7 isn't in slot 1.
    3. Clue 4 has no digit in the right slot. 6 isn't in slot 4; 8 isn't in slot 3; 9 isn't in slot 1.
    4. Clue 6 has no digit in the right slot. 2 isn't in slot 1; 3 isn't in slot 4; 7 isn't in slot 3; 9 isn't in slot 2.
    5. Suppose 2 is in the code. Then clue 3 can't be true anymore. 2 isn't in the code.
    6. Suppose 4 isn't in the code. Then clue 6 can't be true anymore. 4 is in the code.
    7. Clue 4 has 3 digits that aren't in the code, and only 9, 8 and 6 can still be missing. 9, 8 and 6 aren't in the code.
    8. Clue 1 has 1 digit that isn't in the code, and 6 is already that one. 0, 5 and 7 are in the code.
    9. Clue 3 has 1 digit that isn't in the code, and only 3 can still be missing. 3 isn't in the code.
    10. Clue 5 has 2 digits that aren't in the code, and only 1 and 6 can still be missing. 1 isn't in the code.
    11. Clue 5 needs 1 digit in the right slot, and only 5 can still be there. 5 goes in slot 2.
    12. Only 4 can still go in slot 1. 4 goes in slot 1.

5 digits

The longest codes, with up to nine clues. Keep a grid of digits and positions on scrap paper.

  1. E1 5 digits, 9 clues

    GuessClue
    74890Exactly 2 digits are in the code but in different positions.
    16523Exactly 3 digits are correct in total, of which 1 is in the correct position.
    47396Exactly 1 digit is correct and in the correct position.
    89024Exactly 2 digits are in the code but in different positions.
    28306Exactly 2 digits are in the code but in different positions.
    76451Exactly 3 digits are in the code but in different positions.
    73408Exactly 2 digits are in the code but in different positions.
    13847Exactly 2 digits are in the code but in different positions.
    13095Exactly 3 digits are in the code but in different positions.

    Code:

    Answer to E1

    The code is 07512. Step by step:

    1. Clue 1 has no digit in the right slot. 0 isn't in slot 5; 4 isn't in slot 2; 7 isn't in slot 1; 8 isn't in slot 3; 9 isn't in slot 4.
    2. Clue 3 has no correct digit in a different slot. 3 isn't in slots 1, 2, 4 or 5; 4 isn't in slots 3, 4 or 5; 6 isn't in slots 1, 2, 3 or 4; 7 isn't in slots 3, 4 or 5; 9 isn't in slots 1, 2, 3 or 5.
    3. 9 has no slot left where it could go. 9 isn't in the code.
    4. Clue 4 has no digit in the right slot. 0 isn't in slot 3; 2 isn't in slot 4; 8 isn't in slot 1.
    5. Clue 5 has no digit in the right slot. 0 isn't in slot 4; 2 isn't in slot 1; 3 isn't in slot 3; 6 isn't in slot 5; 8 isn't in slot 2.
    6. 3 has no slot left where it could go. 3 isn't in the code.
    7. 6 has no slot left where it could go. 6 isn't in the code.
    8. Clue 2 has 2 digits that aren't in the code, and 6 and 3 are already those. 1, 5 and 2 are in the code.
    9. Clue 6 has no digit in the right slot. 1 isn't in slot 5; 5 isn't in slot 4.
    10. Clue 7 has no digit in the right slot. 8 isn't in slot 5.
    11. Clue 8 has no digit in the right slot. 1 isn't in slot 1.
    12. Clue 2 needs 1 digit in the right slot, and only 5 can still be there. 5 goes in slot 3.
    13. Only 2 can still go in slot 5. 2 goes in slot 5.
    14. Clue 9 has 2 digits that aren't in the code, and 3 and 9 are already those. 0 is in the code.
    15. Clue 4 has 3 digits that aren't in the code, and only 8, 9 and 4 can still be missing. 8 and 4 aren't in the code.
    16. Only 0 can still go in slot 1. 0 goes in slot 1.
    17. Only 1 can still go in slot 4. 1 goes in slot 4.
    18. Only 7 can still go in slot 2. 7 goes in slot 2.
  2. E2 5 digits, 8 clues

    GuessClue
    06871Exactly 2 digits are in the code but in different positions.
    25198Exactly 3 digits are correct in total, of which 1 is in the correct position.
    37085Exactly 2 digits are in the code but in different positions.
    26398Exactly 3 digits are correct in total, of which 1 is in the correct position.
    84513Exactly 1 digit is in the code but in a different position.
    27031Exactly 2 digits are in the code but in different positions.
    83701Exactly 1 digit is correct and in the correct position.
    34582Exactly 2 digits are in the code but in different positions.

    Code:

    Answer to E2

    The code is 52796. Step by step:

    1. Clue 1 has no digit in the right slot. 0 isn't in slot 1; 1 isn't in slot 5; 6 isn't in slot 2; 7 isn't in slot 4; 8 isn't in slot 3.
    2. Clue 3 has no digit in the right slot. 0 isn't in slot 3; 3 isn't in slot 1; 5 isn't in slot 5; 7 isn't in slot 2; 8 isn't in slot 4.
    3. Clue 5 has no digit in the right slot. 1 isn't in slot 4; 3 isn't in slot 5; 4 isn't in slot 2; 5 isn't in slot 3; 8 isn't in slot 1.
    4. Clue 6 has no digit in the right slot. 2 isn't in slot 1; 3 isn't in slot 4.
    5. Clue 7 has no correct digit in a different slot. 0 isn't in slots 2 or 5; 1 isn't in slots 1, 2 or 3; 3 isn't in slot 3; 7 isn't in slots 1 or 5; 8 isn't in slots 2 or 5.
    6. 1 has no slot left where it could go. 1 isn't in the code.
    7. 8 has no slot left where it could go. 8 isn't in the code.
    8. Clue 2 has 2 digits that aren't in the code, and 1 and 8 are already those. 2, 5 and 9 are in the code.
    9. Clue 4 needs 1 digit in the right slot, and only 9 can still be there. 9 goes in slot 4.
    10. 0 has no slot left where it could go. 0 isn't in the code.
    11. Clue 1 has 3 digits that aren't in the code, and 0, 8 and 1 are already those. 6 and 7 are in the code.
    12. Clue 2 has 1 digit in the right slot, and 9 is already that one. 5 isn't in slot 2.
    13. Clue 3 has 3 digits that aren't in the code, and only 3, 0 and 8 can still be missing. 3 isn't in the code.
    14. Only 2 can still go in slot 2. 2 goes in slot 2.
    15. Clue 5 has 4 digits that aren't in the code, and only 8, 4, 1 and 3 can still be missing. 4 isn't in the code.
    16. Only 6 can still go in slot 5. 6 goes in slot 5.
  3. E3 5 digits, 9 clues

    GuessClue
    98214Exactly 2 digits are in the code but in different positions.
    81537Exactly 3 digits are correct in total, of which 1 is in the correct position.
    30198Exactly 2 digits are in the code but in different positions.
    03916Exactly 2 digits are in the code but in different positions.
    61285Exactly 2 digits are in the code but in different positions.
    05197Exactly 4 digits are in the code but in different positions.
    17429Exactly 3 digits are correct in total, of which 1 is in the correct position.
    98351Exactly 2 digits are in the code but in different positions.
    96108Exactly 2 digits are in the code but in different positions.

    Code:

    Answer to E3

    The code is 14570. Step by step:

    1. Clue 1 has no digit in the right slot. 1 isn't in slot 4; 2 isn't in slot 3; 4 isn't in slot 5; 8 isn't in slot 2; 9 isn't in slot 1.
    2. Clue 3 has no digit in the right slot. 0 isn't in slot 2; 1 isn't in slot 3; 3 isn't in slot 1; 8 isn't in slot 5; 9 isn't in slot 4.
    3. Clue 4 has no digit in the right slot. 0 isn't in slot 1; 3 isn't in slot 2; 6 isn't in slot 5; 9 isn't in slot 3.
    4. Clue 5 has no digit in the right slot. 1 isn't in slot 2; 5 isn't in slot 5; 6 isn't in slot 1; 8 isn't in slot 4.
    5. Clue 6 has no digit in the right slot. 5 isn't in slot 2; 7 isn't in slot 5.
    6. Clue 8 has no digit in the right slot. 1 isn't in slot 5; 3 isn't in slot 3; 5 isn't in slot 4.
    7. Clue 9 has no digit in the right slot. 0 isn't in slot 4; 6 isn't in slot 2.
    8. Suppose 0 isn't in the code. Then clue 8 can't be true anymore. 0 is in the code.
    9. Suppose 3 is in the code. Then clue 6 can't be true anymore. 3 isn't in the code.
    10. Suppose 5 goes in slot 1. Then clue 2 can't be true anymore. 5 isn't in slot 1.
    11. Suppose 8 goes in slot 1. Then clue 2 can't be true anymore. 8 isn't in slot 1.
    12. Clue 2 needs 1 digit in the right slot, and only 5 can still be there. 5 goes in slot 3.
    13. 8 has no slot left where it could go. 8 isn't in the code.
    14. Clue 2 has 2 digits that aren't in the code, and 8 and 3 are already those. 1 and 7 are in the code.
    15. Clue 3 has 3 digits that aren't in the code, and only 3, 9 and 8 can still be missing. 9 isn't in the code.
    16. Clue 4 has 3 digits that aren't in the code, and only 3, 9 and 6 can still be missing. 6 isn't in the code.
    17. Clue 5 has 3 digits that aren't in the code, and only 6, 2 and 8 can still be missing. 2 isn't in the code.
    18. Clue 1 has 3 digits that aren't in the code, and 9, 8 and 2 are already those. 4 is in the code.
    19. Clue 7 has 1 digit in the right slot, and 1 is already that one. 7 isn't in slot 2.
    20. Only 4 can still go in slot 2. 4 goes in slot 2.
    21. Only 7 can still go in slot 4. 7 goes in slot 4.
  4. E4 5 digits, 7 clues

    GuessClue
    93106Exactly 2 digits are in the code but in different positions.
    68190Exactly 3 digits are in the code but in different positions.
    09364Exactly 2 digits are in the code but in different positions.
    68743Exactly 3 digits are correct in total, of which 1 is in the correct position.
    60493Exactly 2 digits are in the code but in different positions.
    63701Exactly 2 digits are in the code but in different positions.
    03854Exactly 3 digits are correct in total, of which 1 is in the correct position.

    Code:

    Answer to E4

    The code is 16845. Step by step:

    1. Clue 1 has no digit in the right slot. 0 isn't in slot 4; 1 isn't in slot 3; 3 isn't in slot 2; 6 isn't in slot 5; 9 isn't in slot 1.
    2. Clue 2 has no digit in the right slot. 0 isn't in slot 5; 6 isn't in slot 1; 8 isn't in slot 2; 9 isn't in slot 4.
    3. Clue 3 has no digit in the right slot. 0 isn't in slot 1; 3 isn't in slot 3; 4 isn't in slot 5; 6 isn't in slot 4; 9 isn't in slot 2.
    4. Clue 5 has no digit in the right slot. 0 isn't in slot 2; 3 isn't in slot 5; 4 isn't in slot 3.
    5. Clue 6 has no digit in the right slot. 1 isn't in slot 5; 7 isn't in slot 3.
    6. Clue 4 needs 1 digit in the right slot, and only 4 can still be there. 4 goes in slot 4.
    7. Clue 7 needs 1 digit in the right slot, and only 8 can still be there. 8 goes in slot 3.
    8. 0 has no slot left where it could go. 0 isn't in the code.
    9. Suppose 1 isn't in the code. Then clue 3 can't be true anymore. 1 is in the code.
    10. Suppose 3 is in the code. Then clue 2 can't be true anymore. 3 isn't in the code.
    11. Clue 7 has 2 digits that aren't in the code, and 0 and 3 are already those. 5 is in the code.
    12. Suppose 2 is in the code. Then clue 1 can't be true anymore. 2 isn't in the code.
    13. Suppose 6 isn't in the code. Then the code would need too many digits. 6 is in the code.
    14. Clue 1 has 3 digits that aren't in the code, and only 9, 3 and 0 can still be missing. 9 isn't in the code.
    15. Clue 4 has 2 digits that aren't in the code, and only 7 and 3 can still be missing. 7 isn't in the code.
    16. Only 5 can still go in slot 5. 5 goes in slot 5.
    17. Only 1 can still go in slot 1. 1 goes in slot 1.

A quick method

  1. Cross out the none clues.

    Every digit in a "none of these" clue is gone, everywhere.

  2. Use those cross outs on the other clues.

    Once a clue's dead digits are gone, its count often has only one way to fit.

  3. Place digits by position.

    A digit that's "in the code but in a different position" can't sit where that guess had it.

  4. Try a what if.

    When you're stuck, suppose a digit is in the code and follow the clues. If one breaks, the digit is out.

The full guide to solving code breaker puzzles works through three puzzles step by step, including the famous 682 riddle.

How these were made

The puzzles come from the generator in my game Crack the Vault, the same one behind the daily code breaker on this site. Each answer above was written by the same step by step solver that gives the hints in the daily code breaker, so every step is one you can follow with a pencil. Before the page goes up, a separate program tries every possible code against every clue to make sure exactly one fits.

Answer key
PuzzleKindCode
B1Lock riddles, 3 digits156
B2Lock riddles, 3 digits397
B3Lock riddles, 3 digits302
B4Lock riddles, 3 digits102
B5Lock riddles, 3 digits674
B6Lock riddles, 3 digits934
M14 digits2053
M24 digits1290
M34 digits0845
M44 digits8650
M54 digits7132
M64 digits8354
H14 digits, harder7023
H24 digits, harder7139
H34 digits, harder7465
H44 digits, harder4507
E15 digits07512
E25 digits52796
E35 digits14570
E45 digits16845

Questions

Can I use these in class?

Yes. Print as many copies as you like for your class or club. The answer key prints on its own page, so you can hand out the puzzles without it.

Can a digit appear twice in the code?

Not in these puzzles. Every code uses different digits, and so does every guess.

Is there only one answer to each?

Yes. Every possible code was tested against every clue, and exactly one fits each puzzle.

Where can I play more?

There are three new vaults every day in the daily code breaker, and my Crack the Vault app for Android has 500 levels from 3 to 5 digits with hints that explain each step.

Crack the Vault
500 levels from 3 to 5 digits, a daily vault, and hints that explain the next step.

Get it on Google Play
All puzzles
Code breaker

How to solve code breaker puzzles

One method for lock riddles, daily vaults and bulls and cows, with three puzzles solved step by step.

Solving guide · 9 min read
Code breaker

Daily code breaker

Crack a secret code from number clues. Three vaults every day, 3 to 5 digits, one answer each.

Playable puzzle
Code breaker

Bulls and cows solver

Enter your guesses and their bulls and cows. See every code that still fits and a suggested next guess.

Solver