Hard Sudoku Puzzle Creation Algorithm in quadratic time Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Announcing the arrival of Valued Associate #679: Cesar Manara Unicorn Meta Zoo #1: Why another podcast?Sudoku solving algorithm - Revision neededNumber-to-word converterSudoku Puzzle GeneratorSudoku Puzzle SolverAlberi puzzle creator - follow-upAlberi creator. Keepalivegoogle foo.bar max path algorithm puzzle optimizationGeneralized Project Euler 2: A sledgehammer to crack a nutTime complexity of common ancestor algorithmEnhance Sudoku puzzle generator

Co-worker has annoying ringtone

How were pictures turned from film to a big picture in a picture frame before digital scanning?

Lagrange four-squares theorem --- deterministic complexity

Why weren't discrete x86 CPUs ever used in game hardware?

What order were files/directories output in dir?

Do wooden building fires get hotter than 600°C?

macOS: Name for app shortcut screen found by pinching with thumb and three fingers

Karn the great creator - 'card from outside the game' in sealed

Why are my pictures showing a dark band on one edge?

What is the chair depicted in Cesare Maccari's 1889 painting "Cicerone denuncia Catilina"?

How do I find out the mythology and history of my Fortress?

How many time has Arya actually used Needle?

Did Mueller's report provide an evidentiary basis for the claim of Russian govt election interference via social media?

Central Vacuuming: Is it worth it, and how does it compare to normal vacuuming?

What makes a man succeed?

How many morphisms from 1 to 1+1 can there be?

AppleTVs create a chatty alternate WiFi network

How did Fremen produce and carry enough thumpers to use Sandworms as de facto Ubers?

Trademark violation for app?

Is the IBM 5153 color display compatible with the Tandy 1000 16 color modes?

Crossing US/Canada Border for less than 24 hours

Draw 4 of the same figure in the same tikzpicture

How to identify unknown coordinate type and convert to lat/lon?

Deconstruction is ambiguous



Hard Sudoku Puzzle Creation Algorithm in quadratic time



Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern)
Announcing the arrival of Valued Associate #679: Cesar Manara
Unicorn Meta Zoo #1: Why another podcast?Sudoku solving algorithm - Revision neededNumber-to-word converterSudoku Puzzle GeneratorSudoku Puzzle SolverAlberi puzzle creator - follow-upAlberi creator. Keepalivegoogle foo.bar max path algorithm puzzle optimizationGeneralized Project Euler 2: A sledgehammer to crack a nutTime complexity of common ancestor algorithmEnhance Sudoku puzzle generator



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0












$begingroup$


To avoid backtracking, I've generated an algorithm with some research into a polynomial time algorithm.



Overall, I'm looking for constructive-criticism, improvement, recommendations, etc.



I've found out that if I control all parameters in the creation of a Sudoku puzzle I can generate the puzzle from a solution in quadratic time.



Here's the summary of the entire description of the algorithm. Before you get into your reading.




Step 1 Follow the grid and puzzle generation method(mentioned at the end of the question).



Step 2 Enter for input l to generate a solution before generating the
puzzle [8,5,9,6,1,2,4,3,7]



Step 3. Now generate the puzzle Example- Take the output of the complete grid and compare to the world's hardest sudoku puzzle and arrange the elements in some algorthim(paper or computer) to match the below.




--



n = 0
l = input('Enter the first solved box to get a correct solution')

note when script asks for input you must write it like this

[1,2,3,4,5,6,7,8,9]

indices = []
for i in xrange(1, 1+len(l)):
indices.append(n % i)
n //= i
indices.reverse()

perm = l
for index in indices:
perm.append(l.pop(index))
print(perm)


2nd part of algorthim not yet implemented in the script



To convert the result(which is an horizantal solution) into human readable format follow this method.



You take the first three rows from the output



[1,2,3,4,5,6,7,8,9]

[1,2,3,4,5,6,7,8,9]

[1,2,3,4,5,6,7,8,9]


and do this.... Line them up one by one side by side in this order and I'm seemingly always getting correct grids!!



Yeah, I know this isn't in right order but just to show illustration



[1,2,3]



[4,5,6]



[7,8,9]



-



[1,2,3]



[4,5,6]



[7,8,9]



-



[1,2,3]



[4,5,6]



[7,8,9]



Here's an actual output of a solution in horizontal format.



[9, 6, 1, 2, 4, 3, 7, 8, 5]

[6, 1, 2, 4, 3, 7, 8, 5, 9]

[1, 2, 4, 3, 7, 8, 5, 9, 6]

[2, 4, 3, 7, 8, 5, 9, 6, 1]

[4, 3, 7, 8, 5, 9, 6, 1, 2]

[3, 7, 8, 5, 9, 6, 1, 2, 4]

[7, 8, 5, 9, 6, 1, 2, 4, 3]

[8, 5, 9, 6, 1, 2, 4, 3, 7]

[5, 9, 6, 1, 2, 4, 3, 7, 8]


Following the aforementioned method.



You get a correct Sudoku grid. (The checker says its correct every time I've ran it) I've taken out some elements to see if there's a puzzle with 1 solution and behold.



[9 6 1][2 4 3][7 8 5]

[2 4 3][7 8 5][9 6 1]

[7 8 5][9 6 1][2 4 3]

[6 1 2][4 3 7][8 5 9]

[4 3 7][8 5 9][6 1 2]

[8 5 9][6 1 2][4 3 7]

[1 2 4][3 7 8][5 9 6]

[3 7 8][5 9 6][1 2 4]

[5 9 6][1 2 4][3 7 8]


Pseudo-code



Python2.7



>>>World-s hardest Sudoku puzzle converted in vertical format

800000000003600000070090200050007000000045700000100030001000068008500010090000400

Manipulating your generated grid to match index by index of hardest puzzle. (This is making sure there should only be 1 solution)

961243785612437859124378596243785961437859612378596124785961243859612437596124378

Poof!! string manipulation done in linear time.
900000000002400000020070500040005000000059600000500020005000043009600030090000300


(warning manual typos will happen if done by hand)



Converting into correct format with one solution only(supposedly)



-- Solve this. Warning I've probably got typos.



900 040 050
000 005 000
000 000 430

002 000 096
400 000 000
000 059 300

020 005 900
070 000 003
500 200 000


Since, I've made sure that the grids are always correct. I took a screenshot of Sudoku checker. Generating Complete Grids. Even the puzzles are seemingly always generated correctly in quadratic time.



enter image description here



Not enough testing has confirmed if every puzzle generated from this algorithm is correct, but every grid has been correct so far if you actually follow the method correctly.



http://www.birot.hu/sudoku.php










share|improve this question









$endgroup$


















    0












    $begingroup$


    To avoid backtracking, I've generated an algorithm with some research into a polynomial time algorithm.



    Overall, I'm looking for constructive-criticism, improvement, recommendations, etc.



    I've found out that if I control all parameters in the creation of a Sudoku puzzle I can generate the puzzle from a solution in quadratic time.



    Here's the summary of the entire description of the algorithm. Before you get into your reading.




    Step 1 Follow the grid and puzzle generation method(mentioned at the end of the question).



    Step 2 Enter for input l to generate a solution before generating the
    puzzle [8,5,9,6,1,2,4,3,7]



    Step 3. Now generate the puzzle Example- Take the output of the complete grid and compare to the world's hardest sudoku puzzle and arrange the elements in some algorthim(paper or computer) to match the below.




    --



    n = 0
    l = input('Enter the first solved box to get a correct solution')

    note when script asks for input you must write it like this

    [1,2,3,4,5,6,7,8,9]

    indices = []
    for i in xrange(1, 1+len(l)):
    indices.append(n % i)
    n //= i
    indices.reverse()

    perm = l
    for index in indices:
    perm.append(l.pop(index))
    print(perm)


    2nd part of algorthim not yet implemented in the script



    To convert the result(which is an horizantal solution) into human readable format follow this method.



    You take the first three rows from the output



    [1,2,3,4,5,6,7,8,9]

    [1,2,3,4,5,6,7,8,9]

    [1,2,3,4,5,6,7,8,9]


    and do this.... Line them up one by one side by side in this order and I'm seemingly always getting correct grids!!



    Yeah, I know this isn't in right order but just to show illustration



    [1,2,3]



    [4,5,6]



    [7,8,9]



    -



    [1,2,3]



    [4,5,6]



    [7,8,9]



    -



    [1,2,3]



    [4,5,6]



    [7,8,9]



    Here's an actual output of a solution in horizontal format.



    [9, 6, 1, 2, 4, 3, 7, 8, 5]

    [6, 1, 2, 4, 3, 7, 8, 5, 9]

    [1, 2, 4, 3, 7, 8, 5, 9, 6]

    [2, 4, 3, 7, 8, 5, 9, 6, 1]

    [4, 3, 7, 8, 5, 9, 6, 1, 2]

    [3, 7, 8, 5, 9, 6, 1, 2, 4]

    [7, 8, 5, 9, 6, 1, 2, 4, 3]

    [8, 5, 9, 6, 1, 2, 4, 3, 7]

    [5, 9, 6, 1, 2, 4, 3, 7, 8]


    Following the aforementioned method.



    You get a correct Sudoku grid. (The checker says its correct every time I've ran it) I've taken out some elements to see if there's a puzzle with 1 solution and behold.



    [9 6 1][2 4 3][7 8 5]

    [2 4 3][7 8 5][9 6 1]

    [7 8 5][9 6 1][2 4 3]

    [6 1 2][4 3 7][8 5 9]

    [4 3 7][8 5 9][6 1 2]

    [8 5 9][6 1 2][4 3 7]

    [1 2 4][3 7 8][5 9 6]

    [3 7 8][5 9 6][1 2 4]

    [5 9 6][1 2 4][3 7 8]


    Pseudo-code



    Python2.7



    >>>World-s hardest Sudoku puzzle converted in vertical format

    800000000003600000070090200050007000000045700000100030001000068008500010090000400

    Manipulating your generated grid to match index by index of hardest puzzle. (This is making sure there should only be 1 solution)

    961243785612437859124378596243785961437859612378596124785961243859612437596124378

    Poof!! string manipulation done in linear time.
    900000000002400000020070500040005000000059600000500020005000043009600030090000300


    (warning manual typos will happen if done by hand)



    Converting into correct format with one solution only(supposedly)



    -- Solve this. Warning I've probably got typos.



    900 040 050
    000 005 000
    000 000 430

    002 000 096
    400 000 000
    000 059 300

    020 005 900
    070 000 003
    500 200 000


    Since, I've made sure that the grids are always correct. I took a screenshot of Sudoku checker. Generating Complete Grids. Even the puzzles are seemingly always generated correctly in quadratic time.



    enter image description here



    Not enough testing has confirmed if every puzzle generated from this algorithm is correct, but every grid has been correct so far if you actually follow the method correctly.



    http://www.birot.hu/sudoku.php










    share|improve this question









    $endgroup$














      0












      0








      0





      $begingroup$


      To avoid backtracking, I've generated an algorithm with some research into a polynomial time algorithm.



      Overall, I'm looking for constructive-criticism, improvement, recommendations, etc.



      I've found out that if I control all parameters in the creation of a Sudoku puzzle I can generate the puzzle from a solution in quadratic time.



      Here's the summary of the entire description of the algorithm. Before you get into your reading.




      Step 1 Follow the grid and puzzle generation method(mentioned at the end of the question).



      Step 2 Enter for input l to generate a solution before generating the
      puzzle [8,5,9,6,1,2,4,3,7]



      Step 3. Now generate the puzzle Example- Take the output of the complete grid and compare to the world's hardest sudoku puzzle and arrange the elements in some algorthim(paper or computer) to match the below.




      --



      n = 0
      l = input('Enter the first solved box to get a correct solution')

      note when script asks for input you must write it like this

      [1,2,3,4,5,6,7,8,9]

      indices = []
      for i in xrange(1, 1+len(l)):
      indices.append(n % i)
      n //= i
      indices.reverse()

      perm = l
      for index in indices:
      perm.append(l.pop(index))
      print(perm)


      2nd part of algorthim not yet implemented in the script



      To convert the result(which is an horizantal solution) into human readable format follow this method.



      You take the first three rows from the output



      [1,2,3,4,5,6,7,8,9]

      [1,2,3,4,5,6,7,8,9]

      [1,2,3,4,5,6,7,8,9]


      and do this.... Line them up one by one side by side in this order and I'm seemingly always getting correct grids!!



      Yeah, I know this isn't in right order but just to show illustration



      [1,2,3]



      [4,5,6]



      [7,8,9]



      -



      [1,2,3]



      [4,5,6]



      [7,8,9]



      -



      [1,2,3]



      [4,5,6]



      [7,8,9]



      Here's an actual output of a solution in horizontal format.



      [9, 6, 1, 2, 4, 3, 7, 8, 5]

      [6, 1, 2, 4, 3, 7, 8, 5, 9]

      [1, 2, 4, 3, 7, 8, 5, 9, 6]

      [2, 4, 3, 7, 8, 5, 9, 6, 1]

      [4, 3, 7, 8, 5, 9, 6, 1, 2]

      [3, 7, 8, 5, 9, 6, 1, 2, 4]

      [7, 8, 5, 9, 6, 1, 2, 4, 3]

      [8, 5, 9, 6, 1, 2, 4, 3, 7]

      [5, 9, 6, 1, 2, 4, 3, 7, 8]


      Following the aforementioned method.



      You get a correct Sudoku grid. (The checker says its correct every time I've ran it) I've taken out some elements to see if there's a puzzle with 1 solution and behold.



      [9 6 1][2 4 3][7 8 5]

      [2 4 3][7 8 5][9 6 1]

      [7 8 5][9 6 1][2 4 3]

      [6 1 2][4 3 7][8 5 9]

      [4 3 7][8 5 9][6 1 2]

      [8 5 9][6 1 2][4 3 7]

      [1 2 4][3 7 8][5 9 6]

      [3 7 8][5 9 6][1 2 4]

      [5 9 6][1 2 4][3 7 8]


      Pseudo-code



      Python2.7



      >>>World-s hardest Sudoku puzzle converted in vertical format

      800000000003600000070090200050007000000045700000100030001000068008500010090000400

      Manipulating your generated grid to match index by index of hardest puzzle. (This is making sure there should only be 1 solution)

      961243785612437859124378596243785961437859612378596124785961243859612437596124378

      Poof!! string manipulation done in linear time.
      900000000002400000020070500040005000000059600000500020005000043009600030090000300


      (warning manual typos will happen if done by hand)



      Converting into correct format with one solution only(supposedly)



      -- Solve this. Warning I've probably got typos.



      900 040 050
      000 005 000
      000 000 430

      002 000 096
      400 000 000
      000 059 300

      020 005 900
      070 000 003
      500 200 000


      Since, I've made sure that the grids are always correct. I took a screenshot of Sudoku checker. Generating Complete Grids. Even the puzzles are seemingly always generated correctly in quadratic time.



      enter image description here



      Not enough testing has confirmed if every puzzle generated from this algorithm is correct, but every grid has been correct so far if you actually follow the method correctly.



      http://www.birot.hu/sudoku.php










      share|improve this question









      $endgroup$




      To avoid backtracking, I've generated an algorithm with some research into a polynomial time algorithm.



      Overall, I'm looking for constructive-criticism, improvement, recommendations, etc.



      I've found out that if I control all parameters in the creation of a Sudoku puzzle I can generate the puzzle from a solution in quadratic time.



      Here's the summary of the entire description of the algorithm. Before you get into your reading.




      Step 1 Follow the grid and puzzle generation method(mentioned at the end of the question).



      Step 2 Enter for input l to generate a solution before generating the
      puzzle [8,5,9,6,1,2,4,3,7]



      Step 3. Now generate the puzzle Example- Take the output of the complete grid and compare to the world's hardest sudoku puzzle and arrange the elements in some algorthim(paper or computer) to match the below.




      --



      n = 0
      l = input('Enter the first solved box to get a correct solution')

      note when script asks for input you must write it like this

      [1,2,3,4,5,6,7,8,9]

      indices = []
      for i in xrange(1, 1+len(l)):
      indices.append(n % i)
      n //= i
      indices.reverse()

      perm = l
      for index in indices:
      perm.append(l.pop(index))
      print(perm)


      2nd part of algorthim not yet implemented in the script



      To convert the result(which is an horizantal solution) into human readable format follow this method.



      You take the first three rows from the output



      [1,2,3,4,5,6,7,8,9]

      [1,2,3,4,5,6,7,8,9]

      [1,2,3,4,5,6,7,8,9]


      and do this.... Line them up one by one side by side in this order and I'm seemingly always getting correct grids!!



      Yeah, I know this isn't in right order but just to show illustration



      [1,2,3]



      [4,5,6]



      [7,8,9]



      -



      [1,2,3]



      [4,5,6]



      [7,8,9]



      -



      [1,2,3]



      [4,5,6]



      [7,8,9]



      Here's an actual output of a solution in horizontal format.



      [9, 6, 1, 2, 4, 3, 7, 8, 5]

      [6, 1, 2, 4, 3, 7, 8, 5, 9]

      [1, 2, 4, 3, 7, 8, 5, 9, 6]

      [2, 4, 3, 7, 8, 5, 9, 6, 1]

      [4, 3, 7, 8, 5, 9, 6, 1, 2]

      [3, 7, 8, 5, 9, 6, 1, 2, 4]

      [7, 8, 5, 9, 6, 1, 2, 4, 3]

      [8, 5, 9, 6, 1, 2, 4, 3, 7]

      [5, 9, 6, 1, 2, 4, 3, 7, 8]


      Following the aforementioned method.



      You get a correct Sudoku grid. (The checker says its correct every time I've ran it) I've taken out some elements to see if there's a puzzle with 1 solution and behold.



      [9 6 1][2 4 3][7 8 5]

      [2 4 3][7 8 5][9 6 1]

      [7 8 5][9 6 1][2 4 3]

      [6 1 2][4 3 7][8 5 9]

      [4 3 7][8 5 9][6 1 2]

      [8 5 9][6 1 2][4 3 7]

      [1 2 4][3 7 8][5 9 6]

      [3 7 8][5 9 6][1 2 4]

      [5 9 6][1 2 4][3 7 8]


      Pseudo-code



      Python2.7



      >>>World-s hardest Sudoku puzzle converted in vertical format

      800000000003600000070090200050007000000045700000100030001000068008500010090000400

      Manipulating your generated grid to match index by index of hardest puzzle. (This is making sure there should only be 1 solution)

      961243785612437859124378596243785961437859612378596124785961243859612437596124378

      Poof!! string manipulation done in linear time.
      900000000002400000020070500040005000000059600000500020005000043009600030090000300


      (warning manual typos will happen if done by hand)



      Converting into correct format with one solution only(supposedly)



      -- Solve this. Warning I've probably got typos.



      900 040 050
      000 005 000
      000 000 430

      002 000 096
      400 000 000
      000 059 300

      020 005 900
      070 000 003
      500 200 000


      Since, I've made sure that the grids are always correct. I took a screenshot of Sudoku checker. Generating Complete Grids. Even the puzzles are seemingly always generated correctly in quadratic time.



      enter image description here



      Not enough testing has confirmed if every puzzle generated from this algorithm is correct, but every grid has been correct so far if you actually follow the method correctly.



      http://www.birot.hu/sudoku.php







      python






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked 14 mins ago









      Travis WellsTravis Wells

      113




      113




















          0






          active

          oldest

          votes












          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "196"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f217759%2fhard-sudoku-puzzle-creation-algorithm-in-quadratic-time%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Code Review Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          Use MathJax to format equations. MathJax reference.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f217759%2fhard-sudoku-puzzle-creation-algorithm-in-quadratic-time%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          名間水力發電廠 目录 沿革 設施 鄰近設施 註釋 外部連結 导航菜单23°50′10″N 120°42′41″E / 23.83611°N 120.71139°E / 23.83611; 120.7113923°50′10″N 120°42′41″E / 23.83611°N 120.71139°E / 23.83611; 120.71139計畫概要原始内容臺灣第一座BOT 模式開發的水力發電廠-名間水力電廠名間水力發電廠 水利署首件BOT案原始内容《小檔案》名間電廠 首座BOT水力發電廠原始内容名間電廠BOT - 經濟部水利署中區水資源局

          Prove that NP is closed under karp reduction?Space(n) not closed under Karp reductions - what about NTime(n)?Class P is closed under rotation?Prove or disprove that $NL$ is closed under polynomial many-one reductions$mathbfNC_2$ is closed under log-space reductionOn Karp reductionwhen can I know if a class (complexity) is closed under reduction (cook/karp)Check if class $PSPACE$ is closed under polyonomially space reductionIs NPSPACE also closed under polynomial-time reduction and under log-space reduction?Prove PSPACE is closed under complement?Prove PSPACE is closed under union?

          Is my guitar’s action too high? Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern)Strings too stiff on a recently purchased acoustic guitar | Cort AD880CEIs the action of my guitar really high?Μy little finger is too weak to play guitarWith guitar, how long should I give my fingers to strengthen / callous?When playing a fret the guitar sounds mutedPlaying (Barre) chords up the guitar neckI think my guitar strings are wound too tight and I can't play barre chordsF barre chord on an SG guitarHow to find to the right strings of a barre chord by feel?High action on higher fret on my steel acoustic guitar