Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Problem 3 - Word Search Create a program in a file called word_search.py where we input a string and then a word to search for.

image text in transcribed
image text in transcribed
Problem 3 - Word Search Create a program in a file called word_search.py where we input a string and then a "word" to search for. We'll allow the word to be "hidden" in the following ways: 1. We can hide the word by using a gap, meaning that the word can be hidden with a gap of letters in between. a. We have hidden the word hello in hxexlxlxo with x's in between but they can be anything. b. The "word" abcd is hidden twice in aabbccdd. 2. The word can be hidden with an offset, meaning it can start in the middle of the string, a. The word abcd is "hidden" in xyzabcdxyz. 3. We can combine gaps and offsets: a. Gap is hidden in abcdgrasp NOTE: The gap has to be the same size between each letter in the word! So your task is to find out and display all of the different offsets and gaps with which the original word is hidden in the string. linux1[150] % python3 word_search.py Enter the block of characters to search: abcdgrasp What word are we looking for? gap Found with offset = 4, gap = 2 linux1[151] % python3 word_search.py Enter the block of characters to search: aaabbbcccddd What word are we looking for? abcd Found with offset 0, gap = 3 Found with offset = 1, gap = 3 Found with offset 2, gap = 3 linux1[152] % python3 word_search.py Enter the block of characters to search: jklsdfljkasdfljkfasdkljfasdkl What word are we looking for? xyz [no output) linux1[153] % python3 word_search.py Enter the block of characters to search: hellohellohello What word are we looking for? hello Found with offset = o, gap = 1 Found with offset 5, gap = 1 Found with offset = 10, gap = 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

Transact SQL Cookbook Help For Database Programmers

Authors: Ales Spetic, Jonathan Gennick

1st Edition

1565927567, 978-1565927568

More Books

Students also viewed these Databases questions