Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Magic square!
#1
Hello! I was asked to make a magic square solver program.By breaking the program into categories,i must get the user input which will be given with entries separated with commas.So far so good. But i must create lists according to the user input length. For example, if the user inputs 1,2,3,4, this is a 2X2 table, or if it is 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16it should be a 4X4 table.I am thinking to use the modulo operator to make the identification. If we have a 4x4 table i must have 4 lists or if its a 2x2 table it will be 2 lists .Any ideas would be great
Reply
#2
I don't see how modulo is going to help you. If you get to assume that the input is valid (no gaps or anything) you can just take the square root of the length of the number of comma-separated numbers.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Finding square roots using long division. jahuja73 10 5,293 Feb-24-2021, 01:25 PM
Last Post: jahuja73
  Square reverse sum(overloaded) shihomiyano 6 4,024 Aug-18-2018, 06:27 AM
Last Post: micseydel
  Perfect Square program forumer444 4 8,878 Sep-01-2017, 09:32 PM
Last Post: forumer444
  Magic Square Puzzle Harnick 1 4,842 Aug-09-2017, 04:51 PM
Last Post: nilamo
  Square Root on calculator MP1234593 1 7,859 Jun-06-2017, 06:58 PM
Last Post: nilamo
  List of square roots python py7 6 6,297 Apr-08-2017, 11:26 PM
Last Post: ichabod801
  Square root of a number mbestivert 1 4,004 Nov-24-2016, 04:35 PM
Last Post: casevh

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020