findBlocks.go 746 B

12345678910111213141516171819202122232425262728293031323334353637
  1. package solver
  2. // The actual function that finds the blocks matching the partial blocks.
  3. func (solver *Solver) findBlocks(row *string, rows *[]string) {
  4. // Declare selection
  5. var selection []string
  6. var currBlocks []string
  7. funcRow := *row
  8. for letter := range funcRow {
  9. if len(selection) == 0 {
  10. currBlocks = solver.Controller.Blocks
  11. } else {
  12. currBlocks = selection
  13. selection = nil
  14. }
  15. for _, block := range currBlocks {
  16. currRow := block
  17. if funcRow[letter] == currRow[letter] {
  18. foundRow := currRow
  19. selection = append(selection, foundRow)
  20. }
  21. if funcRow[letter] == '0' {
  22. foundRow := currRow
  23. selection = append(selection, foundRow)
  24. }
  25. } // End for-loop
  26. } // End for-loop
  27. *rows = selection
  28. }