├── Simple-sudoku-master
├── app
│ ├── .gitignore
│ ├── src
│ │ ├── main
│ │ │ ├── res
│ │ │ │ ├── values
│ │ │ │ │ ├── strings.xml
│ │ │ │ │ ├── dimens.xml
│ │ │ │ │ ├── colors.xml
│ │ │ │ │ └── styles.xml
│ │ │ │ ├── mipmap-hdpi
│ │ │ │ │ └── ic_launcher.png
│ │ │ │ ├── mipmap-mdpi
│ │ │ │ │ └── ic_launcher.png
│ │ │ │ ├── mipmap-xhdpi
│ │ │ │ │ └── ic_launcher.png
│ │ │ │ ├── mipmap-xxhdpi
│ │ │ │ │ └── ic_launcher.png
│ │ │ │ ├── mipmap-xxxhdpi
│ │ │ │ │ └── ic_launcher.png
│ │ │ │ ├── layout
│ │ │ │ │ ├── activity_main.xml
│ │ │ │ │ └── item_choose_layout.xml
│ │ │ │ └── values-w820dp
│ │ │ │ │ └── dimens.xml
│ │ │ ├── java
│ │ │ │ └── com
│ │ │ │ │ └── example
│ │ │ │ │ └── jobs
│ │ │ │ │ └── newsudo
│ │ │ │ │ ├── MainActivity.java
│ │ │ │ │ └── Sudo.java
│ │ │ └── AndroidManifest.xml
│ │ ├── test
│ │ │ └── java
│ │ │ │ └── com
│ │ │ │ └── example
│ │ │ │ └── jobs
│ │ │ │ └── newsudo
│ │ │ │ └── ExampleUnitTest.java
│ │ └── androidTest
│ │ │ └── java
│ │ │ └── com
│ │ │ └── example
│ │ │ └── jobs
│ │ │ └── newsudo
│ │ │ └── ExampleInstrumentedTest.java
│ ├── proguard-rules.pro
│ └── build.gradle
├── settings.gradle
├── README.md
├── .idea
│ ├── copyright
│ │ └── profiles_settings.xml
│ ├── caches
│ │ ├── gradle_models.ser
│ │ └── build_file_checksums.ser
│ ├── encodings.xml
│ ├── vcs.xml
│ ├── modules.xml
│ ├── runConfigurations.xml
│ ├── gradle.xml
│ ├── compiler.xml
│ ├── misc.xml
│ └── codeStyles
│ │ └── Project.xml
├── gradle
│ └── wrapper
│ │ ├── gradle-wrapper.jar
│ │ └── gradle-wrapper.properties
├── .gitignore
├── build.gradle
├── gradle.properties
├── gradlew.bat
└── gradlew
├── SudokuApp-GS
└── Sudoku
│ ├── app
│ ├── .gitignore
│ ├── src
│ │ ├── main
│ │ │ ├── ic_launcher-web.png
│ │ │ ├── res
│ │ │ │ ├── mipmap-hdpi
│ │ │ │ │ ├── ic_launcher.png
│ │ │ │ │ ├── ic_launcher_round.png
│ │ │ │ │ └── ic_launcher_foreground.png
│ │ │ │ ├── mipmap-mdpi
│ │ │ │ │ ├── ic_launcher.png
│ │ │ │ │ ├── ic_launcher_round.png
│ │ │ │ │ └── ic_launcher_foreground.png
│ │ │ │ ├── mipmap-xhdpi
│ │ │ │ │ ├── ic_launcher.png
│ │ │ │ │ ├── ic_launcher_round.png
│ │ │ │ │ └── ic_launcher_foreground.png
│ │ │ │ ├── mipmap-xxhdpi
│ │ │ │ │ ├── ic_launcher.png
│ │ │ │ │ ├── ic_launcher_round.png
│ │ │ │ │ └── ic_launcher_foreground.png
│ │ │ │ ├── mipmap-xxxhdpi
│ │ │ │ │ ├── ic_launcher.png
│ │ │ │ │ ├── ic_launcher_round.png
│ │ │ │ │ └── ic_launcher_foreground.png
│ │ │ │ ├── values
│ │ │ │ │ ├── colors.xml
│ │ │ │ │ ├── dimens.xml
│ │ │ │ │ ├── attrs.xml
│ │ │ │ │ ├── styles.xml
│ │ │ │ │ └── strings.xml
│ │ │ │ ├── drawable
│ │ │ │ │ ├── focus.xml
│ │ │ │ │ ├── wrong_box.xml
│ │ │ │ │ ├── border.xml
│ │ │ │ │ ├── option_background.xml
│ │ │ │ │ ├── border_selected.xml
│ │ │ │ │ ├── ic_play_arrow_black_24dp.xml
│ │ │ │ │ ├── ic_pause_black_24dp.xml
│ │ │ │ │ ├── ic_equalizer_black_12dp.xml
│ │ │ │ │ ├── ic_star_black_24dp.xml
│ │ │ │ │ ├── ic_create_black_24dp.xml
│ │ │ │ │ ├── ic_info_outline_black_12dp.xml
│ │ │ │ │ ├── ic_star_border_black_24dp.xml
│ │ │ │ │ ├── ic_restore_black_24dp.xml
│ │ │ │ │ ├── ic_timer_black_12dp.xml
│ │ │ │ │ ├── ic_timer_black_24dp.xml
│ │ │ │ │ ├── ic_person_outline_black_12dp.xml
│ │ │ │ │ ├── ic_iconmonstr_eraser_2.xml
│ │ │ │ │ ├── ic_iconmonstr_light_bulb_18.xml
│ │ │ │ │ └── ic_launcher_background.xml
│ │ │ │ ├── mipmap-anydpi-v26
│ │ │ │ │ ├── ic_launcher.xml
│ │ │ │ │ └── ic_launcher_round.xml
│ │ │ │ ├── anim
│ │ │ │ │ ├── rotateundo.xml
│ │ │ │ │ ├── moveerase.xml
│ │ │ │ │ └── scalenote.xml
│ │ │ │ ├── layout
│ │ │ │ │ ├── activity_history.xml
│ │ │ │ │ ├── activity_main.xml
│ │ │ │ │ ├── activity_choose_type.xml
│ │ │ │ │ ├── activity_login.xml
│ │ │ │ │ └── history_item.xml
│ │ │ │ └── drawable-v24
│ │ │ │ │ └── ic_launcher_foreground.xml
│ │ │ ├── assets
│ │ │ │ └── litepal.xml
│ │ │ ├── java
│ │ │ │ └── com
│ │ │ │ │ └── example
│ │ │ │ │ └── sudoku
│ │ │ │ │ ├── UserAction
│ │ │ │ │ ├── EnterAction.java
│ │ │ │ │ ├── EraseAction.java
│ │ │ │ │ ├── ReplaceAction.java
│ │ │ │ │ └── UserAction.java
│ │ │ │ │ ├── userInfo.java
│ │ │ │ │ ├── dlx
│ │ │ │ │ ├── SudokuHandler.java
│ │ │ │ │ ├── DancingLinks.java
│ │ │ │ │ └── GenerateBoard.java
│ │ │ │ │ ├── SudokuTextView.java
│ │ │ │ │ ├── MD5.java
│ │ │ │ │ ├── History.java
│ │ │ │ │ ├── MainActivity.java
│ │ │ │ │ ├── GameRecord.java
│ │ │ │ │ ├── SudokuGrid.java
│ │ │ │ │ ├── LastRecord.java
│ │ │ │ │ ├── ChooseLevel.java
│ │ │ │ │ ├── ChooseType.java
│ │ │ │ │ ├── HistoryItemAdapter.java
│ │ │ │ │ └── login.java
│ │ │ └── AndroidManifest.xml
│ │ ├── test
│ │ │ └── java
│ │ │ │ └── com
│ │ │ │ └── example
│ │ │ │ └── sudoku
│ │ │ │ └── ExampleUnitTest.java
│ │ └── androidTest
│ │ │ └── java
│ │ │ └── com
│ │ │ └── example
│ │ │ └── sudoku
│ │ │ └── ExampleInstrumentedTest.java
│ ├── proguard-rules.pro
│ └── build.gradle
│ ├── settings.gradle
│ ├── gradle
│ └── wrapper
│ │ ├── gradle-wrapper.jar
│ │ └── gradle-wrapper.properties
│ ├── .gitignore
│ ├── .idea
│ ├── runConfigurations.xml
│ ├── gradle.xml
│ ├── misc.xml
│ └── codeStyles
│ │ └── Project.xml
│ ├── build.gradle
│ ├── gradle.properties
│ ├── gradlew.bat
│ └── gradlew
├── newSudoku
├── .idea
│ ├── .gitignore
│ ├── vcs.xml
│ ├── misc.xml
│ ├── modules.xml
│ └── $PRODUCT_WORKSPACE_FILE$
├── Sudoku_Guide.md
├── SudokuDLXTest.java
├── dlx
│ ├── SudokuHandler.java
│ ├── GenerateBoard.java
│ ├── DancingLinks.java
│ └── SudokuDLX.java
└── dlxTest.java
├── Sudoku
└── dlx
│ ├── .idea
│ ├── .gitignore
│ ├── vcs.xml
│ ├── misc.xml
│ ├── modules.xml
│ └── $PRODUCT_WORKSPACE_FILE$
│ ├── dlx
│ ├── SolutionHandler.java
│ ├── SudokuDLX.java
│ ├── AbstractSudokuSolver.java
│ ├── GenerateBoard.java
│ └── DancingLinks.java
│ └── dlxTest.java
├── imgs
├── 九宫.png
├── 历史.png
└── 四宫.png
├── 新建文本文档.txt
├── dancing-color.ps.pdf
├── 2019《软件工程》项目任务书(2017级).docx
├── 《软件工程》项目报告撰写内容及规范化参考样本.docx
├── assignment
├── 2019《软件工程》项目任务书(2017级).docx
└── 《软件工程》项目报告撰写内容及规范化参考样本.docx
├── DailyRecord.md
├── NABCD.md
├── .gitignore
└── README.md
/Simple-sudoku-master/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/SudokuApp-GS/Sudoku/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/Simple-sudoku-master/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------
/newSudoku/.idea/.gitignore:
--------------------------------------------------------------------------------
1 | # Default ignored files
2 | /workspace.xml
--------------------------------------------------------------------------------
/Sudoku/dlx/.idea/.gitignore:
--------------------------------------------------------------------------------
1 | # Default ignored files
2 | /workspace.xml
--------------------------------------------------------------------------------
/Simple-sudoku-master/README.md:
--------------------------------------------------------------------------------
1 | # Simple-sudoku
2 |
3 | 这个是我在 CSDN 上的博文写的简单数独实现的代码。
4 |
--------------------------------------------------------------------------------
/SudokuApp-GS/Sudoku/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 | rootProject.name='Sudoku'
3 |
--------------------------------------------------------------------------------
/imgs/九宫.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HUSTERGS/SoftwareEngineeringProject/HEAD/imgs/九宫.png
--------------------------------------------------------------------------------
/imgs/历史.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HUSTERGS/SoftwareEngineeringProject/HEAD/imgs/历史.png
--------------------------------------------------------------------------------
/imgs/四宫.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HUSTERGS/SoftwareEngineeringProject/HEAD/imgs/四宫.png
--------------------------------------------------------------------------------
/新建文本文档.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HUSTERGS/SoftwareEngineeringProject/HEAD/新建文本文档.txt
--------------------------------------------------------------------------------
/dancing-color.ps.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HUSTERGS/SoftwareEngineeringProject/HEAD/dancing-color.ps.pdf
--------------------------------------------------------------------------------
/2019《软件工程》项目任务书(2017级).docx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HUSTERGS/SoftwareEngineeringProject/HEAD/2019《软件工程》项目任务书(2017级).docx
--------------------------------------------------------------------------------
/《软件工程》项目报告撰写内容及规范化参考样本.docx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HUSTERGS/SoftwareEngineeringProject/HEAD/《软件工程》项目报告撰写内容及规范化参考样本.docx
--------------------------------------------------------------------------------
/Simple-sudoku-master/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | NewSudo
3 |
4 |
--------------------------------------------------------------------------------
/Simple-sudoku-master/.idea/copyright/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/assignment/2019《软件工程》项目任务书(2017级).docx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HUSTERGS/SoftwareEngineeringProject/HEAD/assignment/2019《软件工程》项目任务书(2017级).docx
--------------------------------------------------------------------------------
/assignment/《软件工程》项目报告撰写内容及规范化参考样本.docx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HUSTERGS/SoftwareEngineeringProject/HEAD/assignment/《软件工程》项目报告撰写内容及规范化参考样本.docx
--------------------------------------------------------------------------------
/Simple-sudoku-master/.idea/caches/gradle_models.ser:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HUSTERGS/SoftwareEngineeringProject/HEAD/Simple-sudoku-master/.idea/caches/gradle_models.ser
--------------------------------------------------------------------------------
/SudokuApp-GS/Sudoku/app/src/main/ic_launcher-web.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HUSTERGS/SoftwareEngineeringProject/HEAD/SudokuApp-GS/Sudoku/app/src/main/ic_launcher-web.png
--------------------------------------------------------------------------------
/SudokuApp-GS/Sudoku/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HUSTERGS/SoftwareEngineeringProject/HEAD/SudokuApp-GS/Sudoku/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/Simple-sudoku-master/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HUSTERGS/SoftwareEngineeringProject/HEAD/Simple-sudoku-master/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/Simple-sudoku-master/.idea/caches/build_file_checksums.ser:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HUSTERGS/SoftwareEngineeringProject/HEAD/Simple-sudoku-master/.idea/caches/build_file_checksums.ser
--------------------------------------------------------------------------------
/Simple-sudoku-master/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/workspace.xml
5 | /.idea/libraries
6 | .DS_Store
7 | /build
8 | /captures
9 | .externalNativeBuild
10 |
--------------------------------------------------------------------------------
/Simple-sudoku-master/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HUSTERGS/SoftwareEngineeringProject/HEAD/Simple-sudoku-master/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/Simple-sudoku-master/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HUSTERGS/SoftwareEngineeringProject/HEAD/Simple-sudoku-master/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/Simple-sudoku-master/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HUSTERGS/SoftwareEngineeringProject/HEAD/Simple-sudoku-master/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/SudokuApp-GS/Sudoku/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HUSTERGS/SoftwareEngineeringProject/HEAD/SudokuApp-GS/Sudoku/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/SudokuApp-GS/Sudoku/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HUSTERGS/SoftwareEngineeringProject/HEAD/SudokuApp-GS/Sudoku/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/SudokuApp-GS/Sudoku/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HUSTERGS/SoftwareEngineeringProject/HEAD/SudokuApp-GS/Sudoku/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/SudokuApp-GS/Sudoku/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HUSTERGS/SoftwareEngineeringProject/HEAD/SudokuApp-GS/Sudoku/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/Simple-sudoku-master/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HUSTERGS/SoftwareEngineeringProject/HEAD/Simple-sudoku-master/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/Simple-sudoku-master/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HUSTERGS/SoftwareEngineeringProject/HEAD/Simple-sudoku-master/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/SudokuApp-GS/Sudoku/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HUSTERGS/SoftwareEngineeringProject/HEAD/SudokuApp-GS/Sudoku/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/SudokuApp-GS/Sudoku/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HUSTERGS/SoftwareEngineeringProject/HEAD/SudokuApp-GS/Sudoku/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/SudokuApp-GS/Sudoku/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HUSTERGS/SoftwareEngineeringProject/HEAD/SudokuApp-GS/Sudoku/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/SudokuApp-GS/Sudoku/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HUSTERGS/SoftwareEngineeringProject/HEAD/SudokuApp-GS/Sudoku/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/SudokuApp-GS/Sudoku/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HUSTERGS/SoftwareEngineeringProject/HEAD/SudokuApp-GS/Sudoku/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/SudokuApp-GS/Sudoku/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HUSTERGS/SoftwareEngineeringProject/HEAD/SudokuApp-GS/Sudoku/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/Simple-sudoku-master/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/SudokuApp-GS/Sudoku/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HUSTERGS/SoftwareEngineeringProject/HEAD/SudokuApp-GS/Sudoku/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/SudokuApp-GS/Sudoku/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HUSTERGS/SoftwareEngineeringProject/HEAD/SudokuApp-GS/Sudoku/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/SudokuApp-GS/Sudoku/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HUSTERGS/SoftwareEngineeringProject/HEAD/SudokuApp-GS/Sudoku/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/SudokuApp-GS/Sudoku/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HUSTERGS/SoftwareEngineeringProject/HEAD/SudokuApp-GS/Sudoku/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/SudokuApp-GS/Sudoku/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HUSTERGS/SoftwareEngineeringProject/HEAD/SudokuApp-GS/Sudoku/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/newSudoku/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/Sudoku/dlx/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/Simple-sudoku-master/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/Simple-sudoku-master/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
6 |
--------------------------------------------------------------------------------
/SudokuApp-GS/Sudoku/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #008577
4 | #00574B
5 | #D81B60
6 |
7 |
--------------------------------------------------------------------------------
/SudokuApp-GS/Sudoku/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
6 |
--------------------------------------------------------------------------------
/Sudoku/dlx/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/Sudoku/dlx/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/newSudoku/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/SudokuApp-GS/Sudoku/app/src/main/res/drawable/focus.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/SudokuApp-GS/Sudoku/app/src/main/res/values/attrs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/Simple-sudoku-master/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
--------------------------------------------------------------------------------
/SudokuApp-GS/Sudoku/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/caches
5 | /.idea/libraries
6 | /.idea/modules.xml
7 | /.idea/workspace.xml
8 | /.idea/navEditor.xml
9 | /.idea/assetWizardSettings.xml
10 | .DS_Store
11 | /build
12 | /captures
13 | .externalNativeBuild
14 | .cxx
15 |
--------------------------------------------------------------------------------
/SudokuApp-GS/Sudoku/app/src/main/res/drawable/wrong_box.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/newSudoku/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/Simple-sudoku-master/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Mon Dec 28 10:00:20 PST 2015
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
7 |
--------------------------------------------------------------------------------
/SudokuApp-GS/Sudoku/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Thu Oct 17 17:05:31 CST 2019
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
7 |
--------------------------------------------------------------------------------
/SudokuApp-GS/Sudoku/app/src/main/res/drawable/border.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/SudokuApp-GS/Sudoku/app/src/main/res/drawable/option_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/SudokuApp-GS/Sudoku/app/src/main/res/drawable/border_selected.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/SudokuApp-GS/Sudoku/app/src/main/res/drawable/ic_play_arrow_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/SudokuApp-GS/Sudoku/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/SudokuApp-GS/Sudoku/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/SudokuApp-GS/Sudoku/app/src/main/res/drawable/ic_pause_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/SudokuApp-GS/Sudoku/app/src/main/res/drawable/ic_equalizer_black_12dp.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/SudokuApp-GS/Sudoku/app/src/main/res/drawable/ic_star_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/Simple-sudoku-master/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 | #ffffffff
7 | #ff9E9E9E
8 | #ff000000
9 |
10 |
--------------------------------------------------------------------------------
/Simple-sudoku-master/app/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/SudokuApp-GS/Sudoku/app/src/main/assets/litepal.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/Simple-sudoku-master/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/SudokuApp-GS/Sudoku/app/src/main/res/drawable/ic_create_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/SudokuApp-GS/Sudoku/app/src/main/res/drawable/ic_info_outline_black_12dp.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/Simple-sudoku-master/app/src/main/java/com/example/jobs/newsudo/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.example.jobs.newsudo;
2 |
3 | import android.support.v7.app.AppCompatActivity;
4 | import android.os.Bundle;
5 |
6 | public class MainActivity extends AppCompatActivity {
7 |
8 | @Override
9 | protected void onCreate(Bundle savedInstanceState) {
10 | super.onCreate(savedInstanceState);
11 | //setContentView(R.layout.activity_main);
12 | setContentView(new Sudo(this));
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/SudokuApp-GS/Sudoku/app/src/test/java/com/example/sudoku/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.example.sudoku;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/SudokuApp-GS/Sudoku/app/src/main/res/drawable/ic_star_border_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/Simple-sudoku-master/app/src/test/java/com/example/jobs/newsudo/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.example.jobs.newsudo;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/SudokuApp-GS/Sudoku/app/src/main/res/anim/rotateundo.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
8 |
14 |
--------------------------------------------------------------------------------
/SudokuApp-GS/Sudoku/app/src/main/res/drawable/ic_restore_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/Simple-sudoku-master/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/SudokuApp-GS/Sudoku/app/src/main/res/drawable/ic_timer_black_12dp.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/SudokuApp-GS/Sudoku/app/src/main/res/drawable/ic_timer_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/Sudoku/dlx/.idea/$PRODUCT_WORKSPACE_FILE$:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | 11
8 |
9 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/SudokuApp-GS/Sudoku/app/src/main/res/drawable/ic_person_outline_black_12dp.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/newSudoku/.idea/$PRODUCT_WORKSPACE_FILE$:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | 11
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/Simple-sudoku-master/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | repositories {
5 | jcenter()
6 | }
7 | dependencies {
8 | classpath 'com.android.tools.build:gradle:2.2.2'
9 |
10 | // NOTE: Do not place your application dependencies here; they belong
11 | // in the individual module build.gradle files
12 | }
13 | }
14 |
15 | allprojects {
16 | repositories {
17 | jcenter()
18 | }
19 | }
20 |
21 | task clean(type: Delete) {
22 | delete rootProject.buildDir
23 | }
24 |
--------------------------------------------------------------------------------
/SudokuApp-GS/Sudoku/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
14 |
15 |
--------------------------------------------------------------------------------
/SudokuApp-GS/Sudoku/app/src/main/java/com/example/sudoku/UserAction/EnterAction.java:
--------------------------------------------------------------------------------
1 | package com.example.sudoku.UserAction;
2 |
3 | import android.widget.GridLayout;
4 |
5 | import com.example.sudoku.SudokuTextView;
6 |
7 | public class EnterAction extends UserAction {
8 | public EnterAction(int column, int row, int currentNum, int size) {
9 | super(1, column, row, -1, currentNum, size);
10 | }
11 |
12 | @Override
13 | void undoAction(SudokuTextView textView, int[][] currentBoard) {
14 | textView.setText("");
15 | currentBoard[textView.getRow()][textView.getColumn()] = 0;
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/Simple-sudoku-master/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/SudokuApp-GS/Sudoku/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/SudokuApp-GS/Sudoku/app/src/main/res/anim/moveerase.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 |
7 |
11 |
12 |
16 |
17 |
--------------------------------------------------------------------------------
/SudokuApp-GS/Sudoku/app/src/main/java/com/example/sudoku/UserAction/EraseAction.java:
--------------------------------------------------------------------------------
1 | package com.example.sudoku.UserAction;
2 |
3 | import android.widget.GridLayout;
4 |
5 | import com.example.sudoku.SudokuTextView;
6 |
7 | public class EraseAction extends UserAction {
8 |
9 | public EraseAction(int column, int row, int originNum, int size) {
10 | super(0, column, row, originNum, -1, size);
11 | }
12 |
13 | @Override
14 | void undoAction(SudokuTextView textView, int[][] currentBoard) {
15 | textView.setText(Integer.toString(originNum));
16 | currentBoard[textView.getRow()][textView.getColumn()] = originNum;
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/SudokuApp-GS/Sudoku/app/src/main/java/com/example/sudoku/userInfo.java:
--------------------------------------------------------------------------------
1 | package com.example.sudoku;
2 |
3 | import org.litepal.crud.LitePalSupport;
4 |
5 | public class userInfo extends LitePalSupport {
6 | private String userName;
7 | private String passwordHash;
8 |
9 | public String getUserName() {
10 | return this.userName;
11 | }
12 | public String getPasswordHash() {
13 | return this.passwordHash;
14 | }
15 | public void setUserName(String userName) {
16 | this.userName = userName;
17 | }
18 | public void setPasswordHash(String passwordHash) {
19 | this.passwordHash = passwordHash;
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/SudokuApp-GS/Sudoku/app/src/main/java/com/example/sudoku/UserAction/ReplaceAction.java:
--------------------------------------------------------------------------------
1 | package com.example.sudoku.UserAction;
2 |
3 | import android.widget.GridLayout;
4 |
5 | import com.example.sudoku.SudokuTextView;
6 |
7 | public class ReplaceAction extends UserAction {
8 | public ReplaceAction(int column, int row, int originNum, int currentNum, int size) {
9 | super(2, column, row, originNum, currentNum, size);
10 | }
11 |
12 | @Override
13 | void undoAction(SudokuTextView textView, int[][] currentBoard) {
14 | textView.setText(Integer.toString(originNum));
15 | currentBoard[textView.getRow()][textView.getColumn()] = originNum;
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/SudokuApp-GS/Sudoku/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | repositories {
5 | google()
6 | jcenter()
7 |
8 | }
9 | dependencies {
10 | classpath 'com.android.tools.build:gradle:3.5.1'
11 |
12 | // NOTE: Do not place your application dependencies here; they belong
13 | // in the individual module build.gradle files
14 | }
15 | }
16 |
17 | allprojects {
18 | repositories {
19 | google()
20 | jcenter()
21 |
22 | }
23 | }
24 |
25 | task clean(type: Delete) {
26 | delete rootProject.buildDir
27 | }
28 |
--------------------------------------------------------------------------------
/SudokuApp-GS/Sudoku/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/SudokuApp-GS/Sudoku/app/src/main/res/anim/scalenote.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
11 |
20 |
--------------------------------------------------------------------------------
/SudokuApp-GS/Sudoku/app/src/main/res/drawable/ic_iconmonstr_eraser_2.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/DailyRecord.md:
--------------------------------------------------------------------------------
1 | # 9.9 讨论
2 |
3 | 1. 选题
4 | 2. NABCD大纲
5 | 3. 试玩其他的软件找到缺陷和优点
6 |
7 |
8 |
9 |
10 |
11 | 1. 广告
12 | 2. 权限
13 | 3. 很单一,题目单一
14 | 4. 不同大小盘局
15 | 5.
16 |
17 |
18 |
19 | ## 9.10
20 |
21 | 注册,安装github =>
22 |
23 | 熟悉modao
24 |
25 | 下载安装AS
26 |
27 | github follow
28 |
29 | git 基本操作
30 |
31 | 分工:
32 |
33 | 1. 前端
34 | 2. 后端
35 | 3. presentation
36 | 4. 了解基本操作Android
37 | * 界面跳转
38 | * pop
39 |
40 | 推荐?:
41 |
42 | 1. 第一行代码
43 | 2. Java?基本了解 《Core Java》《Java 核心编程》
44 |
45 | 直接做?
46 |
47 | NABCD,word?
48 |
49 |
50 |
51 | ## 9.18
52 |
53 | modao => 基本的界面 孙 很棒
54 |
55 | git!!
56 |
57 | 基本数独开始写9x9, java => 葛 没有完成
58 |
59 | 前端 => 林 完成
60 |
61 | 解包apk?
62 |
63 | 时限;一周
64 |
65 | ## 9.25
66 |
67 | 数独算法
68 |
69 | 提交 android 代码
70 |
71 |
--------------------------------------------------------------------------------
/Simple-sudoku-master/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in C:\Users\jobs\AppData\Local\Android\Sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/Simple-sudoku-master/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/Simple-sudoku-master/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/newSudoku/Sudoku_Guide.md:
--------------------------------------------------------------------------------
1 | 类说明
2 |
3 | `DancingLinks`
4 |
5 | 用于解决**exact cover problem**
6 |
7 | 调用传入的`SudokuHandler`将解出来的答案(如果有的话)转化为数独格局,并返回
8 |
9 |
10 |
11 | `SudokuHandler`
12 |
13 | 纯粹的方法类,用于辅助`DancingLinks`
14 |
15 |
16 |
17 | `SudokuDLX(int gridLength, int side)`
18 |
19 | 利用`DancingLinks`算法来解决
20 |
21 | `gridLength`为棋盘宽度,`side`为一个block的宽度,九宫格分别为`9`和`3`
22 |
23 | 实例属性:
24 |
25 | `solutions`解的个数
26 |
27 | `solutionBoard`解出来的棋盘
28 |
29 | 静态方法:
30 |
31 | * `printBoard(int[][])`
32 | * `copyBoard(int[][] board, int[][] newBoard)`,将`board`复制到`newBoard`
33 |
34 | 实例方法:
35 |
36 | * `solve(int[][] sudoku)`解决输入的数独
37 |
38 |
39 |
40 | `GenerateBoard`
41 |
42 | 1. `init`
43 | 2. `run(int level)`表示挖掉的个数 9宫不要超过50个,4宫不要超过12个
44 | 3. 通过`.board`方法得到生成的数独
45 | 4. 通过`.anwser`方法得到答案(也可以重新算一遍)
--------------------------------------------------------------------------------
/Simple-sudoku-master/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/Simple-sudoku-master/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | org.gradle.jvmargs=-Xmx1536m
13 |
14 | # When configured, Gradle will run in incubating parallel mode.
15 | # This option should only be used with decoupled projects. More details, visit
16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
17 | # org.gradle.parallel=true
18 |
--------------------------------------------------------------------------------
/SudokuApp-GS/Sudoku/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/Simple-sudoku-master/app/src/androidTest/java/com/example/jobs/newsudo/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.example.jobs.newsudo;
2 |
3 | import android.content.Context;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumentation test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() throws Exception {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("com.example.jobs.newsudo", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/SudokuApp-GS/Sudoku/app/src/androidTest/java/com/example/sudoku/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.example.sudoku;
2 |
3 | import android.content.Context;
4 |
5 | import androidx.test.platform.app.InstrumentationRegistry;
6 | import androidx.test.ext.junit.runners.AndroidJUnit4;
7 |
8 | import org.junit.Test;
9 | import org.junit.runner.RunWith;
10 |
11 | import static org.junit.Assert.*;
12 |
13 | /**
14 | * Instrumented test, which will execute on an Android device.
15 | *
16 | * @see Testing documentation
17 | */
18 | @RunWith(AndroidJUnit4.class)
19 | public class ExampleInstrumentedTest {
20 | @Test
21 | public void useAppContext() {
22 | // Context of the app under test.
23 | Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
24 |
25 | assertEquals("com.example.sudoku", appContext.getPackageName());
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/SudokuApp-GS/Sudoku/app/src/main/res/layout/activity_history.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/Simple-sudoku-master/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 23
5 | buildToolsVersion "24.0.0"
6 | defaultConfig {
7 | applicationId "com.example.jobs.newsudo"
8 | minSdkVersion 21
9 | targetSdkVersion 23
10 | versionCode 1
11 | versionName "1.0"
12 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
13 | }
14 | buildTypes {
15 | release {
16 | minifyEnabled false
17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18 | }
19 | }
20 | }
21 |
22 | dependencies {
23 | compile fileTree(dir: 'libs', include: ['*.jar'])
24 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
25 | exclude group: 'com.android.support', module: 'support-annotations'
26 | })
27 | compile 'com.android.support:appcompat-v7:23.4.0'
28 | testCompile 'junit:junit:4.12'
29 | }
30 |
--------------------------------------------------------------------------------
/SudokuApp-GS/Sudoku/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 | Android
10 |
11 |
12 | EncapsulationJava
13 |
14 |
15 | Java
16 |
17 |
18 | LintAndroid
19 |
20 |
21 | SecurityLintAndroid
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/SudokuApp-GS/Sudoku/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/newSudoku/SudokuDLXTest.java:
--------------------------------------------------------------------------------
1 | import dlx.SudokuDLX;
2 | import org.junit.Assert;
3 | import org.junit.Assert.*;
4 | import org.junit.Test;
5 |
6 | public class SudokuDLXTest {
7 | @Test
8 | public void test() {
9 | int[][] hardest = {
10 | {0,0,0,0,8,2,9,5,6},
11 | {5,8,0,6,0,0,0,0,4},
12 | {0,0,3,1,0,0,2,0,0},
13 | {0,4,1,0,7,0,5,0,0},
14 | {7,6,0,5,0,1,0,9,2},
15 | {0,0,9,0,4,0,1,8,0},
16 | {0,0,5,0,0,8,7,0,0},
17 | {8,0,0,0,0,5,0,3,9},
18 | {9,2,6,7,1,0,0,0,0}
19 | };
20 |
21 | int[][] testFour = {
22 | {0,3,1,0},
23 | {1,0,0,3},
24 | {2,0,3,4},
25 | {0,4,2,0}
26 | };
27 | Assert.assertTrue(SudokuDLX.validateSudoku(hardest));
28 | Assert.assertTrue(SudokuDLX.validateSudoku(testFour));
29 | Assert.assertTrue(SudokuDLX.validatePosition(testFour, 0, 0, 4));
30 | Assert.assertFalse(SudokuDLX.validatePosition(testFour,0,0,2));
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/SudokuApp-GS/Sudoku/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 | # IDE (e.g. Android Studio) users:
3 | # Gradle settings configured through the IDE *will override*
4 | # any settings specified in this file.
5 | # For more details on how to configure your build environment visit
6 | # http://www.gradle.org/docs/current/userguide/build_environment.html
7 | # Specifies the JVM arguments used for the daemon process.
8 | # The setting is particularly useful for tweaking memory settings.
9 | org.gradle.jvmargs=-Xmx1536m
10 | # When configured, Gradle will run in incubating parallel mode.
11 | # This option should only be used with decoupled projects. More details, visit
12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
13 | # org.gradle.parallel=true
14 | # AndroidX package structure to make it clearer which packages are bundled with the
15 | # Android operating system, and which are packaged with your app's APK
16 | # https://developer.android.com/topic/libraries/support-library/androidx-rn
17 | android.useAndroidX=true
18 | # Automatically convert third-party libraries to use AndroidX
19 | android.enableJetifier=true
20 |
21 |
--------------------------------------------------------------------------------
/NABCD.md:
--------------------------------------------------------------------------------
1 | # 基本信息
2 |
3 | ### 组名:中秋快乐
4 |
5 | ### 组员:
6 |
7 | * 林瑞忞 U201714590
8 | * 孙雯 U201714617
9 | * 葛松 U201714668
10 |
11 | ### 所选题目: 数独 APP
12 |
13 | # NABCD模型
14 |
15 | ### N(Need 需求)你的创意解决了用户的什么需求?
16 |
17 | 首先,通勤时间或一些零碎时间,需要具有一定的挑战性的事情来消磨,但不至于玩物丧志;其次,对于益智类数独游戏而言,由于用户手边没有纸和笔,使用手机APP操作会更便捷,且市场上存在的数独游戏APP有权限索要、广告繁杂、数独形式单一等问题;同时,数独爱好者对于专业性、高难度数独有所渴求,而且普通用户缺乏数独技巧,对一些专业知识的指导也有需求;除此之外,玩数独游戏考验耐心,缺乏趣味性,单人作战略显枯燥。
18 |
19 | ### A(Approach 做法)你有什么招数来解决用户的痛苦或问题?
20 |
21 | 首先,提供离线游玩的可能,在用户没有网络时也可以进行游戏。其次,对于不同的用户人群和空闲时间限制,提供不同玩法模式的选择(如限时和闯关),可以增加多样性。比如,向高阶数独爱好者提供数独比赛中的一些独特类型的数独,如:具有额外区域的数独、有标注提示要求的数独、不同形状的数独等;向普通用户提供一些常用的技巧,供查找学习和讨论,提高求解数独的能力。并且为增加趣味性,提供多人游玩的功能,如通过网络或者局域网与朋友或陌生人进行比赛或协作,有一些社交属性。
22 |
23 | ### B(Benefit 好处)你这个产品或服务会给用户带来什么好处?
24 |
25 | 用户可以充分利用闲暇时间放松一下,而又不至于玩物丧志,且多人对战或者协作可以认识新的朋友、增进朋友之间的感情、收获乐趣。同时,硬核玩家可以通过这个游戏得到专业锻炼,而普通用户可以通过查看学习相关的数独技巧,可以循序渐进地掌握数独的高阶玩法,进一步锻炼大脑,提高解题能力。
26 |
27 | ### C(Competitors 竞争)你的产品有没有类似的竞争者,他们的产品怎么样?
28 |
29 | 市面上存在许多数独游戏,基本功能也比较齐全。但是大多数APP都充斥着各种广告,并且请求各种不需要的权限,不仅会让用户感到烦心,还可能对用户的个人信息安全造成不可预知的威胁。大多数的产品也缺乏创新,都是更改盘局大小或者增减一开始会出现的数字来调整难度,没有什么独特的题型。
30 |
31 | ### D(Delivery 推广)你如何推销你的产品?
32 |
33 | 联合各大数独比赛进行联合宣传,与他们合作,在APP中提供往届经典试题和解法等;还可以在社交软件上进行嵌入,如微信小程序,借助软件可能具有的社交属性进行宣传。
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Built application files
2 | *.apk
3 | *.ap_
4 |
5 | # Files for the ART/Dalvik VM
6 | *.dex
7 |
8 | # Java class files
9 | *.class
10 |
11 | # Generated files
12 | bin/
13 | gen/
14 | out/
15 |
16 | # Gradle files
17 | .gradle/
18 | build/
19 |
20 | # Local configuration file (sdk path, etc)
21 | local.properties
22 |
23 | # Proguard folder generated by Eclipse
24 | proguard/
25 |
26 | # Log Files
27 | *.log
28 |
29 | # Android Studio Navigation editor temp files
30 | .navigation/
31 |
32 | # Android Studio captures folder
33 | captures/
34 |
35 | # IntelliJ
36 | *.iml
37 | .idea/workspace.xml
38 | .idea/tasks.xml
39 | .idea/gradle.xml
40 | .idea/assetWizardSettings.xml
41 | .idea/dictionaries
42 | .idea/libraries
43 | .idea/caches
44 |
45 | # Keystore files
46 | # Uncomment the following line if you do not want to check your keystore files in.
47 | #*.jks
48 |
49 | # External native build folder generated in Android Studio 2.2 and later
50 | .externalNativeBuild
51 |
52 | # Google Services (e.g. APIs or Firebase)
53 | google-services.json
54 |
55 | # Freeline
56 | freeline.py
57 | freeline/
58 | freeline_project_description.json
59 |
60 | # fastlane
61 | fastlane/report.xml
62 | fastlane/Preview.html
63 | fastlane/screenshots
64 | fastlane/test_output
65 | fastlane/readme.md
66 |
--------------------------------------------------------------------------------
/SudokuApp-GS/Sudoku/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Sudoku
3 | Undo
4 | Erase
5 | Note
6 | Count Down
7 | 开启纠错
8 | 开启颜色
9 | 简单
10 | 中等
11 | 困难
12 | 极难
13 | 选择难度
14 | 选择模式
15 | 四 宫
16 | 九 宫
17 | 继续上一次
18 | Sign in
19 | Email
20 | Password
21 | Sign in or register
22 | Sign in
23 | "Welcome !"
24 | Not a valid username
25 | Password must be >5 characters
26 | "Login failed"
27 |
28 |
--------------------------------------------------------------------------------
/newSudoku/dlx/SudokuHandler.java:
--------------------------------------------------------------------------------
1 | package dlx;
2 |
3 | import dlx.DancingLinks.*;
4 | import java.util.*;
5 |
6 | // 纯粹的功能类
7 | public class SudokuHandler {
8 | private int size;
9 | // 将dancing link 得到的结果转化为board
10 | public int[][] handleSolution(List answer){
11 | int[][] result = parseBoard(answer);
12 | // AbstractSudokuSolver.printSolution(result);
13 | return result;
14 | }
15 |
16 | private int[][] parseBoard(List answer){
17 | int[][] result = new int[size][size];
18 | for(DancingNode n : answer){
19 | DancingNode rcNode = n;
20 | int min = Integer.parseInt(rcNode.C.name);
21 | for(DancingNode tmp = n.R; tmp != n; tmp = tmp.R){
22 | int val = Integer.parseInt(tmp.C.name);
23 | if (val < min){
24 | min = val;
25 | rcNode = tmp;
26 | }
27 | }
28 | int ans1 = Integer.parseInt(rcNode.C.name);
29 | int ans2 = Integer.parseInt(rcNode.R.C.name);
30 | int r = ans1 / size;
31 | int c = ans1 % size;
32 | int num = (ans2 % size) + 1;
33 | result[r][c] = num;
34 | }
35 | return result;
36 | }
37 |
38 | public SudokuHandler(int boardSize){
39 | size = boardSize;
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/SudokuApp-GS/Sudoku/app/src/main/java/com/example/sudoku/dlx/SudokuHandler.java:
--------------------------------------------------------------------------------
1 | package com.example.sudoku.dlx;
2 |
3 | import com.example.sudoku.dlx.DancingLinks.*;
4 | import java.util.*;
5 |
6 | // 纯粹的功能类
7 | public class SudokuHandler {
8 | private int size;
9 | // 将dancing link 得到的结果转化为board
10 | public int[][] handleSolution(List answer){
11 | int[][] result = parseBoard(answer);
12 | // AbstractSudokuSolver.printSolution(result);
13 | return result;
14 | }
15 |
16 | private int[][] parseBoard(List answer){
17 | int[][] result = new int[size][size];
18 | for(DancingNode n : answer){
19 | DancingNode rcNode = n;
20 | int min = Integer.parseInt(rcNode.C.name);
21 | for(DancingNode tmp = n.R; tmp != n; tmp = tmp.R){
22 | int val = Integer.parseInt(tmp.C.name);
23 | if (val < min){
24 | min = val;
25 | rcNode = tmp;
26 | }
27 | }
28 | int ans1 = Integer.parseInt(rcNode.C.name);
29 | int ans2 = Integer.parseInt(rcNode.R.C.name);
30 | int r = ans1 / size;
31 | int c = ans1 % size;
32 | int num = (ans2 % size) + 1;
33 | result[r][c] = num;
34 | }
35 | return result;
36 | }
37 |
38 | public SudokuHandler(int boardSize){
39 | size = boardSize;
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/Sudoku/dlx/dlx/SolutionHandler.java:
--------------------------------------------------------------------------------
1 | package dlx;
2 |
3 | import dlx.DancingLinks.*;
4 | import java.util.*;
5 |
6 | public interface SolutionHandler{
7 | int[][] handleSolution(List solution);
8 | }
9 |
10 | class SudokuHandler implements SolutionHandler{
11 | int size = 9;
12 |
13 | public int[][] handleSolution(List answer){
14 | int[][] result = parseBoard(answer);
15 | // AbstractSudokuSolver.printSolution(result);
16 | return result;
17 | }
18 |
19 | private int[][] parseBoard(List answer){
20 | int[][] result = new int[size][size];
21 | for(DancingNode n : answer){
22 | DancingNode rcNode = n;
23 | int min = Integer.parseInt(rcNode.C.name);
24 | for(DancingNode tmp = n.R; tmp != n; tmp = tmp.R){
25 | int val = Integer.parseInt(tmp.C.name);
26 | if (val < min){
27 | min = val;
28 | rcNode = tmp;
29 | }
30 | }
31 | int ans1 = Integer.parseInt(rcNode.C.name);
32 | int ans2 = Integer.parseInt(rcNode.R.C.name);
33 | int r = ans1 / size;
34 | int c = ans1 % size;
35 | int num = (ans2 % size) + 1;
36 | result[r][c] = num;
37 | }
38 | return result;
39 | }
40 |
41 |
42 |
43 | public SudokuHandler(int boardSize){
44 | size = boardSize;
45 | }
46 |
47 | }
--------------------------------------------------------------------------------
/SudokuApp-GS/Sudoku/app/src/main/java/com/example/sudoku/SudokuTextView.java:
--------------------------------------------------------------------------------
1 | package com.example.sudoku;
2 |
3 |
4 | import android.content.Context;
5 | import android.content.res.TypedArray;
6 | import android.util.AttributeSet;
7 | import android.view.Gravity;
8 | import android.widget.GridLayout;
9 | import android.widget.LinearLayout;
10 | import android.widget.TextView;
11 |
12 | import androidx.appcompat.widget.AppCompatTextView;
13 | import androidx.constraintlayout.solver.GoalRow;
14 |
15 | import org.w3c.dom.Text;
16 | import com.example.sudoku.SudokuNine;
17 |
18 | public class SudokuTextView extends AppCompatTextView {
19 | private int column;
20 | private int row;
21 |
22 | public int getColumn(){
23 | return column;
24 | }
25 |
26 | public int getRow() {
27 | return row;
28 | }
29 |
30 | public SudokuTextView(Context context, AttributeSet attrs) {
31 | super(context,attrs);
32 |
33 | TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.SudokuTextViewCustomAttr);
34 |
35 | int column = ta.getInteger(R.styleable.SudokuTextViewCustomAttr_column, -1);
36 | int row = ta.getInteger(R.styleable.SudokuTextViewCustomAttr_row, -1);
37 | this.column = column;
38 | this.row = row;
39 | }
40 |
41 | public SudokuTextView(Context context, int column, int row) {
42 | super(context);
43 | this.column = column;
44 | this.row = row;
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/SudokuApp-GS/Sudoku/app/src/main/java/com/example/sudoku/MD5.java:
--------------------------------------------------------------------------------
1 | package com.example.sudoku;
2 | import java.math.BigInteger;
3 | import java.security.MessageDigest;
4 | import java.security.NoSuchAlgorithmException;
5 |
6 | public class MD5 {
7 | public static String getMd5(String input)
8 | {
9 | try {
10 |
11 | // Static getInstance method is called with hashing MD5
12 | MessageDigest md = MessageDigest.getInstance("MD5");
13 |
14 | // digest() method is called to calculate message digest
15 | // of an input digest() return array of byte
16 | byte[] messageDigest = md.digest(input.getBytes());
17 |
18 | // Convert byte array into signum representation
19 | BigInteger no = new BigInteger(1, messageDigest);
20 |
21 | // Convert message digest into hex value
22 | String hashtext = no.toString(16);
23 | while (hashtext.length() < 32) {
24 | hashtext = "0" + hashtext;
25 | }
26 | return hashtext;
27 | }
28 |
29 | // For specifying wrong message digest algorithms
30 | catch (NoSuchAlgorithmException e) {
31 | throw new RuntimeException(e);
32 | }
33 | }
34 |
35 | // Driver code
36 | public static void main(String args[]) throws NoSuchAlgorithmException
37 | {
38 | String s = "GeeksForGeeks";
39 | System.out.println("Your HashCode Generated by MD5 is: " + getMd5(s));
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/SudokuApp-GS/Sudoku/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 29
5 | buildToolsVersion "29.0.2"
6 | defaultConfig {
7 | applicationId "com.example.sudoku"
8 | minSdkVersion 24
9 | targetSdkVersion 29
10 | versionCode 1
11 | versionName "1.0"
12 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
13 | vectorDrawables.useSupportLibrary = true
14 | }
15 | buildTypes {
16 | release {
17 | minifyEnabled false
18 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
19 | }
20 | }
21 | compileOptions {
22 | sourceCompatibility = 1.8
23 | targetCompatibility = 1.8
24 | }
25 | }
26 |
27 | dependencies {
28 | implementation fileTree(dir: 'libs', include: ['*.jar'])
29 | implementation 'androidx.appcompat:appcompat:1.1.0'
30 | implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
31 | implementation 'androidx.annotation:annotation:1.1.0'
32 | implementation 'androidx.lifecycle:lifecycle-extensions:2.1.0'
33 | testImplementation 'junit:junit:4.12'
34 | androidTestImplementation 'androidx.test.ext:junit:1.1.1'
35 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
36 | implementation 'androidx.gridlayout:gridlayout:1.0.0'
37 | implementation 'com.google.android.material:material:1.0.0'
38 | implementation 'org.litepal.android:java:3.0.0'
39 | }
40 |
--------------------------------------------------------------------------------
/SudokuApp-GS/Sudoku/app/src/main/java/com/example/sudoku/UserAction/UserAction.java:
--------------------------------------------------------------------------------
1 | package com.example.sudoku.UserAction;
2 |
3 | import android.widget.GridLayout;
4 | import android.widget.RelativeLayout;
5 |
6 | import com.example.sudoku.SudokuNine;
7 | import com.example.sudoku.SudokuTextView;
8 |
9 | abstract public class UserAction {
10 | // 几种动作,擦除,在空的位置输入,在非空位置输入
11 | protected final int ERASE = 0;
12 | protected final int ENTER = 1;
13 | protected final int REPLACE = 2;
14 |
15 | protected int column;
16 | protected int row;
17 | protected int originNum;
18 | protected int currentNum;
19 | protected int actionType;
20 | protected int size;
21 |
22 | public int getIndex() {
23 | return row * size + column;
24 | }
25 |
26 | public UserAction(int type, int column, int row, int originNum, int currentNum, int size) {
27 | this.column = column;
28 | this.row = row;
29 | this.originNum = originNum;
30 | this.currentNum = currentNum;
31 | this.actionType = type;
32 | this.size = size;
33 | }
34 | public void undo(GridLayout gridLayout, int[][] currentBoard){
35 | RelativeLayout relativeLayout = (RelativeLayout) gridLayout.getChildAt(row * size + column);
36 | // undoAction((SudokuTextView) gridLayout.getChildAt(row * size + column), currentBoard);
37 | undoAction((SudokuTextView) relativeLayout.getChildAt(0), currentBoard);
38 | }
39 | abstract void undoAction(SudokuTextView textView, int[][] currentBoard);
40 | }
41 |
--------------------------------------------------------------------------------
/SudokuApp-GS/Sudoku/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
18 |
19 |
28 |
29 |
--------------------------------------------------------------------------------
/newSudoku/dlxTest.java:
--------------------------------------------------------------------------------
1 | import dlx.*;
2 |
3 | public class dlxTest {
4 | public static void main(String[] args) {
5 | // int[][] hardest = {
6 | // {0,0,0,0,8,2,9,5,6},
7 | // {5,8,0,6,0,0,0,0,4},
8 | // {0,0,3,1,0,0,2,0,0},
9 | // {0,4,1,0,7,0,5,0,0},
10 | // {7,6,0,5,0,1,0,9,2},
11 | // {0,0,9,0,4,0,1,8,0},
12 | // {0,0,5,0,0,8,7,0,0},
13 | // {8,0,0,0,0,5,0,3,9},
14 | // {9,2,6,7,1,0,0,0,0}
15 | // };
16 | // int[][] testFour = {
17 | // {0,3,1,0},
18 | // {1,0,0,3},
19 | // {2,0,3,4},
20 | // {0,4,2,0}
21 | // };
22 | // SudokuDLX sudoku = new SudokuDLX(9, 3);
23 | //
24 | // if (sudoku.solve(hardest)) {
25 | // System.out.println(sudoku.solutions);
26 | // SudokuDLX.printBoard(sudoku.solutionBoard);
27 | // } else {
28 | // System.out.println("Invalid sudoku!");
29 | // }
30 |
31 | GenerateBoard newBoard = new GenerateBoard(9,3);
32 | // 初始化一个棋盘,最开始随机放置了INITNUM个数字,然后开始解这个棋盘来得到终局,可以通过多次init来得到不同的终局
33 | newBoard.initBoard();
34 | // 开始挖洞,level参数为挖掉的数目
35 | newBoard.run(12);
36 | // 打印棋盘
37 | newBoard.printBoard();
38 |
39 | System.out.println(newBoard.actualLevel);
40 | SudokuDLX sudokuDLX = new SudokuDLX(4,2);
41 | sudokuDLX.solve(newBoard.board);
42 | System.out.println(sudokuDLX.solutions);
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/SudokuApp-GS/Sudoku/app/src/main/java/com/example/sudoku/History.java:
--------------------------------------------------------------------------------
1 | package com.example.sudoku;
2 |
3 | import androidx.appcompat.app.AppCompatActivity;
4 | import androidx.recyclerview.widget.LinearLayoutManager;
5 | import androidx.recyclerview.widget.RecyclerView;
6 |
7 | import android.content.SharedPreferences;
8 | import android.os.Bundle;
9 |
10 | import org.litepal.LitePal;
11 |
12 | import java.util.Collection;
13 | import java.util.Collections;
14 | import java.util.List;
15 |
16 | public class History extends AppCompatActivity {
17 | private RecyclerView recyclerView;
18 | private RecyclerView.Adapter mAdapter;
19 | private RecyclerView.LayoutManager layoutManager;
20 |
21 | @Override
22 | protected void onCreate(Bundle savedInstanceState) {
23 | super.onCreate(savedInstanceState);
24 | setContentView(R.layout.activity_history);
25 |
26 | recyclerView = (RecyclerView) findViewById(R.id.history_recycler_view);
27 | recyclerView.setHasFixedSize(true);
28 |
29 | layoutManager = new LinearLayoutManager(this);
30 | recyclerView.setLayoutManager(layoutManager);
31 | // LitePal.findAll(GameRecord.class);
32 | SharedPreferences pref = getSharedPreferences("currentUser", MODE_PRIVATE);
33 | String name = pref.getString("name", "");
34 |
35 | List gameRecords = LitePal.where("user = ?", name).find(GameRecord.class);
36 | Collections.reverse(gameRecords);
37 | mAdapter = new HistoryItemAdapter(gameRecords);
38 | recyclerView.setAdapter(mAdapter);
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/Sudoku/dlx/dlxTest.java:
--------------------------------------------------------------------------------
1 | import dlx.*;
2 |
3 | public class dlxTest {
4 | public static void main(String[] args) {
5 | int[][] hardest = {
6 | {0,0,0,0,8,2,9,5,6},
7 | {5,8,0,6,0,0,0,0,4},
8 | {0,0,3,1,0,0,2,0,0},
9 | {0,4,1,0,7,0,5,0,0},
10 | {7,6,0,5,0,1,0,9,2},
11 | {0,0,9,0,4,0,1,8,0},
12 | {0,0,5,0,0,8,7,0,0},
13 | {8,0,0,0,0,5,0,3,9},
14 | {9,2,6,7,1,0,0,0,0}
15 | };
16 | // 单纯解数独
17 | // 1. 实例化SudokuDLX();
18 | // 2. sudoku.solve(int[][] board) 返回是否成功
19 | // 3. 如果成功则可以通过 sudoku.solutionBoard获得解出来的board,并通过soduku.solutions查看可能的解的个数
20 | // 4. 如果不成功则sudoku.solutionBoard为null
21 | SudokuDLX sudoku = new SudokuDLX();
22 |
23 | if (sudoku.solve(hardest)) {
24 | System.out.println(sudoku.solutions);
25 | GenerateBoard.printBoard(sudoku.solutionBoard);
26 | } else {
27 | System.out.println("Invalid sudoku!");
28 | }
29 |
30 | // 生成数独
31 | GenerateBoard newBoard = new GenerateBoard();
32 | // 初始化一个棋盘,最开始随机放置了INITNUM个数字,然后开始解这个棋盘来得到终局,可以通过多次init来得到不同的终局
33 | newBoard.initBoard();
34 | // 开始挖洞,level参数为挖掉的数目
35 | newBoard.run(50);
36 | // 打印棋盘
37 | newBoard.printBoard();
38 | System.out.println(newBoard.actualLevel);
39 | SudokuDLX sudokuDLX = new SudokuDLX();
40 | sudokuDLX.solve(newBoard.board);
41 | System.out.println(sudokuDLX.solutions);
42 |
43 | // 可用的一些方法
44 | // GenerateBoard 类方法以及实例方法 printBoard 打印一个棋盘
45 | // GenerateBoard.printBoard(newBoard.board);
46 | // 或
47 | // newBoard.printBoard();
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/SudokuApp-GS/Sudoku/app/src/main/res/drawable/ic_iconmonstr_light_bulb_18.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/SudokuApp-GS/Sudoku/app/src/main/java/com/example/sudoku/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.example.sudoku;
2 |
3 | import androidx.appcompat.app.AppCompatActivity;
4 |
5 | import android.content.Intent;
6 | import android.content.SharedPreferences;
7 | import android.os.Bundle;
8 | import android.view.View;
9 | import android.widget.TextView;
10 | import android.widget.Toast;
11 |
12 | import com.google.android.material.button.MaterialButton;
13 |
14 | import org.litepal.LitePal;
15 | import org.w3c.dom.Text;
16 |
17 | public class MainActivity extends AppCompatActivity {
18 |
19 | @Override
20 | protected void onCreate(Bundle savedInstanceState) {
21 | super.onCreate(savedInstanceState);
22 | // LitePal.initialize(this);
23 | setContentView(R.layout.activity_main);
24 | // LitePal.getDatabase();
25 | MaterialButton startGame = findViewById(R.id.materialButton4);
26 | startGame.setOnClickListener(new View.OnClickListener() {
27 | @Override
28 | public void onClick(View v) {
29 | Intent intent = new Intent(MainActivity.this, ChooseType.class);
30 | startActivity(intent);
31 | }
32 | });
33 |
34 | MaterialButton checkHistory = findViewById(R.id.materialButton3);
35 | checkHistory.setOnClickListener(new View.OnClickListener() {
36 | @Override
37 | public void onClick(View v) {
38 | Intent intent = new Intent(MainActivity.this, History.class);
39 | startActivity(intent);
40 | }
41 | });
42 |
43 | SharedPreferences pref = getSharedPreferences("currentUser", MODE_PRIVATE);
44 | String name = pref.getString("name", "");
45 | if (name == "Anonymous") {
46 | Toast.makeText(getApplicationContext(), "你以匿名模式登录" + name, Toast.LENGTH_SHORT).show();
47 | } else {
48 | Toast.makeText(getApplicationContext(), "欢迎来到数独世界~ " + name, Toast.LENGTH_SHORT).show();
49 | }
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/SudokuApp-GS/Sudoku/app/src/main/res/drawable-v24/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
12 |
13 |
19 |
22 |
25 |
26 |
27 |
28 |
34 |
35 |
--------------------------------------------------------------------------------
/Simple-sudoku-master/app/src/main/res/layout/item_choose_layout.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
12 |
13 |
14 |
15 |
20 |
21 |
26 |
27 |
32 |
33 |
34 |
35 |
36 |
41 |
42 |
47 |
48 |
53 |
54 |
55 |
56 |
57 |
62 |
63 |
68 |
69 |
74 |
75 |
76 |
77 |
78 |
--------------------------------------------------------------------------------
/SudokuApp-GS/Sudoku/app/src/main/java/com/example/sudoku/GameRecord.java:
--------------------------------------------------------------------------------
1 | package com.example.sudoku;
2 |
3 | import org.litepal.crud.LitePalSupport;
4 |
5 | public class GameRecord extends LitePalSupport {
6 | // 使用的时间
7 | private long usedTime;
8 | // level
9 | private int level;
10 | // 是否显示颜色 0 / 1
11 | private int showColor;
12 | // 是否实时纠错
13 | private int showHint;
14 | // 答案的布局
15 | private String anwser;
16 | // 当前的布局
17 | private String current;
18 | // 最初的布局
19 | private String origin;
20 | // 类型 4 / 9
21 | private int type;
22 | // 用户名
23 | private String user;
24 | // 草稿
25 | private String note;
26 |
27 | public long getusedTime() {
28 | return usedTime;
29 | }
30 | public void setusedTime(long usedTime) {
31 | this.usedTime = usedTime;
32 | }
33 | public int getLevel() {
34 | return level;
35 | }
36 | public void setLevel(int level) {
37 | this.level = level;
38 | }
39 | public int getShowColor() {
40 | return showColor;
41 | }
42 | public void setShowColor(int showColor) {
43 | this.showColor = showColor;
44 | }
45 | public int getshowHint() {
46 | return showHint;
47 | }
48 | public void setshowHint(int showHint) {
49 | this.showHint = showHint;
50 | }
51 | public String getAnwser() {
52 | return anwser;
53 | }
54 | public void setAnwser(String anwser) {
55 | this.anwser = anwser;
56 | }
57 | public String getCurrent() {
58 | return current;
59 | }
60 | public void setCurrent(String current) {
61 | this.current = current;
62 | }
63 | public String getOrigin() {
64 | return origin;
65 | }
66 | public void setOrigin(String origin) {
67 | this.origin = origin;
68 | }
69 | public String getUser() {
70 | return user;
71 | }
72 | public void setUser(String user) {
73 | this.user = user;
74 | }
75 | public int getType() {
76 | return type;
77 | }
78 | public void setType(int type) {
79 | this.type = type;
80 | }
81 | public String getNote() {
82 | return note;
83 | }
84 | public void setNote(String note) {
85 | this.note = note;
86 | }
87 |
88 | }
89 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # SoftwareEngineeringProject
2 | 华中科技大学 软件工程大作业 数独APP
3 |
4 | ## 组员
5 |
6 | [lrm142857](https://github.com/lrm142857)
7 |
8 | [swliky](https://github.com/swliky)
9 |
10 | [Samuel.G](https://github.com/HUSTERGS)
11 |
12 | # 项目概述
13 |
14 | 希望可以通过App的形式将数独这一游戏带给大家,解决广告以及错误次数限制等问题.详情请见[NABCD模型文档](NABCD.md)以及[项目说明书]([https://github.com/HUSTERGS/SoftwareEngineeringProject/blob/master/assignment/2019%E3%80%8A%E8%BD%AF%E4%BB%B6%E5%B7%A5%E7%A8%8B%E3%80%8B%E9%A1%B9%E7%9B%AE%E4%BB%BB%E5%8A%A1%E4%B9%A6%EF%BC%882017%E7%BA%A7%EF%BC%89.docx](https://github.com/HUSTERGS/SoftwareEngineeringProject/blob/master/assignment/2019《软件工程》项目任务书(2017级).docx))
15 |
16 | > 最终的数独以及安卓代码均在在[SudokuApp-GS](https://github.com/HUSTERGS/SoftwareEngineeringProject/tree/master/SudokuApp-GS/Sudoku)下,对`dlx`类也做了一些修改,如为了将其放到子线程中运行改为了`Runable`的子类
17 |
18 | # 具体实现
19 |
20 | ## 数独部分
21 |
22 | 实时生成具有唯一解的数独, 采用先生成终局后挖洞的方式,考虑到移动设备的算力可能不足的问题,使用了目前速度最快(待求证)的[Dancing Links](https://en.wikipedia.org/wiki/Dancing_Links)算法以来解数独,具体实现参考此[论文](dancing-color.ps.pdf)以及此[仓库](https://github.com/rafalio/dancing-links-java/), 挖洞参考了百度文库的[一篇论文](https://wenku.baidu.com/view/f9e3f17101f69e31433294e1.html)来提高挖洞效率,其中的剪枝操作极大的减少了挖洞所需要的时间.
23 |
24 | ## 安卓部分
25 |
26 | > 速成, 主要参考郭霖的[第一行代码](https://book.douban.com/subject/26915433/),[Google官方文档](https://developer.android.com/),以及`Material UI`的[文档](https://material.io/develop/android/),由于各种原因,其实真正的开发时间没有很长
27 |
28 | 储存数据用到了[LitePal](https://github.com/LitePalFramework/LitePal/)、安卓原生提供的本地数据库以及`SP`,由于种种不可抗力,没有实现真正的登录注册功能,只是在本地写了个假的。也没有提供显式的结算按钮,如需结算,请另开一局新的,旧的数据会被储存在历史中,即变相结算?
29 |
30 |
31 |
32 | 没有特殊原因应该不会继续完善
33 |
34 | ### 截图
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 | > 其他的部分实在太丑了,就不截图了。。。
43 |
44 |
45 |
46 | ## TODO
47 |
48 | ### 数独类型
49 |
50 | - [x] 四宫
51 | - [x] 九宫
52 | - [ ] 六宫
53 | - [ ] 不规则
54 |
55 | ### 基本操作
56 |
57 | - [x] 填入/擦除数字
58 | - [x] 高亮同一列同一行以及同一个小方格的数字
59 | - [x] 实时纠错
60 | - [x] 方格内做笔记
61 | - [x] 计时/暂停
62 | - [x] 撤回
63 | - [x] 难度选择
64 | - [x] 提示指定方格
65 | - [x] 恢复上一次进度
66 |
67 | ### 模式选择
68 |
69 | - [ ] 闯关模式
70 | - [ ] 限时模式
71 | - [ ] 联机模式
72 |
73 | ### 用户
74 |
75 | - [x] 登录注册 (Fake)
76 | - [x] 历史数据
77 |
78 | ### 其他
79 |
80 | - [ ] 查看解题技巧
81 | - [ ] 查看排名
82 | - [ ] 国际化
83 |
84 |
--------------------------------------------------------------------------------
/Simple-sudoku-master/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/SudokuApp-GS/Sudoku/app/src/main/java/com/example/sudoku/SudokuGrid.java:
--------------------------------------------------------------------------------
1 | package com.example.sudoku;
2 |
3 | import android.content.Context;
4 | import android.graphics.Color;
5 | import android.util.AttributeSet;
6 | import android.view.Gravity;
7 | import android.widget.GridLayout;
8 | import android.widget.LinearLayout;
9 | import android.widget.RelativeLayout;
10 | import android.widget.TextView;
11 |
12 |
13 | public class SudokuGrid extends GridLayout {
14 | private int side;
15 | private int S;
16 |
17 | public SudokuGrid(Context context, AttributeSet attrs) {
18 | super(context, attrs);
19 | }
20 |
21 | public SudokuGrid(Context context, int S) {
22 | super(context);
23 | // this.setColumnCount(3);
24 | // this.setRowCount(3);
25 | this.S = S;
26 | if (S == 9) {
27 | this.side = 3;
28 | } else if (S == 4) {
29 | this.side = 2;
30 | }
31 | this.setColumnCount(side);
32 | this.setRowCount(side);
33 | LinearLayout.LayoutParams layoutParams = new LinearLayout
34 | .LayoutParams(SudokuNine.dp2px(S == 9 ? 12 : 36, this.getContext()), SudokuNine.dp2px(S == 9 ? 12 : 36, this.getContext()));
35 | layoutParams.gravity = Gravity.CENTER;
36 | // this.setForegroundGravity(Gravity.CENTER);
37 | for (int i = 1; i <= S; i++) {
38 | TextView textView = new TextView(getContext());
39 | textView.setLayoutParams(layoutParams);
40 | textView.setLineSpacing(0, new Float(0.1));
41 | // textView.setText(Integer.toString(i));
42 | textView.setText("");
43 | textView.setTextSize(S == 9 ? 8 : 24);
44 | textView.setGravity(Gravity.CENTER);
45 | textView.setTextColor(Color.parseColor("#669999"));
46 | this.addView(textView);
47 | }
48 | RelativeLayout.LayoutParams layoutParams1 = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT,
49 | RelativeLayout.LayoutParams.MATCH_PARENT);
50 | layoutParams.gravity = Gravity.CENTER;
51 | // layoutParams.height = LayoutParams.MATCH_PARENT;
52 | // layoutParams.width = LayoutParams.MATCH_PARENT;
53 | //// layoutParams1.setGravity(Gravity.CENTER);
54 | //
55 | //// LinearLayout layoutParams1 = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT);
56 | this.setLayoutParams(layoutParams1);
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/SudokuApp-GS/Sudoku/app/src/main/res/layout/activity_choose_type.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
17 |
23 |
32 |
33 |
42 |
51 |
52 |
--------------------------------------------------------------------------------
/SudokuApp-GS/Sudoku/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | set DIRNAME=%~dp0
12 | if "%DIRNAME%" == "" set DIRNAME=.
13 | set APP_BASE_NAME=%~n0
14 | set APP_HOME=%DIRNAME%
15 |
16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
17 | set DEFAULT_JVM_OPTS=
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windows variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 |
53 | :win9xME_args
54 | @rem Slurp the command line arguments.
55 | set CMD_LINE_ARGS=
56 | set _SKIP=2
57 |
58 | :win9xME_args_slurp
59 | if "x%~1" == "x" goto execute
60 |
61 | set CMD_LINE_ARGS=%*
62 |
63 | :execute
64 | @rem Setup the command line
65 |
66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
67 |
68 | @rem Execute Gradle
69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
70 |
71 | :end
72 | @rem End local scope for the variables with windows NT shell
73 | if "%ERRORLEVEL%"=="0" goto mainEnd
74 |
75 | :fail
76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
77 | rem the _cmd.exe /c_ return code!
78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
79 | exit /b 1
80 |
81 | :mainEnd
82 | if "%OS%"=="Windows_NT" endlocal
83 |
84 | :omega
85 |
--------------------------------------------------------------------------------
/Simple-sudoku-master/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/SudokuApp-GS/Sudoku/app/src/main/java/com/example/sudoku/LastRecord.java:
--------------------------------------------------------------------------------
1 | package com.example.sudoku;
2 |
3 | import org.litepal.crud.LitePalSupport;
4 |
5 | public class LastRecord extends LitePalSupport {
6 | // 使用的时间
7 | private long usedTime;
8 | // level
9 | private int level;
10 | // 是否显示颜色 0 / 1
11 | private int showColor;
12 | // 是否实时纠错
13 | private int showHint;
14 | // 答案的布局
15 | private String anwser;
16 | // 当前的布局
17 | private String current;
18 | // 最初的布局
19 | private String origin;
20 | // 类型 4 / 9
21 | private int type;
22 | // 用户名
23 | private String user;
24 | // 草稿
25 | private String note;
26 |
27 | public long getusedTime() {
28 | return usedTime;
29 | }
30 | public void setusedTime(long usedTime) {
31 | this.usedTime = usedTime;
32 | }
33 | public int getLevel() {
34 | return level;
35 | }
36 | public void setLevel(int level) {
37 | this.level = level;
38 | }
39 | public int getShowColor() {
40 | return showColor;
41 | }
42 | public void setShowColor(int showColor) {
43 | this.showColor = showColor;
44 | }
45 | public int getshowHint() {
46 | return showHint;
47 | }
48 | public void setshowHint(int showHint) {
49 | this.showHint = showHint;
50 | }
51 | public String getAnwser() {
52 | return anwser;
53 | }
54 | public void setAnwser(String anwser) {
55 | this.anwser = anwser;
56 | }
57 | public String getCurrent() {
58 | return current;
59 | }
60 | public void setCurrent(String current) {
61 | this.current = current;
62 | }
63 | public String getOrigin() {
64 | return origin;
65 | }
66 | public void setOrigin(String origin) {
67 | this.origin = origin;
68 | }
69 | public String getUser() {
70 | return user;
71 | }
72 | public void setUser(String user) {
73 | this.user = user;
74 | }
75 | public int getType() {
76 | return type;
77 | }
78 | public void setType(int type) {
79 | this.type = type;
80 | }
81 | public String getNote() {
82 | return note;
83 | }
84 | public void setNote(String note) {
85 | this.note = note;
86 | }
87 |
88 |
89 | public static GameRecord LastToHistory(LastRecord lastRecord) {
90 | GameRecord gameRecord = new GameRecord();
91 | gameRecord.setAnwser(lastRecord.getAnwser());
92 | gameRecord.setCurrent(lastRecord.getCurrent());
93 | gameRecord.setLevel(lastRecord.getLevel());
94 | gameRecord.setNote(lastRecord.getNote());
95 | gameRecord.setOrigin(lastRecord.getOrigin());
96 | gameRecord.setShowColor(lastRecord.getShowColor());
97 | gameRecord.setshowHint(lastRecord.getshowHint());
98 | gameRecord.setType(lastRecord.getType());
99 | gameRecord.setUser(lastRecord.getUser());
100 | gameRecord.setusedTime(lastRecord.getusedTime());
101 | return gameRecord;
102 | }
103 | }
104 |
--------------------------------------------------------------------------------
/SudokuApp-GS/Sudoku/app/src/main/java/com/example/sudoku/ChooseLevel.java:
--------------------------------------------------------------------------------
1 | package com.example.sudoku;
2 |
3 | import androidx.appcompat.app.AppCompatActivity;
4 |
5 | import android.content.Intent;
6 | import android.media.Image;
7 | import android.os.Bundle;
8 | import android.view.View;
9 | import android.widget.ImageButton;
10 | import android.widget.LinearLayout;
11 |
12 | public class ChooseLevel extends AppCompatActivity {
13 |
14 |
15 | private void disableButtons() {
16 | LinearLayout easy = (LinearLayout) findViewById(R.id.easylevel);
17 | LinearLayout medium = (LinearLayout) findViewById(R.id.mediumlevel);
18 | LinearLayout hard = (LinearLayout) findViewById(R.id.hardlevel);
19 | LinearLayout devil = (LinearLayout) findViewById(R.id.devil_level);
20 | easy.setClickable(false);
21 | easy.setFocusable(false);
22 | medium.setClickable(false);
23 | medium.setFocusable(false);
24 | hard.setClickable(false);
25 | hard.setFocusable(false);
26 | devil.setClickable(false);
27 | devil.setFocusable(false);
28 | }
29 |
30 |
31 |
32 | @Override
33 | protected void onCreate(Bundle savedInstanceState) {
34 | super.onCreate(savedInstanceState);
35 | setContentView(R.layout.activity_choose_level);
36 |
37 | Intent intent = getIntent();
38 | int gridLength = intent.getIntExtra("gridLength", 9);
39 | LinearLayout easy = findViewById(R.id.easylevel);
40 | LinearLayout medium = findViewById(R.id.mediumlevel);
41 | LinearLayout hard = findViewById(R.id.hardlevel);
42 | LinearLayout devil = findViewById(R.id.devil_level);
43 |
44 | LinearLayout[] layouts = new LinearLayout[]{easy, medium, hard, devil};
45 | for (int i = 0; i < layouts.length; i++) {
46 | final int value = gridLength == 9? i * 10 + 20 : i * 3 + 3;
47 | layouts[i].setOnClickListener(new View.OnClickListener() {
48 | @Override
49 | public void onClick(View v) {
50 | disableButtons();
51 | Intent intent = new Intent(ChooseLevel.this, SudokuNine.class);
52 | intent.putExtra("level", value);
53 | intent.putExtra("gridLength", gridLength);
54 | startActivity(intent);
55 | }
56 | });
57 | LinearLayout subLinear = (LinearLayout) layouts[i].getChildAt(1);
58 | for (int t = 0; t < subLinear.getChildCount(); t++) {
59 | ImageButton imageButton = (ImageButton) subLinear.getChildAt(t);
60 | imageButton.setOnClickListener(new View.OnClickListener() {
61 | @Override
62 | public void onClick(View v) {
63 | disableButtons();
64 | Intent intent = new Intent(ChooseLevel.this, SudokuNine.class);
65 | intent.putExtra("level", value);
66 | intent.putExtra("gridLength", gridLength);
67 | startActivity(intent);
68 | }
69 | });
70 | }
71 | }
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/SudokuApp-GS/Sudoku/app/src/main/res/layout/activity_login.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
13 |
14 |
22 |
23 |
32 |
33 |
34 |
35 |
43 |
52 |
61 |
62 |
65 |
66 |
75 |
76 |
85 |
86 |
87 |
88 |
--------------------------------------------------------------------------------
/Simple-sudoku-master/.idea/codeStyles/Project.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 | xmlns:android
14 |
15 | ^$
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 | xmlns:.*
25 |
26 | ^$
27 |
28 |
29 | BY_NAME
30 |
31 |
32 |
33 |
34 |
35 |
36 | .*:id
37 |
38 | http://schemas.android.com/apk/res/android
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 | .*:name
48 |
49 | http://schemas.android.com/apk/res/android
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 | name
59 |
60 | ^$
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 | style
70 |
71 | ^$
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 | .*
81 |
82 | ^$
83 |
84 |
85 | BY_NAME
86 |
87 |
88 |
89 |
90 |
91 |
92 | .*
93 |
94 | http://schemas.android.com/apk/res/android
95 |
96 |
97 | ANDROID_ATTRIBUTE_ORDER
98 |
99 |
100 |
101 |
102 |
103 |
104 | .*
105 |
106 | .*
107 |
108 |
109 | BY_NAME
110 |
111 |
112 |
113 |
114 |
115 |
116 |
--------------------------------------------------------------------------------
/SudokuApp-GS/Sudoku/.idea/codeStyles/Project.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 | xmlns:android
14 |
15 | ^$
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 | xmlns:.*
25 |
26 | ^$
27 |
28 |
29 | BY_NAME
30 |
31 |
32 |
33 |
34 |
35 |
36 | .*:id
37 |
38 | http://schemas.android.com/apk/res/android
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 | .*:name
48 |
49 | http://schemas.android.com/apk/res/android
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 | name
59 |
60 | ^$
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 | style
70 |
71 | ^$
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 | .*
81 |
82 | ^$
83 |
84 |
85 | BY_NAME
86 |
87 |
88 |
89 |
90 |
91 |
92 | .*
93 |
94 | http://schemas.android.com/apk/res/android
95 |
96 |
97 | ANDROID_ATTRIBUTE_ORDER
98 |
99 |
100 |
101 |
102 |
103 |
104 | .*
105 |
106 | .*
107 |
108 |
109 | BY_NAME
110 |
111 |
112 |
113 |
114 |
115 |
116 |
--------------------------------------------------------------------------------
/Sudoku/dlx/dlx/SudokuDLX.java:
--------------------------------------------------------------------------------
1 | package dlx;
2 |
3 | import java.util.*;
4 |
5 | public class SudokuDLX extends AbstractSudokuSolver {
6 | public static void copyBoard(int[][] board, int[][] newBoard) {
7 | for (int i = 0; i < 9; i ++) {
8 | for (int j = 0; j < 9; j ++) {
9 | newBoard[i][j] = board[i][j];
10 | }
11 | }
12 | }
13 |
14 | public static int[][] fromString(String s) {
15 | int[][] board = new int[9][9];
16 | for (int i = 0; i < 81; i++) {
17 | char c = s.charAt(i);
18 | int row = i / 9;
19 | int col = i % 9;
20 | if (c != '.') {
21 | board[row][col] = c - '0';
22 | }
23 | }
24 | return board;
25 | }
26 |
27 |
28 |
29 | // sudoku has numbers 1-9. A 0 indicates an empty cell that we will need to
30 | // fill in.
31 | private int[][] makeExactCoverGrid(int[][] sudoku) {
32 | int[][] R = sudokuExactCover();
33 | for (int i = 1; i <= S; i++) {
34 | for (int j = 1; j <= S; j++) {
35 | int n = sudoku[i - 1][j - 1];
36 | if (n != 0) { // zero out in the constraint board
37 | for (int num = 1; num <= S; num++) {
38 | if (num != n) {
39 | Arrays.fill(R[getIdx(i, j, num)], 0);
40 | }
41 | }
42 | }
43 | }
44 | }
45 | return R;
46 | }
47 |
48 | // Returns the base exact cover grid for a SUDOKU puzzle
49 | private int[][] sudokuExactCover() {
50 | int[][] R = new int[9 * 9 * 9][9 * 9 * 4];
51 |
52 | int hBase = 0;
53 |
54 | // row-column constraints
55 | for (int r = 1; r <= S; r++) {
56 | for (int c = 1; c <= S; c++, hBase++) {
57 | for (int n = 1; n <= S; n++) {
58 | R[getIdx(r, c, n)][hBase] = 1;
59 | }
60 | }
61 | }
62 |
63 | // row-number constraints
64 | for (int r = 1; r <= S; r++) {
65 | for (int n = 1; n <= S; n++, hBase++) {
66 | for (int c1 = 1; c1 <= S; c1++) {
67 | R[getIdx(r, c1, n)][hBase] = 1;
68 | }
69 | }
70 | }
71 |
72 | // column-number constraints
73 |
74 | for (int c = 1; c <= S; c++) {
75 | for (int n = 1; n <= S; n++, hBase++) {
76 | for (int r1 = 1; r1 <= S; r1++) {
77 | R[getIdx(r1, c, n)][hBase] = 1;
78 | }
79 | }
80 | }
81 |
82 | // box-number constraints
83 |
84 | for (int br = 1; br <= S; br += side) {
85 | for (int bc = 1; bc <= S; bc += side) {
86 | for (int n = 1; n <= S; n++, hBase++) {
87 | for (int rDelta = 0; rDelta < side; rDelta++) {
88 | for (int cDelta = 0; cDelta < side; cDelta++) {
89 | R[getIdx(br + rDelta, bc + cDelta, n)][hBase] = 1;
90 | }
91 | }
92 | }
93 | }
94 | }
95 |
96 | return R;
97 | }
98 |
99 | // row [1,S], col [1,S], num [1,S]
100 | private int getIdx(int row, int col, int num) {
101 | return (row - 1) * S * S + (col - 1) * S + (num - 1);
102 | }
103 |
104 |
105 | protected void runSolver(int[][] sudoku) {
106 | int[][] cover = makeExactCoverGrid(sudoku);
107 | DancingLinks dlx = new DancingLinks(cover, new SudokuHandler(S));
108 | dlx.runSolver();
109 | if (dlx.solutionBoard != null) {
110 | this.solutionBoard = new int[9][9];
111 | copyBoard(dlx.solutionBoard, this.solutionBoard);
112 | }
113 | solutions = dlx.solutions;
114 | }
115 | }
116 |
--------------------------------------------------------------------------------
/Sudoku/dlx/dlx/AbstractSudokuSolver.java:
--------------------------------------------------------------------------------
1 | package dlx;
2 |
3 | import java.util.Arrays;
4 |
5 | abstract class AbstractSudokuSolver{
6 | public int solutions;
7 | protected int S = 9; // size of the board
8 | protected int side = 3; // how long the side is
9 | public int[][] solutionBoard;
10 |
11 | protected abstract void runSolver(int[][] sudoku);
12 |
13 | public boolean solve(int[][] sudoku){
14 | if(!validateSudoku(sudoku)){
15 | // System.out.println("Error: Invalid sudoku. Aborting....");
16 | return false;
17 | }
18 | S = sudoku.length;
19 | side = (int)Math.sqrt(S);
20 | runSolver(sudoku);
21 | if (solutionBoard != null) {
22 | return true;
23 | }
24 | return false;
25 | }
26 |
27 | public boolean solve(String[] s){
28 | return solve(fromCharArr(s));
29 | }
30 |
31 |
32 | private static int[][] fromCharArr(String[] s){
33 | int S = s.length;
34 | int[][] out = new int[S][S];
35 | for(int i = 0; i < S; i++){
36 | for(int j = 0; j < S; j++){
37 | int num = s[i].charAt(j) - '1';
38 | if (num >= 1 && num <= S)
39 | out[i][j] = num;
40 | }
41 | }
42 | return out;
43 | }
44 |
45 | public static void printSolution(int[][] result){
46 | int N = result.length;
47 | for(int i = 0; i < N; i++){
48 | String ret = "";
49 | for(int j = 0; j < N; j++){
50 | ret += result[i][j] + " ";
51 | }
52 | System.out.println(ret);
53 | }
54 | System.out.println();
55 | }
56 |
57 |
58 | // Checks whether `grid` represents a valid sudoku puzzle.
59 | // O's represent empty cells. 1..n^2 represent numbers in the grid.
60 | // Only allowed sizes are 9 and 16 for now.
61 | public static boolean validateSudoku(int[][] grid){
62 | if (grid.length != 9 && grid.length != 16)
63 | return false; // only 9 or 16 for now
64 | for(int i = 0; i < grid.length; i++){
65 | if (grid[i].length != grid.length)
66 | return false;
67 | for(int j = 0; j < grid[i].length; j++){
68 | if (!(i >= 0 && i <= grid.length))
69 | return false; // 0 means not filled in
70 | }
71 | }
72 |
73 | int N = grid.length;
74 |
75 | boolean[] b = new boolean[N+1];
76 |
77 | for(int i = 0; i < N; i++){
78 | for(int j = 0; j < N; j++){
79 | if (grid[i][j] == 0)
80 | continue;
81 | if (b[grid[i][j]])
82 | return false;
83 | b[grid[i][j]] = true;
84 | }
85 | Arrays.fill(b, false);
86 | }
87 |
88 | for(int i = 0; i < N; i++){
89 | for(int j = 0; j < N; j++){
90 | if (grid[j][i] == 0)
91 | continue;
92 | if (b[grid[j][i]])
93 | return false;
94 | b[grid[j][i]] = true;
95 | }
96 | Arrays.fill(b, false);
97 | }
98 |
99 | int side = (int)Math.sqrt(N);
100 |
101 | for(int i = 0; i < N; i += side){
102 | for(int j = 0; j < N; j += side){
103 | for(int d1 = 0; d1 < side; d1++){
104 | for(int d2 = 0; d2 < side; d2++){
105 | if (grid[i + d1][j + d2] == 0)
106 | continue;
107 | if (b[grid[i + d1][j + d2]])
108 | return false;
109 | b[grid[i + d1][j + d2]] = true;
110 | }
111 | }
112 | Arrays.fill(b, false);
113 | }
114 | }
115 | return true;
116 | }
117 |
118 |
119 | }
120 |
--------------------------------------------------------------------------------
/Sudoku/dlx/dlx/GenerateBoard.java:
--------------------------------------------------------------------------------
1 | package dlx;
2 |
3 | import java.util.*;
4 | import java.util.stream.Collectors;
5 | import java.util.stream.IntStream;
6 |
7 | public class GenerateBoard {
8 |
9 | public int[][] board;
10 | private static final int INITNUM = 30;
11 | public int level;
12 | public int actualLevel;
13 | public static void printBoard(int[][] solutionBoard) {
14 | System.out.println("--------------------------");
15 | for (int[] row : solutionBoard) {
16 | for (int item : row) {
17 | System.out.print(item + " ");
18 | }
19 | System.out.println("");
20 | }
21 | System.out.println("--------------------------");
22 | }
23 |
24 | public void printBoard() {
25 | printBoard(board);
26 | }
27 |
28 |
29 | // public static void main(String[] args) {
30 | // GenerateBoard newBoard = new GenerateBoard();
31 | //
32 | // newBoard.initBoard();
33 | // newBoard.printBoard();
34 | // newBoard.run(10);
35 | //
36 | // newBoard.printBoard();
37 | // }
38 |
39 | public void run(int level) {
40 | this.level = level;
41 | while(actualLevel != level) {
42 | initBoard();
43 | dig();
44 | }
45 | }
46 |
47 | // 根据初始局解出任意一个终局
48 | public void initBoard() {
49 | SudokuDLX sudoku = new SudokuDLX();
50 | randBorad();
51 | while(!sudoku.solve(board)) {
52 | randBorad();
53 | }
54 | SudokuDLX.copyBoard(sudoku.solutionBoard, board);
55 | }
56 | // 生成一个随机的初始局,随机填入 INITNUM 个数字
57 | private void randBorad() {
58 | this.board = new int[9][9];
59 | int count = INITNUM;
60 | Random random = new Random();
61 | while(count > 0) {
62 | int xPositionRand = random.nextInt(9);
63 | int yPositionRand = random.nextInt(9);
64 | int value = random.nextInt(9);
65 | if (board[xPositionRand][yPositionRand] == 0) {
66 | board[xPositionRand][yPositionRand] = value + 1;
67 | if (SudokuDLX.validateSudoku(board)) {
68 | count--;
69 | } else {
70 | board[xPositionRand][yPositionRand] = 0;
71 | }
72 | }
73 | }
74 | }
75 |
76 | private void dig() {
77 | List positions = IntStream.range(0, 81)
78 | .boxed().collect(Collectors.toList());
79 | int count = level;
80 | Random random = new Random();
81 | SudokuDLX sudoku = new SudokuDLX();
82 | while(count > 0) {
83 | if (positions.isEmpty()) {
84 | // System.out.println("未达标");
85 | break;
86 | } else {
87 | // int targetPosition = random.nextInt(positions.size());
88 | int targetPosition = 0;
89 | int xPosition = positions.get(targetPosition) / 9;
90 | int yPosition = positions.get(targetPosition) % 9;
91 | int prevValue = board[xPosition][yPosition];
92 | positions.remove(targetPosition);
93 |
94 | boolean digAble = true;
95 |
96 | for (int i : IntStream.rangeClosed(1, 9).toArray()) {
97 | if (i != prevValue) {
98 | board[xPosition][yPosition] = i;
99 | if (sudoku.solve(board)) {
100 | // 如果有解
101 | digAble = false;
102 | break;
103 | }
104 | }
105 | }
106 | if (digAble) {
107 | board[xPosition][yPosition] = 0;
108 | count--;
109 | } else {
110 | board[xPosition][yPosition] = prevValue;
111 | }
112 | }
113 | }
114 | actualLevel = level - count;
115 | }
116 |
117 |
118 | }
119 |
--------------------------------------------------------------------------------
/newSudoku/dlx/GenerateBoard.java:
--------------------------------------------------------------------------------
1 | package dlx;
2 |
3 | import java.util.List;
4 | import java.util.Random;
5 | import java.util.stream.Collectors;
6 | import java.util.stream.IntStream;
7 |
8 | public class GenerateBoard {
9 | public int[][] board;
10 | public int[][] anwser;
11 | private final int INITNUM;
12 | public int level;
13 | public int actualLevel;
14 | private int S;
15 | private int side;
16 |
17 | public GenerateBoard(int gridLength, int side) {
18 | this.S = gridLength;
19 | this.side = side;
20 | if (S == 9) {
21 | INITNUM = 30;
22 | } else {
23 | INITNUM = 5;
24 | }
25 | }
26 |
27 | public static void printBoard(int[][] solutionBoard) {
28 | System.out.println("--------------------------");
29 | for (int[] row : solutionBoard) {
30 | for (int item : row) {
31 | System.out.print(item + " ");
32 | }
33 | System.out.println("");
34 | }
35 | System.out.println("--------------------------");
36 | }
37 |
38 | public void printBoard() {
39 | printBoard(board);
40 | }
41 |
42 |
43 | public void run(int level) {
44 | if (level > S * S) {
45 | System.out.println("臣妾做不到啊~");
46 | return;
47 | }
48 | this.level = level;
49 | while(actualLevel != level) {
50 | initBoard();
51 | dig();
52 | }
53 | }
54 |
55 | // 根据初始局解出任意一个终局
56 | public void initBoard() {
57 | SudokuDLX sudoku = new SudokuDLX(S, side);
58 | randBorad();
59 | while(!sudoku.solve(board)) {
60 | randBorad();
61 | }
62 | SudokuDLX.copyBoard(sudoku.solutionBoard, board);
63 | anwser = new int[S][S];
64 | SudokuDLX.copyBoard(sudoku.solutionBoard, anwser);
65 | }
66 |
67 | // 生成一个随机的初始局,随机填入 INITNUM 个数字
68 | private void randBorad() {
69 | this.board = new int[S][S];
70 | int count = INITNUM;
71 | Random random = new Random();
72 | while(count > 0) {
73 | int xPositionRand = random.nextInt(S);
74 | int yPositionRand = random.nextInt(S);
75 | int value = random.nextInt(S);
76 | if (board[yPositionRand][xPositionRand] == 0) {
77 | if (SudokuDLX.validatePosition(board, yPositionRand, xPositionRand, value + 1)) {
78 | board[yPositionRand][xPositionRand] = value + 1;
79 | count--;
80 | }
81 | }
82 | }
83 | }
84 |
85 | private void dig() {
86 | List positions = IntStream.range(0, S * S)
87 | .boxed().collect(Collectors.toList());
88 | int count = level;
89 | Random random = new Random();
90 | SudokuDLX sudoku = new SudokuDLX(S, side);
91 | while(count > 0) {
92 | if (positions.isEmpty()) {
93 | // System.out.println("未达标");
94 | break;
95 | } else {
96 | int targetPosition = random.nextInt(positions.size());
97 | // int targetPosition = 0;
98 | int xPosition = positions.get(targetPosition) / S;
99 | int yPosition = positions.get(targetPosition) % S;
100 | int prevValue = board[xPosition][yPosition];
101 | positions.remove(targetPosition);
102 |
103 | boolean digAble = true;
104 |
105 | for (int i : IntStream.rangeClosed(1, S).toArray()) {
106 | if (i != prevValue) {
107 | board[xPosition][yPosition] = i;
108 | if (sudoku.solve(board)) {
109 | // 如果有解
110 | digAble = false;
111 | break;
112 | }
113 | }
114 | }
115 | if (digAble) {
116 | board[xPosition][yPosition] = 0;
117 | count--;
118 | } else {
119 | board[xPosition][yPosition] = prevValue;
120 | }
121 | }
122 | }
123 | actualLevel = level - count;
124 | }
125 | }
126 |
--------------------------------------------------------------------------------
/SudokuApp-GS/Sudoku/app/src/main/java/com/example/sudoku/ChooseType.java:
--------------------------------------------------------------------------------
1 | package com.example.sudoku;
2 |
3 | import androidx.appcompat.app.AppCompatActivity;
4 |
5 | import android.content.Intent;
6 | import android.content.SharedPreferences;
7 | import android.os.Bundle;
8 | import android.view.View;
9 |
10 | import com.google.android.material.button.MaterialButton;
11 |
12 | import org.litepal.LitePal;
13 | import org.litepal.crud.LitePalSupport;
14 |
15 | import java.util.List;
16 |
17 | public class ChooseType extends AppCompatActivity {
18 |
19 | private LastRecord lastRecord = null;
20 |
21 | @Override
22 | protected void onCreate(Bundle savedInstanceState) {
23 | super.onCreate(savedInstanceState);
24 | setContentView(R.layout.activity_choose_type);
25 |
26 | MaterialButton typeFour = (MaterialButton) findViewById(R.id.typeFour);
27 | MaterialButton typeNine = (MaterialButton) findViewById(R.id.typeNine);
28 | typeFour.setOnClickListener(new View.OnClickListener() {
29 | @Override
30 | public void onClick(View v) {
31 | Intent intent = new Intent(ChooseType.this, ChooseLevel.class);
32 | intent.putExtra("gridLength", 4);
33 |
34 | SharedPreferences pref = getSharedPreferences("currentUser", MODE_PRIVATE);
35 | String name = pref.getString("name", "");
36 |
37 | List records = LitePal.where("user = ?", name).find(LastRecord.class);
38 | if (!records.isEmpty()) {
39 | LastRecord preRecord = records.get(0);
40 | LastRecord.LastToHistory(preRecord).save();
41 | LitePal.deleteAll(LastRecord.class, "user = ?", name);
42 | }
43 | startActivity(intent);
44 | }
45 | });
46 |
47 | typeNine.setOnClickListener(new View.OnClickListener() {
48 | @Override
49 | public void onClick(View v) {
50 | Intent intent = new Intent(ChooseType.this, ChooseLevel.class);
51 | intent.putExtra("gridLength", 9);
52 | SharedPreferences pref = getSharedPreferences("currentUser", MODE_PRIVATE);
53 | String name = pref.getString("name", "");
54 |
55 | List records = LitePal.where("user = ?", name).find(LastRecord.class);
56 | if (!records.isEmpty()) {
57 | LastRecord preRecord = records.get(0);
58 | LastRecord.LastToHistory(preRecord).save();
59 | LitePal.deleteAll(LastRecord.class, "user = ?", name);
60 | }
61 | startActivity(intent);
62 | }
63 | });
64 |
65 | MaterialButton resume = (MaterialButton) findViewById(R.id.resume);
66 |
67 | SharedPreferences pref = getSharedPreferences("currentUser", MODE_PRIVATE);
68 | String name = pref.getString("name", "");
69 |
70 | List record = LitePal.where("user = ?", name).find(LastRecord.class);
71 | if (record.isEmpty()) {
72 | // resume.setClickable(false);
73 | resume.setVisibility(View.GONE);
74 | }
75 |
76 | resume.setOnClickListener(new View.OnClickListener() {
77 | @Override
78 | public void onClick(View v) {
79 | SharedPreferences pref = getSharedPreferences("currentUser", MODE_PRIVATE);
80 | String name = pref.getString("name", "");
81 |
82 | Intent intent = new Intent(ChooseType.this, SudokuNine.class);
83 | intent.putExtra("resume", true);
84 | intent.putExtra("gridLength", LitePal.where("user = ?", name).find(LastRecord.class).get(0).getType());
85 | startActivity(intent);
86 | }
87 | });
88 | }
89 |
90 | @Override
91 | protected void onResume() {
92 | super.onResume();
93 | MaterialButton resume = (MaterialButton) findViewById(R.id.resume);
94 | SharedPreferences pref = getSharedPreferences("currentUser", MODE_PRIVATE);
95 | String name = pref.getString("name", "");
96 |
97 | List record = LitePal.where("user = ?", name).find(LastRecord.class);
98 | if (!record.isEmpty()) {
99 | // resume.setClickable(false);
100 | resume.setVisibility(View.VISIBLE);
101 | }
102 | }
103 | }
104 |
--------------------------------------------------------------------------------
/SudokuApp-GS/Sudoku/app/src/main/java/com/example/sudoku/HistoryItemAdapter.java:
--------------------------------------------------------------------------------
1 | package com.example.sudoku;
2 |
3 |
4 | import android.graphics.Color;
5 | import android.view.LayoutInflater;
6 | import android.view.ViewGroup;
7 | import android.widget.LinearLayout;
8 | import android.widget.TextView;
9 |
10 | import androidx.annotation.NonNull;
11 | import androidx.constraintlayout.widget.ConstraintLayout;
12 | import androidx.recyclerview.widget.RecyclerView;
13 |
14 | import com.example.sudoku.dlx.GenerateBoard;
15 | import com.google.android.material.card.MaterialCardView;
16 |
17 | import java.util.List;
18 | import java.util.concurrent.TimeUnit;
19 |
20 | public class HistoryItemAdapter extends RecyclerView.Adapter {
21 | private List mHistory;
22 |
23 | private static String formatInterval(final long millis) {
24 | final long hr = TimeUnit.MILLISECONDS.toHours(millis);
25 | final long min = TimeUnit.MILLISECONDS.toMinutes(millis - TimeUnit.HOURS.toMillis(hr));
26 | final long sec = TimeUnit.MILLISECONDS.toSeconds(millis - TimeUnit.HOURS.toMillis(hr) - TimeUnit.MINUTES.toMillis(min));
27 | // final long ms = TimeUnit.MILLISECONDS.toMillis(millis - TimeUnit.HOURS.toMillis(hr) - TimeUnit.MINUTES.toMillis(min) - TimeUnit.SECONDS.toMillis(sec));
28 | return String.format("%02d:%02d:%02d", hr, min, sec);
29 | }
30 | static class ViewHolder extends RecyclerView.ViewHolder {
31 | public MaterialCardView materialCardView;
32 | public TextView userText;
33 | public TextView timeText;
34 | public TextView typeText;
35 | public TextView levelText;
36 | public TextView resultText;
37 | public TextView progressText;
38 | public ViewHolder(MaterialCardView v) {
39 | super(v);
40 | materialCardView = v;
41 | LinearLayout linearLayout = (LinearLayout) materialCardView.getChildAt(0);
42 | ConstraintLayout icons = (ConstraintLayout) linearLayout.getChildAt(0);
43 | ConstraintLayout result = (ConstraintLayout) linearLayout.getChildAt(1);
44 |
45 | LinearLayout temp = (LinearLayout) icons.getChildAt(0);
46 | userText = (TextView) temp.getChildAt(1);
47 | temp = (LinearLayout) icons.getChildAt(1);
48 | timeText = (TextView) temp.getChildAt(1);
49 | temp = (LinearLayout) icons.getChildAt(2);
50 | typeText = (TextView) temp.getChildAt(1);
51 | temp = (LinearLayout) icons.getChildAt(3);
52 | levelText = (TextView) temp.getChildAt(1);
53 |
54 |
55 | resultText = (TextView) result.getChildAt(0);
56 | progressText = (TextView) result.getChildAt(1);
57 | }
58 | }
59 |
60 | public HistoryItemAdapter(List gameRecords) {
61 | mHistory = gameRecords;
62 | }
63 |
64 | @NonNull
65 | @Override
66 | public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
67 | MaterialCardView v= (MaterialCardView) LayoutInflater.from(parent.getContext())
68 | .inflate(R.layout.history_item, parent, false);
69 | ViewHolder vh = new ViewHolder(v);
70 | return vh;
71 | }
72 |
73 | @Override
74 | public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
75 | GameRecord gameRecord= mHistory.get(position);
76 | holder.userText.setText(gameRecord.getUser());
77 | holder.timeText.setText(formatInterval(-gameRecord.getusedTime()));
78 | holder.typeText.setText(gameRecord.getType() == 9 ? "九宫" : "四宫");
79 | int level = gameRecord.getLevel();
80 | String[] texts = new String[] {"简单", "中等", "困难", "极难"};
81 | if (gameRecord.getType() == 9) {
82 | holder.levelText.setText(texts[(gameRecord.getLevel() - 20) / 10]);
83 | } else {
84 | holder.levelText.setText(texts[(gameRecord.getLevel() - 3) / 3]);
85 | }
86 |
87 | int correctCount = GenerateBoard.correctCount(
88 | gameRecord.getOrigin(), gameRecord.getAnwser(), gameRecord.getCurrent()
89 | );
90 | holder.progressText.setText(correctCount + " / " + gameRecord.getLevel());
91 |
92 | holder.resultText.setText(correctCount == level ? "成功" : "失败");
93 | holder.resultText.setTextColor(correctCount == level ?
94 | Color.parseColor("#66ff33") :
95 | Color.parseColor("#ff0000")
96 | );
97 |
98 | holder.materialCardView.setStrokeColor(correctCount == level ?
99 | Color.parseColor("#66ff33") :
100 | Color.parseColor("#ff4d4d"));
101 | }
102 |
103 | @Override
104 | public int getItemCount() {
105 | return mHistory.size();
106 | }
107 | }
108 |
--------------------------------------------------------------------------------
/SudokuApp-GS/Sudoku/app/src/main/res/drawable/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
10 |
12 |
14 |
16 |
18 |
20 |
22 |
24 |
26 |
28 |
30 |
32 |
34 |
36 |
38 |
40 |
42 |
44 |
46 |
48 |
50 |
52 |
54 |
56 |
58 |
60 |
62 |
64 |
66 |
68 |
70 |
72 |
74 |
75 |
--------------------------------------------------------------------------------
/Sudoku/dlx/dlx/DancingLinks.java:
--------------------------------------------------------------------------------
1 | // Author: Rafal Szymanski
2 |
3 | // Implementation of the Dancing Links algorithm for exact cover.
4 |
5 | package dlx;
6 |
7 | import java.util.*;
8 |
9 | public class DancingLinks{
10 |
11 | static final boolean verbose = true;
12 |
13 | class DancingNode{
14 | DancingNode L, R, U, D;
15 | ColumnNode C;
16 |
17 | DancingNode hookDown(DancingNode n1){
18 | assert (this.C == n1.C);
19 | n1.D = this.D;
20 | n1.D.U = n1;
21 | n1.U = this;
22 | this.D = n1;
23 | return n1;
24 | }
25 |
26 | DancingNode hookRight(DancingNode n1){
27 | n1.R = this.R;
28 | n1.R.L = n1;
29 | n1.L = this;
30 | this.R = n1;
31 | return n1;
32 | }
33 |
34 | void unlinkLR(){
35 | this.L.R = this.R;
36 | this.R.L = this.L;
37 | }
38 |
39 | void relinkLR(){
40 | this.L.R = this.R.L = this;
41 | }
42 |
43 | void unlinkUD(){
44 | this.U.D = this.D;
45 | this.D.U = this.U;
46 | }
47 |
48 | void relinkUD(){
49 | this.U.D = this.D.U = this;
50 | }
51 |
52 | public DancingNode(){
53 | L = R = U = D = this;
54 | }
55 |
56 | public DancingNode(ColumnNode c){
57 | this();
58 | C = c;
59 | }
60 | }
61 |
62 | class ColumnNode extends DancingNode{
63 | int size; // number of ones in current column
64 | String name;
65 |
66 | public ColumnNode(String n){
67 | super();
68 | size = 0;
69 | name = n;
70 | C = this;
71 | }
72 |
73 | void cover(){
74 | unlinkLR();
75 | for(DancingNode i = this.D; i != this; i = i.D){
76 | for(DancingNode j = i.R; j != i; j = j.R){
77 | j.unlinkUD();
78 | j.C.size--;
79 | }
80 | }
81 | header.size--;
82 | }
83 |
84 | void uncover(){
85 | for(DancingNode i = this.U; i != this; i = i.U){
86 | for(DancingNode j = i.L; j != i; j = j.L){
87 | j.C.size++;
88 | j.relinkUD();
89 | }
90 | }
91 | relinkLR();
92 | header.size++;
93 | }
94 | }
95 |
96 | private ColumnNode header;
97 | public int solutions = 0;
98 | private SolutionHandler handler;
99 | private List answer;
100 | public int [][] solutionBoard;
101 |
102 | private void search(int k){
103 | if (header.R == header){
104 | solutionBoard = handler.handleSolution(answer);
105 | solutions++;
106 | } else{
107 | ColumnNode c = selectColumnNodeHeuristic();
108 | c.cover();
109 |
110 | for(DancingNode r = c.D; r != c; r = r.D){
111 | answer.add(r);
112 |
113 | for(DancingNode j = r.R; j != r; j = j.R){
114 | j.C.cover();
115 | }
116 |
117 | search(k + 1);
118 |
119 | r = answer.remove(answer.size() - 1);
120 | c = r.C;
121 |
122 | for(DancingNode j = r.L; j != r; j = j.L){
123 | j.C.uncover();
124 | }
125 | }
126 | c.uncover();
127 | }
128 | }
129 |
130 | private ColumnNode selectColumnNodeHeuristic(){
131 | int min = Integer.MAX_VALUE;
132 | ColumnNode ret = null;
133 | for(ColumnNode c = (ColumnNode) header.R; c != header; c = (ColumnNode) c.R){
134 | if (c.size < min){
135 | min = c.size;
136 | ret = c;
137 | }
138 | }
139 | return ret;
140 | }
141 |
142 | private ColumnNode makeDLXBoard(int[][] grid){
143 | final int COLS = grid[0].length;
144 | final int ROWS = grid.length;
145 |
146 | ColumnNode headerNode = new ColumnNode("header");
147 | ArrayList columnNodes = new ArrayList();
148 |
149 | for(int i = 0; i < COLS; i++){
150 | ColumnNode n = new ColumnNode(Integer.toString(i));
151 | columnNodes.add(n);
152 | headerNode = (ColumnNode) headerNode.hookRight(n);
153 | }
154 | headerNode = headerNode.R.C;
155 |
156 | for(int i = 0; i < ROWS; i++){
157 | DancingNode prev = null;
158 | for(int j = 0; j < COLS; j++){
159 | if (grid[i][j] == 1){
160 | ColumnNode col = columnNodes.get(j);
161 | DancingNode newNode = new DancingNode(col);
162 | if (prev == null)
163 | prev = newNode;
164 | col.U.hookDown(newNode);
165 | prev = prev.hookRight(newNode);
166 | col.size++;
167 | }
168 | }
169 | }
170 |
171 | headerNode.size = COLS;
172 |
173 | return headerNode;
174 | }
175 |
176 |
177 |
178 | public DancingLinks(int[][] grid, SolutionHandler h){
179 | header = makeDLXBoard(grid);
180 | handler = h;
181 | }
182 |
183 | public void runSolver(){
184 | solutions = 0;
185 | answer = new LinkedList();
186 | search(0);
187 | }
188 |
189 | }
190 |
--------------------------------------------------------------------------------
/newSudoku/dlx/DancingLinks.java:
--------------------------------------------------------------------------------
1 | // Author: Rafal Szymanski
2 |
3 | // Implementation of the Dancing Links algorithm for exact cover.
4 |
5 | package dlx;
6 |
7 | import java.util.*;
8 |
9 | public class DancingLinks{
10 |
11 | // static final boolean verbose = true;
12 |
13 | private ColumnNode header;
14 | public int solutions = 0;
15 | private SudokuHandler handler;
16 | private List answer;
17 | public int [][] solutionBoard;
18 |
19 | class DancingNode{
20 | DancingNode L, R, U, D;
21 | ColumnNode C;
22 |
23 | DancingNode hookDown(DancingNode n1){
24 | assert (this.C == n1.C);
25 | n1.D = this.D;
26 | n1.D.U = n1;
27 | n1.U = this;
28 | this.D = n1;
29 | return n1;
30 | }
31 |
32 | DancingNode hookRight(DancingNode n1){
33 | n1.R = this.R;
34 | n1.R.L = n1;
35 | n1.L = this;
36 | this.R = n1;
37 | return n1;
38 | }
39 |
40 | void unlinkLR(){
41 | this.L.R = this.R;
42 | this.R.L = this.L;
43 | }
44 |
45 | void relinkLR(){
46 | this.L.R = this.R.L = this;
47 | }
48 |
49 | void unlinkUD(){
50 | this.U.D = this.D;
51 | this.D.U = this.U;
52 | }
53 |
54 | void relinkUD(){
55 | this.U.D = this.D.U = this;
56 | }
57 |
58 | public DancingNode(){
59 | L = R = U = D = this;
60 | }
61 |
62 | public DancingNode(ColumnNode c){
63 | this();
64 | C = c;
65 | }
66 | }
67 |
68 | class ColumnNode extends DancingNode{
69 | int size; // number of ones in current column
70 | String name;
71 |
72 | public ColumnNode(String n){
73 | super();
74 | size = 0;
75 | name = n;
76 | C = this;
77 | }
78 |
79 | void cover(){
80 | unlinkLR();
81 | for(DancingNode i = this.D; i != this; i = i.D){
82 | for(DancingNode j = i.R; j != i; j = j.R){
83 | j.unlinkUD();
84 | j.C.size--;
85 | }
86 | }
87 | header.size--;
88 | }
89 |
90 | void uncover(){
91 | for(DancingNode i = this.U; i != this; i = i.U){
92 | for(DancingNode j = i.L; j != i; j = j.L){
93 | j.C.size++;
94 | j.relinkUD();
95 | }
96 | }
97 | relinkLR();
98 | header.size++;
99 | }
100 | }
101 |
102 |
103 |
104 | private void search(int k){
105 | if (header.R == header){
106 | solutionBoard = handler.handleSolution(answer);
107 | solutions++;
108 | } else{
109 | ColumnNode c = selectColumnNodeHeuristic();
110 | c.cover();
111 |
112 | for(DancingNode r = c.D; r != c; r = r.D){
113 | answer.add(r);
114 |
115 | for(DancingNode j = r.R; j != r; j = j.R){
116 | j.C.cover();
117 | }
118 |
119 | search(k + 1);
120 |
121 | r = answer.remove(answer.size() - 1);
122 | c = r.C;
123 |
124 | for(DancingNode j = r.L; j != r; j = j.L){
125 | j.C.uncover();
126 | }
127 | }
128 | c.uncover();
129 | }
130 | }
131 |
132 | private ColumnNode selectColumnNodeHeuristic(){
133 | int min = Integer.MAX_VALUE;
134 | ColumnNode ret = null;
135 | for(ColumnNode c = (ColumnNode) header.R; c != header; c = (ColumnNode) c.R){
136 | if (c.size < min){
137 | min = c.size;
138 | ret = c;
139 | }
140 | }
141 | return ret;
142 | }
143 |
144 | private ColumnNode makeDLXBoard(int[][] grid){
145 | final int COLS = grid[0].length;
146 | final int ROWS = grid.length;
147 |
148 | ColumnNode headerNode = new ColumnNode("header");
149 | ArrayList columnNodes = new ArrayList();
150 |
151 | for(int i = 0; i < COLS; i++){
152 | ColumnNode n = new ColumnNode(Integer.toString(i));
153 | columnNodes.add(n);
154 | headerNode = (ColumnNode) headerNode.hookRight(n);
155 | }
156 | headerNode = headerNode.R.C;
157 |
158 | for(int i = 0; i < ROWS; i++){
159 | DancingNode prev = null;
160 | for(int j = 0; j < COLS; j++){
161 | if (grid[i][j] == 1){
162 | ColumnNode col = columnNodes.get(j);
163 | DancingNode newNode = new DancingNode(col);
164 | if (prev == null)
165 | prev = newNode;
166 | col.U.hookDown(newNode);
167 | prev = prev.hookRight(newNode);
168 | col.size++;
169 | }
170 | }
171 | }
172 |
173 | headerNode.size = COLS;
174 |
175 | return headerNode;
176 | }
177 |
178 |
179 |
180 | public DancingLinks(int[][] grid, SudokuHandler h){
181 | header = makeDLXBoard(grid);
182 | handler = h;
183 | }
184 |
185 | public void runSolver(){
186 | solutions = 0;
187 | answer = new LinkedList();
188 | search(0);
189 | }
190 |
191 | }
192 |
--------------------------------------------------------------------------------
/SudokuApp-GS/Sudoku/app/src/main/java/com/example/sudoku/dlx/DancingLinks.java:
--------------------------------------------------------------------------------
1 | // Author: Rafal Szymanski
2 |
3 | // Implementation of the Dancing Links algorithm for exact cover.
4 |
5 | package com.example.sudoku.dlx;
6 |
7 | import java.util.*;
8 |
9 | public class DancingLinks{
10 |
11 | // static final boolean verbose = true;
12 |
13 | private ColumnNode header;
14 | public int solutions = 0;
15 | private SudokuHandler handler;
16 | private List answer;
17 | public int [][] solutionBoard;
18 |
19 | class DancingNode{
20 | DancingNode L, R, U, D;
21 | ColumnNode C;
22 |
23 | DancingNode hookDown(DancingNode n1){
24 | assert (this.C == n1.C);
25 | n1.D = this.D;
26 | n1.D.U = n1;
27 | n1.U = this;
28 | this.D = n1;
29 | return n1;
30 | }
31 |
32 | DancingNode hookRight(DancingNode n1){
33 | n1.R = this.R;
34 | n1.R.L = n1;
35 | n1.L = this;
36 | this.R = n1;
37 | return n1;
38 | }
39 |
40 | void unlinkLR(){
41 | this.L.R = this.R;
42 | this.R.L = this.L;
43 | }
44 |
45 | void relinkLR(){
46 | this.L.R = this.R.L = this;
47 | }
48 |
49 | void unlinkUD(){
50 | this.U.D = this.D;
51 | this.D.U = this.U;
52 | }
53 |
54 | void relinkUD(){
55 | this.U.D = this.D.U = this;
56 | }
57 |
58 | public DancingNode(){
59 | L = R = U = D = this;
60 | }
61 |
62 | public DancingNode(ColumnNode c){
63 | this();
64 | C = c;
65 | }
66 | }
67 |
68 | class ColumnNode extends DancingNode{
69 | int size; // number of ones in current column
70 | String name;
71 |
72 | public ColumnNode(String n){
73 | super();
74 | size = 0;
75 | name = n;
76 | C = this;
77 | }
78 |
79 | void cover(){
80 | unlinkLR();
81 | for(DancingNode i = this.D; i != this; i = i.D){
82 | for(DancingNode j = i.R; j != i; j = j.R){
83 | j.unlinkUD();
84 | j.C.size--;
85 | }
86 | }
87 | header.size--;
88 | }
89 |
90 | void uncover(){
91 | for(DancingNode i = this.U; i != this; i = i.U){
92 | for(DancingNode j = i.L; j != i; j = j.L){
93 | j.C.size++;
94 | j.relinkUD();
95 | }
96 | }
97 | relinkLR();
98 | header.size++;
99 | }
100 | }
101 |
102 |
103 |
104 | private void search(int k){
105 | if (header.R == header){
106 | solutionBoard = handler.handleSolution(answer);
107 | solutions++;
108 | } else{
109 | ColumnNode c = selectColumnNodeHeuristic();
110 | c.cover();
111 |
112 | for(DancingNode r = c.D; r != c; r = r.D){
113 | answer.add(r);
114 |
115 | for(DancingNode j = r.R; j != r; j = j.R){
116 | j.C.cover();
117 | }
118 |
119 | search(k + 1);
120 |
121 | r = answer.remove(answer.size() - 1);
122 | c = r.C;
123 |
124 | for(DancingNode j = r.L; j != r; j = j.L){
125 | j.C.uncover();
126 | }
127 | }
128 | c.uncover();
129 | }
130 | }
131 |
132 | private ColumnNode selectColumnNodeHeuristic(){
133 | int min = Integer.MAX_VALUE;
134 | ColumnNode ret = null;
135 | for(ColumnNode c = (ColumnNode) header.R; c != header; c = (ColumnNode) c.R){
136 | if (c.size < min){
137 | min = c.size;
138 | ret = c;
139 | }
140 | }
141 | return ret;
142 | }
143 |
144 | private ColumnNode makeDLXBoard(int[][] grid){
145 | final int COLS = grid[0].length;
146 | final int ROWS = grid.length;
147 |
148 | ColumnNode headerNode = new ColumnNode("header");
149 | ArrayList columnNodes = new ArrayList();
150 |
151 | for(int i = 0; i < COLS; i++){
152 | ColumnNode n = new ColumnNode(Integer.toString(i));
153 | columnNodes.add(n);
154 | headerNode = (ColumnNode) headerNode.hookRight(n);
155 | }
156 | headerNode = headerNode.R.C;
157 |
158 | for(int i = 0; i < ROWS; i++){
159 | DancingNode prev = null;
160 | for(int j = 0; j < COLS; j++){
161 | if (grid[i][j] == 1){
162 | ColumnNode col = columnNodes.get(j);
163 | DancingNode newNode = new DancingNode(col);
164 | if (prev == null)
165 | prev = newNode;
166 | col.U.hookDown(newNode);
167 | prev = prev.hookRight(newNode);
168 | col.size++;
169 | }
170 | }
171 | }
172 |
173 | headerNode.size = COLS;
174 |
175 | return headerNode;
176 | }
177 |
178 |
179 |
180 | public DancingLinks(int[][] grid, SudokuHandler h){
181 | header = makeDLXBoard(grid);
182 | handler = h;
183 | }
184 |
185 | public void runSolver(){
186 | solutions = 0;
187 | answer = new LinkedList();
188 | search(0);
189 | }
190 |
191 | }
192 |
--------------------------------------------------------------------------------
/Simple-sudoku-master/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/SudokuApp-GS/Sudoku/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Attempt to set APP_HOME
10 | # Resolve links: $0 may be a link
11 | PRG="$0"
12 | # Need this for relative symlinks.
13 | while [ -h "$PRG" ] ; do
14 | ls=`ls -ld "$PRG"`
15 | link=`expr "$ls" : '.*-> \(.*\)$'`
16 | if expr "$link" : '/.*' > /dev/null; then
17 | PRG="$link"
18 | else
19 | PRG=`dirname "$PRG"`"/$link"
20 | fi
21 | done
22 | SAVED="`pwd`"
23 | cd "`dirname \"$PRG\"`/" >/dev/null
24 | APP_HOME="`pwd -P`"
25 | cd "$SAVED" >/dev/null
26 |
27 | APP_NAME="Gradle"
28 | APP_BASE_NAME=`basename "$0"`
29 |
30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
31 | DEFAULT_JVM_OPTS=""
32 |
33 | # Use the maximum available, or set MAX_FD != -1 to use that value.
34 | MAX_FD="maximum"
35 |
36 | warn () {
37 | echo "$*"
38 | }
39 |
40 | die () {
41 | echo
42 | echo "$*"
43 | echo
44 | exit 1
45 | }
46 |
47 | # OS specific support (must be 'true' or 'false').
48 | cygwin=false
49 | msys=false
50 | darwin=false
51 | nonstop=false
52 | case "`uname`" in
53 | CYGWIN* )
54 | cygwin=true
55 | ;;
56 | Darwin* )
57 | darwin=true
58 | ;;
59 | MINGW* )
60 | msys=true
61 | ;;
62 | NONSTOP* )
63 | nonstop=true
64 | ;;
65 | esac
66 |
67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
68 |
69 | # Determine the Java command to use to start the JVM.
70 | if [ -n "$JAVA_HOME" ] ; then
71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
72 | # IBM's JDK on AIX uses strange locations for the executables
73 | JAVACMD="$JAVA_HOME/jre/sh/java"
74 | else
75 | JAVACMD="$JAVA_HOME/bin/java"
76 | fi
77 | if [ ! -x "$JAVACMD" ] ; then
78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
79 |
80 | Please set the JAVA_HOME variable in your environment to match the
81 | location of your Java installation."
82 | fi
83 | else
84 | JAVACMD="java"
85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
86 |
87 | Please set the JAVA_HOME variable in your environment to match the
88 | location of your Java installation."
89 | fi
90 |
91 | # Increase the maximum file descriptors if we can.
92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
93 | MAX_FD_LIMIT=`ulimit -H -n`
94 | if [ $? -eq 0 ] ; then
95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
96 | MAX_FD="$MAX_FD_LIMIT"
97 | fi
98 | ulimit -n $MAX_FD
99 | if [ $? -ne 0 ] ; then
100 | warn "Could not set maximum file descriptor limit: $MAX_FD"
101 | fi
102 | else
103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
104 | fi
105 | fi
106 |
107 | # For Darwin, add options to specify how the application appears in the dock
108 | if $darwin; then
109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
110 | fi
111 |
112 | # For Cygwin, switch paths to Windows format before running java
113 | if $cygwin ; then
114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
116 | JAVACMD=`cygpath --unix "$JAVACMD"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Escape application args
158 | save () {
159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
160 | echo " "
161 | }
162 | APP_ARGS=$(save "$@")
163 |
164 | # Collect all arguments for the java command, following the shell quoting and substitution rules
165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
166 |
167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
169 | cd "$(dirname "$0")"
170 | fi
171 |
172 | exec "$JAVACMD" "$@"
173 |
--------------------------------------------------------------------------------
/SudokuApp-GS/Sudoku/app/src/main/java/com/example/sudoku/login.java:
--------------------------------------------------------------------------------
1 | package com.example.sudoku;
2 |
3 | import androidx.appcompat.app.AppCompatActivity;
4 |
5 | import android.annotation.TargetApi;
6 | import android.content.Intent;
7 | import android.content.SharedPreferences;
8 | import android.graphics.Color;
9 | import android.os.Bundle;
10 | import android.speech.tts.TextToSpeech;
11 | import android.view.View;
12 | import android.widget.TextView;
13 | import android.widget.Toast;
14 |
15 | import com.google.android.material.button.MaterialButton;
16 | import com.google.android.material.textfield.TextInputEditText;
17 |
18 | import org.litepal.LitePal;
19 | import org.w3c.dom.Text;
20 |
21 | import java.util.List;
22 |
23 | public class login extends AppCompatActivity {
24 |
25 | @Override
26 | protected void onCreate(Bundle savedInstanceState) {
27 | super.onCreate(savedInstanceState);
28 | LitePal.initialize(this);
29 | setContentView(R.layout.activity_login);
30 | LitePal.getDatabase();
31 | // 用户名和密码
32 | TextInputEditText userName = findViewById(R.id.userName);
33 | TextInputEditText password = findViewById(R.id.pw);
34 |
35 | MaterialButton registerBt = findViewById(R.id.registerBt);
36 | MaterialButton loginBt = findViewById(R.id.loginBt);
37 | TextView skip = findViewById(R.id.skipLogin);
38 | skip.setOnClickListener(new View.OnClickListener() {
39 | @Override
40 | public void onClick(View v) {
41 | SharedPreferences.Editor editor = getSharedPreferences("currentUser", MODE_PRIVATE).edit();
42 | editor.putString("name", "Anonymous");
43 | editor.putString("pass", "Anonymous");
44 | editor.apply();
45 | Intent intent = new Intent(login.this, MainActivity.class);
46 | startActivity(intent);
47 | }
48 | });
49 |
50 | loginBt.setOnClickListener(new View.OnClickListener() {
51 | @Override
52 | public void onClick(View v) {
53 | String user = userName.getText().toString();
54 | String pw = password.getText().toString();
55 | if (user.length() == 0 || pw.length() == 0) {
56 | Toast.makeText(getApplicationContext(), "用户名或密码不能为空哦"
57 | , Toast.LENGTH_SHORT).show();
58 | } else {
59 | List result = LitePal.where("userName = ?", user).find(userInfo.class);
60 | if (result.size() == 0) {
61 | Toast.makeText(getApplicationContext(), "用户不存在哦",
62 | Toast.LENGTH_SHORT).show();
63 | } else if (result.get(0).getPasswordHash().equals(MD5.getMd5(pw))) {
64 | // 如果密码正确则登录成功
65 | SharedPreferences.Editor editor = getSharedPreferences("currentUser", MODE_PRIVATE).edit();
66 | editor.putString("name", user);
67 | // editor.putString("pass", MD5.getMd5(pw));
68 | editor.apply();
69 | Toast.makeText(getApplicationContext(), "登录成功",
70 | Toast.LENGTH_SHORT).show();
71 | Intent intent = new Intent(login.this, MainActivity.class);
72 | startActivity(intent);
73 | } else {
74 | password.setText("");
75 | password.callOnClick();
76 | Toast.makeText(getApplicationContext(), "密码错误哦",
77 | Toast.LENGTH_SHORT).show();
78 | }
79 | }
80 | }
81 | });
82 |
83 | registerBt.setOnClickListener(new View.OnClickListener() {
84 | @Override
85 | public void onClick(View v) {
86 | String user = userName.getText().toString();
87 | String pw = password.getText().toString();
88 | if (user.length() == 0 || pw.length() == 0) {
89 | Toast.makeText(getApplicationContext(), "用户名或密码不能为空哦"
90 | , Toast.LENGTH_SHORT).show();
91 | // userName.setOutlineAmbientShadowColor(Color.parseColor("#ff0000"));
92 | // userName.setOutlineSpotShadowColor(Color.parseColor("#ff0000"));
93 | } else {
94 | List result = LitePal.where("userName = ?", user).find(userInfo.class);
95 | if (result.size() != 0) {
96 | Toast.makeText(getApplicationContext(), "用户已存在哦,请换个名字吧",
97 | Toast.LENGTH_SHORT).show();
98 | } else {
99 | userInfo userRegister = new userInfo();
100 | userRegister.setUserName(user);
101 | userRegister.setPasswordHash(MD5.getMd5(pw));
102 | userRegister.save();
103 | SharedPreferences.Editor editor = getSharedPreferences("currentUser", MODE_PRIVATE).edit();
104 | editor.putString("name", user);
105 | // editor.putString("pass", MD5.getMd5(pw));
106 | editor.apply();
107 | Intent intent = new Intent(login.this, MainActivity.class);
108 | startActivity(intent);
109 | }
110 | }
111 | }
112 | });
113 |
114 |
115 | TextView wipeAll = findViewById(R.id.wipeAll);
116 | wipeAll.setOnClickListener(new View.OnClickListener() {
117 | @Override
118 | public void onClick(View v) {
119 | LitePal.deleteAll(userInfo.class);
120 | LitePal.deleteAll(LastRecord.class);
121 | LitePal.deleteAll(GameRecord.class);
122 |
123 | Toast.makeText(getApplicationContext(), "所有数据已清除", Toast.LENGTH_SHORT).show();
124 | }
125 | });
126 | }
127 | }
128 |
--------------------------------------------------------------------------------
/SudokuApp-GS/Sudoku/app/src/main/res/layout/history_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
13 |
17 |
21 |
22 |
30 |
31 |
38 |
39 |
46 |
47 |
48 |
56 |
57 |
64 |
65 |
72 |
73 |
74 |
82 |
83 |
90 |
91 |
98 |
99 |
100 |
108 |
109 |
116 |
117 |
124 |
125 |
126 |
127 |
128 |
132 |
133 |
146 |
147 |
157 |
158 |
159 |
160 |
161 |
--------------------------------------------------------------------------------
/SudokuApp-GS/Sudoku/app/src/main/java/com/example/sudoku/dlx/GenerateBoard.java:
--------------------------------------------------------------------------------
1 | package com.example.sudoku.dlx;
2 |
3 | import android.annotation.TargetApi;
4 | import android.content.Intent;
5 | import android.os.Handler;
6 | import android.os.Message;
7 | import android.util.Log;
8 |
9 | import java.util.List;
10 | import java.util.Random;
11 |
12 | import java.util.stream.Collectors;
13 | import java.util.stream.IntStream;
14 |
15 | public class GenerateBoard implements Runnable{
16 | public int[][] board;
17 | public int[][] anwser;
18 | private final int INITNUM;
19 | public int level;
20 | public int actualLevel;
21 | private int S;
22 | private int side;
23 | private Handler handler;
24 |
25 | public static String boardToString(int[][] board) {
26 | StringBuilder stringBuilder = new StringBuilder();
27 | int length = board.length;
28 | int value;
29 | for (int r = 0; r < length; r++) {
30 | for (int c = 0; c < length; c++) {
31 | value = board[r][c];
32 | if (value != 0) {
33 | stringBuilder.append(Integer.toString(value));
34 | } else {
35 | stringBuilder.append(".");
36 | }
37 | }
38 | }
39 | return stringBuilder.toString();
40 | }
41 |
42 | public static int[][] boardFromString(String s, int type) {
43 | int[][] board = new int[type][type];
44 | char value;
45 | for (int r = 0; r < type; r++) {
46 | for (int c = 0; c < type; c++) {
47 | value = s.charAt(r * type + c);
48 | if (value != '.') {
49 | board[r][c] = value - '0';
50 | } else {
51 | board[r][c] = 0;
52 | }
53 | }
54 | }
55 |
56 | return board;
57 | }
58 |
59 | public static String noteToString(int[][][] note) {
60 | StringBuilder stringBuilder = new StringBuilder();
61 | int length = note.length;
62 | int value;
63 | for (int r = 0; r < length; r++) {
64 | for (int c = 0; c < length; c++) {
65 | for (int i = 0; i < length; i++) {
66 | value = note[r][c][i];
67 | if (value != 0) {
68 | stringBuilder.append(Integer.toString(value));
69 | } else {
70 | stringBuilder.append(".");
71 | }
72 | }
73 | }
74 | }
75 | return stringBuilder.toString();
76 | }
77 |
78 | public static int[][][] noteFromString(String s, int type) {
79 | int[][][] note = new int[type][type][type];
80 | int index;
81 | for (int r = 0; r < type; r++) {
82 | for (int c = 0; c < type; c++) {
83 | for (int i = 0; i < type; i++) {
84 | index = r * type * type + c * type + i;
85 | char item = s.charAt(index);
86 | if (item != '.') {
87 | note[r][c][i] = item - '0';
88 | } else {
89 | note[r][c][i] = 0;
90 | }
91 | }
92 | }
93 | }
94 | return note;
95 | }
96 |
97 | public GenerateBoard(int gridLength, int level, Handler handler) {
98 | this.handler = handler;
99 | this.level = level;
100 | this.S = gridLength;
101 | this.side = (int) Math.sqrt(gridLength);
102 | if (S == 9) {
103 | INITNUM = 30;
104 | } else {
105 | INITNUM = 5;
106 | }
107 | }
108 |
109 | public static void printBoard(int[][] solutionBoard) {
110 | System.out.println("--------------------------");
111 | for (int[] row : solutionBoard) {
112 | for (int item : row) {
113 | System.out.print(item + " ");
114 | }
115 | System.out.println("");
116 | }
117 | System.out.println("--------------------------");
118 | }
119 |
120 | public static int correctCount(String origin, String anwser, String current) {
121 | int correctNum = 0;
122 | for (int i = origin.length() - 1; i >=0; i--) {
123 | if (origin.charAt(i) == '.' && anwser.charAt(i) == current.charAt(i)) {
124 | correctNum++;
125 | }
126 | }
127 | return correctNum;
128 | }
129 |
130 | public void printBoard() {
131 | printBoard(board);
132 | }
133 |
134 | @Override
135 | public void run() {
136 | initBoard();
137 | if (level > S * S) {
138 | System.out.println("臣妾做不到啊~");
139 | return;
140 | }
141 | while(actualLevel != level) {
142 | initBoard();
143 | dig();
144 | }
145 | Message message = new Message();
146 | message.obj = this;
147 | handler.sendMessage(message);
148 | }
149 |
150 | // 根据初始局解出任意一个终局
151 | public void initBoard() {
152 | SudokuDLX sudoku = new SudokuDLX(S, side);
153 | randBorad();
154 | while(!sudoku.solve(board)) {
155 | randBorad();
156 | }
157 | SudokuDLX.copyBoard(sudoku.solutionBoard, board);
158 | anwser = new int[S][S];
159 | SudokuDLX.copyBoard(sudoku.solutionBoard, anwser);
160 | }
161 |
162 | // 生成一个随机的初始局,随机填入 INITNUM 个数字
163 | private void randBorad() {
164 | this.board = new int[S][S];
165 | int count = INITNUM;
166 | Random random = new Random();
167 | while(count > 0) {
168 | int xPositionRand = random.nextInt(S);
169 | int yPositionRand = random.nextInt(S);
170 | int value = random.nextInt(S);
171 | if (board[yPositionRand][xPositionRand] == 0) {
172 | if (SudokuDLX.validatePosition(board, yPositionRand, xPositionRand, value + 1)) {
173 | board[yPositionRand][xPositionRand] = value + 1;
174 | count--;
175 | }
176 | }
177 | }
178 | }
179 | @TargetApi(24)
180 | private void dig() {
181 | List positions = IntStream.range(0, S * S)
182 | .boxed().collect(Collectors.toList());
183 | int count = level;
184 | Random random = new Random();
185 | SudokuDLX sudoku = new SudokuDLX(S, side);
186 | while(count > 0) {
187 | if (positions.isEmpty()) {
188 | // System.out.println("未达标");
189 | break;
190 | } else {
191 | int targetPosition = random.nextInt(positions.size());
192 | // int targetPosition = 0;
193 | int xPosition = positions.get(targetPosition) / S;
194 | int yPosition = positions.get(targetPosition) % S;
195 | int prevValue = board[xPosition][yPosition];
196 | positions.remove(targetPosition);
197 |
198 | boolean digAble = true;
199 |
200 | for (int i : IntStream.rangeClosed(1, S).toArray()) {
201 | if (i != prevValue) {
202 | board[xPosition][yPosition] = i;
203 | if (sudoku.solve(board)) {
204 | // 如果有解
205 | digAble = false;
206 | break;
207 | }
208 | }
209 | }
210 | if (digAble) {
211 | board[xPosition][yPosition] = 0;
212 | count--;
213 | } else {
214 | board[xPosition][yPosition] = prevValue;
215 | }
216 | }
217 | }
218 | actualLevel = level - count;
219 | }
220 | }
221 |
--------------------------------------------------------------------------------
/Simple-sudoku-master/app/src/main/java/com/example/jobs/newsudo/Sudo.java:
--------------------------------------------------------------------------------
1 | package com.example.jobs.newsudo;
2 |
3 | import android.app.AlertDialog;
4 | import android.content.Context;
5 | import android.graphics.Canvas;
6 | import android.graphics.Color;
7 | import android.graphics.Paint;
8 | import android.support.v4.content.ContextCompat;
9 | import android.view.LayoutInflater;
10 | import android.view.MotionEvent;
11 | import android.view.View;
12 | import android.widget.Button;
13 |
14 | /**
15 | * Created by jobs on 2016/11/4.
16 | */
17 |
18 | public class Sudo extends View {
19 | private String STR = "360000000004230800000004200"
20 | + "070460003820000014500013020" + "001900000007048300000000045";
21 | private Context mContext;
22 | private float width;
23 | private float height;
24 | // 用一个 三维数组 存放已经对应的 x y 已经有的数据
25 | private int usedArray[][][] = new int[9][9][];
26 | // 用 Button 数组将按键记录下来
27 | private Button bt[] = new Button[9];
28 |
29 |
30 |
31 | public Sudo(Context context) {
32 | super(context);
33 | mContext = context;
34 | getUsedArray();
35 | }
36 |
37 |
38 | // 计算对应的 x y 已有的数据
39 | public int[] computerXAndYUsed(int x, int y) {
40 | int used[] = new int[9];
41 |
42 | // 查找横轴 (X)
43 | for (int i = 0; i < 9;
44 | i++) {
45 | int point = getValue(i, y);
46 | if (point != 0) {
47 | used[point - 1] = point;
48 | }
49 | }
50 |
51 | // 查找纵轴 (Y)
52 | for (int i = 0; i < 9; i++) {
53 | int point = getValue(x, i);
54 | if (point != 0) {
55 | used[point - 1] = point;
56 | }
57 | }
58 |
59 | // 查找网格
60 | // 计算出 x y 在网格中的最初位置
61 | int xStart = (x / 3) * 3;
62 | int yStart = (y / 3) * 3;
63 |
64 | for (int i = xStart; i < xStart + 3; i++) {
65 | for (int j = yStart; j < yStart + 3; j++) {
66 | int point = getValue(i, j);
67 | if (point != 0) {
68 | used[point -1] = point;
69 | }
70 | }
71 | }
72 | return used;
73 | }
74 |
75 | // 得到所有 x y 已有的数据
76 | public void getUsedArray() {
77 | for (int i = 0; i < 9; i++) {
78 | for (int j = 0; j < 9; j++) {
79 | usedArray[i][j] = computerXAndYUsed(i, j);
80 | }
81 | }
82 | }
83 |
84 | // 进行修改
85 | public void setSTR(int x, int y, char c) {
86 | // 得到 x y 的长度
87 | int index = y * 9 + x;
88 | String reSTR = STR.substring(0, index);
89 | reSTR += c;
90 | reSTR += STR.substring(index + 1, STR.length());
91 | STR = reSTR;
92 | }
93 |
94 | // 进行重新绘图
95 | public void reDraw() {
96 | // 进行数据刷新
97 | getUsedArray();
98 | invalidate();
99 | }
100 |
101 | // 得到对应 x y 的值
102 | public int getValue(int x, int y) {
103 | return STR.charAt(y * 9 + x) - '0';
104 | }
105 |
106 | @Override
107 | protected void onSizeChanged(int w, int h, int oldw, int oldh) {
108 | // 得到 九宫格 的高度和宽度
109 | width = w / 18f;
110 | height = h / 18f;
111 | super.onSizeChanged(w, h, oldw, oldh);
112 | }
113 |
114 | @Override
115 | protected void onDraw(Canvas canvas) {
116 | Paint paint = new Paint();
117 |
118 | //消除锯齿一样的边缘
119 | paint.setAntiAlias(true);
120 |
121 | // 先画一个空心的矩形 作为外背景
122 | paint.setStyle(Paint.Style.STROKE);
123 | paint.setColor(ContextCompat.getColor(mContext, R.color.top2));
124 | canvas.drawRect(0, 0, this.width*9, this.height*9, paint);
125 |
126 | // 再继续画9条横轴 纵轴
127 | for (int i = 0; i < 9; i++) {
128 | paint.setColor(ContextCompat.getColor(mContext, R.color.back));
129 |
130 | // 横轴
131 | canvas.drawLine(0, i * height, width*9, i * height, paint);
132 | // 纵轴
133 | canvas.drawLine(i * width, 0, i * width, height*9, paint);
134 |
135 | //进行条纹加深
136 | paint.setColor(ContextCompat.getColor(mContext, R.color.top1));
137 |
138 | // 横轴
139 | canvas.drawLine(0, i * height + 3, width*9, i * height + 3, paint);
140 | // 纵轴
141 | canvas.drawLine(i * width + 3, 0, i * width + 3, height*9, paint);
142 |
143 | //将目前的 九宫格 分为 3 块
144 | if (i % 3 == 0) {
145 | paint.setColor(ContextCompat.getColor(mContext, R.color.top2));
146 | // 横轴
147 | canvas.drawLine(0, i * height + 3, width*9, i * height + 3, paint);
148 | // 纵轴
149 | canvas.drawLine(i * width + 3, 0, i * width + 3, height*9, paint);
150 | }
151 | }
152 |
153 | //进行 写入 数字操作 9 * 9
154 |
155 | //Paint.FontMetrics fontMetrics = new Paint.FontMetrics();
156 | paint.setColor(Color.BLACK);
157 | paint.setStyle(Paint.Style.STROKE);
158 | paint.setTextAlign(Paint.Align.CENTER);
159 | paint.setTextSize((float) (height * 0.75));
160 | Paint.FontMetrics fontMetrics = paint.getFontMetrics();
161 | float x = width / 2;
162 | float y = height / 2 - (fontMetrics.ascent + fontMetrics.descent) / 2;
163 |
164 |
165 |
166 | for (int i = 0; i < 9; i++) {
167 | for (int j = 0; j < 9; j++) {
168 | int point = getValue(j, i);
169 | if (point != 0) {
170 | canvas.drawText(String.valueOf(point), j * width + x, i * height + y, paint);
171 | }
172 | }
173 | }
174 | super.onDraw(canvas);
175 | }
176 |
177 | public int[] getUsedToArray(int x, int y) {
178 | return usedArray[x][y];
179 | }
180 |
181 | // 重写 触摸 事件
182 | @Override
183 | public boolean onTouchEvent(MotionEvent event) {
184 | if (event.getAction() == MotionEvent.ACTION_DOWN && event.getX() S) {
214 | return false;
215 | }
216 | if (S == 4 || S == 9) {
217 | int side = (int) Math.sqrt(S);
218 | boolean[] filter = new boolean[S+1];
219 | Arrays.fill(filter,false);
220 | // 检查填入后的行
221 | for (int i = 0; i < S; i++) {
222 | if (board[yPos][i] == value) {
223 | return false;
224 | }
225 | }
226 |
227 | Arrays.fill(filter, false);
228 | for (int i = 0; i < S; i++) {
229 | if (board[i][xPos] == value) {
230 | return false;
231 | }
232 | }
233 |
234 | Arrays.fill(filter, false);
235 | // 算出所在的block
236 | int xBlock = xPos / side;
237 | int yBlock = yPos / side;
238 | for (int m = yBlock * side; m < yBlock * side + side; m++) {
239 | for (int n = xBlock * side; n < xBlock * side + side; n++) {
240 | if (board[m][n] == value) {
241 | return false;
242 | }
243 | }
244 | }
245 |
246 | } else {
247 | return false;
248 | }
249 | return true;
250 | }
251 | }
252 |
--------------------------------------------------------------------------------