Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

A square array of n x n numbers is said to be a Latin square if the array contains n different numbers each occurring exactly

image text in transcribed

A square array of n x n numbers is said to be a Latin square if the array contains n different numbers each occurring exactly once in each row and exactly once in each column; an example of a 3 x 3 Latin square is: 123 312 231 and an example of a 4 x 4 Latin square is: 9876 6 7 8 9 8967 7698 In the module question.py, create some functions that lets a caller determine if a two-dimensional array of integer values is or is not a Latin square. There must be one function named: def is_latin_square (t): where t is a two-dimensional array (list of lists) of integer values that returns True if t represents a Latin square, and False otherwise. The function should not modify the array t. You should decompose the problem down into separate functions rather than trying to solve the problem all in a single function. A sensible decomposition of the problem into separate functions contributes to your mark for this question Hint #1: You need to be able to get a column of the square; it is useful if you get the column of values as a list. Hint #2: You can get a sorted copy of a list using the sorted function: - otad 15, 2, 2, 1.4) + is equal to 11,2,3,4,5 Hint #3: You can test if two lists are equal using == A user of the module would call your is_latin_square function like so for the first Latin square shown above: t - [[1, 2, 3), (3, 1, 21, [2, 3, 11] boo - questiond.is_latin_square (t) Here are some more Latin squares for testing purposes: t = [[9, B, 7, 6], [ 6, 7, 8, 9], [B, 3, 6, 71, 7, 8, 9, 8]] t - [[2, 10), [10, 211 t - [[1]]

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_step_2

Step: 3

blur-text-image_step3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions