Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started