![Thinking Like an Engineer: An Active Learning Approach (3rd Edition)](https://www.bartleby.com/isbn_cover_images/9780133593211/9780133593211_largeCoverImage.gif)
Concept explainers
As early as 650 BC, mathematicians have been composing magic squares, a sequence of n numbers arranged in a square such that all rows, columns, and diagonals sum to the same constant. Used in China, India, and Arab countries for centuries, artist Albrecht Durer’s engraving Melencolia I (year: 1514) is considered the first time a magic square appears in European art. Each row, column, and diagonal of Dürer’s magic square sums to 34. In addition, each quadrant, the center four squares, and the corner squares all sum to 34. The following is an example of a magic square:
Write a program to determine if a series of numbers is indeed a 4 × 4 magic square. Your program should complete the following steps, in this order
- a. Ask the user to enter the proposed magic square in a single input statement (e.g., [1 2 3 4; 5 6 7 8; 9 10 11 12; 13 14 15 16]—note this example is a 4 × 4 matrix, but NOT a magic square). You may assume the user will enter whole numbers; they will not enter either decimal values or text.
- b. Check that all values are positive; ** for-loop or nested for-loop required in the solution. If one or more of the values in the matrix are negative or zero, issue a statement to the command window informing the user of the mistake and ask the user to enter another matrix. This check should be repeated until the user enters a matrix with positive values. This check should work even if the user does not enter a 4 × 4 matrix; it should work regardless of the size of matrix entered.
- c. Check for an arrangement of 4 × 4 If the matrix is not a 4 × 4, issue a statement to the command window informing the user of the mistake, and ask the user to enter another matrix. This check should be repeated until the user enters a 4 × 4 matrix. You may assume the reentered matrix contains only positive values; you do not need to recheck the new matrix for positive values, only for matrix dimensions.
- d. Determine if the matrix is a form of a magic square. The minimum requirement to be classified as a magic square is each row and column sums to the same value. ** for-loop or nested for-loop required in the solution. If this criterion is not met, issue a statement to the command window informing the user they have not entered a magic square and ask the user if they wish to try another magic square. This question can be posed using either a text answer entered by the user (Yes, No) or by using a menu. If the user chooses to run the program again, the entire program starting with step (a) should begin again.
- e. Determine the classification of the magic square using the following requirements:
- 1. If each row and column sums to the same value, the magic square is classified as semi-magic; the summation value is ca led the magic constant. **for-loop or nested for-loop required in the solution.
- 2. If, in addition to criterion 1, each diagonal sums to the same value, the magic square is classified as normal; **for-loop or nested for-loop required in the solution. The use of built-in functions such as diag, flipir, rot90, trace or similar built-in functions is forbidden.
- 3. If, in addition to 1 and 2, the largest value in the magic square is equal to 16, the magic square is classified as perfect.
Format your magic square classification similar to the format shown below. You may choose to format your table differently, but each classification should contain a Yes or No next to each magic square category.
The magic constant for your magic square is 24. The classification for your magic square:
Semi-magic | Normal | Perfect |
Yes | Yes | Yes |
After this table appears, ask users if they wish to try another magic square following the instructions given earlier. A few test cases for you to consider:
- Albrecht Dürer magic square: [16, 3, 2, 13; 5, 10, 11, 8; 9, 6, 7, 12, 4, 15, 14, 1];
- Chautisa Yantra magic square: [7, 12, 1, 14, 2, 13, 8, 11; 16, 3, 10, 5; 9, 6, 15, 4];
- Sangrada Familia church, Barcelona magic square: [1, 14, 14, 4; 11, 7, 6, 9; 8, 10, 10, 5; 13, 2, 3, 15].
- Random magic square: [80, 15, 10, 65; 25, 50, 55, 40; 45, 30, 35, 60; 20, 75, 70, 5];
- Steve Wozniak’s magic square: [8, 11, 22, 1; 21, 2, 7, 12; 3, 24, 9, 6; 10, 5, 4, 23]
![Check Mark](/static/check-mark.png)
Want to see the full answer?
Check out a sample textbook solution![Blurred answer](/static/blurred-answer.jpg)
Chapter 20 Solutions
Thinking Like an Engineer: An Active Learning Approach (3rd Edition)
- Draw top, side, front view With pen(cil) and paper Multi view drawing and handwriting all of itarrow_forwardA wheel of diameter 150.0 mm and width 37.00 mm carrying a load 2.200 kN rolls on a flat rail. Take the wheel material as steel and the rail material as cast iron. Assume the figure given, which is based on a Poisson's ratio of 0.3, is applicable to estimate the depth at which the maximum shear stress occurs for these materials. At this critical depth, calculate the Hertzian stresses σr, σy, σz, and Tmax for the wheel. 1.0 0.8 0, т Ratio of stress to Pmax 0.4 0.6 90 69 0.2 0.5b b 1.5b Tmax 2b Distance from contact surface The Hertizian stresses are as follows: 02 = or = -23.8 psi for the wheel =| necessary.) σy for the wheel =| MPa σz for the wheel = MPa V4 for the wheel = | MPa 2.5b ཡི 3b MPa (Include a minus sign ifarrow_forwardOnly question 3arrow_forward
- In cold isostatic pressing, the mold is most typically made of which one of the following: thermosetting polymer tool steel sheet metal textile rubberarrow_forwardThe coefficient of friction between the part and the tool in cold working tends to be: lower higher no different relative to its value in hot workingarrow_forwardThe force F={25i−45j+15k}F={25i−45j+15k} lblb acts at the end A of the pipe assembly shown in (Figure 1). Determine the magnitude of the component F1 which acts along the member AB. Determine the magnitude of the component F2 which acts perpendicular to the AB.arrow_forward
- Elements Of ElectromagneticsMechanical EngineeringISBN:9780190698614Author:Sadiku, Matthew N. O.Publisher:Oxford University PressMechanics of Materials (10th Edition)Mechanical EngineeringISBN:9780134319650Author:Russell C. HibbelerPublisher:PEARSONThermodynamics: An Engineering ApproachMechanical EngineeringISBN:9781259822674Author:Yunus A. Cengel Dr., Michael A. BolesPublisher:McGraw-Hill Education
- Control Systems EngineeringMechanical EngineeringISBN:9781118170519Author:Norman S. NisePublisher:WILEYMechanics of Materials (MindTap Course List)Mechanical EngineeringISBN:9781337093347Author:Barry J. Goodno, James M. GerePublisher:Cengage LearningEngineering Mechanics: StaticsMechanical EngineeringISBN:9781118807330Author:James L. Meriam, L. G. Kraige, J. N. BoltonPublisher:WILEY
![Text book image](https://www.bartleby.com/isbn_cover_images/9780190698614/9780190698614_smallCoverImage.gif)
![Text book image](https://www.bartleby.com/isbn_cover_images/9780134319650/9780134319650_smallCoverImage.gif)
![Text book image](https://www.bartleby.com/isbn_cover_images/9781259822674/9781259822674_smallCoverImage.gif)
![Text book image](https://www.bartleby.com/isbn_cover_images/9781118170519/9781118170519_smallCoverImage.gif)
![Text book image](https://www.bartleby.com/isbn_cover_images/9781337093347/9781337093347_smallCoverImage.gif)
![Text book image](https://www.bartleby.com/isbn_cover_images/9781118807330/9781118807330_smallCoverImage.gif)