Question
C. ( 15 points ) Latin Square A Latin Square is an NxN array of N symbols such that each symbol appears in each row
C. ( 15 points ) Latin Square A Latin Square is an NxN array of N symbols such that each symbol appears in each row and each column exactly once. Write a function called latinSquare which takes in two parameters and returns a Latin square as a string. The function should take in two parameters, the first an integer telling the size N of the square, and the second a single character to use as the upper-left corner.
Here are some examples: >>> print(latinSquare(4,'A')) A,B,C,D B,C,D,A C,D,A,B D,A,B,C >>> print(latinSquare(5,'D')) D,E,A,B,C E,A,B,C,D A,B,C,D,E B,C,D,E,A C,D,E,A,B Your program should use N consecutive letters starting with A as the symbols in the square (you can assume the size N is an integer that is 26 or less, and that the letter provided as the second argument is one of the first N uppercase letters in the alphabet). ou should have commas between each character on the same row, and newlines at the end of each row. There should not be an extra newline character at the end of the result string, space between commas, or any other character, such as a dot anywhere. Hint: Start with a Latin square of just numbers before trying letters. Break the problem into stages: 1) Only worry about the size of the square; 2) Get the correct top left value; 3) Use letters instead of numbers
D. ( 15 points ) Roman Calculator Write a function named romanAdd that takes two strings representing roman numbers and returns their sum. (You can refer to Lab 3 for a brief tutorial on Roman numerals). For full credit, return the sum of the two numbers as an int. For 1 point of extra credit write a function named romanAddExtra that takes two strings and return a string with the roman numeral of the sum instead. (You may assume all inputs are valid roman numeral strings that represent numbers less than 400/CD.) For Example: romanAdd('I','XI') #returns 12 (Full Credit Version) romanAdd('I','IX') #returns 10 (Full Credit Version) romanAddExtra ('I','IX') #returns 'X' (Extra Credit Version) Hint: Again, break the problem into easier sub-problems. At first, ignore cases where you need to look at pairs of symbols, then try the full problem.
C. (15 points) Latin Square A Latin Square is an NxN array of N symbols such that each symbol appears in each row and each column exactly once. Write a function called latinSquare which takes in two parameters and returns a Latin square as a string. The function should take in two parameters, the first an integer telling the size N of the square, and the second a single character to use as the upper-left corner Here are some examples: >>>print (latinSquare (4, 'A')) A, B, C, D B,C, D, A C,D, A, B D, A, B,C >>>print (latinSquare (5, 'D')) D, E, A,B,C E, A, B,C, D A, B,C, D, E B,C, D,E,A C, D, E,A, B Your program should use N consecutive letters starting with 'A' as the symbols in the square you can assume the size N is an integer that is 26 or less, and that the letter provided as the second argument is one of the first N uppercase letters in the alphabet). ou should have commas between each character on the same row, and newlines at the end of each row. There should not be an extra newline character at the end of the result string, space between commas, or any other character, such as a dot anywhere Hint: Start with a Latin square of just numbers before trying letters. Break the problem into stages: 1) Only worry about the size of the square; 2) Get the correct top left value; 3) Use letters instead of numbers D. (15 points) Roman Calculator Write a function named romanAdd that takes two strings representing roman numbers and returns their sum. (You can refer to Lab 3 for a brief tutorial on Roman numerals). For full credit, return the sum of the two numbers as an int. For1 point of extra credit write a function named romanAddExtra that takes two strings and return a string with the roman numeral of the sum instead. (You may assume all inputs are valid roman numeral strings that represent numbers less than 400/ CD) For Example romanAdd ('", 'xi') romanAdd ('I', 'IX') roma nAddExtra ( ' I ' , ' IX' ) #returns 12 (Full credit version) #returns 10 (Full credit version) #returns 'X' (Extra Credit Version) Hint: Again, break the problem into easier sub-problems. At first, ignore cases where you need to look at pairs of symbols, then try the full problem. Test your function thoroughlyStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started