Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed
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

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: 3

blur-text-image

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

Database Management An Organizational Perspective

Authors: Richard T. Watson

1st Edition

0471305340, 978-0471305347

More Books

Students also viewed these Databases questions