Guest User

Untitled

a guest
Dec 5th, 2019
70
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def attempt_to_plot_value(board_, i, j):
  2.     cell_values = get_cell_values(board_, get_cell_row(i), get_cell_column(j))
  3.     seen_numbers = []
  4.     possible_numbers = []
  5.  
  6. # Looks for numbers that are set horizontally
  7.  
  8.     for x in range(0, 6):
  9.         current_cell = board_[i][x]
  10.         if current_cell != 0:
  11.             seen_numbers.append(current_cell)
  12.  
  13. # Looks for numbers that are set vertical
  14.  
  15.     for y in range(0, 6):
  16.         current_cell = board_[y][j]
  17.         if current_cell != 0:
  18.             seen_numbers.append(current_cell)
  19.  
  20. # For all numbers 1-6, if the number does not exist horizontally or vertically,
  21. # and the current grid does not contain the value, add the number as a possible candidate
  22.  
  23.     for z in range(1, 7):
  24.         if z not in seen_numbers and z not in cell_values:
  25.             possible_numbers.append(z)
  26.  
  27. # if it's just a candidate, "assign" the number to the cell
  28.  
  29.     if len(possible_numbers) == 1:
  30.         board_[i][j] = possible_numbers[0]
  31.     return
RAW Paste Data