# SAI Season7 S+ Team6 "SUPLeme" 
# 2nd week
# 23011832 Seunghwan Jo

# ====================================================================================== #
# Practical Problem

import numpy as np

# Q1-1)

a = np.random.randint(-100, 101, size = 3)
b = np.random.randint(-100, 101, size = 3)
c = np.random.randint(-100, 101, size = 3)

# Q1-2)

def l2_norm(v):
    return np.sqrt(np.sum(v * v))

def is_triangle(p0, p1, p2):
    v01 = np.subtract(p1, p0) # Create a vector from p0 to p1
    v02 = np.subtract(p2, p0) # Create a vector from p0 to p2
    # The two vectors in R^3 are parallel if and only if the one is the other's scalar multiple.(u = kv)
    # It also means that the dot product of the vectors is equal to the product of their l2 norms.(u dot v = ||u|| * ||v||)
    if np.dot(v01, v02) != l2_norm(v01) * l2_norm(v02):
        return True
    else:
        return False

while is_triangle(a, b, c) == False:
    a = np.random.randint(-100, 101, size = 3)
    b = np.random.randint(-100, 101, size = 3)
    c = np.random.randint(-100, 101, size = 3)

print(np.array([a,b,c]))

# Q2-1)

nrow = np.random.randint(1, 11)
ncol = np.random.randint(1, 11)

matA = np.random.randint(-100, 101, size = (nrow, ncol))
matB = np.random.randint(-100, 101, size = (nrow, ncol))

print(matA)
print(matB)

# Q2-2)

def solution(mat0, mat1):
    return np.array([np.add(mat0[i], mat1[i]) for i in range(mat0.shape[0])])

mat_result = solution(matA, matB)

# Q2-3)

print(mat_result)

# Q2_4)

print("{}X{}".format(mat_result.shape[0], mat_result.shape[1]))

# ====================================================================================== #
# Theoretical Problem

# Q1) X(Not 1-dimensional array but correct array)
# Q2) O
# Q3) O
# Q4) O
# Q5) X(The function is available)