
from itertools import zip_longest

def test_zip():
    a = [1, 4, 3, 5]
    b = [123, 323, 543, 234]
    c = 'asdf'

    # for i in range(4):
    #     print(a[i], b[i])

    res = zip(a, b, c)

    col1, col2, col3 = zip(*res)

    print(col1, col2, col3)

    for i in res:
        print(i)

def test_1():
    x = [1, 2, 3]
    y = [4, 5, 6]
    zipped = zip(x, y, strict=True)
    result = list(zipped)
    print(result)

# test_1()


def zip_longest_test():
    ids = [1, 2, 3, 4]
    leaders = ['Elon Mask', 'Tim Cook', 'Bill Gates', 'Yang Zhou']
    countries = ('Australia', 'USA')
    records = zip_longest(ids, leaders, countries)

    print(list(records))

    records_2 = zip_longest(ids, leaders, countries, fillvalue='Unknown')
    print(list(records_2))


def unzip_test():
    record = [(1, 'Elon Mask', 'Australia'),
          (2, 'Tim Cook', 'USA'),
          (3, 'Bill Gates', 'USA'),
          (4, 'Yang Zhou', 'China')]
    ids, leaders, countries = zip(*record)
    print(ids)
    print(leaders)
    print(countries)
    
# unzip_test()

def zip_iter_1():
    employee_numbers = [2, 9, 18, 28]
    employee_names = ["Valentin", "Leonti", "Andrew", "Sasha"]
    salaries = (100, 200, 3000, 450)

    for name, number, salary in zip(employee_names, employee_numbers, salaries):
        print(name, number, salary)

# zip_iter_1()

def zip_dict():
    dict_one = {'name': 'John', 'last_name': 'Doe', 'job': 'Python Consultant'}
    dict_two = {'name': 'Jane', 'last_name': 'Doe', 'job': 'Community Manager'}
    for (k1, v1), (k2, v2) in zip(dict_one.items(), dict_two.items()):
        print(k1, '->', v1)
        print(k2, '->', v2)

# zip_dict()

def creat_dict():
    employee_numbers = [2, 9, 18]
    employee_names = ["Valentin", "Leonti", "Andrew"]

    numbers = dict(zip(employee_numbers, employee_names))
    employees = dict(zip(employee_names, employee_numbers))

    print(numbers)
    print('------')
    print(employees)


    # обновляе словаря
    other_num = [50, 63]
    other_names = ['Misha', 'Sergey']
    numbers.update(zip(other_num, other_names))
    print('------')
    print(numbers)

# creat_dict()

def zip_comp():
    employee_numbers = [2, 9, 18]
    employee_names = ["Valentin", "Leonti", "Andrew"]

    numbers = {num: name for num, name in zip(employee_numbers, employee_names)}
    names = [name[0]*num for num, name in zip(employee_numbers, employee_names)]
    print(numbers)
    print(names)

# zip_comp()

def zip_matrix():
    matrix = [[1, 2, 3, 4], [5, 6, 7, 8]]
    matrix_trans = [list(i) for i in zip(*matrix)]
    print(matrix_trans)

# zip_matrix()

def task_1():
    keys = ['Ten', 'Twenty', 'Thirty', 'Forty', 'Fifty', 'Sixty', 'Seventy', 'Eighty', 'Ninety', 'One hundred']
    values = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]
    result = dict(zip(keys, values))
    print(result)

# task_1()

def task_2():
    employees = ['Pankratiy', 'Innokentiy', 'Anfisa', 'Yaroslava', 'Veniamin',
                'Leonti', 'Daniil', 'Mishka', 'Lidochka',
                'Terenti', 'Vladik', 'Svetka', 'Maks', 'Yura', 'Sergei']
    identifiers = [77, 48, 88, 85, 76, 81, 62, 43, 5, 56, 17, 20, 37, 32, 96]

    # employees_data = dict(zip(identifiers, employees))
    employees_data = dict(zip(sorted(identifiers), sorted(employees)))
    print(employees_data)

# task_2()


def combine_strings(a: str, b: str) -> str:
    return a + b

def get_sum_two_numbers(a: int, b: int) -> int:
    return a + b

def get_sum_three_numbers(a: int, b: int, c: int) -> int:
    return a + b + c

def zip_with_function(list_data, f):
    combined_list = list(zip(*list_data))
    combined_list = list(map(lambda args: f(*args), combined_list))
    return combined_list


# zip_with_function([[1, 2, 3], [4, 5, 6], [7, 8, 9]], get_sum_three_numbers)
# zip_with_function([[1, 2, 4], [3, 5, 8]], get_sum_two_numbers)

