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) =...
-
A company has 1,250 employees, and you want to take a simple random sample of n = 60 employees. Explain how you would go about selecting this sample by using the table of random numbers. Are there...
-
SW Flour Company buys 1 input of standard flour and refines it using a special sifting process to 3 cups of baking flour and 9 cups of bread flour. In May 2017, SW bought 12,000 inputs of flour for...
-
Omaha, Inc., recorded certain capital stock transactions shown in the following journal entries: (1) issued common stock for \(\$ 40\) cash per share, (2) purchased treasury shares at \(\$ 50\) per...
-
Bevans Co. makes two products, Product X and Product Y. Bevans has produced Product X for many years without generating any hazardous wastes. Recently, Bevans developed Product Y, which is superior...
-
Al interpretar los indicadores del Test de la persona bajo la lluvia, el psiclogo evaluador se detiene a observar la orientacin de la persona, el dibujo ha sido realizado muy a la derecha abajo, esto...
-
Using CAPM: A stock has a of 1.2. The equity risk premium is 6 percent and the risk free rate is 2 percent. What is the rate of return required by investors in the stock? Question 2 4.1.b - using...
-
The current price-to-earnings (p/e) ratio of Manchester United plc is 20, against an average for the Leisure and Hotels (L&H) sector of 15. Manchester United has a beta of 1.12 against the L&H sector...
-
Jameel owns a popular burger sandwich restaurant in Ramallah, since five years following the success of his first restaurant, Jameel is now considering opening a second one in Nablus, by which he...
-
QUESTION 2. You would like to have $ 1,500,000 accumulated by the time you turn 65, which will be 43 years from now. How much would you have to put away each year to reach your goal assuming you're...
-
Oil prices have completely collapsed - contracts were being valued at -$40,or, you would be PAID to have oil barrels delivered.Yahoo finance completely broke because this has never been seen before....
-
There are two three year bonds with par values of $100; one pays $8 annually and costs $108 and the other $4 semi-annually and costs $109. You are asked to calculate the initial yield on both and...
-
Ecological scientists suggest the closing of a national marine park for one year for restoration purposes. It is owned by the county, which allows free access to visitors. However, a parking fee of...
-
In terms of an all women gym please answer this question in terms of entrepreneurship only The support functions within technology management. You can include financials, entrepreneur, Social...
-
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...
-
Part of the added producer surplus when the price rises as a result of an increase in demand is due to a higher price for the quantity _________ being produced, and part is due to the expansion of...
-
The total welfare gain to the economy from trade in a good is the sum of the _________ and _________ created.
-
With a price floor where the government buys up the surplus, the cost to the government is _________ than the gain to _________.
Study smarter with the SolutionInn App