All the code for the Medium Post
Code for the medium post
numpy==1.19.5
tensorflow==2.4.1
scikit-learn==0.24.2
Code for the Medium post Link
Code for the Medium post Link
Code for the Medium post Link
- Python puzzle
- Given a
$2 \times 1$ non-negative integer array$\vec{a}$ and a$1 \times n$ integer array$\vec{b}$ , write a function to return a$2 \times n$ logical matrix$x_{ij}$ such that$\sum_{j=1}^{n}x_{ij} = a_i$ and$\sum_{i=1}^{2}x_{ij} = b_j$ . If there is no working matrix, please return string "impossible" (15 mins). - What is logical matrix? This is a matrix that
$x_{ij} \in {0,1}$ - Example: $\vec{a} = \begin{bmatrix} 3 \ 2\end{bmatrix}$, $\vec{b} = \begin{bmatrix} 2 & 1 & 1 & 0 & 1\end{bmatrix}$, one possible matrix is $\begin{bmatrix} 1 & 1 & 1 & 0 & 0 \ 1 & 0 & 0 & 0 & 1\end{bmatrix}$
- Solution:
import numpy as np
- Given a
Code for the Medium post Link
- Code from the Medium post Link