From 88fb65409ddce5d9a02d33387fc103d1f5576097 Mon Sep 17 00:00:00 2001 From: Trimutex Date: Mon, 9 Oct 2023 10:25:17 -0500 Subject: [PATCH 01/10] Added base sudoku files --- CMakeLists.txt | 2 +- src/CMakeLists.txt | 6 +++--- src/main.cpp | 6 ------ src/sudoku.cpp | 7 +++++++ 4 files changed, 11 insertions(+), 10 deletions(-) delete mode 100644 src/main.cpp create mode 100644 src/sudoku.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index da0b217..d71f53a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 3.10) project( - something + sudoku LANGUAGES CXX) set(CMAKE_CXX_STANDARD 11 CACHE STRING "The C++ standard to use") diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 4a2d7eb..aa7da15 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,5 +1,5 @@ -add_executable(something - ./main.cpp +add_executable(sudoku + ./sudoku.cpp ) -target_include_directories(something PUBLIC ${CMAKE_CURRENT_LIST_DIR}) +target_include_directories(sudoku PUBLIC ${CMAKE_CURRENT_LIST_DIR}) diff --git a/src/main.cpp b/src/main.cpp deleted file mode 100644 index 29b2fa0..0000000 --- a/src/main.cpp +++ /dev/null @@ -1,6 +0,0 @@ -#include - -int main(void) { - std::cout << "Hello world" << std::endl; - return 0; -} diff --git a/src/sudoku.cpp b/src/sudoku.cpp new file mode 100644 index 0000000..9294f97 --- /dev/null +++ b/src/sudoku.cpp @@ -0,0 +1,7 @@ +#include + +int main(void) { + std::cout << "Sudoku started" << std::endl; + std::cout << "Sudoku ended" << std::endl; + return 0; +} -- 2.45.2 From 84f73df5a0979c0e875a8f32e7ded5e42da114b0 Mon Sep 17 00:00:00 2001 From: Trimutex Date: Mon, 9 Oct 2023 10:27:18 -0500 Subject: [PATCH 02/10] Added easy 50 test --- test/sudoku-easy-50.txt | 499 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 499 insertions(+) create mode 100644 test/sudoku-easy-50.txt diff --git a/test/sudoku-easy-50.txt b/test/sudoku-easy-50.txt new file mode 100644 index 0000000..e9b7224 --- /dev/null +++ b/test/sudoku-easy-50.txt @@ -0,0 +1,499 @@ +003020600 +900305001 +001806400 +008102900 +700000008 +006708200 +002609500 +800203009 +005010300 +======== +200080300 +060070084 +030500209 +000105408 +000000000 +402706000 +301007040 +720040060 +004010003 +======== +000000907 +000420180 +000705026 +100904000 +050000040 +000507009 +920108000 +034059000 +507000000 +======== +030050040 +008010500 +460000012 +070502080 +000603000 +040109030 +250000098 +001020600 +080060020 +======== +020810740 +700003100 +090002805 +009040087 +400208003 +160030200 +302700060 +005600008 +076051090 +======== +100920000 +524010000 +000000070 +050008102 +000000000 +402700090 +060000000 +000030945 +000071006 +======== +043080250 +600000000 +000001094 +900004070 +000608000 +010200003 +820500000 +000000005 +034090710 +======== +480006902 +002008001 +900370060 +840010200 +003704100 +001060049 +020085007 +700900600 +609200018 +======== +000900002 +050123400 +030000160 +908000000 +070000090 +000000205 +091000050 +007439020 +400007000 +======== +001900003 +900700160 +030005007 +050000009 +004302600 +200000070 +600100030 +042007006 +500006800 +======== +000125400 +008400000 +420800000 +030000095 +060902010 +510000060 +000003049 +000007200 +001298000 +======== +062340750 +100005600 +570000040 +000094800 +400000006 +005830000 +030000091 +006400007 +059083260 +======== +300000000 +005009000 +200504000 +020000700 +160000058 +704310600 +000890100 +000067080 +000005437 +======== +630000000 +000500008 +005674000 +000020000 +003401020 +000000345 +000007004 +080300902 +947100080 +======== +000020040 +008035000 +000070602 +031046970 +200000000 +000501203 +049000730 +000000010 +800004000 +======== +361025900 +080960010 +400000057 +008000471 +000603000 +259000800 +740000005 +020018060 +005470329 +======== +050807020 +600010090 +702540006 +070020301 +504000908 +103080070 +900076205 +060090003 +080103040 +======== +080005000 +000003457 +000070809 +060400903 +007010500 +408007020 +901020000 +842300000 +000100080 +======== +003502900 +000040000 +106000305 +900251008 +070408030 +800763001 +308000104 +000020000 +005104800 +======== +000000000 +009805100 +051907420 +290401065 +000000000 +140508093 +026709580 +005103600 +000000000 +======== +020030090 +000907000 +900208005 +004806500 +607000208 +003102900 +800605007 +000309000 +030020050 +======== +005000006 +070009020 +000500107 +804150000 +000803000 +000092805 +907006000 +030400010 +200000600 +======== +040000050 +001943600 +009000300 +600050002 +103000506 +800020007 +005000200 +002436700 +030000040 +======== +004000000 +000030002 +390700080 +400009001 +209801307 +600200008 +010008053 +900040000 +000000800 +======== +360020089 +000361000 +000000000 +803000602 +400603007 +607000108 +000000000 +000418000 +970030014 +======== +500400060 +009000800 +640020000 +000001008 +208000501 +700500000 +000090084 +003000600 +060003002 +======== +007256400 +400000005 +010030060 +000508000 +008060200 +000107000 +030070090 +200000004 +006312700 +======== +000000000 +079050180 +800000007 +007306800 +450708096 +003502700 +700000005 +016030420 +000000000 +======== +030000080 +009000500 +007509200 +700105008 +020090030 +900402001 +004207100 +002000800 +070000090 +======== +200170603 +050000100 +000006079 +000040700 +000801000 +009050000 +310400000 +005000060 +906037002 +======== +000000080 +800701040 +040020030 +374000900 +000030000 +005000321 +010060050 +050802006 +080000000 +======== +000000085 +000210009 +960080100 +500800016 +000000000 +890006007 +009070052 +300054000 +480000000 +======== +608070502 +050608070 +002000300 +500090006 +040302050 +800050003 +005000200 +010704090 +409060701 +======== +050010040 +107000602 +000905000 +208030501 +040070020 +901080406 +000401000 +304000709 +020060010 +======== +053000790 +009753400 +100000002 +090080010 +000907000 +080030070 +500000003 +007641200 +061000940 +======== +006080300 +049070250 +000405000 +600317004 +007000800 +100826009 +000702000 +075040190 +003090600 +======== +005080700 +700204005 +320000084 +060105040 +008000500 +070803010 +450000091 +600508007 +003010600 +======== +000900800 +128006400 +070800060 +800430007 +500000009 +600079008 +090004010 +003600284 +001007000 +======== +000080000 +270000054 +095000810 +009806400 +020403060 +006905100 +017000620 +460000038 +000090000 +======== +000602000 +400050001 +085010620 +038206710 +000000000 +019407350 +026040530 +900020007 +000809000 +======== +000900002 +050123400 +030000160 +908000000 +070000090 +000000205 +091000050 +007439020 +400007000 +======== +380000000 +000400785 +009020300 +060090000 +800302009 +000040070 +001070500 +495006000 +000000092 +======== +000158000 +002060800 +030000040 +027030510 +000000000 +046080790 +050000080 +004070100 +000325000 +======== +010500200 +900001000 +002008030 +500030007 +008000500 +600080004 +040100700 +000700006 +003004050 +======== +080000040 +000469000 +400000007 +005904600 +070608030 +008502100 +900000005 +000781000 +060000010 +======== +904200007 +010000000 +000706500 +000800090 +020904060 +040002000 +001607000 +000000030 +300005702 +======== +000700800 +006000031 +040002000 +024070000 +010030080 +000060290 +000800070 +860000500 +002006000 +======== +001007090 +590080001 +030000080 +000005800 +050060020 +004100000 +080000030 +100020079 +020700400 +======== +000003017 +015009008 +060000000 +100007000 +009000200 +000500004 +000000020 +500600340 +340200000 +======== +300200000 +000107000 +706030500 +070009080 +900020004 +010800050 +009040301 +000702000 +000008006 -- 2.45.2 From f509269fb2312af58b64c0b31e9fc42b08d027ec Mon Sep 17 00:00:00 2001 From: Trimutex Date: Mon, 9 Oct 2023 10:27:42 -0500 Subject: [PATCH 03/10] Updated README --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 74f552d..f9962be 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# cpp-unity-template +# sudoku-solver ## Compiling the project @@ -11,11 +11,11 @@ In order to compile the project, simply run these two commands: cmake --build build ## Running the Project -The program should now be compiled at ./build/bin/something +The program should now be compiled at ./build/bin/sudoku Simply run the program using: - build/bin/something + build/bin/sudoku ## Testing the Project In order to compile the tests for the project, simply run these two commands: @@ -23,8 +23,8 @@ In order to compile the tests for the project, simply run these two commands: cmake -DCMAKE_BUILD_TYPE=Debug -B build -S . cmake --build build -The program should now be compiled at ./build/bin/somethingTest +The program should now be compiled at ./build/bin/sudoku Simply run the tests using: - build/bin/somethingTest \ No newline at end of file + build/bin/sudoku-test -- 2.45.2 From 4a6a9d4eca21b00361385ea7dfa5bba68703ded9 Mon Sep 17 00:00:00 2001 From: Trianta <56975502+Trimutex@users.noreply.github.com> Date: Sat, 21 Oct 2023 15:44:05 -0500 Subject: [PATCH 04/10] Split full list into a bunch of files for testing --- test/sudoku-easy-01.txt | 9 + test/sudoku-easy-02.txt | 9 + test/sudoku-easy-03.txt | 9 + test/sudoku-easy-04.txt | 9 + test/sudoku-easy-05.txt | 9 + test/sudoku-easy-06.txt | 9 + test/sudoku-easy-07.txt | 9 + test/sudoku-easy-08.txt | 9 + test/sudoku-easy-09.txt | 9 + test/sudoku-easy-10.txt | 9 + test/sudoku-easy-11.txt | 9 + test/sudoku-easy-12.txt | 9 + test/sudoku-easy-13.txt | 9 + test/sudoku-easy-14.txt | 9 + test/sudoku-easy-15.txt | 9 + test/sudoku-easy-16.txt | 9 + test/sudoku-easy-17.txt | 9 + test/sudoku-easy-18.txt | 9 + test/sudoku-easy-19.txt | 9 + test/sudoku-easy-20.txt | 9 + test/sudoku-easy-21.txt | 9 + test/sudoku-easy-22.txt | 9 + test/sudoku-easy-23.txt | 9 + test/sudoku-easy-24.txt | 9 + test/sudoku-easy-25.txt | 9 + test/sudoku-easy-26.txt | 9 + test/sudoku-easy-27.txt | 9 + test/sudoku-easy-28.txt | 9 + test/sudoku-easy-29.txt | 9 + test/sudoku-easy-30.txt | 9 + test/sudoku-easy-31.txt | 9 + test/sudoku-easy-32.txt | 9 + test/sudoku-easy-33.txt | 9 + test/sudoku-easy-34.txt | 9 + test/sudoku-easy-35.txt | 9 + test/sudoku-easy-36.txt | 9 + test/sudoku-easy-37.txt | 9 + test/sudoku-easy-38.txt | 9 + test/sudoku-easy-39.txt | 9 + test/sudoku-easy-40.txt | 9 + test/sudoku-easy-41.txt | 9 + test/sudoku-easy-42.txt | 9 + test/sudoku-easy-43.txt | 9 + test/sudoku-easy-44.txt | 9 + test/sudoku-easy-45.txt | 9 + test/sudoku-easy-46.txt | 9 + test/sudoku-easy-47.txt | 9 + test/sudoku-easy-48.txt | 9 + test/sudoku-easy-49.txt | 9 + test/sudoku-easy-50.txt | 490 ------------------------------------- test/sudoku-easy-full.txt | 499 ++++++++++++++++++++++++++++++++++++++ 51 files changed, 940 insertions(+), 490 deletions(-) create mode 100644 test/sudoku-easy-01.txt create mode 100644 test/sudoku-easy-02.txt create mode 100644 test/sudoku-easy-03.txt create mode 100644 test/sudoku-easy-04.txt create mode 100644 test/sudoku-easy-05.txt create mode 100644 test/sudoku-easy-06.txt create mode 100644 test/sudoku-easy-07.txt create mode 100644 test/sudoku-easy-08.txt create mode 100644 test/sudoku-easy-09.txt create mode 100644 test/sudoku-easy-10.txt create mode 100644 test/sudoku-easy-11.txt create mode 100644 test/sudoku-easy-12.txt create mode 100644 test/sudoku-easy-13.txt create mode 100644 test/sudoku-easy-14.txt create mode 100644 test/sudoku-easy-15.txt create mode 100644 test/sudoku-easy-16.txt create mode 100644 test/sudoku-easy-17.txt create mode 100644 test/sudoku-easy-18.txt create mode 100644 test/sudoku-easy-19.txt create mode 100644 test/sudoku-easy-20.txt create mode 100644 test/sudoku-easy-21.txt create mode 100644 test/sudoku-easy-22.txt create mode 100644 test/sudoku-easy-23.txt create mode 100644 test/sudoku-easy-24.txt create mode 100644 test/sudoku-easy-25.txt create mode 100644 test/sudoku-easy-26.txt create mode 100644 test/sudoku-easy-27.txt create mode 100644 test/sudoku-easy-28.txt create mode 100644 test/sudoku-easy-29.txt create mode 100644 test/sudoku-easy-30.txt create mode 100644 test/sudoku-easy-31.txt create mode 100644 test/sudoku-easy-32.txt create mode 100644 test/sudoku-easy-33.txt create mode 100644 test/sudoku-easy-34.txt create mode 100644 test/sudoku-easy-35.txt create mode 100644 test/sudoku-easy-36.txt create mode 100644 test/sudoku-easy-37.txt create mode 100644 test/sudoku-easy-38.txt create mode 100644 test/sudoku-easy-39.txt create mode 100644 test/sudoku-easy-40.txt create mode 100644 test/sudoku-easy-41.txt create mode 100644 test/sudoku-easy-42.txt create mode 100644 test/sudoku-easy-43.txt create mode 100644 test/sudoku-easy-44.txt create mode 100644 test/sudoku-easy-45.txt create mode 100644 test/sudoku-easy-46.txt create mode 100644 test/sudoku-easy-47.txt create mode 100644 test/sudoku-easy-48.txt create mode 100644 test/sudoku-easy-49.txt create mode 100644 test/sudoku-easy-full.txt diff --git a/test/sudoku-easy-01.txt b/test/sudoku-easy-01.txt new file mode 100644 index 0000000..98cbd6b --- /dev/null +++ b/test/sudoku-easy-01.txt @@ -0,0 +1,9 @@ +003020600 +900305001 +001806400 +008102900 +700000008 +006708200 +002609500 +800203009 +005010300 diff --git a/test/sudoku-easy-02.txt b/test/sudoku-easy-02.txt new file mode 100644 index 0000000..1a68168 --- /dev/null +++ b/test/sudoku-easy-02.txt @@ -0,0 +1,9 @@ +200080300 +060070084 +030500209 +000105408 +000000000 +402706000 +301007040 +720040060 +004010003 diff --git a/test/sudoku-easy-03.txt b/test/sudoku-easy-03.txt new file mode 100644 index 0000000..611e092 --- /dev/null +++ b/test/sudoku-easy-03.txt @@ -0,0 +1,9 @@ +000000907 +000420180 +000705026 +100904000 +050000040 +000507009 +920108000 +034059000 +507000000 diff --git a/test/sudoku-easy-04.txt b/test/sudoku-easy-04.txt new file mode 100644 index 0000000..ba65c6d --- /dev/null +++ b/test/sudoku-easy-04.txt @@ -0,0 +1,9 @@ +030050040 +008010500 +460000012 +070502080 +000603000 +040109030 +250000098 +001020600 +080060020 diff --git a/test/sudoku-easy-05.txt b/test/sudoku-easy-05.txt new file mode 100644 index 0000000..4ec2834 --- /dev/null +++ b/test/sudoku-easy-05.txt @@ -0,0 +1,9 @@ +020810740 +700003100 +090002805 +009040087 +400208003 +160030200 +302700060 +005600008 +076051090 diff --git a/test/sudoku-easy-06.txt b/test/sudoku-easy-06.txt new file mode 100644 index 0000000..a92ea9d --- /dev/null +++ b/test/sudoku-easy-06.txt @@ -0,0 +1,9 @@ +100920000 +524010000 +000000070 +050008102 +000000000 +402700090 +060000000 +000030945 +000071006 diff --git a/test/sudoku-easy-07.txt b/test/sudoku-easy-07.txt new file mode 100644 index 0000000..05e9566 --- /dev/null +++ b/test/sudoku-easy-07.txt @@ -0,0 +1,9 @@ +043080250 +600000000 +000001094 +900004070 +000608000 +010200003 +820500000 +000000005 +034090710 diff --git a/test/sudoku-easy-08.txt b/test/sudoku-easy-08.txt new file mode 100644 index 0000000..372779e --- /dev/null +++ b/test/sudoku-easy-08.txt @@ -0,0 +1,9 @@ +480006902 +002008001 +900370060 +840010200 +003704100 +001060049 +020085007 +700900600 +609200018 diff --git a/test/sudoku-easy-09.txt b/test/sudoku-easy-09.txt new file mode 100644 index 0000000..9026332 --- /dev/null +++ b/test/sudoku-easy-09.txt @@ -0,0 +1,9 @@ +000900002 +050123400 +030000160 +908000000 +070000090 +000000205 +091000050 +007439020 +400007000 diff --git a/test/sudoku-easy-10.txt b/test/sudoku-easy-10.txt new file mode 100644 index 0000000..bfd4f67 --- /dev/null +++ b/test/sudoku-easy-10.txt @@ -0,0 +1,9 @@ +001900003 +900700160 +030005007 +050000009 +004302600 +200000070 +600100030 +042007006 +500006800 diff --git a/test/sudoku-easy-11.txt b/test/sudoku-easy-11.txt new file mode 100644 index 0000000..3068cfa --- /dev/null +++ b/test/sudoku-easy-11.txt @@ -0,0 +1,9 @@ +000125400 +008400000 +420800000 +030000095 +060902010 +510000060 +000003049 +000007200 +001298000 diff --git a/test/sudoku-easy-12.txt b/test/sudoku-easy-12.txt new file mode 100644 index 0000000..db870f8 --- /dev/null +++ b/test/sudoku-easy-12.txt @@ -0,0 +1,9 @@ +062340750 +100005600 +570000040 +000094800 +400000006 +005830000 +030000091 +006400007 +059083260 diff --git a/test/sudoku-easy-13.txt b/test/sudoku-easy-13.txt new file mode 100644 index 0000000..e60d6d9 --- /dev/null +++ b/test/sudoku-easy-13.txt @@ -0,0 +1,9 @@ +300000000 +005009000 +200504000 +020000700 +160000058 +704310600 +000890100 +000067080 +000005437 diff --git a/test/sudoku-easy-14.txt b/test/sudoku-easy-14.txt new file mode 100644 index 0000000..a8feae9 --- /dev/null +++ b/test/sudoku-easy-14.txt @@ -0,0 +1,9 @@ +630000000 +000500008 +005674000 +000020000 +003401020 +000000345 +000007004 +080300902 +947100080 diff --git a/test/sudoku-easy-15.txt b/test/sudoku-easy-15.txt new file mode 100644 index 0000000..504c26e --- /dev/null +++ b/test/sudoku-easy-15.txt @@ -0,0 +1,9 @@ +000020040 +008035000 +000070602 +031046970 +200000000 +000501203 +049000730 +000000010 +800004000 diff --git a/test/sudoku-easy-16.txt b/test/sudoku-easy-16.txt new file mode 100644 index 0000000..51172cd --- /dev/null +++ b/test/sudoku-easy-16.txt @@ -0,0 +1,9 @@ +361025900 +080960010 +400000057 +008000471 +000603000 +259000800 +740000005 +020018060 +005470329 diff --git a/test/sudoku-easy-17.txt b/test/sudoku-easy-17.txt new file mode 100644 index 0000000..2ae7529 --- /dev/null +++ b/test/sudoku-easy-17.txt @@ -0,0 +1,9 @@ +050807020 +600010090 +702540006 +070020301 +504000908 +103080070 +900076205 +060090003 +080103040 diff --git a/test/sudoku-easy-18.txt b/test/sudoku-easy-18.txt new file mode 100644 index 0000000..5678b18 --- /dev/null +++ b/test/sudoku-easy-18.txt @@ -0,0 +1,9 @@ +080005000 +000003457 +000070809 +060400903 +007010500 +408007020 +901020000 +842300000 +000100080 diff --git a/test/sudoku-easy-19.txt b/test/sudoku-easy-19.txt new file mode 100644 index 0000000..51881d1 --- /dev/null +++ b/test/sudoku-easy-19.txt @@ -0,0 +1,9 @@ +003502900 +000040000 +106000305 +900251008 +070408030 +800763001 +308000104 +000020000 +005104800 diff --git a/test/sudoku-easy-20.txt b/test/sudoku-easy-20.txt new file mode 100644 index 0000000..257c1f1 --- /dev/null +++ b/test/sudoku-easy-20.txt @@ -0,0 +1,9 @@ +000000000 +009805100 +051907420 +290401065 +000000000 +140508093 +026709580 +005103600 +000000000 diff --git a/test/sudoku-easy-21.txt b/test/sudoku-easy-21.txt new file mode 100644 index 0000000..f1c6151 --- /dev/null +++ b/test/sudoku-easy-21.txt @@ -0,0 +1,9 @@ +020030090 +000907000 +900208005 +004806500 +607000208 +003102900 +800605007 +000309000 +030020050 diff --git a/test/sudoku-easy-22.txt b/test/sudoku-easy-22.txt new file mode 100644 index 0000000..a53cb1b --- /dev/null +++ b/test/sudoku-easy-22.txt @@ -0,0 +1,9 @@ +005000006 +070009020 +000500107 +804150000 +000803000 +000092805 +907006000 +030400010 +200000600 diff --git a/test/sudoku-easy-23.txt b/test/sudoku-easy-23.txt new file mode 100644 index 0000000..43dcf92 --- /dev/null +++ b/test/sudoku-easy-23.txt @@ -0,0 +1,9 @@ +040000050 +001943600 +009000300 +600050002 +103000506 +800020007 +005000200 +002436700 +030000040 diff --git a/test/sudoku-easy-24.txt b/test/sudoku-easy-24.txt new file mode 100644 index 0000000..1729d5c --- /dev/null +++ b/test/sudoku-easy-24.txt @@ -0,0 +1,9 @@ +004000000 +000030002 +390700080 +400009001 +209801307 +600200008 +010008053 +900040000 +000000800 diff --git a/test/sudoku-easy-25.txt b/test/sudoku-easy-25.txt new file mode 100644 index 0000000..f090c20 --- /dev/null +++ b/test/sudoku-easy-25.txt @@ -0,0 +1,9 @@ +360020089 +000361000 +000000000 +803000602 +400603007 +607000108 +000000000 +000418000 +970030014 diff --git a/test/sudoku-easy-26.txt b/test/sudoku-easy-26.txt new file mode 100644 index 0000000..3919938 --- /dev/null +++ b/test/sudoku-easy-26.txt @@ -0,0 +1,9 @@ +500400060 +009000800 +640020000 +000001008 +208000501 +700500000 +000090084 +003000600 +060003002 diff --git a/test/sudoku-easy-27.txt b/test/sudoku-easy-27.txt new file mode 100644 index 0000000..8134b0e --- /dev/null +++ b/test/sudoku-easy-27.txt @@ -0,0 +1,9 @@ +007256400 +400000005 +010030060 +000508000 +008060200 +000107000 +030070090 +200000004 +006312700 diff --git a/test/sudoku-easy-28.txt b/test/sudoku-easy-28.txt new file mode 100644 index 0000000..d7becae --- /dev/null +++ b/test/sudoku-easy-28.txt @@ -0,0 +1,9 @@ +000000000 +079050180 +800000007 +007306800 +450708096 +003502700 +700000005 +016030420 +000000000 diff --git a/test/sudoku-easy-29.txt b/test/sudoku-easy-29.txt new file mode 100644 index 0000000..cc1d702 --- /dev/null +++ b/test/sudoku-easy-29.txt @@ -0,0 +1,9 @@ +030000080 +009000500 +007509200 +700105008 +020090030 +900402001 +004207100 +002000800 +070000090 diff --git a/test/sudoku-easy-30.txt b/test/sudoku-easy-30.txt new file mode 100644 index 0000000..b2aa01a --- /dev/null +++ b/test/sudoku-easy-30.txt @@ -0,0 +1,9 @@ +200170603 +050000100 +000006079 +000040700 +000801000 +009050000 +310400000 +005000060 +906037002 diff --git a/test/sudoku-easy-31.txt b/test/sudoku-easy-31.txt new file mode 100644 index 0000000..852b3cc --- /dev/null +++ b/test/sudoku-easy-31.txt @@ -0,0 +1,9 @@ +000000080 +800701040 +040020030 +374000900 +000030000 +005000321 +010060050 +050802006 +080000000 diff --git a/test/sudoku-easy-32.txt b/test/sudoku-easy-32.txt new file mode 100644 index 0000000..1e865f4 --- /dev/null +++ b/test/sudoku-easy-32.txt @@ -0,0 +1,9 @@ +000000085 +000210009 +960080100 +500800016 +000000000 +890006007 +009070052 +300054000 +480000000 diff --git a/test/sudoku-easy-33.txt b/test/sudoku-easy-33.txt new file mode 100644 index 0000000..a08c9ae --- /dev/null +++ b/test/sudoku-easy-33.txt @@ -0,0 +1,9 @@ +608070502 +050608070 +002000300 +500090006 +040302050 +800050003 +005000200 +010704090 +409060701 diff --git a/test/sudoku-easy-34.txt b/test/sudoku-easy-34.txt new file mode 100644 index 0000000..035f1ca --- /dev/null +++ b/test/sudoku-easy-34.txt @@ -0,0 +1,9 @@ +050010040 +107000602 +000905000 +208030501 +040070020 +901080406 +000401000 +304000709 +020060010 diff --git a/test/sudoku-easy-35.txt b/test/sudoku-easy-35.txt new file mode 100644 index 0000000..39a09ac --- /dev/null +++ b/test/sudoku-easy-35.txt @@ -0,0 +1,9 @@ +053000790 +009753400 +100000002 +090080010 +000907000 +080030070 +500000003 +007641200 +061000940 diff --git a/test/sudoku-easy-36.txt b/test/sudoku-easy-36.txt new file mode 100644 index 0000000..dc3e63d --- /dev/null +++ b/test/sudoku-easy-36.txt @@ -0,0 +1,9 @@ +006080300 +049070250 +000405000 +600317004 +007000800 +100826009 +000702000 +075040190 +003090600 diff --git a/test/sudoku-easy-37.txt b/test/sudoku-easy-37.txt new file mode 100644 index 0000000..a91f208 --- /dev/null +++ b/test/sudoku-easy-37.txt @@ -0,0 +1,9 @@ +005080700 +700204005 +320000084 +060105040 +008000500 +070803010 +450000091 +600508007 +003010600 diff --git a/test/sudoku-easy-38.txt b/test/sudoku-easy-38.txt new file mode 100644 index 0000000..7876861 --- /dev/null +++ b/test/sudoku-easy-38.txt @@ -0,0 +1,9 @@ +000900800 +128006400 +070800060 +800430007 +500000009 +600079008 +090004010 +003600284 +001007000 diff --git a/test/sudoku-easy-39.txt b/test/sudoku-easy-39.txt new file mode 100644 index 0000000..4d0a931 --- /dev/null +++ b/test/sudoku-easy-39.txt @@ -0,0 +1,9 @@ +000080000 +270000054 +095000810 +009806400 +020403060 +006905100 +017000620 +460000038 +000090000 diff --git a/test/sudoku-easy-40.txt b/test/sudoku-easy-40.txt new file mode 100644 index 0000000..f44b173 --- /dev/null +++ b/test/sudoku-easy-40.txt @@ -0,0 +1,9 @@ +000602000 +400050001 +085010620 +038206710 +000000000 +019407350 +026040530 +900020007 +000809000 diff --git a/test/sudoku-easy-41.txt b/test/sudoku-easy-41.txt new file mode 100644 index 0000000..9026332 --- /dev/null +++ b/test/sudoku-easy-41.txt @@ -0,0 +1,9 @@ +000900002 +050123400 +030000160 +908000000 +070000090 +000000205 +091000050 +007439020 +400007000 diff --git a/test/sudoku-easy-42.txt b/test/sudoku-easy-42.txt new file mode 100644 index 0000000..e663dc4 --- /dev/null +++ b/test/sudoku-easy-42.txt @@ -0,0 +1,9 @@ +380000000 +000400785 +009020300 +060090000 +800302009 +000040070 +001070500 +495006000 +000000092 diff --git a/test/sudoku-easy-43.txt b/test/sudoku-easy-43.txt new file mode 100644 index 0000000..c45846f --- /dev/null +++ b/test/sudoku-easy-43.txt @@ -0,0 +1,9 @@ +000158000 +002060800 +030000040 +027030510 +000000000 +046080790 +050000080 +004070100 +000325000 diff --git a/test/sudoku-easy-44.txt b/test/sudoku-easy-44.txt new file mode 100644 index 0000000..3d4a955 --- /dev/null +++ b/test/sudoku-easy-44.txt @@ -0,0 +1,9 @@ +010500200 +900001000 +002008030 +500030007 +008000500 +600080004 +040100700 +000700006 +003004050 diff --git a/test/sudoku-easy-45.txt b/test/sudoku-easy-45.txt new file mode 100644 index 0000000..29fd2f4 --- /dev/null +++ b/test/sudoku-easy-45.txt @@ -0,0 +1,9 @@ +080000040 +000469000 +400000007 +005904600 +070608030 +008502100 +900000005 +000781000 +060000010 diff --git a/test/sudoku-easy-46.txt b/test/sudoku-easy-46.txt new file mode 100644 index 0000000..cf293af --- /dev/null +++ b/test/sudoku-easy-46.txt @@ -0,0 +1,9 @@ +904200007 +010000000 +000706500 +000800090 +020904060 +040002000 +001607000 +000000030 +300005702 diff --git a/test/sudoku-easy-47.txt b/test/sudoku-easy-47.txt new file mode 100644 index 0000000..b252580 --- /dev/null +++ b/test/sudoku-easy-47.txt @@ -0,0 +1,9 @@ +000700800 +006000031 +040002000 +024070000 +010030080 +000060290 +000800070 +860000500 +002006000 diff --git a/test/sudoku-easy-48.txt b/test/sudoku-easy-48.txt new file mode 100644 index 0000000..0a0b837 --- /dev/null +++ b/test/sudoku-easy-48.txt @@ -0,0 +1,9 @@ +001007090 +590080001 +030000080 +000005800 +050060020 +004100000 +080000030 +100020079 +020700400 diff --git a/test/sudoku-easy-49.txt b/test/sudoku-easy-49.txt new file mode 100644 index 0000000..dd287f6 --- /dev/null +++ b/test/sudoku-easy-49.txt @@ -0,0 +1,9 @@ +000003017 +015009008 +060000000 +100007000 +009000200 +000500004 +000000020 +500600340 +340200000 diff --git a/test/sudoku-easy-50.txt b/test/sudoku-easy-50.txt index e9b7224..60d5a23 100644 --- a/test/sudoku-easy-50.txt +++ b/test/sudoku-easy-50.txt @@ -1,493 +1,3 @@ -003020600 -900305001 -001806400 -008102900 -700000008 -006708200 -002609500 -800203009 -005010300 -======== -200080300 -060070084 -030500209 -000105408 -000000000 -402706000 -301007040 -720040060 -004010003 -======== -000000907 -000420180 -000705026 -100904000 -050000040 -000507009 -920108000 -034059000 -507000000 -======== -030050040 -008010500 -460000012 -070502080 -000603000 -040109030 -250000098 -001020600 -080060020 -======== -020810740 -700003100 -090002805 -009040087 -400208003 -160030200 -302700060 -005600008 -076051090 -======== -100920000 -524010000 -000000070 -050008102 -000000000 -402700090 -060000000 -000030945 -000071006 -======== -043080250 -600000000 -000001094 -900004070 -000608000 -010200003 -820500000 -000000005 -034090710 -======== -480006902 -002008001 -900370060 -840010200 -003704100 -001060049 -020085007 -700900600 -609200018 -======== -000900002 -050123400 -030000160 -908000000 -070000090 -000000205 -091000050 -007439020 -400007000 -======== -001900003 -900700160 -030005007 -050000009 -004302600 -200000070 -600100030 -042007006 -500006800 -======== -000125400 -008400000 -420800000 -030000095 -060902010 -510000060 -000003049 -000007200 -001298000 -======== -062340750 -100005600 -570000040 -000094800 -400000006 -005830000 -030000091 -006400007 -059083260 -======== -300000000 -005009000 -200504000 -020000700 -160000058 -704310600 -000890100 -000067080 -000005437 -======== -630000000 -000500008 -005674000 -000020000 -003401020 -000000345 -000007004 -080300902 -947100080 -======== -000020040 -008035000 -000070602 -031046970 -200000000 -000501203 -049000730 -000000010 -800004000 -======== -361025900 -080960010 -400000057 -008000471 -000603000 -259000800 -740000005 -020018060 -005470329 -======== -050807020 -600010090 -702540006 -070020301 -504000908 -103080070 -900076205 -060090003 -080103040 -======== -080005000 -000003457 -000070809 -060400903 -007010500 -408007020 -901020000 -842300000 -000100080 -======== -003502900 -000040000 -106000305 -900251008 -070408030 -800763001 -308000104 -000020000 -005104800 -======== -000000000 -009805100 -051907420 -290401065 -000000000 -140508093 -026709580 -005103600 -000000000 -======== -020030090 -000907000 -900208005 -004806500 -607000208 -003102900 -800605007 -000309000 -030020050 -======== -005000006 -070009020 -000500107 -804150000 -000803000 -000092805 -907006000 -030400010 -200000600 -======== -040000050 -001943600 -009000300 -600050002 -103000506 -800020007 -005000200 -002436700 -030000040 -======== -004000000 -000030002 -390700080 -400009001 -209801307 -600200008 -010008053 -900040000 -000000800 -======== -360020089 -000361000 -000000000 -803000602 -400603007 -607000108 -000000000 -000418000 -970030014 -======== -500400060 -009000800 -640020000 -000001008 -208000501 -700500000 -000090084 -003000600 -060003002 -======== -007256400 -400000005 -010030060 -000508000 -008060200 -000107000 -030070090 -200000004 -006312700 -======== -000000000 -079050180 -800000007 -007306800 -450708096 -003502700 -700000005 -016030420 -000000000 -======== -030000080 -009000500 -007509200 -700105008 -020090030 -900402001 -004207100 -002000800 -070000090 -======== -200170603 -050000100 -000006079 -000040700 -000801000 -009050000 -310400000 -005000060 -906037002 -======== -000000080 -800701040 -040020030 -374000900 -000030000 -005000321 -010060050 -050802006 -080000000 -======== -000000085 -000210009 -960080100 -500800016 -000000000 -890006007 -009070052 -300054000 -480000000 -======== -608070502 -050608070 -002000300 -500090006 -040302050 -800050003 -005000200 -010704090 -409060701 -======== -050010040 -107000602 -000905000 -208030501 -040070020 -901080406 -000401000 -304000709 -020060010 -======== -053000790 -009753400 -100000002 -090080010 -000907000 -080030070 -500000003 -007641200 -061000940 -======== -006080300 -049070250 -000405000 -600317004 -007000800 -100826009 -000702000 -075040190 -003090600 -======== -005080700 -700204005 -320000084 -060105040 -008000500 -070803010 -450000091 -600508007 -003010600 -======== -000900800 -128006400 -070800060 -800430007 -500000009 -600079008 -090004010 -003600284 -001007000 -======== -000080000 -270000054 -095000810 -009806400 -020403060 -006905100 -017000620 -460000038 -000090000 -======== -000602000 -400050001 -085010620 -038206710 -000000000 -019407350 -026040530 -900020007 -000809000 -======== -000900002 -050123400 -030000160 -908000000 -070000090 -000000205 -091000050 -007439020 -400007000 -======== -380000000 -000400785 -009020300 -060090000 -800302009 -000040070 -001070500 -495006000 -000000092 -======== -000158000 -002060800 -030000040 -027030510 -000000000 -046080790 -050000080 -004070100 -000325000 -======== -010500200 -900001000 -002008030 -500030007 -008000500 -600080004 -040100700 -000700006 -003004050 -======== -080000040 -000469000 -400000007 -005904600 -070608030 -008502100 -900000005 -000781000 -060000010 -======== -904200007 -010000000 -000706500 -000800090 -020904060 -040002000 -001607000 -000000030 -300005702 -======== -000700800 -006000031 -040002000 -024070000 -010030080 -000060290 -000800070 -860000500 -002006000 -======== -001007090 -590080001 -030000080 -000005800 -050060020 -004100000 -080000030 -100020079 -020700400 -======== -000003017 -015009008 -060000000 -100007000 -009000200 -000500004 -000000020 -500600340 -340200000 -======== 300200000 000107000 706030500 diff --git a/test/sudoku-easy-full.txt b/test/sudoku-easy-full.txt new file mode 100644 index 0000000..e9b7224 --- /dev/null +++ b/test/sudoku-easy-full.txt @@ -0,0 +1,499 @@ +003020600 +900305001 +001806400 +008102900 +700000008 +006708200 +002609500 +800203009 +005010300 +======== +200080300 +060070084 +030500209 +000105408 +000000000 +402706000 +301007040 +720040060 +004010003 +======== +000000907 +000420180 +000705026 +100904000 +050000040 +000507009 +920108000 +034059000 +507000000 +======== +030050040 +008010500 +460000012 +070502080 +000603000 +040109030 +250000098 +001020600 +080060020 +======== +020810740 +700003100 +090002805 +009040087 +400208003 +160030200 +302700060 +005600008 +076051090 +======== +100920000 +524010000 +000000070 +050008102 +000000000 +402700090 +060000000 +000030945 +000071006 +======== +043080250 +600000000 +000001094 +900004070 +000608000 +010200003 +820500000 +000000005 +034090710 +======== +480006902 +002008001 +900370060 +840010200 +003704100 +001060049 +020085007 +700900600 +609200018 +======== +000900002 +050123400 +030000160 +908000000 +070000090 +000000205 +091000050 +007439020 +400007000 +======== +001900003 +900700160 +030005007 +050000009 +004302600 +200000070 +600100030 +042007006 +500006800 +======== +000125400 +008400000 +420800000 +030000095 +060902010 +510000060 +000003049 +000007200 +001298000 +======== +062340750 +100005600 +570000040 +000094800 +400000006 +005830000 +030000091 +006400007 +059083260 +======== +300000000 +005009000 +200504000 +020000700 +160000058 +704310600 +000890100 +000067080 +000005437 +======== +630000000 +000500008 +005674000 +000020000 +003401020 +000000345 +000007004 +080300902 +947100080 +======== +000020040 +008035000 +000070602 +031046970 +200000000 +000501203 +049000730 +000000010 +800004000 +======== +361025900 +080960010 +400000057 +008000471 +000603000 +259000800 +740000005 +020018060 +005470329 +======== +050807020 +600010090 +702540006 +070020301 +504000908 +103080070 +900076205 +060090003 +080103040 +======== +080005000 +000003457 +000070809 +060400903 +007010500 +408007020 +901020000 +842300000 +000100080 +======== +003502900 +000040000 +106000305 +900251008 +070408030 +800763001 +308000104 +000020000 +005104800 +======== +000000000 +009805100 +051907420 +290401065 +000000000 +140508093 +026709580 +005103600 +000000000 +======== +020030090 +000907000 +900208005 +004806500 +607000208 +003102900 +800605007 +000309000 +030020050 +======== +005000006 +070009020 +000500107 +804150000 +000803000 +000092805 +907006000 +030400010 +200000600 +======== +040000050 +001943600 +009000300 +600050002 +103000506 +800020007 +005000200 +002436700 +030000040 +======== +004000000 +000030002 +390700080 +400009001 +209801307 +600200008 +010008053 +900040000 +000000800 +======== +360020089 +000361000 +000000000 +803000602 +400603007 +607000108 +000000000 +000418000 +970030014 +======== +500400060 +009000800 +640020000 +000001008 +208000501 +700500000 +000090084 +003000600 +060003002 +======== +007256400 +400000005 +010030060 +000508000 +008060200 +000107000 +030070090 +200000004 +006312700 +======== +000000000 +079050180 +800000007 +007306800 +450708096 +003502700 +700000005 +016030420 +000000000 +======== +030000080 +009000500 +007509200 +700105008 +020090030 +900402001 +004207100 +002000800 +070000090 +======== +200170603 +050000100 +000006079 +000040700 +000801000 +009050000 +310400000 +005000060 +906037002 +======== +000000080 +800701040 +040020030 +374000900 +000030000 +005000321 +010060050 +050802006 +080000000 +======== +000000085 +000210009 +960080100 +500800016 +000000000 +890006007 +009070052 +300054000 +480000000 +======== +608070502 +050608070 +002000300 +500090006 +040302050 +800050003 +005000200 +010704090 +409060701 +======== +050010040 +107000602 +000905000 +208030501 +040070020 +901080406 +000401000 +304000709 +020060010 +======== +053000790 +009753400 +100000002 +090080010 +000907000 +080030070 +500000003 +007641200 +061000940 +======== +006080300 +049070250 +000405000 +600317004 +007000800 +100826009 +000702000 +075040190 +003090600 +======== +005080700 +700204005 +320000084 +060105040 +008000500 +070803010 +450000091 +600508007 +003010600 +======== +000900800 +128006400 +070800060 +800430007 +500000009 +600079008 +090004010 +003600284 +001007000 +======== +000080000 +270000054 +095000810 +009806400 +020403060 +006905100 +017000620 +460000038 +000090000 +======== +000602000 +400050001 +085010620 +038206710 +000000000 +019407350 +026040530 +900020007 +000809000 +======== +000900002 +050123400 +030000160 +908000000 +070000090 +000000205 +091000050 +007439020 +400007000 +======== +380000000 +000400785 +009020300 +060090000 +800302009 +000040070 +001070500 +495006000 +000000092 +======== +000158000 +002060800 +030000040 +027030510 +000000000 +046080790 +050000080 +004070100 +000325000 +======== +010500200 +900001000 +002008030 +500030007 +008000500 +600080004 +040100700 +000700006 +003004050 +======== +080000040 +000469000 +400000007 +005904600 +070608030 +008502100 +900000005 +000781000 +060000010 +======== +904200007 +010000000 +000706500 +000800090 +020904060 +040002000 +001607000 +000000030 +300005702 +======== +000700800 +006000031 +040002000 +024070000 +010030080 +000060290 +000800070 +860000500 +002006000 +======== +001007090 +590080001 +030000080 +000005800 +050060020 +004100000 +080000030 +100020079 +020700400 +======== +000003017 +015009008 +060000000 +100007000 +009000200 +000500004 +000000020 +500600340 +340200000 +======== +300200000 +000107000 +706030500 +070009080 +900020004 +010800050 +009040301 +000702000 +000008006 -- 2.45.2 From d35bd25e2848073c92250d2461bbab7841e9dedd Mon Sep 17 00:00:00 2001 From: Trianta <56975502+Trimutex@users.noreply.github.com> Date: Sat, 21 Oct 2023 17:03:14 -0500 Subject: [PATCH 05/10] Prepared test files --- test/CMakeLists.txt | 4 +- test/{ => files}/sudoku-easy-01.txt | 0 test/{ => files}/sudoku-easy-02.txt | 0 test/{ => files}/sudoku-easy-03.txt | 0 test/{ => files}/sudoku-easy-04.txt | 0 test/{ => files}/sudoku-easy-05.txt | 0 test/{ => files}/sudoku-easy-06.txt | 0 test/{ => files}/sudoku-easy-07.txt | 0 test/{ => files}/sudoku-easy-08.txt | 0 test/{ => files}/sudoku-easy-09.txt | 0 test/{ => files}/sudoku-easy-10.txt | 0 test/{ => files}/sudoku-easy-11.txt | 0 test/{ => files}/sudoku-easy-12.txt | 0 test/{ => files}/sudoku-easy-13.txt | 0 test/{ => files}/sudoku-easy-14.txt | 0 test/{ => files}/sudoku-easy-15.txt | 0 test/{ => files}/sudoku-easy-16.txt | 0 test/{ => files}/sudoku-easy-17.txt | 0 test/{ => files}/sudoku-easy-18.txt | 0 test/{ => files}/sudoku-easy-19.txt | 0 test/{ => files}/sudoku-easy-20.txt | 0 test/{ => files}/sudoku-easy-21.txt | 0 test/{ => files}/sudoku-easy-22.txt | 0 test/{ => files}/sudoku-easy-23.txt | 0 test/{ => files}/sudoku-easy-24.txt | 0 test/{ => files}/sudoku-easy-25.txt | 0 test/{ => files}/sudoku-easy-26.txt | 0 test/{ => files}/sudoku-easy-27.txt | 0 test/{ => files}/sudoku-easy-28.txt | 0 test/{ => files}/sudoku-easy-29.txt | 0 test/{ => files}/sudoku-easy-30.txt | 0 test/{ => files}/sudoku-easy-31.txt | 0 test/{ => files}/sudoku-easy-32.txt | 0 test/{ => files}/sudoku-easy-33.txt | 0 test/{ => files}/sudoku-easy-34.txt | 0 test/{ => files}/sudoku-easy-35.txt | 0 test/{ => files}/sudoku-easy-36.txt | 0 test/{ => files}/sudoku-easy-37.txt | 0 test/{ => files}/sudoku-easy-38.txt | 0 test/{ => files}/sudoku-easy-39.txt | 0 test/{ => files}/sudoku-easy-40.txt | 0 test/{ => files}/sudoku-easy-41.txt | 0 test/{ => files}/sudoku-easy-42.txt | 0 test/{ => files}/sudoku-easy-43.txt | 0 test/{ => files}/sudoku-easy-44.txt | 0 test/{ => files}/sudoku-easy-45.txt | 0 test/{ => files}/sudoku-easy-46.txt | 0 test/{ => files}/sudoku-easy-47.txt | 0 test/{ => files}/sudoku-easy-48.txt | 0 test/{ => files}/sudoku-easy-49.txt | 0 test/{ => files}/sudoku-easy-50.txt | 0 test/{ => files}/sudoku-easy-full.txt | 0 test/test.cpp | 12 +- test/test_list.cpp | 354 ++++++++++++++++++++++++++ test/test_list.hpp | 55 ++++ 55 files changed, 415 insertions(+), 10 deletions(-) rename test/{ => files}/sudoku-easy-01.txt (100%) rename test/{ => files}/sudoku-easy-02.txt (100%) rename test/{ => files}/sudoku-easy-03.txt (100%) rename test/{ => files}/sudoku-easy-04.txt (100%) rename test/{ => files}/sudoku-easy-05.txt (100%) rename test/{ => files}/sudoku-easy-06.txt (100%) rename test/{ => files}/sudoku-easy-07.txt (100%) rename test/{ => files}/sudoku-easy-08.txt (100%) rename test/{ => files}/sudoku-easy-09.txt (100%) rename test/{ => files}/sudoku-easy-10.txt (100%) rename test/{ => files}/sudoku-easy-11.txt (100%) rename test/{ => files}/sudoku-easy-12.txt (100%) rename test/{ => files}/sudoku-easy-13.txt (100%) rename test/{ => files}/sudoku-easy-14.txt (100%) rename test/{ => files}/sudoku-easy-15.txt (100%) rename test/{ => files}/sudoku-easy-16.txt (100%) rename test/{ => files}/sudoku-easy-17.txt (100%) rename test/{ => files}/sudoku-easy-18.txt (100%) rename test/{ => files}/sudoku-easy-19.txt (100%) rename test/{ => files}/sudoku-easy-20.txt (100%) rename test/{ => files}/sudoku-easy-21.txt (100%) rename test/{ => files}/sudoku-easy-22.txt (100%) rename test/{ => files}/sudoku-easy-23.txt (100%) rename test/{ => files}/sudoku-easy-24.txt (100%) rename test/{ => files}/sudoku-easy-25.txt (100%) rename test/{ => files}/sudoku-easy-26.txt (100%) rename test/{ => files}/sudoku-easy-27.txt (100%) rename test/{ => files}/sudoku-easy-28.txt (100%) rename test/{ => files}/sudoku-easy-29.txt (100%) rename test/{ => files}/sudoku-easy-30.txt (100%) rename test/{ => files}/sudoku-easy-31.txt (100%) rename test/{ => files}/sudoku-easy-32.txt (100%) rename test/{ => files}/sudoku-easy-33.txt (100%) rename test/{ => files}/sudoku-easy-34.txt (100%) rename test/{ => files}/sudoku-easy-35.txt (100%) rename test/{ => files}/sudoku-easy-36.txt (100%) rename test/{ => files}/sudoku-easy-37.txt (100%) rename test/{ => files}/sudoku-easy-38.txt (100%) rename test/{ => files}/sudoku-easy-39.txt (100%) rename test/{ => files}/sudoku-easy-40.txt (100%) rename test/{ => files}/sudoku-easy-41.txt (100%) rename test/{ => files}/sudoku-easy-42.txt (100%) rename test/{ => files}/sudoku-easy-43.txt (100%) rename test/{ => files}/sudoku-easy-44.txt (100%) rename test/{ => files}/sudoku-easy-45.txt (100%) rename test/{ => files}/sudoku-easy-46.txt (100%) rename test/{ => files}/sudoku-easy-47.txt (100%) rename test/{ => files}/sudoku-easy-48.txt (100%) rename test/{ => files}/sudoku-easy-49.txt (100%) rename test/{ => files}/sudoku-easy-50.txt (100%) rename test/{ => files}/sudoku-easy-full.txt (100%) create mode 100644 test/test_list.cpp create mode 100644 test/test_list.hpp diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 8a65233..65c9e96 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,7 +1,9 @@ find_package(unity REQUIRED) -include_directories(${CMAKE_SOURCE_DIR}/src) +include_directories(${sudoku_SOURCE_DIR}/src) add_executable(testing test.cpp + test_list.cpp + ../src/sudoku.cpp ) set_target_properties(testing PROPERTIES LINKER_LANGUAGE CXX) target_link_libraries(testing unity) diff --git a/test/sudoku-easy-01.txt b/test/files/sudoku-easy-01.txt similarity index 100% rename from test/sudoku-easy-01.txt rename to test/files/sudoku-easy-01.txt diff --git a/test/sudoku-easy-02.txt b/test/files/sudoku-easy-02.txt similarity index 100% rename from test/sudoku-easy-02.txt rename to test/files/sudoku-easy-02.txt diff --git a/test/sudoku-easy-03.txt b/test/files/sudoku-easy-03.txt similarity index 100% rename from test/sudoku-easy-03.txt rename to test/files/sudoku-easy-03.txt diff --git a/test/sudoku-easy-04.txt b/test/files/sudoku-easy-04.txt similarity index 100% rename from test/sudoku-easy-04.txt rename to test/files/sudoku-easy-04.txt diff --git a/test/sudoku-easy-05.txt b/test/files/sudoku-easy-05.txt similarity index 100% rename from test/sudoku-easy-05.txt rename to test/files/sudoku-easy-05.txt diff --git a/test/sudoku-easy-06.txt b/test/files/sudoku-easy-06.txt similarity index 100% rename from test/sudoku-easy-06.txt rename to test/files/sudoku-easy-06.txt diff --git a/test/sudoku-easy-07.txt b/test/files/sudoku-easy-07.txt similarity index 100% rename from test/sudoku-easy-07.txt rename to test/files/sudoku-easy-07.txt diff --git a/test/sudoku-easy-08.txt b/test/files/sudoku-easy-08.txt similarity index 100% rename from test/sudoku-easy-08.txt rename to test/files/sudoku-easy-08.txt diff --git a/test/sudoku-easy-09.txt b/test/files/sudoku-easy-09.txt similarity index 100% rename from test/sudoku-easy-09.txt rename to test/files/sudoku-easy-09.txt diff --git a/test/sudoku-easy-10.txt b/test/files/sudoku-easy-10.txt similarity index 100% rename from test/sudoku-easy-10.txt rename to test/files/sudoku-easy-10.txt diff --git a/test/sudoku-easy-11.txt b/test/files/sudoku-easy-11.txt similarity index 100% rename from test/sudoku-easy-11.txt rename to test/files/sudoku-easy-11.txt diff --git a/test/sudoku-easy-12.txt b/test/files/sudoku-easy-12.txt similarity index 100% rename from test/sudoku-easy-12.txt rename to test/files/sudoku-easy-12.txt diff --git a/test/sudoku-easy-13.txt b/test/files/sudoku-easy-13.txt similarity index 100% rename from test/sudoku-easy-13.txt rename to test/files/sudoku-easy-13.txt diff --git a/test/sudoku-easy-14.txt b/test/files/sudoku-easy-14.txt similarity index 100% rename from test/sudoku-easy-14.txt rename to test/files/sudoku-easy-14.txt diff --git a/test/sudoku-easy-15.txt b/test/files/sudoku-easy-15.txt similarity index 100% rename from test/sudoku-easy-15.txt rename to test/files/sudoku-easy-15.txt diff --git a/test/sudoku-easy-16.txt b/test/files/sudoku-easy-16.txt similarity index 100% rename from test/sudoku-easy-16.txt rename to test/files/sudoku-easy-16.txt diff --git a/test/sudoku-easy-17.txt b/test/files/sudoku-easy-17.txt similarity index 100% rename from test/sudoku-easy-17.txt rename to test/files/sudoku-easy-17.txt diff --git a/test/sudoku-easy-18.txt b/test/files/sudoku-easy-18.txt similarity index 100% rename from test/sudoku-easy-18.txt rename to test/files/sudoku-easy-18.txt diff --git a/test/sudoku-easy-19.txt b/test/files/sudoku-easy-19.txt similarity index 100% rename from test/sudoku-easy-19.txt rename to test/files/sudoku-easy-19.txt diff --git a/test/sudoku-easy-20.txt b/test/files/sudoku-easy-20.txt similarity index 100% rename from test/sudoku-easy-20.txt rename to test/files/sudoku-easy-20.txt diff --git a/test/sudoku-easy-21.txt b/test/files/sudoku-easy-21.txt similarity index 100% rename from test/sudoku-easy-21.txt rename to test/files/sudoku-easy-21.txt diff --git a/test/sudoku-easy-22.txt b/test/files/sudoku-easy-22.txt similarity index 100% rename from test/sudoku-easy-22.txt rename to test/files/sudoku-easy-22.txt diff --git a/test/sudoku-easy-23.txt b/test/files/sudoku-easy-23.txt similarity index 100% rename from test/sudoku-easy-23.txt rename to test/files/sudoku-easy-23.txt diff --git a/test/sudoku-easy-24.txt b/test/files/sudoku-easy-24.txt similarity index 100% rename from test/sudoku-easy-24.txt rename to test/files/sudoku-easy-24.txt diff --git a/test/sudoku-easy-25.txt b/test/files/sudoku-easy-25.txt similarity index 100% rename from test/sudoku-easy-25.txt rename to test/files/sudoku-easy-25.txt diff --git a/test/sudoku-easy-26.txt b/test/files/sudoku-easy-26.txt similarity index 100% rename from test/sudoku-easy-26.txt rename to test/files/sudoku-easy-26.txt diff --git a/test/sudoku-easy-27.txt b/test/files/sudoku-easy-27.txt similarity index 100% rename from test/sudoku-easy-27.txt rename to test/files/sudoku-easy-27.txt diff --git a/test/sudoku-easy-28.txt b/test/files/sudoku-easy-28.txt similarity index 100% rename from test/sudoku-easy-28.txt rename to test/files/sudoku-easy-28.txt diff --git a/test/sudoku-easy-29.txt b/test/files/sudoku-easy-29.txt similarity index 100% rename from test/sudoku-easy-29.txt rename to test/files/sudoku-easy-29.txt diff --git a/test/sudoku-easy-30.txt b/test/files/sudoku-easy-30.txt similarity index 100% rename from test/sudoku-easy-30.txt rename to test/files/sudoku-easy-30.txt diff --git a/test/sudoku-easy-31.txt b/test/files/sudoku-easy-31.txt similarity index 100% rename from test/sudoku-easy-31.txt rename to test/files/sudoku-easy-31.txt diff --git a/test/sudoku-easy-32.txt b/test/files/sudoku-easy-32.txt similarity index 100% rename from test/sudoku-easy-32.txt rename to test/files/sudoku-easy-32.txt diff --git a/test/sudoku-easy-33.txt b/test/files/sudoku-easy-33.txt similarity index 100% rename from test/sudoku-easy-33.txt rename to test/files/sudoku-easy-33.txt diff --git a/test/sudoku-easy-34.txt b/test/files/sudoku-easy-34.txt similarity index 100% rename from test/sudoku-easy-34.txt rename to test/files/sudoku-easy-34.txt diff --git a/test/sudoku-easy-35.txt b/test/files/sudoku-easy-35.txt similarity index 100% rename from test/sudoku-easy-35.txt rename to test/files/sudoku-easy-35.txt diff --git a/test/sudoku-easy-36.txt b/test/files/sudoku-easy-36.txt similarity index 100% rename from test/sudoku-easy-36.txt rename to test/files/sudoku-easy-36.txt diff --git a/test/sudoku-easy-37.txt b/test/files/sudoku-easy-37.txt similarity index 100% rename from test/sudoku-easy-37.txt rename to test/files/sudoku-easy-37.txt diff --git a/test/sudoku-easy-38.txt b/test/files/sudoku-easy-38.txt similarity index 100% rename from test/sudoku-easy-38.txt rename to test/files/sudoku-easy-38.txt diff --git a/test/sudoku-easy-39.txt b/test/files/sudoku-easy-39.txt similarity index 100% rename from test/sudoku-easy-39.txt rename to test/files/sudoku-easy-39.txt diff --git a/test/sudoku-easy-40.txt b/test/files/sudoku-easy-40.txt similarity index 100% rename from test/sudoku-easy-40.txt rename to test/files/sudoku-easy-40.txt diff --git a/test/sudoku-easy-41.txt b/test/files/sudoku-easy-41.txt similarity index 100% rename from test/sudoku-easy-41.txt rename to test/files/sudoku-easy-41.txt diff --git a/test/sudoku-easy-42.txt b/test/files/sudoku-easy-42.txt similarity index 100% rename from test/sudoku-easy-42.txt rename to test/files/sudoku-easy-42.txt diff --git a/test/sudoku-easy-43.txt b/test/files/sudoku-easy-43.txt similarity index 100% rename from test/sudoku-easy-43.txt rename to test/files/sudoku-easy-43.txt diff --git a/test/sudoku-easy-44.txt b/test/files/sudoku-easy-44.txt similarity index 100% rename from test/sudoku-easy-44.txt rename to test/files/sudoku-easy-44.txt diff --git a/test/sudoku-easy-45.txt b/test/files/sudoku-easy-45.txt similarity index 100% rename from test/sudoku-easy-45.txt rename to test/files/sudoku-easy-45.txt diff --git a/test/sudoku-easy-46.txt b/test/files/sudoku-easy-46.txt similarity index 100% rename from test/sudoku-easy-46.txt rename to test/files/sudoku-easy-46.txt diff --git a/test/sudoku-easy-47.txt b/test/files/sudoku-easy-47.txt similarity index 100% rename from test/sudoku-easy-47.txt rename to test/files/sudoku-easy-47.txt diff --git a/test/sudoku-easy-48.txt b/test/files/sudoku-easy-48.txt similarity index 100% rename from test/sudoku-easy-48.txt rename to test/files/sudoku-easy-48.txt diff --git a/test/sudoku-easy-49.txt b/test/files/sudoku-easy-49.txt similarity index 100% rename from test/sudoku-easy-49.txt rename to test/files/sudoku-easy-49.txt diff --git a/test/sudoku-easy-50.txt b/test/files/sudoku-easy-50.txt similarity index 100% rename from test/sudoku-easy-50.txt rename to test/files/sudoku-easy-50.txt diff --git a/test/sudoku-easy-full.txt b/test/files/sudoku-easy-full.txt similarity index 100% rename from test/sudoku-easy-full.txt rename to test/files/sudoku-easy-full.txt diff --git a/test/test.cpp b/test/test.cpp index 6668b68..d65e30f 100644 --- a/test/test.cpp +++ b/test/test.cpp @@ -1,21 +1,15 @@ #include #include +#include "sudoku.hpp" +#include "test_list.hpp" void setUp() { ; } void tearDown() { ; } -int Math(void) { - return 2+2; -} - -void test_Math(void) { - TEST_ASSERT_EQUAL_INT(4, Math()); -} - int main(void) { UNITY_BEGIN(); - RUN_TEST(test_Math); + RUN_TEST(test_SudokuEasy01); return UNITY_END(); } diff --git a/test/test_list.cpp b/test/test_list.cpp new file mode 100644 index 0000000..6641fee --- /dev/null +++ b/test/test_list.cpp @@ -0,0 +1,354 @@ +#include "test_list.hpp" +#include +#include +#include "sudoku.hpp" + +void test_SudokuEasy01(void) { + Sudoku testGame; + testGame.FillBoard("test/files/sudoku-easy-01.txt"); + testGame.Solve(); + TEST_ASSERT_TRUE(testGame.IsBoardSolved()); +} + +void test_SudokuEasy02(void) { + Sudoku testGame; + testGame.FillBoard("test/files/sudoku-easy-02.txt"); + testGame.Solve(); + TEST_ASSERT_TRUE(testGame.IsBoardSolved()); +} + +void test_SudokuEasy03(void) { + Sudoku testGame; + testGame.FillBoard("test/files/sudoku-easy-03.txt"); + testGame.Solve(); + TEST_ASSERT_TRUE(testGame.IsBoardSolved()); +} + +void test_SudokuEasy04(void) { + Sudoku testGame; + testGame.FillBoard("test/files/sudoku-easy-04.txt"); + testGame.Solve(); + TEST_ASSERT_TRUE(testGame.IsBoardSolved()); +} + +void test_SudokuEasy05(void) { + Sudoku testGame; + testGame.FillBoard("test/files/sudoku-easy-05.txt"); + testGame.Solve(); + TEST_ASSERT_TRUE(testGame.IsBoardSolved()); +} + +void test_SudokuEasy06(void) { + Sudoku testGame; + testGame.FillBoard("test/files/sudoku-easy-06.txt"); + testGame.Solve(); + TEST_ASSERT_TRUE(testGame.IsBoardSolved()); +} + +void test_SudokuEasy07(void) { + Sudoku testGame; + testGame.FillBoard("test/files/sudoku-easy-07.txt"); + testGame.Solve(); + TEST_ASSERT_TRUE(testGame.IsBoardSolved()); +} + +void test_SudokuEasy08(void) { + Sudoku testGame; + testGame.FillBoard("test/files/sudoku-easy-08.txt"); + testGame.Solve(); + TEST_ASSERT_TRUE(testGame.IsBoardSolved()); +} + +void test_SudokuEasy09(void) { + Sudoku testGame; + testGame.FillBoard("test/files/sudoku-easy-09.txt"); + testGame.Solve(); + TEST_ASSERT_TRUE(testGame.IsBoardSolved()); +} + +void test_SudokuEasy10(void) { + Sudoku testGame; + testGame.FillBoard("test/files/sudoku-easy-10.txt"); + testGame.Solve(); + TEST_ASSERT_TRUE(testGame.IsBoardSolved()); +} + +void test_SudokuEasy11(void) { + Sudoku testGame; + testGame.FillBoard("test/files/sudoku-easy-11.txt"); + testGame.Solve(); + TEST_ASSERT_TRUE(testGame.IsBoardSolved()); +} + +void test_SudokuEasy12(void) { + Sudoku testGame; + testGame.FillBoard("test/files/sudoku-easy-12.txt"); + testGame.Solve(); + TEST_ASSERT_TRUE(testGame.IsBoardSolved()); +} + +void test_SudokuEasy13(void) { + Sudoku testGame; + testGame.FillBoard("test/files/sudoku-easy-13.txt"); + testGame.Solve(); + TEST_ASSERT_TRUE(testGame.IsBoardSolved()); +} + +void test_SudokuEasy14(void) { + Sudoku testGame; + testGame.FillBoard("test/files/sudoku-easy-14.txt"); + testGame.Solve(); + TEST_ASSERT_TRUE(testGame.IsBoardSolved()); +} + +void test_SudokuEasy15(void) { + Sudoku testGame; + testGame.FillBoard("test/files/sudoku-easy-15.txt"); + testGame.Solve(); + TEST_ASSERT_TRUE(testGame.IsBoardSolved()); +} + +void test_SudokuEasy16(void) { + Sudoku testGame; + testGame.FillBoard("test/files/sudoku-easy-16.txt"); + testGame.Solve(); + TEST_ASSERT_TRUE(testGame.IsBoardSolved()); +} + +void test_SudokuEasy17(void) { + Sudoku testGame; + testGame.FillBoard("test/files/sudoku-easy-17.txt"); + testGame.Solve(); + TEST_ASSERT_TRUE(testGame.IsBoardSolved()); +} + +void test_SudokuEasy18(void) { + Sudoku testGame; + testGame.FillBoard("test/files/sudoku-easy-18.txt"); + testGame.Solve(); + TEST_ASSERT_TRUE(testGame.IsBoardSolved()); +} + +void test_SudokuEasy19(void) { + Sudoku testGame; + testGame.FillBoard("test/files/sudoku-easy-19.txt"); + testGame.Solve(); + TEST_ASSERT_TRUE(testGame.IsBoardSolved()); +} + +void test_SudokuEasy20(void) { + Sudoku testGame; + testGame.FillBoard("test/files/sudoku-easy-20.txt"); + testGame.Solve(); + TEST_ASSERT_TRUE(testGame.IsBoardSolved()); +} + +void test_SudokuEasy21(void) { + Sudoku testGame; + testGame.FillBoard("test/files/sudoku-easy-21.txt"); + testGame.Solve(); + TEST_ASSERT_TRUE(testGame.IsBoardSolved()); +} + +void test_SudokuEasy22(void) { + Sudoku testGame; + testGame.FillBoard("test/files/sudoku-easy-22.txt"); + testGame.Solve(); + TEST_ASSERT_TRUE(testGame.IsBoardSolved()); +} + +void test_SudokuEasy23(void) { + Sudoku testGame; + testGame.FillBoard("test/files/sudoku-easy-23.txt"); + testGame.Solve(); + TEST_ASSERT_TRUE(testGame.IsBoardSolved()); +} + +void test_SudokuEasy24(void) { + Sudoku testGame; + testGame.FillBoard("test/files/sudoku-easy-24.txt"); + testGame.Solve(); + TEST_ASSERT_TRUE(testGame.IsBoardSolved()); +} + +void test_SudokuEasy25(void) { + Sudoku testGame; + testGame.FillBoard("test/files/sudoku-easy-25.txt"); + testGame.Solve(); + TEST_ASSERT_TRUE(testGame.IsBoardSolved()); +} + +void test_SudokuEasy26(void) { + Sudoku testGame; + testGame.FillBoard("test/files/sudoku-easy-26.txt"); + testGame.Solve(); + TEST_ASSERT_TRUE(testGame.IsBoardSolved()); +} + +void test_SudokuEasy27(void) { + Sudoku testGame; + testGame.FillBoard("test/files/sudoku-easy-27.txt"); + testGame.Solve(); + TEST_ASSERT_TRUE(testGame.IsBoardSolved()); +} + +void test_SudokuEasy28(void) { + Sudoku testGame; + testGame.FillBoard("test/files/sudoku-easy-28.txt"); + testGame.Solve(); + TEST_ASSERT_TRUE(testGame.IsBoardSolved()); +} + +void test_SudokuEasy29(void) { + Sudoku testGame; + testGame.FillBoard("test/files/sudoku-easy-29.txt"); + testGame.Solve(); + TEST_ASSERT_TRUE(testGame.IsBoardSolved()); +} + +void test_SudokuEasy30(void) { + Sudoku testGame; + testGame.FillBoard("test/files/sudoku-easy-30.txt"); + testGame.Solve(); + TEST_ASSERT_TRUE(testGame.IsBoardSolved()); +} + +void test_SudokuEasy31(void) { + Sudoku testGame; + testGame.FillBoard("test/files/sudoku-easy-31.txt"); + testGame.Solve(); + TEST_ASSERT_TRUE(testGame.IsBoardSolved()); +} + +void test_SudokuEasy32(void) { + Sudoku testGame; + testGame.FillBoard("test/files/sudoku-easy-32.txt"); + testGame.Solve(); + TEST_ASSERT_TRUE(testGame.IsBoardSolved()); +} + +void test_SudokuEasy33(void) { + Sudoku testGame; + testGame.FillBoard("test/files/sudoku-easy-33.txt"); + testGame.Solve(); + TEST_ASSERT_TRUE(testGame.IsBoardSolved()); +} + +void test_SudokuEasy34(void) { + Sudoku testGame; + testGame.FillBoard("test/files/sudoku-easy-34.txt"); + testGame.Solve(); + TEST_ASSERT_TRUE(testGame.IsBoardSolved()); +} + +void test_SudokuEasy35(void) { + Sudoku testGame; + testGame.FillBoard("test/files/sudoku-easy-35.txt"); + testGame.Solve(); + TEST_ASSERT_TRUE(testGame.IsBoardSolved()); +} + +void test_SudokuEasy36(void) { + Sudoku testGame; + testGame.FillBoard("test/files/sudoku-easy-36.txt"); + testGame.Solve(); + TEST_ASSERT_TRUE(testGame.IsBoardSolved()); +} + +void test_SudokuEasy37(void) { + Sudoku testGame; + testGame.FillBoard("test/files/sudoku-easy-37.txt"); + testGame.Solve(); + TEST_ASSERT_TRUE(testGame.IsBoardSolved()); +} + +void test_SudokuEasy38(void) { + Sudoku testGame; + testGame.FillBoard("test/files/sudoku-easy-38.txt"); + testGame.Solve(); + TEST_ASSERT_TRUE(testGame.IsBoardSolved()); +} + +void test_SudokuEasy39(void) { + Sudoku testGame; + testGame.FillBoard("test/files/sudoku-easy-39.txt"); + testGame.Solve(); + TEST_ASSERT_TRUE(testGame.IsBoardSolved()); +} + +void test_SudokuEasy40(void) { + Sudoku testGame; + testGame.FillBoard("test/files/sudoku-easy-40.txt"); + testGame.Solve(); + TEST_ASSERT_TRUE(testGame.IsBoardSolved()); +} + +void test_SudokuEasy41(void) { + Sudoku testGame; + testGame.FillBoard("test/files/sudoku-easy-41.txt"); + testGame.Solve(); + TEST_ASSERT_TRUE(testGame.IsBoardSolved()); +} + +void test_SudokuEasy42(void) { + Sudoku testGame; + testGame.FillBoard("test/files/sudoku-easy-42.txt"); + testGame.Solve(); + TEST_ASSERT_TRUE(testGame.IsBoardSolved()); +} + +void test_SudokuEasy43(void) { + Sudoku testGame; + testGame.FillBoard("test/files/sudoku-easy-43.txt"); + testGame.Solve(); + TEST_ASSERT_TRUE(testGame.IsBoardSolved()); +} + +void test_SudokuEasy44(void) { + Sudoku testGame; + testGame.FillBoard("test/files/sudoku-easy-44.txt"); + testGame.Solve(); + TEST_ASSERT_TRUE(testGame.IsBoardSolved()); +} + +void test_SudokuEasy45(void) { + Sudoku testGame; + testGame.FillBoard("test/files/sudoku-easy-45.txt"); + testGame.Solve(); + TEST_ASSERT_TRUE(testGame.IsBoardSolved()); +} + +void test_SudokuEasy46(void) { + Sudoku testGame; + testGame.FillBoard("test/files/sudoku-easy-46.txt"); + testGame.Solve(); + TEST_ASSERT_TRUE(testGame.IsBoardSolved()); +} + +void test_SudokuEasy47(void) { + Sudoku testGame; + testGame.FillBoard("test/files/sudoku-easy-47.txt"); + testGame.Solve(); + TEST_ASSERT_TRUE(testGame.IsBoardSolved()); +} + +void test_SudokuEasy48(void) { + Sudoku testGame; + testGame.FillBoard("test/files/sudoku-easy-48.txt"); + testGame.Solve(); + TEST_ASSERT_TRUE(testGame.IsBoardSolved()); +} + +void test_SudokuEasy49(void) { + Sudoku testGame; + testGame.FillBoard("test/files/sudoku-easy-49.txt"); + testGame.Solve(); + TEST_ASSERT_TRUE(testGame.IsBoardSolved()); +} + +void test_SudokuEasy50(void) { + Sudoku testGame; + testGame.FillBoard("test/files/sudoku-easy-50.txt"); + testGame.Solve(); + TEST_ASSERT_TRUE(testGame.IsBoardSolved()); +} diff --git a/test/test_list.hpp b/test/test_list.hpp new file mode 100644 index 0000000..1458fde --- /dev/null +++ b/test/test_list.hpp @@ -0,0 +1,55 @@ +#ifndef TEST_LIST_HPP +#define TEST_LIST_HPP + +void test_SudokuEasy01(void); +void test_SudokuEasy02(void); +void test_SudokuEasy03(void); +void test_SudokuEasy04(void); +void test_SudokuEasy05(void); +void test_SudokuEasy06(void); +void test_SudokuEasy07(void); +void test_SudokuEasy08(void); +void test_SudokuEasy09(void); +void test_SudokuEasy10(void); +void test_SudokuEasy11(void); +void test_SudokuEasy12(void); +void test_SudokuEasy13(void); +void test_SudokuEasy14(void); +void test_SudokuEasy15(void); +void test_SudokuEasy16(void); +void test_SudokuEasy17(void); +void test_SudokuEasy18(void); +void test_SudokuEasy19(void); +void test_SudokuEasy20(void); +void test_SudokuEasy21(void); +void test_SudokuEasy22(void); +void test_SudokuEasy23(void); +void test_SudokuEasy24(void); +void test_SudokuEasy25(void); +void test_SudokuEasy26(void); +void test_SudokuEasy27(void); +void test_SudokuEasy28(void); +void test_SudokuEasy29(void); +void test_SudokuEasy30(void); +void test_SudokuEasy31(void); +void test_SudokuEasy32(void); +void test_SudokuEasy33(void); +void test_SudokuEasy34(void); +void test_SudokuEasy35(void); +void test_SudokuEasy36(void); +void test_SudokuEasy37(void); +void test_SudokuEasy38(void); +void test_SudokuEasy39(void); +void test_SudokuEasy40(void); +void test_SudokuEasy41(void); +void test_SudokuEasy42(void); +void test_SudokuEasy43(void); +void test_SudokuEasy44(void); +void test_SudokuEasy45(void); +void test_SudokuEasy46(void); +void test_SudokuEasy47(void); +void test_SudokuEasy48(void); +void test_SudokuEasy49(void); +void test_SudokuEasy50(void); + +#endif -- 2.45.2 From b7217dc8779b7c98468bb431da72ce36571fa9f4 Mon Sep 17 00:00:00 2001 From: Trianta <56975502+Trimutex@users.noreply.github.com> Date: Sat, 21 Oct 2023 17:03:59 -0500 Subject: [PATCH 06/10] Preparation work --- src/CMakeLists.txt | 2 +- src/sudoku.cpp | 48 +++++++++++++++++++++++++++++++++++++++---- src/sudoku.hpp | 21 +++++++++++++++++++ src/sudoku_solver.cpp | 5 +++++ 4 files changed, 71 insertions(+), 5 deletions(-) create mode 100644 src/sudoku.hpp create mode 100644 src/sudoku_solver.cpp diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index aa7da15..894bf98 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,5 +1,5 @@ add_executable(sudoku + ./sudoku_solver.cpp ./sudoku.cpp ) -target_include_directories(sudoku PUBLIC ${CMAKE_CURRENT_LIST_DIR}) diff --git a/src/sudoku.cpp b/src/sudoku.cpp index 9294f97..4911f30 100644 --- a/src/sudoku.cpp +++ b/src/sudoku.cpp @@ -1,7 +1,47 @@ +#include "sudoku.hpp" +#include #include +#include + + +Sudoku::Sudoku(void) { + board.resize(9, std::vector(9, -1)); +} + +void Sudoku::FillBoard(std::string filePath) { + std::ifstream sudokuFile(filePath); + if (!sudokuFile) { + std::cerr << "Error opening file: " << filePath << std::endl; + exit(1); + } + std::string line; + while (!sudokuFile.eof()) { + sudokuFile >> line; + std::cout << line << std::endl; + } + +} + +void Sudoku::Solve(void) { + +} + +bool Sudoku::IsBoardSolved(void) { + return true; +} + +bool Sudoku::IsRowComplete(int row) { + return true; +} + +bool Sudoku::IsColumnComplete(int column) { + return true; +} + +std::vector Sudoku::GetUnusedInRow(int row) { + +} + +std::vector Sudoku::GetUnusedInColumn(int column) { -int main(void) { - std::cout << "Sudoku started" << std::endl; - std::cout << "Sudoku ended" << std::endl; - return 0; } diff --git a/src/sudoku.hpp b/src/sudoku.hpp new file mode 100644 index 0000000..5bb8552 --- /dev/null +++ b/src/sudoku.hpp @@ -0,0 +1,21 @@ +#ifndef SUDOKU_HPP +#define SUDOKU_HPP + +#include +#include + +class Sudoku { +public: + Sudoku(void); + std::vector< std::vector > board; + void FillBoard(std::string filePath); + void Solve(void); + bool IsBoardSolved(void); +private: + bool IsRowComplete(int row); + bool IsColumnComplete(int column); + std::vector GetUnusedInRow(int row); + std::vector GetUnusedInColumn(int column); +}; + +#endif diff --git a/src/sudoku_solver.cpp b/src/sudoku_solver.cpp new file mode 100644 index 0000000..a325153 --- /dev/null +++ b/src/sudoku_solver.cpp @@ -0,0 +1,5 @@ +#include "sudoku.hpp" + +int main(void) { + return 0; +} -- 2.45.2 From 670027c119f300b713d059567267a382d8b01833 Mon Sep 17 00:00:00 2001 From: Trianta <56975502+Trimutex@users.noreply.github.com> Date: Sun, 22 Oct 2023 05:29:20 -0500 Subject: [PATCH 07/10] Final preparations for project --- src/sudoku.cpp | 47 +++++++++++++++++++++++++++++++++++++++++-- src/sudoku.hpp | 1 + src/sudoku_solver.cpp | 4 ++++ 3 files changed, 50 insertions(+), 2 deletions(-) diff --git a/src/sudoku.cpp b/src/sudoku.cpp index 4911f30..903f035 100644 --- a/src/sudoku.cpp +++ b/src/sudoku.cpp @@ -19,29 +19,72 @@ void Sudoku::FillBoard(std::string filePath) { sudokuFile >> line; std::cout << line << std::endl; } + // TODO: Finish inputting sudoku file + // Really just needs to be split by digit then stored } +// TODO: Implement solving algorithm void Sudoku::Solve(void) { } +// TODO: Add checking for full board completion bool Sudoku::IsBoardSolved(void) { return true; } +// TODO: Add printing of board for visuals +// Maybe also print during solve? +void Sudoku::Print(void) { + +} + +// TODO: Add checking for row completion bool Sudoku::IsRowComplete(int row) { return true; } +// TODO: Add checking for column completion bool Sudoku::IsColumnComplete(int column) { return true; } +// WARNING: This function and one below could be swapped, untested std::vector Sudoku::GetUnusedInRow(int row) { - + std::vector leftOver{0,1,2,3,4,5,6,7,8,9}; + int number; + for (int i = 0; i < 9; i++) { + number = board[i][row]; + if (leftOver[number] == number) { + leftOver[number] = 0; + } + if (leftOver[number] == 0) { // Two of same number was placed + leftOver[number] = -1; + } + } + for (auto it = leftOver.begin(); it != leftOver.end();) { + if (*it == 0) { it = leftOver.erase(it); } + else { ++it; } + } + return leftOver; } std::vector Sudoku::GetUnusedInColumn(int column) { - + std::vector leftOver{0,1,2,3,4,5,6,7,8,9}; + int number; + for (int i = 0; i < 9; i++) { + number = board[column][i]; + if (leftOver[number] == number) { + leftOver[number] = 0; + } + if (leftOver[number] == 0) { // Two of same number was placed + leftOver[number] = -1; + } + } + for (auto it = leftOver.begin(); it != leftOver.end();) { + if (*it == 0) { it = leftOver.erase(it); } + else { ++it; } + } + return leftOver; } diff --git a/src/sudoku.hpp b/src/sudoku.hpp index 5bb8552..a466e61 100644 --- a/src/sudoku.hpp +++ b/src/sudoku.hpp @@ -11,6 +11,7 @@ public: void FillBoard(std::string filePath); void Solve(void); bool IsBoardSolved(void); + void Print(void); private: bool IsRowComplete(int row); bool IsColumnComplete(int column); diff --git a/src/sudoku_solver.cpp b/src/sudoku_solver.cpp index a325153..05f35f9 100644 --- a/src/sudoku_solver.cpp +++ b/src/sudoku_solver.cpp @@ -1,5 +1,9 @@ #include "sudoku.hpp" +// TODO: +// Take in sudoku file from arguments +// Run solve +// Print solution int main(void) { return 0; } -- 2.45.2 From e12cb72dcff32b19b16735d0792e5b10530bfa67 Mon Sep 17 00:00:00 2001 From: Trianta <56975502+Trimutex@users.noreply.github.com> Date: Sun, 22 Oct 2023 21:39:36 -0500 Subject: [PATCH 08/10] Successfully solves sudoku --- src/sudoku.cpp | 153 +++++++++++++++++++++++++++++++++--------- src/sudoku.hpp | 8 ++- src/sudoku_solver.cpp | 15 +++-- test/test.cpp | 49 ++++++++++++++ 4 files changed, 187 insertions(+), 38 deletions(-) diff --git a/src/sudoku.cpp b/src/sudoku.cpp index 903f035..52240a2 100644 --- a/src/sudoku.cpp +++ b/src/sudoku.cpp @@ -15,53 +15,129 @@ void Sudoku::FillBoard(std::string filePath) { exit(1); } std::string line; - while (!sudokuFile.eof()) { + int height = 0; + while (!sudokuFile.eof() && height < 9) { sudokuFile >> line; - std::cout << line << std::endl; + for (int i = 0; i < 9; ++i) { board[height][i] = line[i] - '0'; } + ++height; } - // TODO: Finish inputting sudoku file - // Really just needs to be split by digit then stored - } -// TODO: Implement solving algorithm +// Base global call for solving void Sudoku::Solve(void) { - + _Solve(); } -// TODO: Add checking for full board completion bool Sudoku::IsBoardSolved(void) { + for (int i = 0; i < 9; ++i) { + if (!IsColumnComplete(i)) { return false; } + } return true; } -// TODO: Add printing of board for visuals -// Maybe also print during solve? void Sudoku::Print(void) { - + std::cout << "===================" << std::endl; + for (auto i : board) { + std::cout << '|'; + for (auto j : i) { + std::cout << j << '|'; + } + std::cout << std::endl; + } + std::cout << "===================" << std::endl; +} + +// Recursive call for solving +bool Sudoku::_Solve(void) { + int column, row; + if (!FindEmptyCell(&column, &row)) { return true; } + for (int i : GetUnusedRow(row)) { + for (int j : GetUnusedColumn(column)) { + for (int k : GetUnusedSubgrid(column, row)) { + if (i == j == k) { + board[row][column] = i; + if (_Solve()) { return true; } + board[row][column] = 0; + } + } + } + } + return 0; +} + +// Fills column and row of an empty cell and returns true +// If no empty cell is found, return false +bool Sudoku::FindEmptyCell(int* column, int* row) { + for (*row = 0; *row < 9; ++(*row)) { + for (*column = 0; *column < 9; ++(*column)) { + if (board[*row][*column] == 0) { return true; } + } + } + return false; +} + +bool Sudoku::IsValidPlacement(int column, int row, int box) { + // Check column and row + for (int i = 0; i < 9; ++i) { + if (board[row][i] == box || board[i][column] == box) { + return false; + } + } + + // Check subgrid + int startRow = row - row % 3; + int startColumn = column - column % 3; + for (int i = 0; i < 3; ++i) { + for (int j = 0; j < 3; ++j) { + if (board[startRow + i][startColumn + j] == box) { return false; } + } + } + return true; } -// TODO: Add checking for row completion bool Sudoku::IsRowComplete(int row) { + std::vector leftOver{0,1,2,3,4,5,6,7,8,9}; + int box; + for (int i = 0; i < 9; i++) { + box = board[row][i]; + if (leftOver[box] == 0 && box != 0) { + std::cerr << "Invalid assignment detected. Aborting..." << std::endl; + exit(1); + } + if (leftOver[box] == box) { leftOver[box] = 0; } + } + for (auto it = leftOver.begin(); it != leftOver.end();) { + if (*it == 0) { it = leftOver.erase(it); } + else { ++it; } + } + if (leftOver.size() != 0) { return false; } return true; } -// TODO: Add checking for column completion bool Sudoku::IsColumnComplete(int column) { + std::vector leftOver{0,1,2,3,4,5,6,7,8,9}; + int box; + for (int i = 0; i < 9; i++) { + box = board[i][column]; + if (leftOver[box] == 0 && box != 0) { + leftOver[box] = -1; // Duplicate detected in same column + } + if (leftOver[box] == box) { leftOver[box] = 0; } + } + for (auto it = leftOver.begin(); it != leftOver.end();) { + if (*it == 0) { it = leftOver.erase(it); } + else { ++it; } + } + if (leftOver.size() != 0) { return false; } return true; } -// WARNING: This function and one below could be swapped, untested -std::vector Sudoku::GetUnusedInRow(int row) { +std::vector Sudoku::GetUnusedRow(int row) { std::vector leftOver{0,1,2,3,4,5,6,7,8,9}; - int number; + int box; for (int i = 0; i < 9; i++) { - number = board[i][row]; - if (leftOver[number] == number) { - leftOver[number] = 0; - } - if (leftOver[number] == 0) { // Two of same number was placed - leftOver[number] = -1; - } + box = board[row][i]; + if (leftOver[box] == box) { leftOver[box] = 0; } } for (auto it = leftOver.begin(); it != leftOver.end();) { if (*it == 0) { it = leftOver.erase(it); } @@ -70,16 +146,31 @@ std::vector Sudoku::GetUnusedInRow(int row) { return leftOver; } -std::vector Sudoku::GetUnusedInColumn(int column) { +std::vector Sudoku::GetUnusedColumn(int column) { std::vector leftOver{0,1,2,3,4,5,6,7,8,9}; - int number; + int box; for (int i = 0; i < 9; i++) { - number = board[column][i]; - if (leftOver[number] == number) { - leftOver[number] = 0; - } - if (leftOver[number] == 0) { // Two of same number was placed - leftOver[number] = -1; + box = board[i][column]; + if (leftOver[box] == box) { leftOver[box] = 0; } + } + for (auto it = leftOver.begin(); it != leftOver.end();) { + if (*it == 0) { it = leftOver.erase(it); } + else { ++it; } + } + return leftOver; +} + +std::vector Sudoku::GetUnusedSubgrid(int column, int row) { + std::vector leftOver{0,1,2,3,4,5,6,7,8,9}; + int box; + int startRow = row - row % 3; + int startColumn = column - column % 3; + for (int i = 0; i < 3; ++i) { + for (int j = 0; j < 3; ++j) { + box = board[row][column]; + if (board[startRow + i][startColumn + j] == box) { + leftOver[box] = 0; + } } } for (auto it = leftOver.begin(); it != leftOver.end();) { diff --git a/src/sudoku.hpp b/src/sudoku.hpp index a466e61..bb919d9 100644 --- a/src/sudoku.hpp +++ b/src/sudoku.hpp @@ -13,10 +13,14 @@ public: bool IsBoardSolved(void); void Print(void); private: + bool _Solve(void); + bool FindEmptyCell(int* column, int* row); + bool IsValidPlacement(int column, int row, int box); bool IsRowComplete(int row); bool IsColumnComplete(int column); - std::vector GetUnusedInRow(int row); - std::vector GetUnusedInColumn(int column); + std::vector GetUnusedRow(int row); + std::vector GetUnusedColumn(int column); + std::vector GetUnusedSubgrid(int column, int row); }; #endif diff --git a/src/sudoku_solver.cpp b/src/sudoku_solver.cpp index 05f35f9..879c0d7 100644 --- a/src/sudoku_solver.cpp +++ b/src/sudoku_solver.cpp @@ -1,9 +1,14 @@ #include "sudoku.hpp" +#include -// TODO: -// Take in sudoku file from arguments -// Run solve -// Print solution -int main(void) { +int main(int argc, char* argv[]) { + if (argc != 2) { + std::cerr << "Usage: " << argv[0] << " path/to/sudoku" << std::endl; + return 1; + } + Sudoku newGame; + newGame.FillBoard(argv[1]); + newGame.Solve(); + newGame.Print(); return 0; } diff --git a/test/test.cpp b/test/test.cpp index d65e30f..66c8bdc 100644 --- a/test/test.cpp +++ b/test/test.cpp @@ -10,6 +10,55 @@ void tearDown() { ; } int main(void) { UNITY_BEGIN(); RUN_TEST(test_SudokuEasy01); + RUN_TEST(test_SudokuEasy02); + RUN_TEST(test_SudokuEasy03); + RUN_TEST(test_SudokuEasy04); + RUN_TEST(test_SudokuEasy05); + RUN_TEST(test_SudokuEasy06); + RUN_TEST(test_SudokuEasy07); + RUN_TEST(test_SudokuEasy08); + RUN_TEST(test_SudokuEasy09); + RUN_TEST(test_SudokuEasy10); + RUN_TEST(test_SudokuEasy11); + RUN_TEST(test_SudokuEasy12); + RUN_TEST(test_SudokuEasy13); + RUN_TEST(test_SudokuEasy14); + RUN_TEST(test_SudokuEasy15); + RUN_TEST(test_SudokuEasy16); + RUN_TEST(test_SudokuEasy17); + RUN_TEST(test_SudokuEasy18); + RUN_TEST(test_SudokuEasy19); + RUN_TEST(test_SudokuEasy20); + RUN_TEST(test_SudokuEasy21); + RUN_TEST(test_SudokuEasy22); + RUN_TEST(test_SudokuEasy23); + RUN_TEST(test_SudokuEasy24); + RUN_TEST(test_SudokuEasy25); + RUN_TEST(test_SudokuEasy26); + RUN_TEST(test_SudokuEasy27); + RUN_TEST(test_SudokuEasy28); + RUN_TEST(test_SudokuEasy29); + RUN_TEST(test_SudokuEasy30); + RUN_TEST(test_SudokuEasy31); + RUN_TEST(test_SudokuEasy32); + RUN_TEST(test_SudokuEasy33); + RUN_TEST(test_SudokuEasy34); + RUN_TEST(test_SudokuEasy35); + RUN_TEST(test_SudokuEasy36); + RUN_TEST(test_SudokuEasy37); + RUN_TEST(test_SudokuEasy38); + RUN_TEST(test_SudokuEasy39); + RUN_TEST(test_SudokuEasy40); + RUN_TEST(test_SudokuEasy41); + RUN_TEST(test_SudokuEasy42); + RUN_TEST(test_SudokuEasy43); + RUN_TEST(test_SudokuEasy44); + RUN_TEST(test_SudokuEasy45); + RUN_TEST(test_SudokuEasy46); + RUN_TEST(test_SudokuEasy47); + RUN_TEST(test_SudokuEasy48); + RUN_TEST(test_SudokuEasy49); + RUN_TEST(test_SudokuEasy50); return UNITY_END(); } -- 2.45.2 From e57dcce50c03c094c00af74e5ae565762d37ceb8 Mon Sep 17 00:00:00 2001 From: Trianta <56975502+Trimutex@users.noreply.github.com> Date: Sun, 22 Oct 2023 21:46:48 -0500 Subject: [PATCH 09/10] Trimmed project before turn in --- README.md | 14 +++++++++++- src/sudoku.cpp | 53 ++++++++++--------------------------------- src/sudoku.hpp | 3 +-- src/sudoku_solver.cpp | 2 +- 4 files changed, 27 insertions(+), 45 deletions(-) diff --git a/README.md b/README.md index f9962be..3671d86 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,13 @@ # sudoku-solver +## Notes + +Uses a single sudoku file as input + +Tests were ran on sudoku-easy-50 split into individual files + +All were successfully solved + ## Compiling the project Prerequisites @@ -18,6 +26,10 @@ Simply run the program using: build/bin/sudoku ## Testing the Project + +Prerequisites + - Unity (Throw the Switch) + In order to compile the tests for the project, simply run these two commands: cmake -DCMAKE_BUILD_TYPE=Debug -B build -S . @@ -27,4 +39,4 @@ The program should now be compiled at ./build/bin/sudoku Simply run the tests using: - build/bin/sudoku-test + build/bin/testing diff --git a/src/sudoku.cpp b/src/sudoku.cpp index 52240a2..a8fb836 100644 --- a/src/sudoku.cpp +++ b/src/sudoku.cpp @@ -29,10 +29,9 @@ void Sudoku::Solve(void) { } bool Sudoku::IsBoardSolved(void) { - for (int i = 0; i < 9; ++i) { - if (!IsColumnComplete(i)) { return false; } - } - return true; + int column, row; + if (!FindEmptyCell(&column, &row)) { return true; } + return false; } void Sudoku::Print(void) { @@ -47,6 +46,15 @@ void Sudoku::Print(void) { std::cout << "===================" << std::endl; } +void Sudoku::RawPrint(void) { + for (auto i : board) { + for (auto j : i) { + std::cout << j; + } + std::cout << std::endl; + } +} + // Recursive call for solving bool Sudoku::_Solve(void) { int column, row; @@ -95,43 +103,6 @@ bool Sudoku::IsValidPlacement(int column, int row, int box) { return true; } -bool Sudoku::IsRowComplete(int row) { - std::vector leftOver{0,1,2,3,4,5,6,7,8,9}; - int box; - for (int i = 0; i < 9; i++) { - box = board[row][i]; - if (leftOver[box] == 0 && box != 0) { - std::cerr << "Invalid assignment detected. Aborting..." << std::endl; - exit(1); - } - if (leftOver[box] == box) { leftOver[box] = 0; } - } - for (auto it = leftOver.begin(); it != leftOver.end();) { - if (*it == 0) { it = leftOver.erase(it); } - else { ++it; } - } - if (leftOver.size() != 0) { return false; } - return true; -} - -bool Sudoku::IsColumnComplete(int column) { - std::vector leftOver{0,1,2,3,4,5,6,7,8,9}; - int box; - for (int i = 0; i < 9; i++) { - box = board[i][column]; - if (leftOver[box] == 0 && box != 0) { - leftOver[box] = -1; // Duplicate detected in same column - } - if (leftOver[box] == box) { leftOver[box] = 0; } - } - for (auto it = leftOver.begin(); it != leftOver.end();) { - if (*it == 0) { it = leftOver.erase(it); } - else { ++it; } - } - if (leftOver.size() != 0) { return false; } - return true; -} - std::vector Sudoku::GetUnusedRow(int row) { std::vector leftOver{0,1,2,3,4,5,6,7,8,9}; int box; diff --git a/src/sudoku.hpp b/src/sudoku.hpp index bb919d9..b6ff2e8 100644 --- a/src/sudoku.hpp +++ b/src/sudoku.hpp @@ -12,12 +12,11 @@ public: void Solve(void); bool IsBoardSolved(void); void Print(void); + void RawPrint(void); private: bool _Solve(void); bool FindEmptyCell(int* column, int* row); bool IsValidPlacement(int column, int row, int box); - bool IsRowComplete(int row); - bool IsColumnComplete(int column); std::vector GetUnusedRow(int row); std::vector GetUnusedColumn(int column); std::vector GetUnusedSubgrid(int column, int row); diff --git a/src/sudoku_solver.cpp b/src/sudoku_solver.cpp index 879c0d7..af2f165 100644 --- a/src/sudoku_solver.cpp +++ b/src/sudoku_solver.cpp @@ -9,6 +9,6 @@ int main(int argc, char* argv[]) { Sudoku newGame; newGame.FillBoard(argv[1]); newGame.Solve(); - newGame.Print(); + newGame.RawPrint(); return 0; } -- 2.45.2 From 18fb3c71ef41c29db33f3f3f0ae9400301b8c3c1 Mon Sep 17 00:00:00 2001 From: Trianta <56975502+Trimutex@users.noreply.github.com> Date: Sun, 22 Oct 2023 21:51:05 -0500 Subject: [PATCH 10/10] Added reference to testing framework --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 3671d86..0ff4542 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ Simply run the program using: ## Testing the Project Prerequisites - - Unity (Throw the Switch) + - Unity (Throw the Switch) | [AUR](https://aur.archlinux.org/packages/unity-test) In order to compile the tests for the project, simply run these two commands: -- 2.45.2