Python Forum
Cross word puzzle solve using python constraint library
Thread Rating:
  • 1 Vote(s) - 3 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Cross word puzzle solve using python constraint library
#2
The documentation for problem.addVariable always shows items in list as numerics, never strings, although I don't see any constraints on doing so:
Output:
addVariable(self, variable, domain) Add a variable to the problem Example: >>> problem = Problem() >>> problem.addVariable("a", [1, 2]) >>> problem.getSolution() in ({'a': 1}, {'a': 2}) True Parameters: variable - Object representing a problem variable (type=hashable object) domain - Set of items defining the possible values that the given variable may assume (type=list, tuple, or instance of Domain) addVariables(self, variables, domain) Add one or more variables to the problem Example: >>> problem = Problem() >>> problem.addVariables(["a", "b"], [1, 2, 3]) >>> solutions = problem.getSolutions() >>> len(solutions) 9 >>> {'a': 3, 'b': 1} in solutions True Parameters: variables - Any object containing a sequence of objects represeting problem variables (type=sequence of hashable objects) domain - Set of items defining the possible values that the given variables may assume (type=list, tuple, or instance of Domain)
If that were an issue, I would expect it to be documented, but don't see it.

I found the example of building a crossword which uses constraints: http://www.cromulentrambling.com/2017/01...ython.html
Please note that the author builds problem thusly:
problem.addVariables(list(range(s*s)), [0,1])
again with a list of numerics for domain.
Reply


Messages In This Thread
RE: Cross word puzzle solve using python constraint library - by Larz60+ - Nov-29-2018, 10:53 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  How to solve this problem Python configuration? magomes 5 749 Mar-22-2024, 11:11 PM
Last Post: magomes
  Two Python problems to solve djzsp 1 551 Mar-17-2024, 01:18 AM
Last Post: deanhystad
  Constraint function tman 4 1,429 Dec-27-2022, 01:52 PM
Last Post: ndc85430
  How to solve pancake flip with Python longmen 5 2,192 May-09-2022, 05:16 PM
Last Post: deanhystad
Star Interesting Intro to python problem I can't solve. Honestworker 5 12,498 Mar-04-2021, 02:05 AM
Last Post: BashBedlam
  solve probability problem by python Dreammer 1 1,928 Dec-24-2020, 09:51 AM
Last Post: Larz60+
  8 puzzle game aliyark145 4 10,809 May-30-2020, 05:54 PM
Last Post: Alkis
  A sign-Reversal Puzzle HY2000 2 2,541 Dec-05-2019, 11:55 AM
Last Post: HY2000
  Simple Eight-Puzzle not working! BenjaminDJ 2 3,271 May-04-2018, 12:17 PM
Last Post: BenjaminDJ
  help with cross Item97 27 11,681 Nov-28-2017, 09:18 PM
Last Post: Item97

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020