Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9005003
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T01:02:10+00:00 2026-06-16T01:02:10+00:00

I would like to do this: I’ve got a matrix N x N. It

  • 0

I would like to do this: I’ve got a matrix N x N. It can contain number from 1 to n^2. This matrix has a few cells filled with positive numbers. I have to decide, that this already filled matrix can be a magic matrix (magic square). For example:

0 0 0 7 4

0 1 0 0 8

0 0 3 0 0

0 0 0 0 0

0 0 0 0 0 

We can create from this matrix a magic square.
Is there any algorithm to decide this? Could you recommend me something? Thank You!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T01:02:13+00:00Added an answer on June 16, 2026 at 1:02 am

    I’m not sure if it is the most efficient approach, but you can determine the magic constant: as

    magic_constant = n*(n^2+1)/2
    

    Once you have the magic constant, you can work it similar to a Sudoku puzzle, where you determine which possible values could work for each unfilled cell, and then try each one starting with the cell that has the fewest possible values. When you fill a cell with a number, you update the possible values for the rest of the unfilled cells. If you run into a case where a cell has no possible values, then you backtrack. If you run out of possibilities, then the answer is “no”. If you run out of unfilled cells, then the answer is “yes”.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like do some thing like this: SELECT sum(quantity) FROM orders WHERE order_code
I would like to remove all twitter nicknames (@xxx) from a string like this:
I would like to achieve something like this: SELECT col1,col2-(SELECT foo FROM table1) FROM
I would like to have an UPDATE statement like this: SELECT * FROM Employee
I would like to run a LINQ query like this: var words = from
I would like to do something like this from a Ruby script, within a
I would like something like this but dynamically from an array like this: $array
I would like this div to slide up to be hidden and I can
I would like to use something like this: Dictionary<int, string>[] matrix = new Dictionary<int,
I would like to strtotime dateformat like this - Fri Jun 15 05:38:11 +1000

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.