Little update.
This commit is contained in:
		
							
								
								
									
										10
									
								
								.pre-commit-config.yaml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								.pre-commit-config.yaml
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,10 @@ | |||||||
|  | # See https://pre-commit.com for more information | ||||||
|  | # See https://pre-commit.com/hooks.html for more hooks | ||||||
|  | repos: | ||||||
|  | -   repo: https://github.com/pre-commit/pre-commit-hooks | ||||||
|  |     rev: v3.2.0 | ||||||
|  |     hooks: | ||||||
|  |     -   id: trailing-whitespace | ||||||
|  |     -   id: end-of-file-fixer | ||||||
|  |     -   id: check-yaml | ||||||
|  |     -   id: check-added-large-files | ||||||
							
								
								
									
										13
									
								
								Taskfile.yml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								Taskfile.yml
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,13 @@ | |||||||
|  | # https://taskfile.dev | ||||||
|  |  | ||||||
|  | version: '3' | ||||||
|  |  | ||||||
|  | tasks: | ||||||
|  |   default: | ||||||
|  |     cmds: | ||||||
|  |       - go run . | ||||||
|  |     silent: true | ||||||
|  |   precommit: | ||||||
|  |     cmds: | ||||||
|  |       - pre-commit run --all | ||||||
|  |     silent: true | ||||||
							
								
								
									
										362880
									
								
								blocks.csv
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										362880
									
								
								blocks.csv
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										2
									
								
								go.mod
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								go.mod
									
									
									
									
									
								
							| @@ -1,3 +1,5 @@ | |||||||
| module gitea.ligthert.net/golang/sudoku-funpark | module gitea.ligthert.net/golang/sudoku-funpark | ||||||
|  |  | ||||||
| go 1.23.3 | go 1.23.3 | ||||||
|  |  | ||||||
|  | require github.com/gocarina/gocsv v0.0.0-20240520201108-78e41c74b4b1 // indirect | ||||||
|   | |||||||
							
								
								
									
										2
									
								
								go.sum
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								go.sum
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,2 @@ | |||||||
|  | github.com/gocarina/gocsv v0.0.0-20240520201108-78e41c74b4b1 h1:FWNFq4fM1wPfcK40yHE5UO3RUdSNPaBC+j3PokzA6OQ= | ||||||
|  | github.com/gocarina/gocsv v0.0.0-20240520201108-78e41c74b4b1/go.mod h1:5YoVOkjYAQumqlV356Hj3xeYh4BdZuLE0/nRkf2NKkI= | ||||||
							
								
								
									
										113
									
								
								main.go
									
									
									
									
									
								
							
							
						
						
									
										113
									
								
								main.go
									
									
									
									
									
								
							| @@ -1,14 +1,91 @@ | |||||||
| package main | package main | ||||||
|  |  | ||||||
| import ( | import ( | ||||||
|  | 	"encoding/csv" | ||||||
| 	"fmt" | 	"fmt" | ||||||
|  | 	"io" | ||||||
|  | 	"log" | ||||||
|  | 	"os" | ||||||
| 	"strconv" | 	"strconv" | ||||||
| ) | ) | ||||||
|  |  | ||||||
| func main() { | func main() { | ||||||
| 	blocks := generate_blocks() |  | ||||||
| 	fmt.Println(len(blocks)) | 	blocks := load_blocks() | ||||||
| 	fmt.Println(blocks[0]) | 	fmt.Println("Total blocks:", len(blocks)) | ||||||
|  |  | ||||||
|  | 	// Parse parameters | ||||||
|  | 	// Turn parameters into rows | ||||||
|  | 	row1 := "769104803" | ||||||
|  | 	// row2 := "154800060" | ||||||
|  | 	// row3 := "002700150" | ||||||
|  | 	// row4 := "600900308" | ||||||
|  | 	// row5 := "045328670" | ||||||
|  | 	// row6 := "328670945" | ||||||
|  | 	// row7 := "597410280" | ||||||
|  | 	// row8 := "006284090" | ||||||
|  | 	// row9 := "200590006" | ||||||
|  |  | ||||||
|  | 	// Find rows that fit with the entered rows | ||||||
|  | 	rows1 := find_blocks(blocks, row1) | ||||||
|  | 	// rows2 := find_blocks(blocks, row2) | ||||||
|  | 	// rows3 := find_blocks(blocks, row3) | ||||||
|  | 	// rows4 := find_blocks(blocks, row4) | ||||||
|  | 	// rows5 := find_blocks(blocks, row5) | ||||||
|  | 	// rows6 := find_blocks(blocks, row6) | ||||||
|  | 	// rows7 := find_blocks(blocks, row7) | ||||||
|  | 	// rows8 := find_blocks(blocks, row8) | ||||||
|  | 	// rows9 := find_blocks(blocks, row9) | ||||||
|  |  | ||||||
|  | 	fmt.Println("len(rows1):", len(rows1)) | ||||||
|  | 	// fmt.Println(rows1) | ||||||
|  |  | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func find_blocks(blocks []int, row string) []int { | ||||||
|  | 	// Declare selection | ||||||
|  | 	var selection []int | ||||||
|  |  | ||||||
|  | 	fmt.Println(row) | ||||||
|  | 	for letter := range row { | ||||||
|  | 		fmt.Println("Letter", row[letter]) | ||||||
|  | 		//curr_number := row[letter] | ||||||
|  | 		for block := range blocks { | ||||||
|  | 			// fmt.Println(blocks[block]) | ||||||
|  | 			curr_row := strconv.Itoa(blocks[block]) | ||||||
|  | 			fmt.Println(curr_row[0]) | ||||||
|  | 			//if curr_number == | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	// Return selection | ||||||
|  | 	return selection | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func load_blocks() []int { | ||||||
|  | 	var blocks []int | ||||||
|  |  | ||||||
|  | 	file, err := os.Open("blocks.csv") | ||||||
|  | 	if err != nil { | ||||||
|  | 		panic(err) | ||||||
|  | 	} | ||||||
|  | 	defer file.Close() | ||||||
|  |  | ||||||
|  | 	r := csv.NewReader(file) | ||||||
|  | 	for { | ||||||
|  | 		record, err := r.Read() | ||||||
|  | 		if err == io.EOF { | ||||||
|  | 			break | ||||||
|  | 		} | ||||||
|  | 		if err != nil { | ||||||
|  | 			log.Fatal(err) | ||||||
|  | 		} | ||||||
|  |  | ||||||
|  | 		block, _ := strconv.Atoi(record[0]) | ||||||
|  | 		blocks = append(blocks, block) | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	return blocks | ||||||
| } | } | ||||||
|  |  | ||||||
| func generate_blocks() []int { | func generate_blocks() []int { | ||||||
| @@ -46,29 +123,7 @@ func generate_blocks() []int { | |||||||
|  |  | ||||||
| } | } | ||||||
|  |  | ||||||
| // counter: 123456789 | func print_block(block int) { | ||||||
| // 1st Digit: 1 (49) | 	digits := strconv.Itoa(block) | ||||||
| // 2nd Digit: 2 (50) | 	fmt.Printf("%c %c %c\n%c %c %c\n%c %c %c\n\n", digits[0], digits[1], digits[2], digits[3], digits[4], digits[5], digits[6], digits[7], digits[8]) | ||||||
| // 3rd Digit: 3 (51) | } | ||||||
| // 4th Digit: 4 (52) |  | ||||||
| // 5th Digit: 5 (53) |  | ||||||
| // 6th Digit: 6 (54) |  | ||||||
| // 7th Digit: 7 (55) |  | ||||||
| // 8th Digit: 8 (56) |  | ||||||
| // 9th Digit: 9 (57) |  | ||||||
|  |  | ||||||
| // 362880 |  | ||||||
|  |  | ||||||
| // 1 2 3 |  | ||||||
| // 4 5 6 |  | ||||||
| // 7 8 9 |  | ||||||
|  |  | ||||||
| // 1: 1 2 3 4 7 |  | ||||||
| // 2: 1 2 3 5 8 |  | ||||||
| // 3: 1 2 3 6 9 |  | ||||||
| // 4: 1 4 5 6 7 |  | ||||||
| // 5: 2 4 5 6 8 |  | ||||||
| // 6: 3 4 5 6 9 |  | ||||||
| // 7: 1 4 7 8 9 |  | ||||||
| // 8: 2 5 7 8 9 |  | ||||||
| // 9: 3 6 7 8 9 |  | ||||||
|   | |||||||
							
								
								
									
										42
									
								
								notes.txt
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										42
									
								
								notes.txt
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,42 @@ | |||||||
|  | Compat Matrix | ||||||
|  |  | ||||||
|  | 1: 1 2 3 4 7 | ||||||
|  | 2: 1 2 3 5 8 | ||||||
|  | 3: 1 2 3 6 9 | ||||||
|  | 4: 1 4 5 6 7 | ||||||
|  | 5: 2 4 5 6 8 | ||||||
|  | 6: 3 4 5 6 9 | ||||||
|  | 7: 1 4 7 8 9 | ||||||
|  | 8: 2 5 7 8 9 | ||||||
|  | 9: 3 6 7 8 9 | ||||||
|  |  | ||||||
|  | // counter: 123456789 | ||||||
|  | // 1st Digit: 1 (49) | ||||||
|  | // 2nd Digit: 2 (50) | ||||||
|  | // 3rd Digit: 3 (51) | ||||||
|  | // 4th Digit: 4 (52) | ||||||
|  | // 5th Digit: 5 (53) | ||||||
|  | // 6th Digit: 6 (54) | ||||||
|  | // 7th Digit: 7 (55) | ||||||
|  | // 8th Digit: 8 (56) | ||||||
|  | // 9th Digit: 9 (57) | ||||||
|  |  | ||||||
|  | // 362880 | ||||||
|  |  | ||||||
|  | // blocks := generate_blocks() | ||||||
|  | // fmt.Println(len(blocks)) | ||||||
|  | // print_block(blocks[0]) | ||||||
|  | // print_block(blocks[1]) | ||||||
|  | // for i := range blocks { | ||||||
|  | // 	fmt.Println(blocks[i]) | ||||||
|  | // } | ||||||
|  |  | ||||||
|  | // block1 := 714365289 | ||||||
|  | // block2 := 365289714 | ||||||
|  | // block3 := 289714365 | ||||||
|  | // block4 := 173456892 | ||||||
|  | // block5 := 456893173 | ||||||
|  | // block6 := 892173546 | ||||||
|  | // block7 := 647531928 | ||||||
|  | // block8 := 531928647 | ||||||
|  | // block9 := 928647531 | ||||||
		Reference in New Issue
	
	Block a user