Last active
October 25, 2021 12:49
-
-
Save Colk-tech/bd527512b4d93a0633b588632d4ce744 to your computer and use it in GitHub Desktop.
茨城高専 3年情報系 離散数学I の課題を numpy で解いたもの
This file contains hidden or 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
import numpy as np | |
A = ( | |
(0, 1, 1, 1), | |
(0, 1, 1, 0), | |
(1, 1, 0, 2), | |
(1, 0, 0, 0) | |
) | |
B = ( | |
(0, 1, 0), | |
(1, 0, 1), | |
(1, 1, 0) | |
) | |
C = ( | |
(0, 1, 0, 0, 0), | |
(1, 0, 1, 0, 0), | |
(0, 0, 1, 1, 0), | |
(0, 1, 0, 0, 1), | |
(0, 0, 0, 0, 2) | |
) | |
D = ( | |
(1, 0, 0, 0, 0), | |
(0, 1, 0, 0, 1), | |
(0, 0, 0, 1, 1), | |
(0, 0, 0, 0, 1), | |
(1, 0, 0, 0, 0) | |
) | |
A_MATRIX: np.matrix = np.matrix(A) | |
B_MATRIX: np.matrix = np.matrix(B) | |
C_MATRIX: np.matrix = np.matrix(C) | |
D_MATRIX: np.matrix = np.matrix(D) | |
def blank() -> None: | |
print() | |
if __name__ == "__main__": | |
print("Aの長さ3の各点からの歩道の数\n", A_MATRIX ** 3) | |
blank() | |
print("Bの長さ3の各点からの歩道の数\n", B_MATRIX ** 3) | |
blank() | |
print("Cの長さ3の各点からの歩道の数\n", C_MATRIX ** 3) | |
blank() | |
print("Cの長さ3の各点からの歩道の数\n", D_MATRIX ** 3) | |
blank() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment