Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sudoku generator #6

Open
wants to merge 72 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
7873619
Move julia files to a separate folder
h3nnn4n Mar 22, 2021
9dc469c
Ignore gmon files
h3nnn4n Mar 22, 2021
e2482d3
Remove debug statements
h3nnn4n Mar 22, 2021
b648a26
Move dlx solver init and call to a function
h3nnn4n Mar 22, 2021
a1f0cae
Add missing license header
h3nnn4n Mar 22, 2021
f70701e
(cpplint) File should include its own header file
h3nnn4n Mar 22, 2021
824b5b2
Allow building files that are several folders deep
h3nnn4n Mar 22, 2021
7493b41
Add sudoku_generator boilerplate + abort on unexpected arg
h3nnn4n Mar 22, 2021
19db8e4
Boilerplate for sudoku generator + update compile_commands
h3nnn4n Mar 22, 2021
5143993
Add block constraint
h3nnn4n Mar 22, 2021
5a12780
Properly index row and column constraint
h3nnn4n Mar 22, 2021
a305db5
Ignore clang idx files
h3nnn4n Mar 22, 2021
d8ec430
Generate cover sets for clue cells and empty cells
h3nnn4n Mar 22, 2021
d0fc92f
Build file header with matrix size
h3nnn4n Mar 22, 2021
5a5073e
Add missing license headers
h3nnn4n Mar 22, 2021
0db91cd
(cpplint) Replace sprintf with snprintf
h3nnn4n Mar 22, 2021
4a7d066
Fix typo
h3nnn4n Mar 22, 2021
e7bdea8
Fix typo
h3nnn4n Mar 22, 2021
38d90ee
Fix invalid cover sets being generated
h3nnn4n Mar 22, 2021
1af9c26
Generate sudoku from string or file
h3nnn4n Mar 22, 2021
6fc0786
Fix leaks
h3nnn4n Mar 22, 2021
c504af7
Add heapcheck to sudoku gen
h3nnn4n Mar 22, 2021
8af58b0
Run sudoku gen and solve
h3nnn4n Mar 22, 2021
7880ab7
Add missing license header
h3nnn4n Mar 22, 2021
8d7fe51
(cpplint) Replate strcpy with snprintf
h3nnn4n Mar 22, 2021
5ca3fa9
Add clang-format
h3nnn4n Mar 22, 2021
20ad193
Update compile_commands
h3nnn4n Mar 22, 2021
3547cc0
Supress warning
h3nnn4n Mar 22, 2021
fb3720c
Revert "Add clang-format"
h3nnn4n Mar 22, 2021
92a818b
(cppcheck) Code cleanup
h3nnn4n Mar 22, 2021
bee0fa5
(cppcheck) Code cleanup
h3nnn4n Mar 22, 2021
1392b58
Run clang-tidy with same args as CI
h3nnn4n Mar 22, 2021
d72570b
Fix the aftermatch of my brain being off
h3nnn4n Mar 22, 2021
9454bf2
(clang-tidy) Code cleanup
h3nnn4n Mar 22, 2021
358b58d
Update pre-commit config args
h3nnn4n Mar 22, 2021
0cfdb7b
Remove redundant arg from clang-tidy
h3nnn4n Mar 22, 2021
7685e82
Add clang-tidy setting file + update compile_commands
h3nnn4n Mar 22, 2021
1dd4342
Use limits.h instead of linux/limits.h
h3nnn4n Mar 22, 2021
ab82334
(cppcheck) Ignore false alert
h3nnn4n Mar 22, 2021
24590e7
Add debug
h3nnn4n Mar 22, 2021
4443b0d
Fix path (?)
h3nnn4n Mar 22, 2021
4f40e13
messign around until it works
h3nnn4n Mar 22, 2021
9714f81
Go deeper than one level
h3nnn4n Mar 22, 2021
b22af07
Yml isnt helping
h3nnn4n Mar 22, 2021
c3cfef7
Store solutions on a file
h3nnn4n Mar 22, 2021
8ce733e
Add missing whitespace
h3nnn4n Mar 23, 2021
da62344
Fix output format
h3nnn4n Mar 23, 2021
0b5e325
Add a sudoku output parser
h3nnn4n Mar 23, 2021
624102d
Use strtok_r instead of strtok
h3nnn4n Mar 23, 2021
a2f7da4
Only set _POSIX_C_SOURCE locally
h3nnn4n Mar 23, 2021
a1dfb10
Print formated sudoku solution
h3nnn4n Mar 23, 2021
3cd6911
Use external strtok_r implementation
h3nnn4n Mar 23, 2021
67f1293
Update license header
h3nnn4n Mar 23, 2021
5c3ec21
Add some basic sudoku validation
h3nnn4n Mar 23, 2021
68367da
Ensure that all columns have at least one possible cover
h3nnn4n Mar 24, 2021
f008f84
Dont you love when things break just by looking at it?
h3nnn4n Mar 24, 2021
082979d
Fix normal sized sudoku not being properly generated
h3nnn4n Mar 24, 2021
c1b198a
Add sudoku solve and parse to CI
h3nnn4n Mar 24, 2021
01d0ef7
Rebuild
h3nnn4n Mar 24, 2021
1e40687
Fix memory not being properly initialized
h3nnn4n Mar 24, 2021
83a9704
Fix memory not being initialized
h3nnn4n Mar 24, 2021
d4130cf
Add valgrind to CI
h3nnn4n Mar 24, 2021
6de7fd7
Make sudoku gen pipeable
h3nnn4n Mar 24, 2021
5ffc439
Remove hardcoded value + fix CI
h3nnn4n Mar 24, 2021
12813d3
Take file output file descriptor from outside (main, in this case)
h3nnn4n Mar 24, 2021
b195e76
Fix unintialized memory on unit tests
h3nnn4n Mar 24, 2021
d439e4e
Add unit test for sudoku gen
h3nnn4n Mar 24, 2021
e87ef84
Getting started on a better archtecture for sudoku gen
h3nnn4n Mar 24, 2021
21a0a88
Add missing copyright headers
h3nnn4n Mar 24, 2021
8de1677
Make clang-tify happy
h3nnn4n Mar 24, 2021
df3b75e
Dont generate covers for clues
h3nnn4n Mar 24, 2021
09d7584
Add a 5 minute timeout
h3nnn4n Mar 24, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
---
Checks: 'clang-diagnostic-*,clang-analyzer-*'
WarningsAsErrors: '--checks=bugprone-*,performance-*,readability-*,portability-*,modernize-*,clang-analyzer-cplusplus-*,clang-analyzer-*,cppcoreguidelines-*'
HeaderFilterRegex: ''
AnalyzeTemporaryDtors: false
FormatStyle: none
User: h3nnn4n
CheckOptions:
- key: cert-dcl16-c.NewSuffixes
value: 'L;LL;LU;LLU'
- key: cert-oop54-cpp.WarnOnlyIfThisHasSuspiciousField
value: '0'
- key: cert-str34-c.DiagnoseSignedUnsignedCharComparisons
value: '0'
- key: cppcoreguidelines-explicit-virtual-functions.IgnoreDestructors
value: '1'
- key: cppcoreguidelines-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic
value: '1'
- key: google-readability-braces-around-statements.ShortStatementLines
value: '1'
- key: google-readability-function-size.StatementThreshold
value: '800'
- key: google-readability-namespace-comments.ShortNamespaceLines
value: '10'
- key: google-readability-namespace-comments.SpacesBeforeComments
value: '2'
- key: llvm-else-after-return.WarnOnConditionVariables
value: '0'
- key: llvm-else-after-return.WarnOnUnfixable
value: '0'
- key: llvm-qualified-auto.AddConstToQualified
value: '0'
- key: modernize-loop-convert.MaxCopySize
value: '16'
- key: modernize-loop-convert.MinConfidence
value: reasonable
- key: modernize-loop-convert.NamingStyle
value: CamelCase
- key: modernize-pass-by-value.IncludeStyle
value: llvm
- key: modernize-replace-auto-ptr.IncludeStyle
value: llvm
- key: modernize-use-nullptr.NullMacros
value: 'NULL'
...
3 changes: 3 additions & 0 deletions .github/workflows/clang-tidy-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ jobs:
sudo apt-get -y -qq install clang-tidy cmake jq clang cppcheck
python -m pip install scan-build

- name: Update Path
run: echo "$HOME/.local/bin" >> $GITHUB_PATH

- name: Update compile database
run: |
make clean
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/cppcheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,13 @@ jobs:
sudo apt-get -y -qq install clang-tidy cmake jq clang cppcheck
python -m pip install scan-build

- name: Update Path
run: echo "$HOME/.local/bin" >> $GITHUB_PATH

- name: Update compile database
run: |
make clean
intercept-build make

- name: run cppcheck
run: cppcheck --enable=all --std=c11 --language=c --error-exitcode=1 src/*.c
run: cppcheck --enable=all --std=c11 --language=c --error-exitcode=1 src/*.c src/**/*.c
3 changes: 3 additions & 0 deletions .github/workflows/cpplint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ jobs:
python3 -m pip install cpplint
python3 -m pip install scan-build

- name: Update Path
run: echo "$HOME/.local/bin" >> $GITHUB_PATH

- name: Update compile database
run: |
make clean
Expand Down
16 changes: 14 additions & 2 deletions .github/workflows/heap-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,25 @@ jobs:

- name: Build
run: make gperftools
env:
CFLAGS: -DGRID_SIZE=2 -DN_GRIDS=2

- name: Detect Leaks on single solution
run: ./dancing-links --single-solution --quited < samples/5x8_2xAll_freePieces.dat
run: ./dancing-links --single-solution --quiet < samples/5x8_2xAll_freePieces.dat
env:
HEAPCHECK: normal

- name: Detect Leaks on multiple solutions
run: ./dancing-links --multiple-solutions --quited < samples/5x5_5_pentoI.dat
run: ./dancing-links --multiple-solutions --quiet < samples/5x5_5_pentoI.dat
env:
HEAPCHECK: normal

- name: Detect Leaks on generate coverset from file
run: ./dancing-links --sudoku-gen samples/sudoku/sudoku_2.in
env:
HEAPCHECK: normal

- name: Detect Leaks on generate coverset from str
run: ./dancing-links --sudoku-gen 0100002030000004
env:
HEAPCHECK: normal
24 changes: 22 additions & 2 deletions .github/workflows/run.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on: push
jobs:
run-benchmarks:
runs-on: ${{ matrix.os }}
timeout-minutes: 5

strategy:
matrix:
Expand All @@ -16,8 +17,10 @@ jobs:
fetch-depth: 1
submodules: true

- name: Build
run: make
- name: Build (2x2)
run: make rebuild
env:
CFLAGS: -DGRID_SIZE=2 -DN_GRIDS=2

- name: Run simple problem, default args
run: ./dancing-links --multiple-solutions < samples/5x5_5_pentoI.dat
Expand All @@ -27,3 +30,20 @@ jobs:

- name: Run complex problem, single solution
run: ./dancing-links --single-solution < samples/5x8_2xAll_freePieces.dat

- name: Run sudoku gen and solve
run: |
./dancing-links --sudoku-gen samples/sudoku/sudoku_2.in > sudoku_test.dat
./dancing-links --single-solution < sudoku_test.dat
./dancing-links --sudoku-parse output.dat

- name: Build (3x3)
run: make rebuild
env:
CFLAGS: -DGRID_SIZE=3 -DN_GRIDS=3

- name: Run sudoku gen and solve
run: |
./dancing-links --sudoku-gen samples/sudoku/sudoku.in > sudoku_test.dat
./dancing-links --single-solution < sudoku_test.dat
./dancing-links --sudoku-parse output.dat
30 changes: 30 additions & 0 deletions .github/workflows/valgrind.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: valgrind

on: push

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@master
with:
fetch-depth: 1
submodules: true

- name: Install deps
run: |
sudo apt-get update
sudo apt-get -y -qq install valgrind

- name: Build
run: make callgrind

- name: Run valgrind on sudoku gen
run: ./dancing-links --sudoku-gen samples/sudoku/sudoku_2.in > sudoku_test.dat

- name: Run valgrind on sudoku solve
run: ./dancing-links --single-solution < sudoku_test.dat

- name: Run valgrind on sudoku parse
run: ./dancing-links --sudoku-parse output.dat
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,7 @@ build

# Cache files
.cache # used by clang
*.idx # used by clang

# perf files
gmon.out
10 changes: 3 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,15 @@ repos:
hooks:
- id: clang-format

repos:
- repo: https://github.com/pocc/pre-commit-hooks
rev: v1.1.1
hooks:
- id: clang-tidy
args:
- -checks=clang-diagnostic-return-type
args: ['--warnings-as-errors', '--checks=bugprone-*,performance-*,readability-*,portability-*,modernize-*,clang-analyzer-cplusplus-*,clang-analyzer-*,cppcoreguidelines-*']

repos:
- repo: https://github.com/bmorcos/pre-commit-hooks-cpp
rev: 9a5aa38207bf557961110d6a4f7e3a9d352911f9
hooks:
- id: cpplint
args:
- --filter=-build/include_subdir,-readability/nolint,-whitespace/line_length,-readability/casting,-build/header_guard
- id: cppcheck
- id: cpplint
args: ['--filter=-build/include_subdir,-readability/nolint,-whitespace/line_length,-readability/casting,-build/header_guard']
5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ override CFLAGS += -Wall -Wextra -pedantic -std=c11 $(OPTIMIZATION) $(OPTIONS) $
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Linux)
ECHOFLAGS = -e
LDFLAGS = -Wl,-Ldeps/Unity/build/
UNAME_S = -Wl,-Ldeps/Unity/build/
endif
ifeq ($(UNAME_S),Darwin)
CFLAGS += -Wno-unused-command-line-argument
Expand All @@ -27,7 +27,8 @@ endif

CC = gcc

C_FILES := $(wildcard src/*.c)
C_FILES := $(wildcard src/*.c) \
$(wildcard src/**/*.c)
C_FILES_TEST := $(wildcard test/*.c)
C_FILES_TEST_DEPS := $(wildcard deps/Unity/src/*.c)

Expand Down
Loading