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]
Want to see the full answer?
Check out a sample textbook solutionChapter 20 Solutions
Thinking Like an Engineer: An Active Learning Approach (3rd Edition)
- Question 3) On the plate in the figure, the length L is given as L = 18 m . According to this; y 2L L 2L 3 L -- L Question 3-A) Find the X coordinate of the geometric center of the plate. (Enter your result as m without writing units.) Response: Question 3-B) Find the Y coordinate of the geometric center of the plate . (Enter your result as m without writing units.) Response:arrow_forwardPlease help show me how drawing will look in isometric drawing.arrow_forwardCan someone please home me to solve the following question showing all needed work and equation’s. Please and thank you.arrow_forward
- Write the (1) two subscripts and (2) sign of the stress components (\sigma, \tau) under the given coordinate system. You need to answer all 1) to 4). For example, you may answer using the format as: 1) \sigma_cc, +arrow_forwardOz Lawn Care Inc. manufactures and assembles lawnmowers that are shipped to dealers throughout the United States and Canada. Two different procedures have been proposed for mounting the engine on the frame of the lawnmower. PB (Minutes) UPB (Minutes )345798632 5 Is there a difference in the methods' mean time to mount the engines on the frames of the lawnmowers? The answer must be in handwriting. Please write your answer using a ball - point pen on plain paper. Submit your homework by uploading it to the canvas. Good Luck!arrow_forwardNeed only a handwritten solution only (not a typed one).arrow_forward
- Shown in the image is a vertical section of a 66 block grid of a gold mine deposit. Each block is identified with a number and a gold (Au) grade in g/t. As shown, most blocks contain non- valuable or zero ore-grade (G=0). However, the ore-grade of highlighted block #17 is G2= 1.4 g/t, and similarly the ore grades of blocks #28, #39, #50 and #61 are in turn: G3 = 1.2, G4 = 2.3, G5 = 2.8, and G6 = 2.9 g/t. Evaluate the mining methods (o/c or u/g) which should be selected based on economic considerations only.arrow_forwarda diagonal of a polygon is a line segment that connects nonadjacent vertices of the polygon.in the following polygons, a triangle has 3 sides and 0 diagonal, a quadrilateral has 4 sides and 2 diagonals, a pentagon has 5 sides and 5 diagonals, a hexagon has 6 sides and 9 diagonals. predicts the number of diagonals in a 12-sided polygon.arrow_forwardEach bar chart should show the distribution of energy across the categories as well as the total energy for the initial- red and final- blue state. The system includes 3 units of heat energy, and 2 units of radiant energy. All of the energy in the final state will be converted into mechanical energy.arrow_forward
- Due: Wed, 25-Sep-2024, 4pm PM Assignment 20/0 اساس 22.0 KIS AB Q1. Draw an isometric projection of the building below, with point A as the bottom corner in your answer. Three orthographic views of a Student Union (SU) Church are shown below in third angle projection. The sketches are not to scale. Use a scale of 1 cm = 1 m (or 1:100). The church has a centred double door with total width of 3m as shown. Above the door is a 2.5m diameter round window, aligned with the roof apex and centred 5m above the floor. The church has a 3m diameter semi-circular window in the corner as shown. The window is 1.5m above the floor. Roof lights (roof windows) are used to get natural light into the building. [30 Marks] 2 x 1m wide roof windows strips run across the roof as shown. Round window 02.5m centred 5m above floor 3m 12m Front View 15m 3m O.T. Masoso 7211 3467 masoso@ub.ac.bw 10m Top of Right View Right View 10m Page 1 of 1 GAMES + TIME O narrow_forwardI need help with this question please. thank youarrow_forward2022 Tutorial 5 - Isometric Projection.pdf - Adobe Acrobat Reader DC (64-bit) File Edit View Sign Window Help Home Tools 2022 Tutorial 5 - Is... x 8 Q ↑ O Type here to search 2 / 4 QUESTION 2: Make an isometric drawing of the detail with corner A at the bottom. 99 O 8- PROJECTION 30° 135% 66 20 CIES √ l A Q 18°C Cloudy D Search "Highlight A & Select PDF File PExport PDF O Adobe Export PDF Convert PDF Files to Word. or Excel Online Convert to 2022 Tutorjection.pdf 0 Document Language: English (U.S.) Change Microsoft Word (.docx) Sign In Convert Edit PDF 4 40) Free 7-Day Trial A ENG 10:33 PM INTL 9/15/2022 X 2 € X V Convert, edit and e-sign PDF forms & agreementsarrow_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