Skip to content

kclee04/Lo-Shu-Magic-Square

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Lo-Shu-Magic-Square

Lo Shu Magic Square Quiz using C:

Lo Shu Magic Square is a 3x3 grid that contains the following properties:

  • the numbers 1-9
  • none of the numbers repeat
  • the sum of each column, row, and diagonal equals 15

Source: https://media.cheggcdn.com/media/fdf/s614x654/fdf794e4-627d-41d6-9e0d-4bf4fd70388f/phpEUzytT.png


Functions:

  • Generate a random 3x3 square without repeated numbers
  • Test if the square is magic
  • Print out the square in the following format:
    [ 1 2 3 ]
    [ 4 5 6 ]
    [ 7 8 9 ]
  • Continuously generate till a magic square is found. Output:
    Attempt: 43890
    Magic square found!
    [ 4 9 2 ]
    [ 3 5 7 ]
    [ 8 1 6 ]
    Note: If you want to test the other functions by themselves, I recommend uncommenting some of the test cases under main in magicMain.c

About

Lo Shu Magic Square Quiz

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages