Question: Write a function, print_intersected(across, down) that tries to print out the two words intersected like in a crossword puzzle. The words can be intersected if

Write a function,print_intersected(across, down)that tries to print out the two words intersected like in a crossword puzzle. The words can be intersected if they have at least one common letter. The first word (parameteracross) should be printed horizontally from left to right and the second word (parameterdown) should be printed vertically from top to bottom. Thedownword should intersect theacrossword as far to the left as possible (eg, givenmerrie and tester:eis the first letter inmerriethat is also intestersotestshould intersectmerrieat the firste). Theacrossword should also cut thedownword as early as possible (eg, givenmerrieandtester,merriecutstesterat the firstein tester, not the second one).

If the words have no letters in common then the following message should be printed.

Can't intersect the words!

For example:

Test

Result

print_intersected('cross', 'word')

w

o

cross

d

print_intersected('merrie', 'tester')

t

merrie

s

t

e

r

print_intersected('super', 'computer')

c

o

m

p

super

t

e

r

print_intersected('computer', 'nerds')

n

computer

r

d

s

print_intersected('engine', 'eggnog')

engine

g

g

n

o

g

print_intersected('vw', 'tiguan')

Can't intersect the words!

Python3+ language, thanks!

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 Programming Questions!