Question: Create a function (in Python) transdecode(s, shape, limit=4) which takes a string, permuted by transencode, and decodes it by brute force, trying all possible permutations,

Create a function (in Python) transdecode(s, shape, limit=4) which takes a string, permuted by transencode, and decodes it by brute force, trying all possible permutations, checking each one using wordsegment. It returns all possible strings of with more than limit-1 words
FYI: transencode(s, shape) converts a string into a matrix of the given shape, and random permutes both the rows and columns (using random.shuffle()). It returns a flattened string. 
 
>>> q1 = transencode(q, [2,3]) 
>>> q1 'wotneo' 
>>> q2 = transdecode(q1, [2,3], 2) 
>>> q2 ['wot neo', 'wto noe', 'ow teno', 'ot we on', 'two one', 'to woen', 'neo wot', 'noew to', 'eno owt', 'eo not w', 'one two', 'oen to w']

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!