Giter Club home page Giter Club logo

Comments (5)

aaoa avatar aaoa commented on June 22, 2024

The latest fix I made should resolve this issue. The algorithm used to generate puzzles guarantees uniqueness; there was simply a bug in the implementation.

For the record, the algorithm works as follows:
While count is less than 81:

  1. On the current puzzle, run all difficulty-appropriate tutor algorithms. If any are successful (meaning a square's value is forced), put that number into the internal puzzle, and increment count. Return to top of loop.
  2. If no algorithm succeeds, generate a random number between zero and forty, call it n. If the squares n and 80 - n are unfilled, fill them in in the internal puzzle and the puzzle to be displayed, and increment count. If n != 40, increment count again (as two squares would be filled). Return to top of loop.

The algorithm guarantees a unique solution because every square must either be filled at the start, or be deducible using one of the difficulty-appropriate algorithms (it may not be deducible immediately, but it must eventually be). The bug that was causing the problem was in step 2 of the algorithm, which did not originally check if the square n and 80 - n were filled before incrementing count. Thus, if the same squares were selected, count would be incremented without changes being made to the puzzle, and thus, ambiguity could arise.

from sdd-sudoku-teacher.

noitsjocelyn avatar noitsjocelyn commented on June 22, 2024

After this fix, I hit another puzzle without a unique solution. See screenshot below.

photo

from sdd-sudoku-teacher.

noitsjocelyn avatar noitsjocelyn commented on June 22, 2024

Fixed with revision 1bc2ce9

from sdd-sudoku-teacher.

noitsjocelyn avatar noitsjocelyn commented on June 22, 2024

Not totally fixed yet... This is a moderate puzzle.

photo

from sdd-sudoku-teacher.

noitsjocelyn avatar noitsjocelyn commented on June 22, 2024

I haven't seen this for a while, closing.

from sdd-sudoku-teacher.

Related Issues (12)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.