#Practice Problems for Module 6

# Part 1 - Warm up questions
## This problem is repeating practice problem, but using 
## a for loop, instead of a while loop. 

# Write a Python function weird_print, that consumes a natural number, n, 
# and returns a string containing 0,1,2,...,n, with each
# number followed by " ... " all on one line. 
# For example
# weird_print(0) prints "0 ... "
# weird_print(5) prints "0 ... 1 ... 2 ... 3 ... 4 ... 5 ... "
# use a FOR loop.

def weird_string(n):
    pass


## Try this one twice - once using a whlie loop, and once using a for loop. 

# Write a function flip,  that consumes a list of Bool value, called votes,
# and mutates votes by changing all True values to False, and all False values to True.
# The function returns None.

def flip(votes):
    pass


# Part 2 - Extra Practice


#
# Problem 1
# a) Write function to return the longest string in a list of strings.
def longest_str(phrases):
    pass

# b) Write a function to return the index of the longest string in a list of strings.
def index_of_longest(phrases):
    pass

# Problem 2: 
# Write a function longer_than which consumes a list of
# strings los and a non-negative integer n, and counts the number
# of strings in los with more than n characters in them.
# Implement using an abstract list function, a while loop, 
# and a for loop. (i.e. three different implementations)
def longer_than(los, n):
    pass

# Problem 3
# Write a function print_each that consumes a list of strings and prints
# each character of each string on a separate line.
# For example, print_each(["a", "bc", "" "def"]) prints the characters
#  a,b,c,d,e,f, with exactly one character per line.
def print_each(phrases):
    pass

# Problem 4
# Write a function that consumes a list of lists of integers, where each
# element list has the same length. 
# M = [ [1,2,3], [4,5,6], [7,8,9] ]
#
# a) Write the function p_norm, that consumes a list like M, and returns pth-root
#    of the sum of all values in M being raised to the power p. The function consumes
#    the list M and the positive integer p. 
def p_norm(M, p):
    pass

# b) Write the function frobenius_norm, that consumes a list like M, and returns the
#    sum of the squares of all the entries in M.
def frobenius_norm(M):
    pass

# c) Write the function minimax, that consumes a list like M, and returns the minimum of
#    maximum values across each row, i.e. it returns the minimum of R1, R2, R3, etc.,
#    where R1 is the maximum entry in L1, R2 the maximum entry in L2, etc. where
#    M = [L1, L2, ...]
def minimax(M):
    pass

# d) Write the function column_max, that consumes a list like M, and returns the
#    maximum column_sum in M. In the example above, the column sums are 1+4+7, 2+5+8, and
#    3+6+9. 
def column_max(M):
    pass

#
# Additional Problems
# Review previous practice problems. Rewrite all problems that required
# recursion or abstract list fuctions, so that they use iteration. 
# For each, determine if a for loop or a while loop is more suitable.
