Open
Conversation
Signed-off-by: Marcus Smith <marcus@runinskrifter.net>
…HOMEPAGE/logic/ Signed-off-by: Marcus Smith <marcus@runinskrifter.net>
Signed-off-by: Marcus Smith <marcus@runinskrifter.net>
Signed-off-by: Marcus Smith <marcus@runinskrifter.net>
Signed-off-by: Marcus Smith <marcus@runinskrifter.net>
Definition taken from `aa1.pro`. Signed-off-by: Marcus Smith <marcus@runinskrifter.net>
… not implemented, in `buffalo.pro` Definition for write_list\1 taken from `bibmm.pro` Signed-off-by: Marcus Smith <marcus@runinskrifter.net>
…irst/2 was intended. Signed-off-by: Marcus Smith <marcus@runinskrifter.net>
…t is deprecated in favour of \+. Signed-off-by: Marcus Smith <marcus@runinskrifter.net>
… leading to multiple reported solutions where there should only be one. Signed-off-by: Marcus Smith <marcus@runinskrifter.net>
Signed-off-by: Marcus Smith <marcus@runinskrifter.net>
- Singleton variable Son_F should be Son_S - Inconsistent spelling of 'tailor' (as 'taylor') causes errors - Both puzzle and solution have an unstated premise, namely that no fathers have the same profession, and no sons have the same profession (i.e. each profession occurs exactly once within those groups). This causes a significant number of incorrect solutions. Fixed by asserting is_set/1 for each group. - Nonetheless, the puzzle is still ambiguous, and four alternative solutions are produced. Signed-off-by: Marcus Smith <marcus@runinskrifter.net>
…olutions to repeat the starting position unnecessarily.. Signed-off-by: Marcus Smith <marcus@runinskrifter.net>
…oes this for us anyway. Signed-off-by: Marcus Smith <marcus@runinskrifter.net>
Nonetheless, multiple valid solutions are produced. Suspect the puzzle may be incomplete. Signed-off-by: Marcus Smith <marcus@runinskrifter.net>
… house is to the right of the white house, not merely near it. This gave two alternative solutions, where there should only be one. Signed-off-by: Marcus Smith <marcus@runinskrifter.net>
…nd has singletom variables G & W for girls, which should be the same. Also changed variable names för boys' costumes for consistency. Signed-off-by: Marcus Smith <marcus@runinskrifter.net>
Signed-off-by: Marcus Smith <marcus@runinskrifter.net>
Signed-off-by: Marcus Smith <marcus@runinskrifter.net>
…s are output. Since there is no argument to start/0, the toplevel didn't backtrack to try other permutations, outputting only one. Signed-off-by: Marcus Smith <marcus@runinskrifter.net>
Signed-off-by: Marcus Smith <marcus@runinskrifter.net>
Signed-off-by: Marcus Smith <marcus@runinskrifter.net>
…u.pro` These caused partial solutions to be printed with non-ground values. Signed-off-by: Marcus Smith <marcus@runinskrifter.net>
Signed-off-by: Marcus Smith <marcus@runinskrifter.net>
- write_square/1 not called until the end, so incomplete solutions with ungrounded variables are no longer output; - different/2 corrected to work as described and properly account for ungrounded variables; - good/2 and different/2 constraints applied consistently for all rows; NB. This is still an extremely slow sudoku solver which essentially brute-forces the puzzle. Difficult to recommend even for pedagogical purposes. Signed-off-by: Marcus Smith <marcus@runinskrifter.net>
List order was not normalised, leading to unintentional inequality in comparision. Signed-off-by: Marcus Smith <marcus@runinskrifter.net>
Signed-off-by: Marcus Smith <marcus@runinskrifter.net>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR addresses syntax errors and missing puzzle constraints that cause the programs to fail in various ways.
Changes in summary:
knight.prophone.proqueen2.proriver.proseating.prosecretNumber.prosoccer.pro_;not/1(deprecated) with\+/1or\=/2;assert/1(deprecated) withassertz/1;name/2(deprecated) withatom_codes/2;sumlist/2(deprecated) withsum_list/2;aa6.pro: Removed dangling close-bracket (syntax error);anagram.pro: Appendedfalse/0to ensure all solutions are found;buffalo.pro:write_list/1(called but not defined);costume.pro:before/3(called but not defined);girl/1and added 'tess' per the puzzle description;flashlight2.pro: Appliedmsort/2to normalise order for list comparisons so thatflashlight2.proandflashlight.proboth find the same two solutions;gradepuzzle.pro: Renamed predicatebest/2(not defined) tofirst/2;jazz.pro: Added missing clauses for the puzzle's final restriction;jobs1.pro:Son_Fcorrected toSon_S;is_set/1for both fathers and sons as an unstated premise of the puzzle;knight.pro: InitialisedPathto the empty list rather than the start node to avoid unnecessary duplication;queen2.pro: Added missing predicate colon (syntax error);secretNumber.pro: Removedwrite/1since the toplevel prints the solution anyway;sudoku.pro:write_square/1;sudokuSolver.pro:write_square/1;different/2to work as described and properly account for ungrounded variables;good/2anddifferent/2constraints consistently for all rows;writer.pro: Added constraints present in the puzzle description but missing from the code; nonetheless, the puzzle is still ambiguous, and multiple alternative solutions are produced.zebra.pro: Corrected the the green house to be to the right of the white house, not merely near it (produced multiple solutions);I've been using these puzzles to help me teach myself Prolog – thank you so much for sharing them online! They've been extremely useful. I didn't initially intend to fix – or even find! – any bugs, just to read and learn from the code. But over time, working out why the code sometimes didn't work and how to fix it became even more instructive. This PR is submitted in a constructive spirit of appreciation, not as criticism.
This PR includes only bugfixes, but otherwise leaves the files as they are. I have other branches at https://github.com/carwash/PrologPuzzles which incorporate changes in code formatting/style and consistency, as well as adding your logic puzzle solving library
bibmm.pro. These are not included with this PR, as formatting is a matter of taste. But if you'd also like to incorporate those changes in a separate PR, let me know.Thanks again for providing this useful resource!
/Marcus