Generation

generate functionSun, 05 Mar 2023

1. for a rectangle v(i) (i = 1, 2, 3, 4) of base area B × B and height D, an integer lattice binary space V of some horizontal number of elements W, vertical number of elements H and height D, such that A. it contains v(i) for any i, B. for any 1<=i, j<=4 v(i) and v(j) have no common part, C. Define a function that finds and outputs such that each of the four rectangles has one of its own vertices, and D. satisfies the four conditions that the common grid points of the rectangles and the binary space are all zero.

import numpy as np def v(i, B, D): # rectangle v(i) (i = 1, 2, 3, 4) of base area B × B and height D if i == 1: x = 0 y = 0 elif i == 2: x = B y = 0 elif i == 3: x = B y = B elif i == 4: x = 0 y = B return x, y, D def check(x, y, W, H, D): # check if it contains v(i) for any i if x > W or y > H: return False temp = np.zeros((H, W)) for i in range(H): temp[i, x] = 1 for j in range(W): temp[y, j] = 1 temp[y][x] = V(x, y, D, W, H) if V(x, y, D

Questions about programming?Chat with your personal AI assistant