Code for the Medium post
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# colors from https://www.color-hex.com/ | |
format = """ | |
[](#3d414a)\ | |
$os\ | |
$username\ | |
[](bg:#5f6366 fg:#3d414a)\ | |
$directory\ | |
[](fg:#5f6366 bg:#4e6e97)\ | |
$git_branch\ | |
$git_status\ |
- Code from 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 for the Medium post Link
NewerOlder