#
# your solution is here
#
import numpy as np

random_arr = np.random.randn(3,3)
random_arr = np.abs(random_arr)
sum_elements = np.sum(random_arr)
random_arr  = random_arr / sum_elements
print(random_arr)
print("verify the probabilistic state from sum of elements: " + str(np.sum(random_arr)))

#
# your solution is here
#
prob_operator = np.array([[0.6, 0.3], [0.4, 0.7]])    
prob_state = np.array([1, 0])
new_prob_state = np.matmul(prob_operator, prob_state) 
print("1st state transition: " + str(new_prob_state))
new_prob_state = np.matmul(prob_operator, new_prob_state) 
print("2nd state transition: " + str(new_prob_state))

# operator for the test
A = [
    [0.4,0.6,0],
    [0.2,0.1,0.7],
    [0.4,0.3,0.3]
]

# state for test
v = [0.1,0.3,0.6]

#
# your solution is here
#

# v = [1,0,0]

def find_new_state(A, v):
    return np.matmul(A, v)

new_state = find_new_state(A, v)
print(new_state)

# the initial state
initial = [0.5, 0, 0.5, 0]

# probabilistic operator for symbol a
A = [
    [0.5,  0, 0, 0],
    [0.25, 1, 0, 0],
    [0,    0, 1, 0],
    [0.25, 0, 0, 1]
]

# probabilistic operator for symbol b
B = [
    [1, 0, 0,    0],
    [0, 1, 0.25, 0],
    [0, 0, 0.5,  0],
    [0, 0, 0.25, 1]
]

#
# your solution is here
#
def find_new_state(operator, initial):
    return np.matmul(operator, initial)

def read_string(string_to_read):
    for c in string_to_read:

