CSC 15 lab 5 This week's lab will continue to allow you to practice writing functions and loops, including nested loops. These basic skills will allow us to write more interesting programs later. 1. Write a function that takes a string, representing a day of the week ("Sunday" to "Saturday") as an argument, and returns the corresponding number associated with the day: 0 for Sunday, 1 for Monday, 6 for Saturday, etc. If the input string is invalid, then return -1. For example, if your function is called daynum, then calling daynum("Monday") should return 1, calling daynum("someotherstring") will return -1. **Do not use more than one if-else statement in the function. Hint: Days=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"] 1b. Write another function to convert the name of a Month into a number. This time however, calling monthnum("January") should return 1, not 0. Calling monthnum("December") should return 12. Return -1 if the input parameter is not valid. 1c. The following array contains the number of days in each month, starting with Januray. We'll assume that it's not a leap year so Feburary has 28 days: DM = [31,28,31,30,31,30,31,31,30,31,30,31] Write a function "daysin" that takes a STRING representing the Month and returns the number of days in the month. So daysin("Feburary") should return 28, daysin("December") should return 31. Return 0 if the argument is an invalid string. Do not do this from scratch: write this function by calling the other function(s). 2. Write a NESTED loop that prints the following: 1 1 2 1 2 3 1 2 3 4 1 2 3 4 5 ... Your print statements may print AT MOST ONE number at a time. Encapsulate your loop into a function that can print an arbitrary number of lines of this pattern. 2b. Now do this one: 5 5 4 5 4 3 5 4 3 2 5 4 3 2 1 2c. And this one (challenge) 1 2 1 3 2 1 4 3 2 1 5 4 3 2 1 You must use nested loops and your solution must be generalizable. The following problems were optional last week but required this week: 3. Write a function that takes an array parameter and return the same array without duplicates. For example, calling nodups([3,4,1,3,5,1] should return [3,4,1,5]. All duplicates are removed. Hint: don't try to delete an element from an array. Instead, construct a new array, starting from [], that does not include duplicates. 4. Modify problem 1 of lab 4 so that the function returns an array containing the indices of all occurrences of the largest element. For example, largests([3,5,8,2,8,4]) should return [2,4] because the largest element (8) is found at positions 2 and 4 in the array. THIS FUNCTION WILL BE CRUCIAL FOR THE NEXT LAB. 5. (Challenge) In football, scores are in the following units: 8: touchdown + 2 points 7: touchdown + 1 point 6: touchdown with no extra points 3: field goal 2: safety You're to write a function to print all the possible ways for a team to score a given number of points (which will be the parameter to the function) For example, 16 points can be made up of 1 touchdown (with +1 point) and 3 field goals, or 2 touchdowns and 1 safety, or 8 safeties, etc. If the input number of points is 1 or negative, your program should print "impossible to score that many points." However, there is exactly one way to score 0 points. You need to print ALL possible ways to score the given number of points as well as count how many ways there are to score the points.