![]() |
China DOS Union-- Unite DOS · Advance DOS · Grow DOS --Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum |
| Guest | Log in | Register | Members | Search | China DOS Union |
|
中国DOS联盟论坛 The time now is 2026-08-09 16:59 |
47,811 topics / 349,896 posts / today 1 new / 48,254 members |
| DOS批处理 & 脚本技术(批处理室) » [Quiz][Discussion][Sudoku] Three Steps to Solve |
| Printable Version 3,903 / 20 |
| Floor1 flyinspace | Posted 2008-08-20 11:41 |
| 银牌会员 Posts 517 Credits 1,206 | |
|
Please have those who understand Sudoku rules start solving directly from the red text part.
1. Requirement: No third-party tools are allowed to be used 2. The script can be vbs, bat: 3. All commands built into Windows XP can be used. Initially, this topic was proposed by moniuming in the forum: Discussion addresses are as follows: ------------------------------------------------------------------------------------------------ http://www.cn-dos.net/forum/viewthread.php?tid=42108&fpage=3 http://www.cn-dos.net/forum/viewthread.php?tid=42157&fpage=1 ------------------------------------------------------------------------------------------------ Due to work time constraints, I have not had time to study this topic. Now, putting aside the discussion area (the data in the discussion area does not meet the requirements), let's start our Sudoku trilogy. Sudoku rules are as follows: ******************************************************** 1. All data in each row is 1-9, no duplicates, and no unused numbers 2. All data in each column is 1-9, no duplicates, and no unused numbers. 3. In a 9*9 area, it is evenly divided into 9 3*3 small areas. In any 3*3 small area, the data is 1-9, no duplicates, and no unused numbers. ********************************************************** For example, the following is divided into 3 3*3 areas ┏━┳━┳━┳━┳━┳━┳━┳━┳━┓ ┃4 ┃7 ┃2 ┃3 ┃9 ┃6 ┃5 ┃1 ┃8 ┃ ┣━╋━╋━╋━╋━╋━╋━╋━╋━┫ ┃6 ┃8 ┃1 ┃5 ┃4 ┃7 ┃9 ┃2 ┃3 ┃ ┣━╋━╋━╋━╋━╋━╋━╋━╋━┫ ┃3 ┃5 ┃9 ┃2 ┃8 ┃1 ┃7 ┃4 ┃6 ┃ ┗━┻━┻━┻━┻━┻━┻━┻━┻━┛ I generated a 3*9 digital area, and there are no duplicate phenomena in this 3*9 digital area. After understanding the above prerequisites, the problem comes out. First, use the Sudoku rules to generate a 9*9 Sudoku area, and the requirements are 1. The data in all rows is 1-9, no duplicates, and no unused numbers 2. The data in all 3*3 areas is 1-9, no duplicates, and no unused numbers 3. No requirements for columns Those who can complete this question, +1 point for completing item 1. +3 points for completing item 2. +5 points for completing both items 1 and 2 ---------------------------------------------------------------------- Second, use the Sudoku rules to generate a 9*9 area, and the requirements are 1. The data in all rows is 1-9, no duplicates, and no unused numbers 2. The data in all columns is 1-9, no duplicates, and no unused numbers 3. No requirements for 3*3 areas Those who can complete this question, +1 point for completing item 1. +2 points for completing item 2. +4 points for completing both items 1 and 2. ----------------------------------------------------------------------- Third, use the Sudoku rules to generate a 9*9 area, and the requirements are 1. The data in all rows and columns is 1-9, no duplicates, and no unused numbers. 2. The data in all 3*3 areas is 1-9, no duplicates, and no unused numbers. 3. A good conflict detection environment (that is, the problem of computer operation overhead) Those who complete this question, +15 points... (At this time, the Sudoku list is completed)------------------------------------------------------------------------- I have completed question three, but each time it takes a long time, the longest is more than 2 hours. If there were no screen prompts to generate the number sequence, I almost thought I was in an infinite loop. Thank you for correction, and the typo in the question has been corrected. [ Last edited by flyinspace on 2008-8-21 at 03:17 PM ] |
|
| Floor2 flyinspace | Posted 2008-08-20 11:43 |
| 银牌会员 Posts 517 Credits 1,206 | |
|
People who complete the questions, please note: which project number it is. The code is enclosed in
|
|
| Floor3 slore | Posted 2008-08-20 16:46 |
| 铂金会员 Posts 2,478 Credits 5,212 | |
|
The Dancing Links algorithm seems to be the best search algorithm. But it's really hard to implement in scripts... Still have to use the most traditional methods...
|
|
| Floor4 523066680 | Posted 2008-08-20 16:59 |
| 银牌会员 Posts 1,133 Credits 2,362 | |
|
Request slore to join the QQ group of hat (or I don't know if you are in the group). The group number is in hat's signature
|
|
| Floor5 moniuming | Posted 2008-08-20 23:55 |
| 银牌会员 Posts 574 Credits 1,335 From 广西 | |
|
Question 3, not much testing has been done yet, no problems found so far, everyone is welcome to find faults...
|
|
| Floor6 moniuming | Posted 2008-08-21 00:03 |
| 银牌会员 Posts 574 Credits 1,335 From 广西 | |
|
Just now, when testing, a problem was found. When the following situation occurs, it will fall into an infinite loop. The reason is that the first three digits of the sixth line can only take 1, 3, 9, but these three numbers have already appeared in the second column of the first three lines, ==> The infinite loop occurs...
|
|
| Floor7 moniuming | Posted 2008-08-21 00:11 |
| 银牌会员 Posts 574 Credits 1,335 From 广西 | |
|
This problem has occurred again. To solve this problem, we need to reset everything completely, and a lot of code will have to be added. Alas...
[ Last edited by moniuming on 2008-8-21 at 12:15 AM ] |
|
| Floor8 terse | Posted 2008-08-21 03:10 |
| 银牌会员 Posts 946 Credits 2,404 | |
|
### Problem 3
|
|
| Floor9 523066680 | Posted 2008-08-21 07:12 |
| 银牌会员 Posts 1,133 Credits 2,362 | |
|
Ask, the number range mentioned in the subsequent question is 0-9. There are a total of 10 numbers here. Is this confirmed?
|
|
| Floor10 slore | Posted 2008-08-21 09:25 |
| 铂金会员 Posts 2,478 Credits 5,212 | |
| Floor11 moniuming | Posted 2008-08-21 11:31 |
| 银牌会员 Posts 574 Credits 1,335 From 广西 | |
|
Correct the code on floor 6, no more infinite loops, heh...
|
|
| Floor12 flyinspace | Posted 2008-08-21 15:08 |
| 银牌会员 Posts 517 Credits 1,206 | |
|
Statistics through the following code
-------------------------- @echo off set "GetCurTime=00:00:08.17" set "GetOldTime=23:59:09.19" for /f "delims=:. tokens=1,2,3,4" %%i in ('echo %GetCurTime%') do ( set "Curhour=%%i" set "CurMin=%%j" set "CurSec=%%k" set "CurBit=%%l" ) if "%Curhour:~0,1%"=="0" set "Curhour=%Curhour:~1,1%" if "%CurMin:~0,1%"=="0" set "CurMin=%CurMin:~1,1%" if "%CurSec:~0,1%"=="0" set "CurSec=%CurSec:~1,1%" if "%CurBit:~0,1%"=="0" set "CurBit=%CurBit:~1,1%" for /f "delims=:. tokens=1,2,3,4" %%i in ('echo %GetOldTime%') do ( set "Oldhour=%%i" set "OldMin=%%j" set "OldSec=%%k" set "OldBit=%%l" ) if "%Oldhour:~0,1%"=="0" set "Oldhour=%Oldhour:~1,1%" if "%OldMin:~0,1%"=="0" set "OldMin=%OldMin:~1,1%" if "%OldSec:~0,1%"=="0" set "OldSec=%OldSec:~1,1%" if "%OldBit:~0,1%"=="0" set "OldBit=%OldBit:~1,1%" if "%Curhour%" LSS "%Oldhour%" set "Curhour=24" set /a "TotalTime=(%Curhour%-%Oldhour%)*60*60*100 + (%CurMin%-%OldMin%)*60*100+(%CurSec%-%OldSec%)*100+%CurBit%-%OldBit%" echo Total time used: %TotalTime% microseconds pause -------------------------------------------- Code on floor 9 In 1000 calculations, the longest one is 7953 microseconds On floor 12 In 1000 calculations, the longest one is 10513 microseconds If you have any questions, contact flyinspace. I modified the code program to do the statistics automatically |
|
| Floor13 flyinspace | Posted 2008-08-21 15:12 |
| 银牌会员 Posts 517 Credits 1,206 | |
|
Where did you get the algorithm from floor 9? It's amazing.
When my code is almost as long as the code from floor 9, the statistics take a long time. After adding multi - level judgments, the running time is reduced. |
|
| Floor14 523066680 | Posted 2008-08-21 15:41 |
| 银牌会员 Posts 1,133 Credits 2,362 | |
|
Maybe it's original.
Floor 12 really surprised me. I didn't even dare to look at the title. I will definitely explore your code when I have time! Remember to mark the original author, I'm saving it. [ Last edited by 523066680 on 2008-8-21 at 03:46 PM ] |
|
| Floor15 slore | Posted 2008-08-22 16:21 |
| 铂金会员 Posts 2,478 Credits 5,212 | |
Attachment: Download [ Last edited by slore on 2008-8-22 at 04:27 PM ] |
|
| 1 2 Next |
|
[ Contact the Union admin team -
中国DOS联盟 -
Standard version ] Sponsored by ifanr Inc | © 2001–2023 |