# Functions that deal with subarray/subsequence properties
# -> There should be no print or input statements in this section 
# -> Each function should do one thing only
# -> Functions communicate using input parameters and their return values
#   Naive:1       Dynamic:13
import random
# from list_repr import get_modulus,create_number
from dict_repr import get_modulus,create_number

def generate_numbers(n:int)->list:
    list_of_numbers=[]
    while n:
        real_part=random.randint(-10,10)
        img_part=random.randint(-10,10)
        number=create_number(real_part,img_part)
        list_of_numbers.append(number)
        n-=1
    return list_of_numbers

def get_longest_subarray_of_distinct_numbers(numbers:list)->tuple[int,list]:
    """
    :params:
        numbers - list
    :return:
        tuple[int,list]
    
    The function takes in a list of complex numbers and returns the length of 
    a longest subarray of distinct numbers as well as the elements of such subarray 
    """
    max_lenght=0
    solution=[]
    length_of_list=len(numbers)
    for i in range(length_of_list-1):
        current_solution=[numbers[i]]
        for j in range(i+1,length_of_list):
            if numbers[j] not in current_solution:
                current_solution.append(numbers[j])
            else:
                break
        if max_lenght<len(current_solution):
            max_lenght=len(current_solution)
            solution=current_solution
    return max_lenght,solution
 
def get_lenght_of_longest_alternatig_subsequence(numbers:list)->int:
    """
    :params:
        numbers - list
    :return:
        int
    
    The function takes in a list of complex numbers and returns the length of 
    the longest alternating subsequence of numbers, when considering each number's modulus
    """
    lenght=len(numbers)
    inc=1
    dec=1
    for i in range(1,lenght):
        if get_modulus(numbers[i])>get_modulus(numbers[i-1]):
            inc=dec+1
        elif get_modulus(numbers[i])<get_modulus(numbers[i-1]):
            dec=inc+1
    return max(inc,dec)

                
            