Arrays store a linear arrangement of values, accessed by a single index. Two-dimensional arrays or matrices...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Arrays store a linear arrangement of values, accessed by a single index. Two-dimensional arrays or matrices store a tabular arrangement of values, accessed by two indices, for example matrix[i][j], where i is the row index, and j is the column index. Crosswords are a type of puzzle where the "pieces" of the puzzle have letters in common. For example, these pieces share the letter 'o'. d across W n Write a program that will accept a list of words into an array list of strings, then make a 20 x 20 matrix of characters (strings of length 1) that contains a crossword puzzle with these words. For example, when given the list addle, apple, clowning, incline, plan, burr your program might display: addle Р Р clowning e Below is an example which is not legal because of words touching each other. Note how "prove" is added in a fashion which is illegal since it creates additional words "dr", "do", "lv", and "ee". Similarly, the addition of "no" vertically is illegal since it creates the extra word "no" horizontally. You do not have to check a dictionary in this assignment just assume that creation of any new word other than the one you are adding is illegal. n с 1 i plan addle prove clowning Р e no с 1 i plan e Here is another example of how a word can be added legally -- the addition of "loon" uses two letters that are in the puzzle already, which creates no problem since there are no new words created other than the single word added "loon".) addle 0 0 clowning Р Р n C 1 i plan H.H. e To summarize: A legal placement of a word W has the following properties: i. All of the word W lies on the 20x20 grid; ii. If W is not the first word, then W must intersect with one or more words on the grid; iii. The placement of W must not create any new 'words', i.e., W cannot be adjacent to any letter which is not in the word(s) with which W intersects. Hint (optional approach): 1. Place the first word horizontally in the center of the grid. 2. Place the next word vertically (so that it intersects the first word), and keep alternating horizontal with vertical placement. 3. When placing a word W, scan the current grid to find a letter of W, and check if W can legally be placed to overlap with that letter. If yes, then place W in that position on the grid. If no, then continue looking through the grid for some letter of W to try another placement. 4. If it is not possible to place W anywhere, then skip that word, and try the next word. When you skip a word, print the word and a message: "no matching letter" or "illegal adjacencies" or "reaches outside grid". 5. Continue in this fashion until all words have been either placed or at least tried and reported on. 6. When done going through the list of words and placing them if possible, print the crossword puzzle. Notes: 1. Write your program in a file called a2.py, which contains a) a function crossword(L), which makes and prints a crossword puzzle for the words in list L, and b) code that runs crossword (L) on at least two lists of words. 2. Submit two files on D2L: a2.py and output.txt, where output.txt contains the results from your tests in 1(b) above. 3. There are multiple ways to build a crossword puzzle from the given list of words -- many different outputs can be correct for the same list of words. However, if a word can be added to the crossword at the time your program reads it, then your program must add it. 4. Marking: 9 points for producing correct output; 1 point for documentation and readability. 5. Put your name in a comment at the top of the file. If you receive significant help from someone, then acknowledge that person's help in the comment at the top. This is part of the documentation. Copying or letting your work be copied results in a mark of zero as well as other repercussions according to the student code of conduct described in the Ryerson Calendar. Arrays store a linear arrangement of values, accessed by a single index. Two-dimensional arrays or matrices store a tabular arrangement of values, accessed by two indices, for example matrix[i][j], where i is the row index, and j is the column index. Crosswords are a type of puzzle where the "pieces" of the puzzle have letters in common. For example, these pieces share the letter 'o'. d across W n Write a program that will accept a list of words into an array list of strings, then make a 20 x 20 matrix of characters (strings of length 1) that contains a crossword puzzle with these words. For example, when given the list addle, apple, clowning, incline, plan, burr your program might display: addle Р Р clowning e Below is an example which is not legal because of words touching each other. Note how "prove" is added in a fashion which is illegal since it creates additional words "dr", "do", "lv", and "ee". Similarly, the addition of "no" vertically is illegal since it creates the extra word "no" horizontally. You do not have to check a dictionary in this assignment just assume that creation of any new word other than the one you are adding is illegal. n с 1 i plan addle prove clowning Р e no с 1 i plan e Here is another example of how a word can be added legally -- the addition of "loon" uses two letters that are in the puzzle already, which creates no problem since there are no new words created other than the single word added "loon".) addle 0 0 clowning Р Р n C 1 i plan H.H. e To summarize: A legal placement of a word W has the following properties: i. All of the word W lies on the 20x20 grid; ii. If W is not the first word, then W must intersect with one or more words on the grid; iii. The placement of W must not create any new 'words', i.e., W cannot be adjacent to any letter which is not in the word(s) with which W intersects. Hint (optional approach): 1. Place the first word horizontally in the center of the grid. 2. Place the next word vertically (so that it intersects the first word), and keep alternating horizontal with vertical placement. 3. When placing a word W, scan the current grid to find a letter of W, and check if W can legally be placed to overlap with that letter. If yes, then place W in that position on the grid. If no, then continue looking through the grid for some letter of W to try another placement. 4. If it is not possible to place W anywhere, then skip that word, and try the next word. When you skip a word, print the word and a message: "no matching letter" or "illegal adjacencies" or "reaches outside grid". 5. Continue in this fashion until all words have been either placed or at least tried and reported on. 6. When done going through the list of words and placing them if possible, print the crossword puzzle. Notes: 1. Write your program in a file called a2.py, which contains a) a function crossword(L), which makes and prints a crossword puzzle for the words in list L, and b) code that runs crossword (L) on at least two lists of words. 2. Submit two files on D2L: a2.py and output.txt, where output.txt contains the results from your tests in 1(b) above. 3. There are multiple ways to build a crossword puzzle from the given list of words -- many different outputs can be correct for the same list of words. However, if a word can be added to the crossword at the time your program reads it, then your program must add it. 4. Marking: 9 points for producing correct output; 1 point for documentation and readability. 5. Put your name in a comment at the top of the file. If you receive significant help from someone, then acknowledge that person's help in the comment at the top. This is part of the documentation. Copying or letting your work be copied results in a mark of zero as well as other repercussions according to the student code of conduct described in the Ryerson Calendar.
Expert Answer:
Answer rating: 100% (QA)
Arrays store a linear arrangement of values accessed by a single index dispCreate an array with fou... View the full answer
Related Book For
Discovering Advanced Algebra An Investigative Approach
ISBN: 978-1559539845
1st edition
Authors: Jerald Murdock, Ellen Kamischke, Eric Kamischke
Posted Date:
Students also viewed these programming questions
-
Googles ease of use and superior search results have propelled the search engine to its num- ber one status, ousting the early dominance of competitors such as WebCrawler and Infos- eek. Even later...
-
The Crazy Eddie fraud may appear smaller and gentler than the massive billion-dollar frauds exposed in recent times, such as Bernie Madoffs Ponzi scheme, frauds in the subprime mortgage market, the...
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
In Exercises determine whether Rolle's Theorem can be applied to on the closed interval [a, b]. If Rolle's Theorem can be applied, find all values of c in the open interval (a, b) such that '(c) =...
-
Describe and explain the career path for tour operations?
-
Using the data in E3-15, assume Santana Mortgage Company uses the FIFO method. Also, assume that the applications in process on September 1 were 100% complete as to materials (forms) and 40% complete...
-
Tom Slater opened an accounting firm on March 1,2010. During the month of March, the business completed the following transactions: Requirements 1. Open, or set up, the following T-accounts: Cash,...
-
Rembrandt Frame Company prepared the following sales budget for the current year: At the end of December 2008, the following unit sales data were reported for the year: For the year ending December...
-
Problem #4: As part of a promotion, you can buy a new living room set today and make no payments for 3 years. Starting exactly 3 years from today, you will make 5 annual payments of $1500 each. If...
-
Adrienne is a single mother with a 6-year-old daughter who lived with her during the entire year. Adrienne paid $3,900 in child care expenses so that she would be able to work. Of this amount, $500...
-
Partick plc is planning to restructure its financing to introduce some gearing. The company has always been sufficiently profitable to finance its investments from retentions and has avoided the use...
-
Groups can utilize several options for making decisions. Discuss the advantages and disadvantages of voting, consensus, and authority rule decision making.
-
Suppose the work on a project task was expected to cost 1 5 0 0 , to complete the task and the workers were originally scheduled to finish early. As of today however, the workers have expended 1 3...
-
How can we employ advanced algorithms such as machine learning and computational optimization techniques to enhance process efficiency and streamline operations? Explain
-
What is the relationship between the insurance culture and the economic stability of a country like Honduras? Explain.
-
Lift the locking lever and pull the toner cartridge out Select Cartridge Access Control (CAC) from the control panel Manually remove the cartridge from the toner motor drive Select Troubleshooting...
-
Individual Employee Behavior: Behavior, Personality, Values, Ethics, Perceptions, Emotions, Attitudes, Stress, as it relates to Motivation, Decision making and creativity organizational...
-
Information graphics, also called infographics, are wildly popular, especially in online environments. Why do you think infographics continue to receive so much attention? How could infographics be...
-
Consider the line y = -5.02 + 23.45x. a. What is the slope of this line? b. Write an equation for a line that is parallel to this line. c. Write an equation for a line that is perpendicular to this...
-
Sketch a graph that shows the relationship between the time in seconds after you start microwaving a bag of popcorn and the number of pops per second. Describe in words what your graph shows.
-
Scott has 47 coins totaling $5.02. He notices that the number of pennies is the same as the number of quarters and that the sum of the number of pennies and quarters is one more than the sum of the...
-
Consider the following scenario. Restrictions imposed by the client prohibit the observation of stock-take, which accounts for about 40 per cent of all assets. Alternative audit procedures cannot be...
-
If the auditor believes that management should disclose further information about directors remuneration but management does not agree to do this, what should the auditor do? (a) Report the breach to...
-
Fly-By-Night Ltd is a listed public company that manufactures highly sophisticated navigation equipment for defence force aircraft and Navy ships. The company has a 30 June 20X0 year-end, and the...
Study smarter with the SolutionInn App