# POTD 15 skel
# Author: <anonymized>
# Date: May 15th, 2025
# Description: Smooth
import sys

def mean(nums):
    """ Return the arithmetic mean (i.e., average) of the list of numbers
    nums. Precondition: nums is not empty and contains only numbers.
    Does not modify its input (nums). """
    total = 0
    for i in nums:
        total += i
    return total/len(nums)

def smooth(nums):
    """ Return a smoothed copy of nums, where each element in the resulting
    list is the average of its old value and its two neighbors. The neighbor
    relation "wraps": that is, the first element's left neighbor should be the
    last element, and similarly the last element's right neighbor is the first
    element. For example, if we call smooth([a, b, c, d]), it should return a
    list [a', b', c', d'], where:
        a' is the average of d, a, and b
        b' is the average of a, b, and c
        c' is the average of b, c, and d
        d' is the average of c, d, and a
    Preconditions: nums contains only numbers and has length at least 3.
    This function does *not* modify the input list (nums)."""
    ave = [] 
    for i in range(len(nums)):
        sm = (nums[i-1] + nums[i] + nums[ (i+1) % len(nums) ]) / 3
        ave.append(sm)
    return ave


def print_rounded(nums, end="\n"):
    """ Prints a list of numbers, rounded to the given number of decimal
    places. Does not modify nums. This function is provided for you
    and is only needed for use in the main program. You are not required
    to understand the details of how it works. """ 
    print("[", end="")
    for i in range(len(nums)-1):
        print(f"{nums[i]:3.2f}", end=", ")
    print(f"{nums[-1]:3.2f}]", end=end)

if __name__ == "__main__":
#time of smoothing
    num1 = int(sys.argv[1])

#list of argurment
    args_list = sys.argv[2:]
    new_list = []
    for arg in args_list:
        new_list.append(float(arg))
    
#     
#     
#     num2 = float(sys.argv[2])
#     num3 = float(sys.argv[3])
#     num4 = float(sys.argv[4])
#     num5 = float(sys.argv[5])
#     num6 = float(sys.argv[6])

#put into list
#     num_list = [num2, num3, num4, num5, num6]

#print
#     new_list = num_list
    for u in range(num1):
        new_list = smooth(new_list)
        print_rounded(new_list, end = " ")
        print("Mean: ", mean(new_list))
        
        
    
    
