Binary Puzzle Solver

Click here for the Binary Puzzle Solver.

bps_php_unsolved
bps_php_solved

The Binary Puzzle Solver is also available as a web service.

Example request:
http://www.magmeister.be/binarypuzzlesolver/solve.php?puzzle=[["-","-","-","0","-","0","1","-","1","-"],["-","1","-","-","-","-","-","-","0","-"],["-","0","0","-","-","-","-","-","-","0"],["0","-","-","-","-","0","-","0","1","-"],["-","0","1","-","-","-","-","-","-","-"],["-","-","-","-","1","-","-","-","-","-"],["0","-","-","-","-","-","-","-","-","0"],["-","1","-","-","0","-","0","1","-","-"],["1","-","-","-","-","-","0","-","1","-"],["1","-","1","-","-","-","-","1","-","-"]]

Example response:
[["0","1","0","0","1","0","1","0","1","1"],["0","1","1","0","0","1","1","0","0","1"],["1","0","0","1","1","0","0","1","1","0"],["0","1","0","1","0","0","1","0","1","1"],["1","0","1","0","0","1","0","1","0","1"],["1","0","1","0","1","1","0","1","0","0"],["0","1","0","1","1","0","1","0","1","0"],["0","1","0","1","0","1","0","1","0","1"],["1","0","1","0","1","1","0","0","1","0"],["1","0","1","1","0","0","1","1","0","0"]]

47 Replies to “Binary Puzzle Solver”

  1. Your binary puzzle solver is a very handy tool.It is the only one of it's type I was able to find online which is not some kind of app.However on the following puzzle from http://www.binarypuzzle.com it gave me the wrong answer.

    May 9
    8x8
    Very Hard

    -0----10
    -----0--
    -00---11
    ------0-
    -11-----
    ----1--1
    --1----0
    10------

    the answer it gave me was

    10010110
    01101001
    10010011
    01101100
    01100110
    10011001
    01101010
    10010101

    which is not correct because columns 1 and 4 are duplicates and columns 2 and 3 are duplicates.However when I enter the following

    00----10
    -----0--
    -00---11
    ------0-
    -11-----
    ----1--1
    --1----0
    10------

    which is virtually identical to the starting puzzle except I have "guessed"
    at one of the blanks and put in a "0" for the value at the corner of row 1 and column 1,then it comes up with the correct solution of

    00110110
    01101001
    10010011
    11001100
    01100110
    10011001
    01101010
    10010101

    I guess there's some small bug in the program.I don't even think that it's really necessary to try to correct it.I just wanted to bring it to your attention.
    John Manfredi

  2. I am resubmitting my previous post since I had used dashes as blank fields for the binary puzzle and it did not appear properly.I will now substitute "x".

    Your binary puzzle solver is a very handy tool.It is the only one of itโ€™s type I was able to find online which is not some kind of app.However on the following puzzle from http://www.binarypuzzle.com it gave me the wrong answer.

    May 9
    8ร—8
    Very Hard

    x0xxxx1x
    xxxxx0xx
    x00xxx11
    xxxxxx0x
    x11xxxxx
    xxxx1xx1
    xx1xxxx0
    10xxxxxx

    the answer it gave me was

    10010110
    01101001
    10010011
    01101100
    01100110
    10011001
    01101010
    10010101

    which is not correct because columns 1 and 4 are duplicates and columns 2 and 3 are duplicates.However when I enter the following

    00xxxx1x
    xxxxx0xx
    x00xxx11
    xxxxxx0x
    x11xxxxx
    xxxx1xx1
    xx1xxxx0
    10xxxxxx

    which is virtually identical to the starting puzzle except I have โ€œguessedโ€
    at one of the blanks and put in a โ€œ0โ€ณ for the value at the corner of row 1 and column 1,then it comes up with the correct solution of

    00110110
    01101001
    10010011
    11001100
    01100110
    10011001
    01101010
    10010101

    I guess thereโ€™s some small bug in the program.I donโ€™t even think that itโ€™s really necessary to try to correct it.I just wanted to bring it to your attention.
    John Manfredi

    • John,

      Thank you for your feedback!

      I tried the puzzle myself, and you are right. The puzzle isn't solved properly. I will look this into more detail to understand what is going wrong. I can barely live with the fact that my program would not be able to solve all puzzles ๐Ÿ˜› ๐Ÿ™‚

    • It seems that I didn't update the web-application to my newer 2.2 version.

      The online solver will do fine now. Thanks again for your feedback!

  3. I tried entering that same puzzle again which gives the wrong results on your solver and I'm still getting the wrong results.I don't know why.On the bright side,I've entered more difficult puzzles than this and your solver comes up with the right solution.Oh well .......................................

    • Here's an additional oddity I forgot to mention in my above reply.I tried opening the solver on two different browsers to see if that made a difference.It did,insofar as the solver on the Firefox browser that I always use came up with the wrong solution which I had mentioned in my original reply which is

      10010110
      01101001
      10010011
      01101100
      01100110
      10011001
      01101010
      10010101

      and when I access your solver using Internet Explorer 8,it comes up with a different solution which is also wrong.That solution is

      10100110
      01011001
      10010011
      01101100
      01100110
      10011001
      01101010
      10010101

      now there is one duplicate pair of columns instead of the two in the original solution.Now columns 4 and 8 are illegal duplicates.Sorry to make a big fuss about this.I just find it interesting.

      P.S. I have made another discovery.When I entered

      00xxxx1x
      xxxxx0xx
      x00xxx11
      xxxxxx0x
      x11xxxxx
      xxxx1xx1
      xx1xxxx0
      10xxxxxx

      in your solver using Firefox browser it comes up with the correct solution of

      00110110
      01101001
      10010011
      11001100
      01100110
      10011001
      01101010
      10010101

      which is the correct solution but when I enter the same values in your solver but access it through Internet Explorer 8 I get

      00110110
      11001001
      10010011
      01011100
      10011001
      01100110
      00101001

      which is wrong because row 4 has triple 1's and rows 5 and 7 are illegal duplicates.So STRANGE things are happening.

      • Java is browser-independent so the program's execution can not be affected by the browser.

        This would mean my program generates different "solutions" for one same puzzle. Indeed, I was able to reconstruct your findings in Eclipse: sometimes my solver gave me the right solution, other times it gave me the wrong solution.

        There is definitely a bug in my program. I will clear this out and come with an updated version.
        Thank you for your contribution!

      • There was a bug in the validation of the puzzle in the function "guess and validate". I updated the solver to version 2.3. Please try it and let me know if it works for you.

        Greets!

  4. I ran a few puzzles through your updated solver and it appears to be working properly.I commend your for being willing to put in extra time and effort without financial remuneration so that your solver would work properly.You obviously take a lot of pride in your work.Thank you so much.

  5. There are two web sites that I visit for binary puzzles.The first one is:

    http://www.binarypuzzle.com/

    They have 6x6,8x8,10x10,12x12 and 14x14 puzzles of four levels:easy,medium,hard and very hard.Your updated solver seems to come up with the correct solution for different sized grids and different levels.

    The other site is:

    http://www.sudoku-puzzles.net/en/logic-puzzles/binary

    They offer only 9x9 puzzles of three different levels:easy,medium and hard.I have had mixed results on their puzzles.On the easy and medium puzzles,your solver seems to work.On the hard puzzles,especially the first few,your solver encountered several different problems:on the very first one(and possibly others too)it just froze and wouldn't come up with a solution.
    On other ones,it would come up with an erroneous solution where one or more of the starting values I had entered had changed to it's opposite value.It also produced wrong solutions where it violated the duplicate row or column rule.
    But,on some of the hard puzzles,it did come up with the correct solution.

    I am sorry to bother you again.I just don't know why it encountered these problems.If you have a chance,visit the second site and see if you encounter the same problems.Thank you for your patience.

    • You are right. The solver has troubles with the hard puzzles.

      I will look at this when I have the time ๐Ÿ™‚

      If I may ask, why are you so interested in solving all these puzzles?

      • I guess he wants to be sure the solver actually does work correct, so he can trust it in solving other puzzles. You may validate my guess.

  6. It's just something I have become fascinated with lately.I have been a sudoku fan for years.It actually doesn't make much difference if your solver doesn't solve the 9x9 ones correctly since that site shows you the solutions if you wish.The other site doesn't.
    Thanks again for all your hard work.

    • John,

      A major update was necessary to overcome all the problems with those 9x9 puzzles. More details can be found in my post at http://www.magmeister.be/?p=227.

      Thank you again for your feedback. I hope my solver will cover all puzzles now. Feel free to try the new 3.0 version and let me know your findings ๐Ÿ™‚

  7. Magmeister,
    Thank you for having the patience,willingness and determination to again update and improve your solver.Those 9x9 hard puzzles are wicked compared to the ones on the other site.I can only begin to imagine the effort involved.I hope you experienced a great feeling of satisfaction when you finally succeeded.That is the feeling I would get when I successfully completed writing a program in the past.I used to write programs in real old school computer languages(Cobol,Fortran,Basic and Qbasic come to mind).You have to have a certain kind of dedication to do it.
    Your new solver appears to be working perfectly.I hope it will be of use to other Binary puzzle fans besides myself.If you ever visit Las Vegas,Nevada(my home for almost 30 years),I would like you to contact me so that I can take you to dinner as a small token of gratitude for the work you have put into this project.Keep up the good work.
    John Manfredi

  8. I just tested your solver on 18 of the 9x9 hard puzzles and it correctly solved ALL of them.It appears to be working perfectly due to your patience and persistence.Your dinner in Las Vegas is still waiting.I hope that the longer it takes for you to get here,the more of an appetite you will have !!!

  9. Could you describe what you do for each screen shot? Example: find pairs. I think I know this one. Eliminate Set Combinations - Rank 0. (don't have a clue). How do you denote when the program has performed a guess? Thanks.

    • Please first read http://www.binarypuzzle.com/tips.php

      The lexis I use:
      Set - a possible combination (row / column) of zeros and ones
      Rank - the amount zeros (or ones) still to be determined in a row or column

      For example: in a row or column with rank 0, all zeros (or ones) are determined. This means that al other remaining values must be ones (or zeros). In fact a rank 0 is just completing the row or column.

      A guess and validate will be printed in the console. Remember that guess and validate will only be used for more difficult puzzles.

      I hope this helps you.

  10. Lovely solver, I was stuck on a 8x8 Very Hard level and your program solved it perfectly.
    Being interested in where I got stuck, I looked at the output, trying to figure out what my next move would've been, but it said "Solve Level 1, Binary Puzzle Solver" inbetween and it put down a 1 and a 0 which made no sense to me whatsoever. Was it just guessing at this point and see if it was the right solution? Or am I missing some kind of obvious move? When I started playing these puzzles I was told you can always deduct the solution with logic, and wouldn't ever need to guess, was that wrong?

    • I was surprised as well while I was developing the solver. For some hard puzzles the solution can't always be deducted with logic. View my post:
      http://www.magmeister.be/?p=192

      The solving level is indeed an indication that a guess was made. After the guess the puzzle will be solved further with logic.

      Nevertheless there is only 1 solution: if you guessed wrong and you would continue solving the puzzle with logic, it will turn out that the solution is invalid. At this point my solver is implemented to resume at the point where the guess was made, and will take a new guess.

  11. Great solver!

    Could you add a feature to determine the number of solutions? I know there is only supposed to be one, but my local paper published a 12x12 puzzle below. Either I've made a mistake somewhere.or the answer is not unique. The rules state each row and column must have six zeros and six ones, no more than two zeros or ones in a row horizontally or vertically, and no identical rows and columns.

    I've put the original puzzle into your solver and also tried guessing the first row fifth column as either a 1 or 0. In all three cases your solver found a solution that looks valid to me. So I think this example has at least two solutions and possibly more.

    xxxxxxx1xxxx
    xx0xxxxx0xx0
    xxxxx0x1xx1x
    xxxxxxxxxxx1
    xxxxxxxxx00x
    xx1x1xxxxx0x
    xxxx1xxxxxxx
    0x1xxx1xxxxx
    xxxx1xx0xxx0
    xx0xxxxxx0x0
    xx0xxxx0x0xx
    xxxx00xx1xxx

    • Hey, I tried it with my own recursive solver which tries every option. It only has one valid solution. The first row fifth column should be a 1.

    • Indeed, it should be a 1.

      However, you don't need to guess. The puzzle is solved properly without guessing. Since version 4.1 you can show the solving sequence:
      magmeister.be/binarypuzzlesolver/?puzzle=[["-","-","-","-","-","-","-","1","-","-","-","-"],["-","-","0","-","-","-","-","-","0","-","-","0"],["-","-","-","-","-","0","-","1","-","-","1","-"],["-","-","-","-","-","-","-","-","-","-","-","1"],["-","-","-","-","-","-","-","-","-","0","0","-"],["-","-","1","-","1","-","-","-","-","-","0","-"],["-","-","-","-","1","-","-","-","-","-","-","-"],["0","-","1","-","-","-","1","-","-","-","-","-"],["-","-","-","-","1","-","-","0","-","-","-","0"],["-","-","0","-","-","-","-","-","-","0","-","0"],["-","-","0","-","-","-","-","0","-","0","-","-"],["-","-","-","-","0","0","-","-","1","-","-","-"]]&options={"solving_sequence":true,"solve":true}

      Guessing a 0 will lead to an invalid puzzle:
      magmeister.be/binarypuzzlesolver/?puzzle=[["-","-","-","-","0","-","-","1","-","-","-","-"],["-","-","0","-","-","-","-","-","0","-","-","0"],["-","-","-","-","-","0","-","1","-","-","1","-"],["-","-","-","-","-","-","-","-","-","-","-","1"],["-","-","-","-","-","-","-","-","-","0","0","-"],["-","-","1","-","1","-","-","-","-","-","0","-"],["-","-","-","-","1","-","-","-","-","-","-","-"],["0","-","1","-","-","-","1","-","-","-","-","-"],["-","-","-","-","1","-","-","0","-","-","-","0"],["-","-","0","-","-","-","-","-","-","0","-","0"],["-","-","0","-","-","-","-","0","-","0","-","-"],["-","-","-","-","0","0","-","-","1","-","-","-"]]&options={"solving_sequence":true,"solve":true}

  12. Hi MagMeister,

    Today I made a mistake again in a binary puzzle in my booklet. Even just rewriting over it with a black pencil got me the same wrong direction. I noticed I had two equal columns. I didn't feel much like drawing it again myself on paper, so I turned to a "binary" solver again. I think I used yours before. I did think I posted a comment in the past, but I can't find it. I think it was about more easily being able to put the 0's and especially the 1's in the grid (by right clicking).
    I do have a few (more) suggestions.
    Since all puzzles normally are squares, could you just add a simple rotate (left, right) function? (It may work as well for non square puzzles, of course.) This way it could be just a little more comfortable comparing rows instead of columns, which I believe is a little harder to do.
    You may also add a highlighting function to specify the target and the source row or column: highlight the row or column I want to solve and highlight the other row or column I am hovering over in (another) color. I think this would be a great improvement in allowing comparison of rows and columns.
    For Sudoku's I do wrong, I turn to sudoku9x9.
    https://sudoku9x9.com/sudoku_blank_grid_9x9.php
    This is a nice editor to input puzzles as well as solve them. It does show the given values in another color as the solutions I place myself. Could you also do that? After I just enter an original puzzle, I would like to have all values so far to be kept shown in bold type, for example, or another background color.
    I succeeded in solving the puzzle today by just making these two columns different. Could you make a "solve step" button that does solve only one step? I believe your solver does the complete solution at once, doesn't it? (I only took a quick look at it.)
    It would be nice to have some feedback about the steps as my other favorite sudoku solver shows.
    https://www.sudokuwiki.org/sudoku.htm
    I guess that would be a little too much to ask for the moment. Thank you for your service. Keep it up!

    Kind regards,

    Fool4UAnyway

    • Thanks for your suggestions. For now, I don't plan to add any additional features. The goal of the solver is indeed to solve the puzzle completely. However, it is possible to continue puzzling from a certain step. Just click on the desired puzzle from the solving sequence. Please try it out!

  13. The start of the puzzle is shown here:

    https://www.dropbox.com/s/zj2q32u4odjh71x/puzzlestart.png?dl=0

    I started the puzzle and reached a dead end with, apparently, no logical progression.

    I tried the puzzle with your solver and (of course!) it provided a solution. I therefore followed the steps to see why I was unable to do so myself. Up to step 14 everything matched, but in Step 14, seen here:

    https://www.dropbox.com/s/kvmszlvv64sgy4r/puzzlestep14.png?dl=0

    the solver seems to have made a guess; that, at least is how I understand it. I expect I am mistaken, so please help me understand how these two numbers can be placed confidently in their squares.

    • Here a shortcut to your puzzle.

      It's not a guess that's made in step #14, but a column combination that's eliminated. It has to be a 1. Try a 0 and you will find out that you will end up with more than two 1's next to each other as you continue to complete the column.

  14. Great stuff.
    I am wondering about the row/column analysis.
    Is it working on rows and columns independently or is it actually considering "vertical and horizontal" constraints on a single cell ?

  15. As a beginner I don't understand the concept of eliminating column/row combinations yet. Is it about a limited amount of possibilities and unique combinations?

  16. Most publications who print these puzzles place a "marker" at the
    half-way place on the board. That is e.g. for a 12x12 puzzle, between
    cells 6 and 7. That is very useful; perhaps you could do that. At least for even numbers of cells !

    Another suggestion: "fix" and reset buttons, to fix an input/start pattern,
    and then to reset back to that pattern for whatever reason.
    Great program !

  17. Super - thank you!
    Your site solved a puzzle which another site couldn't solve!
    I couldn't solve it because I didnโ€™t know that "Guess and validate" was a thing. Now I know...

  18. I've been working my way through the Very Hard 8x8 puzzles at binarypuzzle.com, and started using your solver after finding more than a few of them that turned out to require Guess and Validate. The solver has a Guess and Validate on puzzle #27
    Step #19: Eliminate Row/Column Combinations
    0 0 1 1 0 1 1 0
    0 1 0 0 1 1 0 1
    1 0 1 0 1 0 0 1
    1 1 0 1 0 0 1 0
    0 1 0 1 0 1 0 1
    1 0 1 0 1 - - 0
    - 0 1 0 - - - 1
    - 1 0 1 - - 1 0

    Step #20: Guess And Validate
    0 0 1 1 0 1 1 0
    0 1 0 0 1 1 0 1
    1 0 1 0 1 0 0 1
    1 1 0 1 0 0 1 0
    0 1 0 1 0 1 0 1
    1 0 1 0 1 1 0 0
    - 0 1 0 - - - 1
    - 1 0 1 - - 1 0

    Your solver missed, what I consider a pretty basic and easy to spot pattern, which makes this puzzle fairly easy:
    Compare row 8 to row 4. 3 ones. R8C1 can't be a one and must be 0, making R7C1 = 1
    Now the same kind of comparison between rows 7 and 3
    0 0 1 1 0 1 1 0
    0 1 0 0 1 1 0 1
    1 0 1 0 1 0 0 1
    1 1 0 1 0 0 1 0
    0 1 0 1 0 1 0 1
    1 0 1 0 1 - - 0
    1 0 1 0 0 - - 1
    0 1 0 1 - - 1 0
    And the rest is trivial. Of course this only works when the position of the fourth element in the completed row is blank in the target row.

  19. whoops, That's puzzle #21, not #27
    0 - - - - - - -
    - - - 0 - - - -
    1 - - - - 0 0 -
    1 1 - - - - - -
    - - - - - - 0 -
    - - 1 0 - - - -
    - 0 - 0 - - - 1
    - - - - - - 1 -

Leave a Reply

Your email address will not be published. Required fields are marked *

*