You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
1.1 KiB

7 months ago
  1. \item \lect Complete the following snippet of the python script with the necessary constraint statements.
  2. The script reads a file that represents a \texttt{size\_x} $\times$ \texttt{size\_y} grid, which includes walkable cells denoted by '$\_$'.
  3. Write constraints for the variables \texttt{coords\_x} and \texttt{coords\_y} such that the variables can only take values that are within the boundaries of the grid and can only represent walkable cells.
  4. \begin{pythonSourceCode}
  5. from z3 import *
  6. ...
  7. # size_x and size_y denote the size of the grid
  8. size_y = len(grid)
  9. size_x = len(grid[0])
  10. coords_x = Int("coords_x")
  11. coords_y = Int("coords_y")
  12. # Enforce that the position is in the grid, use size_x and size_y
  13. # Enforce that the coordinates can only be a valid cell
  14. for i in range(size_y):
  15. for j in range(size_x):
  16. if grid[i][j] != "_":
  17. #
  18. #
  19. #
  20. \end{pythonSourceCode}