import numpy as np

def normalize_data(n_covid, n_people, scale):
    # TODO: Calculate the number of cases per its population

    norm_cases = [i/j*1000000 for i,j in zip(n_covid,n_people)]
    for idx, n in enumerate(n_covid):
        norm_cases.append(idx)
    return norm_cases

  
regions  = ['Seoul', 'Gyeongi', 'Busan', 'Gyeongnam', 'Incheon', 'Gyeongbuk', 'Daegu', 'Chungnam', 'Jeonnam', 'Jeonbuk', 'Chungbuk', 'Gangwon', 'Daejeon', 'Gwangju', 'Ulsan', 'Jeju', 'Sejong']
n_people = [9550227.,  13530519., 3359527.,     3322373.,   2938429.,     2630254., 2393626.,    2118183.,   1838353.,   1792476.,    1597179.,   1536270.,   1454679.,   1441970., 1124459., 675883.,   365309.] # 2021-08
n_covid  = [    644,       529,      38,          29,       148,          28,      41,         62,        23,        27,         27,        33,        16,        40,      20,      5,        4] # 2021-09-21

sum_people = sum(n_people) # TODO: The total number of people
sum_covid  = sum(n_covid) # TODO: The total number of new cases
norm_covid = normalize_data(n_covid, n_people, 1000000) # The new cases per 1 million people

# Print population by region
print('### Korean Population by Region')
print('* Total population:', sum_people)
print("---------------------------------")
print('| Region | Population | Ratio (%) |')
print('| ------ | ---------- | --------- |')
ratio = [x/sum_people*100. for x in n_people]
for idx, pop in enumerate(n_people):
    print('| %s | %d | %.1f |' % (regions[idx], pop, ratio[idx]))
print('')


# TODO: Print COVID-19 new cases by region
print("### Korean COVID-19 New Cases by Region")
print("* Total sum:", sum_covid)
print('| Region | New Cases | Ratio (%) | New Cases/1m |')
print('| ------ | ---------- | --------- | --------- |')
ratio = [i/100 for i in n_covid]
for idx, covid in enumerate(n_covid):
    # TODO: The ratio of new cases to the total
    print('| %s | %d | %.1f | %.1f |' % (regions[idx], covid, ratio[idx], norm_covid[idx]))
print('')
