Questions tagged [magic-square]

A "magic square" is an arrangement of numbers (usually integers) in a square grid, where the numbers in each row, and in each column, and the numbers in the forward and backward main diagonals, all add up to the same number.

In recreational mathematics, a magic square is an arrangement of numbers (usually integers) in the form of a square grid, where the numbers in each row, and in each column, and the numbers in the forward and backward main diagonals, all add up to the same number.

A magic square has the same number of rows as it has columns, and in conventional math notation, "n" stands for the number of rows (and columns) it has.

Thus, a magic square always contains n2 numbers, and its size (the number of rows [and columns] it has) is described as being "of order n". A magic square that contains the integers from 1 to n2 is called a normal magic square. (The term "magic square" is also sometimes used to refer to any of various types of word squares.)

Wikipedia:
http://en.wikipedia.org/wiki/Magic_square

148 questions
0
votes
2 answers

print doubly linked list - no result

I am new to c++ and programming in general. I am trying to implement a doubly linked list. I think the list is created successfully, but I am having trouble printing the list out entirely. Can you please let me know what's wrong with my…
0
votes
2 answers

VBA: adding random numbers to a grid that arent already in the grid

Sub FWP() Dim i As Integer Dim j As Integer Dim n As Integer n = Range("A1").Value For i = 1 To n For j = 1 To n If Cells(i + 1, j) = 0 Then Cells(i + 1, j).Value = Int(((n ^ 2) - 1 + 1) * Rnd + 1) ElseIf Cells(i + 1, j) <> 0…
HWhite
  • 1
  • 2
0
votes
1 answer

assigning to a cell a user input value in python 3

i've been tasked with "Ask the user to select a cell in the table and a number to put into the cell" from a partial magic square table. so far I have numbers = input("Enter two integers: ") numbers = numbers.split(" ") y = [int(x) for x in…
discord1
  • 31
  • 1
  • 3
  • 8
0
votes
0 answers

How to iterate through lists and tuples in multiple ways in Python?

I am new to Python. I won't hide this is homework. I cannot figure out a way to iterate through multiple lists. I originally wrote the below coding for one list ('lst') and it worked perfectly! Then I went back to add the other three lists and I…
0
votes
1 answer

Sum of individual rows and columns in user-specified matrix in Java

This assignment involves a 'matrix.txt' file that is to be imported into the program. This file can have a matrix of any size. The prof has furnished a working program to properly import this file, and has set the task of the students to determine…
JavaNoob
  • 1
  • 1
  • 1
  • 8
0
votes
1 answer

Disable duplication of numbers in an array

I managed to make the program works but the problem is the between Row 3 Column 2 and Row 3 Column 3. Whenever i input two duplicate numbers in row 3 column 2 and row 3 column 3, it accepts those two. If i input 1 there, it loops back. My only…
0
votes
1 answer

Magic square code

#include #include #include using namespace std; // Functions used in the program. bool uniqueCheck(int arr[][3], int num); bool magicSquare(int arr[][3]); int rTotal(int arr[][3], int row); int cTotal(int arr[][3],…
Dust
  • 25
  • 1
  • 8
0
votes
1 answer

Magic Square Solver Using Constraint-Programming

I'm trying to do a custom magic square solver using constraint-programming in Python. For this I use python-constraint (http://labix.org/python-constraint). For this problem the definition of a magic square will be: "A magic square is an arrangement…
Zycho
  • 298
  • 3
  • 13
0
votes
1 answer

Magic Squares - Siamese Method

Is it possible to do magic squares with the Siamese/De La Loubere method without using modulo? I would like to make odd n x n magic squares using it.
Tony Garangean
  • 97
  • 1
  • 1
  • 6
0
votes
0 answers

Magic Squares Checking if Magic

This is probably a very silly question but I am trying to print this output so that it only prints out what is in the system.out.println's not true/false. So in other words I want to get rid of the true/false. I know there are other issues such as…
Kiki
  • 1
0
votes
2 answers

Magic Square Other Diagonal

My other diagonal method won't work correctly. public int sumOtherDiag() { int otherDiag = 0; for (int i = 0; i < square.length−1; i++) { otherDiag += square[i][i]; } return otherDiag; } I don't have my output to show here, but…
0
votes
1 answer

Magic Square preferred output

I have an assignment about MAGIC SQUARE: But i need to rewrite it. This is my code at the moment: Scanner input = new Scanner(System.in); System.out.print("Enter a number: "); int num= input.nextInt(); //Number must be ODD and not…
repsajznav
  • 61
  • 1
  • 8
0
votes
0 answers

(C Program) User made magic square fails on 11x11 array but works on every size up to 11x11?

Alright so I thought my code was working and it seems to do so, it allows the user to choose the size of a magic square where the number one is the start point and starts in the center of the first row. The pattern goes along this line....go up one…
John Conner
  • 233
  • 1
  • 4
  • 18
0
votes
1 answer

Printing Magic Square

So I'm trying to print a magic Square. The program is complete but when it prints the magic square it comes out reversed. The output for a 3X3 should look like this: 8 1 6 3 5 7 4 9 2 but instead I'm getting this: 4 9 2 3 …
Claudia Gomes
  • 41
  • 1
  • 3
  • 7
0
votes
4 answers

Create a subclass, instead, when calling the creation of a class, depending on some logic

The question that I posted initially was lacking so here is an explanation that I hope will satisfy everyone and cancel some down votes that I received on it. I would like to have an intelligence inside a class, that with the creation of an…
Shahar 'Dawn' Or
  • 2,713
  • 1
  • 26
  • 38