Can I create a original Sudoku problem with Schedule Nurse?
Yes, you can. You can have fun while making it.
The difficult part of creating Sudoku problems is to prove that there are no two solutions
A Sudoku problem must be uniquely determined.
There must be no other solutions.
The created problem must prove that there are no two solutions.
You can ensure that there are no two solutions in creating the problem using Schedule Nurse.
Load the Project File
File → Open Project File from GitHub
Solve it
Note we request the solver to obtain two solutions.
When you solve it, it will tell you that it cannot find a second solution.
It is a correct Sudoku problem because we get only one solution and the two solutions do not exist.
Problem Creation
Clear the schedule
Solve it
Since the schedule is a blank, there are of course two solutions. Either solution can be sent to the input.
Copied Schedules are also a sudoku solution as follows.
Since the schedules has no blanks, there are no two solutions.
Create appropriate blanks
Continue to solve while there are no two solution
Continue to make additional blanks until we get two solutions.
Add blanks if we did not get two solutions.
When two solutions exist, Undo the input to the point where the two solutions no longer exist
Verification
Here is the complete problem
Python source
Here is complete python source. The world’s shortest code.
Because GUI description has been already coded, No need to change the code, even if sudoku size becomes different (Ex. 4x4,5x5,6x6…)
import sc3
import math
if len(AllDays) !=len(shiftdef) or len(AllDays) !=len(A_Member_in_All):
raise ValueError("AllDays and shiftdef are inconsistent")
blocks=int(math.sqrt(len(AllDays)))
if math.sqrt(len(AllDays)) not in range(2,11,1):
raise ValueError("Illegal sudoku dimmension. Supported sizes are 4x4,9x9...100x100.")
for day in AllDays: #column
for shift in shiftdef.keys():
V=[]
for person in A_Member_in_All:
V.append(sc3.GetShiftVar(person,day,shift))
sc3.AddHard(sc3.SeqLE(1,1,V),'')
for person in A_Member_in_All: #row
for shift in shiftdef.keys():
V=[]
for day in AllDays:
V.append(sc3.GetShiftVar(person,day,shift))
sc3.AddHard(sc3.SeqLE(1,1,V),'')
for person in range(0,len(A_Member_in_All),blocks): #block
for shift in shiftdef.keys():
for day in range(0,len(AllDays),blocks):
V=[]
for i in range(blocks):
for j in range(blocks):
V.append(sc3.GetShiftVar(person+i,day+j,shift))
sc3.AddHard(sc3.SeqLE(1,1,V),'')
Video