Compare commits

...

7 Commits

Author SHA1 Message Date
0e3aa42b78 #11 It works. 2025-01-27 18:41:33 +01:00
c72bc6b0e5 Start of godoc comments. Closes #5 2025-01-27 18:41:15 +01:00
c73c88679a #13 Clean functions 2025-01-27 18:37:41 +01:00
81b44e1702 Experimenting with Gitea Actions
All checks were successful
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 5s
2025-01-27 13:58:13 +01:00
c8f897cf8d Add Gource 2025-01-27 11:28:25 +01:00
c0525c2bc8 Add autoupdate and extra go checking to pre-commit steps. 2025-01-27 11:19:57 +01:00
3f6ba6e9dc #12 Update README.md 2025-01-27 00:59:29 +01:00
8 changed files with 49 additions and 5 deletions

20
.gitea/workflows/demo.txt Normal file
View File

@ -0,0 +1,20 @@
name: Gitea Actions Demo
run-name: ${{ gitea.actor }} is testing out Gitea Actions 🚀
on: [push]
jobs:
Explore-Gitea-Actions:
runs-on: ubuntu-latest
steps:
- run: echo "🎉 The job was automatically triggered by a ${{ gitea.event_name }} event."
- run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by Gitea!"
- run: echo "🔎 The name of your branch is ${{ gitea.ref }} and your repository is ${{ gitea.repository }}."
- name: Check out repository code
uses: actions/checkout@v4
- run: echo "💡 The ${{ gitea.repository }} repository has been cloned to the runner."
- run: echo "🖥️ The workflow is now ready to test your code on the runner."
- name: List files in the repository
run: |
ls ${{ gitea.workspace }}
- run: echo "🍏 This job's status is ${{ job.status }}."

View File

@ -2,9 +2,17 @@
# See https://pre-commit.com/hooks.html for more hooks # See https://pre-commit.com/hooks.html for more hooks
repos: repos:
- repo: https://github.com/pre-commit/pre-commit-hooks - repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.2.0 rev: v5.0.0
hooks: hooks:
- id: trailing-whitespace - id: trailing-whitespace
- id: end-of-file-fixer - id: end-of-file-fixer
- id: check-yaml - id: check-yaml
- id: check-added-large-files - id: check-added-large-files
- repo: https://github.com/dnephin/pre-commit-golang
rev: v0.5.1
hooks:
- id: go-fmt
- id: go-imports
- id: no-go-testing
- id: golangci-lint
- id: go-unit-tests

View File

@ -9,10 +9,19 @@ _(This was a learning project to get a better grasp of Golang. But more importan
I wrote [a blog post](https://blog.ligthert.net/posts/exploration-fun-and-process-cycles-of-sudoku/) about this. I wrote [a blog post](https://blog.ligthert.net/posts/exploration-fun-and-process-cycles-of-sudoku/) about this.
## Features
* Worlds least efficient Sudoku solver
* Ability to assign a number of CPU cores to this task
* Split workloads among several computers
## Usage ## Usage
To use the sudoku solver, run the binary with all the parameters available: To use the sudoku solver, run the binary with all the parameters available:
``` ```
Usage of ./sudoku-funpark: Usage of ./sudoku-funpark:
-numcpu int
Number of CPU cores to assign to this task. (default 12)
-part int
Process part x in n parts. Cannot be lower than 1, or higher than specified in split. (default 1)
-row1 string -row1 string
1st row of the sudoku puzzle. (default "000000000") 1st row of the sudoku puzzle. (default "000000000")
-row2 string -row2 string
@ -31,6 +40,8 @@ Usage of ./sudoku-funpark:
8th row of the sudoku puzzle. (default "000000000") 8th row of the sudoku puzzle. (default "000000000")
-row9 string -row9 string
9th row of the sudoku puzzle. (default "000000000") 9th row of the sudoku puzzle. (default "000000000")
-split int
Split the tasks in n parts. This depends on the availability of the first row. (default 1)
``` ```
Instead of using the 3x3 blocks with 3x3 digits, it uses horizontal rows from top to bottom. Instead of using the 3x3 blocks with 3x3 digits, it uses horizontal rows from top to bottom.

View File

@ -21,6 +21,7 @@ tasks:
silent: true silent: true
precommit: precommit:
cmds: cmds:
- pre-commit autoupdate
- pre-commit run --all - pre-commit run --all
silent: true silent: true
lint: lint:
@ -33,3 +34,7 @@ tasks:
- rm {{.BUILD_DIR}}/* || true - rm {{.BUILD_DIR}}/* || true
- go tool dist list | grep -v android | grep -v ios | grep -v wasip1 | awk -F '/' '{printf "echo Compiling %s/%s; env CGO_ENABLED=1 GOOS=%s GOARCH=%s go build -o {{.BUILD_DIR}}/{{.APP}}.%s-%s\n",$1,$2,$1,$2,$1,$2 }' | sh - go tool dist list | grep -v android | grep -v ios | grep -v wasip1 | awk -F '/' '{printf "echo Compiling %s/%s; env CGO_ENABLED=1 GOOS=%s GOARCH=%s go build -o {{.BUILD_DIR}}/{{.APP}}.%s-%s\n",$1,$2,$1,$2,$1,$2 }' | sh
- for i in `ls {{.BUILD_DIR}}/*windows*`; do mv -v $i $i.exe; done - for i in `ls {{.BUILD_DIR}}/*windows*`; do mv -v $i $i.exe; done
gource:
cmds:
- gource --auto-skip-seconds 1 --key -r 60
silent: true

View File

@ -143,8 +143,7 @@ func (solver *Solver) validate_row(name string, row string) {
} }
func (solver *Solver) valid_char(char rune) bool { func (solver *Solver) valid_char(char rune) (valid bool) {
var valid bool
decvals := [10]int{48, 49, 50, 51, 52, 53, 54, 55, 56, 57} decvals := [10]int{48, 49, 50, 51, 52, 53, 54, 55, 56, 57}
for _, value := range decvals { for _, value := range decvals {

View File

@ -178,8 +178,7 @@ func (solver *Solver) tracker() {
} }
func (solver *Solver) validate_combination(row1 int, row2 int, row3 int, row4 int, row5 int, row6 int, row7 int, row8 int, row9 int) bool { func (solver *Solver) validate_combination(row1 int, row2 int, row3 int, row4 int, row5 int, row6 int, row7 int, row8 int, row9 int) (retval bool) {
var retval bool
retval = true retval = true
row1s := strconv.Itoa(row1) row1s := strconv.Itoa(row1)

View File

@ -6,6 +6,7 @@ import (
"strconv" "strconv"
) )
// The main loop that orchastrates all the logic.
func Run() { func Run() {
// Instantiate the Solver interface // Instantiate the Solver interface
solver := Solver{} solver := Solver{}

View File

@ -4,6 +4,7 @@ import (
"sync/atomic" "sync/atomic"
) )
// Struct/Interface containing all the important variabes it functions need access to.
type Solver struct { type Solver struct {
blocks []int blocks []int
row1 string row1 string