Question: Simple cryptarithm solver Since I have not yet studied permutation generators, I am not required to write a general cryptarithm solver. Instead, I am supposed

 Simple cryptarithm solver Since I have not yet studied permutation generators,

Simple cryptarithm solver Since I have not yet studied permutation generators, I am not required to write a general cryptarithm solver. Instead, I am supposed to write a special case: Given a puzzle using four digits, such as en four specific numbers, such as 1, 4, 6, and 8, figure out which number goes for which digit to solve the cryptarithm. Write the code for the solve function below. In other words, Given a cryptarithm puzzle using four letters, such as T'a'bisd'l, and a list of the four solution digits, such as [1,4,6,8l, figure out the mapping of digits to letters that solves the cryptarithm. There will be two addends, so the length of the puzzle list is 3. The solution should be expressed as a string; for example, 6+8-14 def solvelpuzzle.disitlist): shege expert please provide python code here that will pass the following tests This is all the code I need from you The following testCase function takes a test identifier, inputs for solve, and the expected result. It then calls solve and prints a message showing the test result. def testCaseltestNumber puzzle digits sxpestedlist): actualResult-solve(puzzle diits) if actualResult in expestedlist: print "Test"testNumbeL,"passed." else: print "Test" testNumber "failed. Expected one of "expestedlist," Actual: "actualResult This function runs the tests for solve. def test(): testcase(1, l'a', b', 'cd'), (1, 4, 6,81, ['6 +8-14" "8 +6-14"1) testcaset2, ['a'''st. [5,2,1,71, r"s+7-12", 7+5-h2") testcasel3, I'xxz, 'zx, xwl, (4, 7,0, 3L I 304 +43-347", "403 +34-437"1)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!