Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a method called isMagic which takes in a 2D integer array. The function returns True if all rows and columns sum to the same

Write a method called isMagic which takes in a 2D integer array. The function returns True if all rows and columns sum to the same value, and False if they do not. 8, 1, 6 3, 5, 7 4, 9, 2 The above array will return True because all rows and columns sum to 15. If we change index [2][0] to 7 then it would return False: 8, 1, 6 3, 5, 7 7, 9, 2 Now the first column and the last row both sum to 18, while all other rows and columns sum to 15. Since not all rows and columns sum to the same number it returns False. (Note if you're familiar with magic matrices in math that I've left out checking the diagonal for this problem.)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions

Question

Why is it important to word interrogatories carefully?

Answered: 1 week ago