Thank you so much. This tutorial is the best. I would like to add just a little thing; The transpose of the magic square matrix follows the same properties discussed at the beginning of the video.
Hello... to try other video with good explain, also can you to download Excel file to resolve Square Magic 3x3 and 5x5. To Find on TH-cam as: Creación Cuadrado Mágico lado impar - Creating Magic Square odd side.
This algorithm is incorrect as it does not fully map the domain for magic squares {x ∈ Z : x > 2} (the set of all integers greater than 2). Instead, it maps {2x + 1 : x ∈ Z : x > 0} (the set of all positive odd integers), which is _half_ of the problem domain. The title and premise of this video, on the other hand, incorrectly state that the domain is the expected {x ∈ Z : x > 2}. A good programmer does not implement only half of a solution. Imagine if Windows only did _half_ of what you need it to do. Imagine if your favorite game ended abruptly at the _halfway_ point. Imagine if your OS kernel only allocated _half_ of the resources you requested. Imagine if the write syscall only wrote _half_ of the text you put in. Imagine if your lazy employee only did _half_ of the work you assigned to them. Oh wait, you're already doing that. I wouldn't even be criticizing you if the title wasn't misleading. That said, click here to see my implementation: gist.github.com/bradenbest/af3c83230e11cf1b5aaeb05598398df6 Not only did I fully (as of this edit) implement the problem domain (it works with any n > 2 that doesn't overflow when n^2 or n(n^2+1)/2 are applied), but I did it using a 1 dimensional array. That might seem crazy, but 1D arrays afford a lot of advantages over 2D arrays, especially when it comes to filling, copying and allocating space for them. The 4n + 2 orders were the most complicated to implement. I based my algorithm on this article: www.1728.org/magicsq3.htm
Also, rules iii. and iv. are overcomplicating things. The index can be expressed as `(n + i) mod n` where i is the index. Where n = 3 and % represents modulo division... (n + -3) % n = 0 % 3 = 0 (n + -2) % n = 1 % 3 = 1 (n + -1) % n = 2 % 3 = 2 (n + 0) % n = 3 % 3 = 0 (n + 1) % n = 4 % 3 = 1 (n + 2) % n = 5 % 3 = 2 (n + 3) % n = 6 % 3 = 0 As you can see, the expression correctly maps each value such that it "wraps" in both directions.
rotation, reverse and mirroring. The same rule is available for left-top shifts,right-bottom and left-bottom shifts as well as the top-right shifts shown in this video.
Hi... to review other video, also can you to download Excel file to resolve Square Magic 3x3 and 5x5. To Find on TH-cam as: Creación Cuadrado Mágico lado impar - Creating Magic Square odd side. Grettings.
surely you mean "magic square of order 4", not "4-dimensional matrix", which means something completely different. en.wikipedia.org/wiki/File:Double-even_magic_construction.png www.math.wichita.edu/~richardson/mathematics/magic%20squares/even-ordermagicsquares.html
Using your formula for creating magic squares, I feel it is possible to derive the magic sum. Can you show the same ?! Another clarification i have is, what happens if the common difference between subsequent numbers is more than one ?? And, how will the formula for the magic sum be affected if the common difference is more than one ??
I guess for those even-degree cases, the four adjustment cases have some recursion relationship, for example when we violate the 4th case, then i++, j-=2, then we violate 1st, or 2nd case again. Perhaps we need to recursively check the violation until we get a full valid (i, j). Just a guess...
thank you sir.your teaching skills are amazing.can you please upload video of converting binary tree to sum tree only if values are greater for the relevant node ? recursivley ? it is very confuse . thank you
0 1 2 3 0 8 3 9 14 34 1 2 12 13 7 34 2 11 16 6 1 34 3 15 5 4 10 34 58 36 36 32 32 36 With the given rule, I have created this magic square. But all sum is not same. Kindly correct me if I am wrong.
So I'm curious how does "3 by 2 equal 1" 3 minus 2 is 1 but he has a division symbol and 3 divided by 2 is 1.5, not 1. Can someone help me understand this??
sir, undoubtedly, algorithm explained by you is appreciabble. i am facing problem while costructiong a magic sq. of order 4........ as entry is becoming (2,-2).......what to do at this point ,,,,,,,,,
Thank you so much. This tutorial is the best. I would like to add just a little thing; The transpose of the magic square matrix follows the same properties discussed at the beginning of the video.
This was an amazing explanation, thank you!! also the clockwise and counterclockwise visualization helps to memorize the approach to this problem
one question why is does n equal 3 ?
@@elianarthur6553 n is numeber of row and columns
thank you soo much for your help, i've been searching for someone who can explain it like you. thx
Hello... to try other video with good explain, also can you to download Excel file to resolve Square Magic 3x3 and 5x5. To Find on TH-cam as: Creación Cuadrado Mágico lado impar - Creating Magic Square odd side.
This is a really great video. I really hope that teachers in highschools explained this well. Thank you.
You have explained this method in a very simple and understanding way, thank you so much Mr
Thank you for amazing explanation. Your teaching skill is very good.
Well done, sir! And many thanks. Subscribed!
I tried the algorithm and it is very well explained(it runs). and I did it 100% ... keep it up
thank teacher, i from VietNam. This video very useful, i love it
This algorithm is incorrect as it does not fully map the domain for magic squares {x ∈ Z : x > 2} (the set of all integers greater than 2). Instead, it maps {2x + 1 : x ∈ Z : x > 0} (the set of all positive odd integers), which is _half_ of the problem domain. The title and premise of this video, on the other hand, incorrectly state that the domain is the expected {x ∈ Z : x > 2}. A good programmer does not implement only half of a solution. Imagine if Windows only did _half_ of what you need it to do. Imagine if your favorite game ended abruptly at the _halfway_ point. Imagine if your OS kernel only allocated _half_ of the resources you requested. Imagine if the write syscall only wrote _half_ of the text you put in. Imagine if your lazy employee only did _half_ of the work you assigned to them. Oh wait, you're already doing that.
I wouldn't even be criticizing you if the title wasn't misleading.
That said, click here to see my implementation: gist.github.com/bradenbest/af3c83230e11cf1b5aaeb05598398df6
Not only did I fully (as of this edit) implement the problem domain (it works with any n > 2 that doesn't overflow when n^2 or n(n^2+1)/2 are applied), but I did it using a 1 dimensional array.
That might seem crazy, but 1D arrays afford a lot of advantages over 2D arrays, especially when it comes to filling, copying and allocating space for them.
The 4n + 2 orders were the most complicated to implement. I based my algorithm on this article: www.1728.org/magicsq3.htm
Also, rules iii. and iv. are overcomplicating things. The index can be expressed as `(n + i) mod n` where i is the index.
Where n = 3 and % represents modulo division...
(n + -3) % n = 0 % 3 = 0
(n + -2) % n = 1 % 3 = 1
(n + -1) % n = 2 % 3 = 2
(n + 0) % n = 3 % 3 = 0
(n + 1) % n = 4 % 3 = 1
(n + 2) % n = 5 % 3 = 2
(n + 3) % n = 6 % 3 = 0
As you can see, the expression correctly maps each value such that it "wraps" in both directions.
You have made it easier to program in computer language. Thank you for that.
Wow what a clear explanation 🙏🙏👍👍👍👍👍👍 super super sir 👍👍👍👍
Thank you for that very detailed and very precise explanation!
Explanation was really good BUT ...........my interest is to know keenly that how you deduce to reach upto this algo///////
He is following a book, Introduction to Algorithm
@@Justdailylife Hi. Author of the book?
gfg
@@guillermodarioacostacabrer2291 CLRS
Thanks a lot sir ji , I have learn lot of thing from your channel
sir please do a video on algorithm of magic square of even order(eg 4,6,8,etc).
The magic matrix only exist for odd values of n.
Sir you are teaching simple things in hard manner
thank you very much for such a good and detailed explanation sir.
Sir. Very very Tq for this one am not having any word to explain about my happiness tqtqqqq
For a 3x3 matrix there will be 8 magic squares ,you just explained how to make one.What about the other 7 magic squares?
rotation, reverse and mirroring. The same rule is available for left-top shifts,right-bottom and left-bottom shifts as well as the top-right shifts shown in this video.
Better presentation and eye contact makes it more interesting.
Thanks bro, well expalined.....
Brilliant Algorithm and explanation!
Thank you for the perfect explanation 🙏🏻
Hi... to review other video, also can you to download Excel file to resolve Square Magic 3x3 and 5x5. To Find on TH-cam as: Creación Cuadrado Mágico lado impar - Creating Magic Square odd side. Grettings.
God bless you my friend
This video was very helpful. Thank you so much.
Superb sir . U r a genius
You are a great Teacher. Thank you. Please do a video on dijkstra's algorithm.
Beautiful explanation. Thanks for the useful information
Awesome explanation sir
nice job bro. It helps me a lot
thanks ,but this algorithm do not working with 4×4
Yes.
I also want to know why
This is only for odd order, not an Even order
Very well explained, thank you!
This was so good, thank you
Loved the video
It is not working for four dimensional matrix please suggest how to do it for 4 dimensional matrix
surely you mean "magic square of order 4", not "4-dimensional matrix", which means something completely different.
en.wikipedia.org/wiki/File:Double-even_magic_construction.png
www.math.wichita.edu/~richardson/mathematics/magic%20squares/even-ordermagicsquares.html
it is for only odd
my question now is where did the formulas come from
Awesome explanation....
Using your formula for creating magic squares, I feel it is possible to derive the magic sum. Can you show the same ?! Another clarification i have is, what happens if the common difference between subsequent numbers is more than one ?? And, how will the formula for the magic sum be affected if the common difference is more than one ??
This technic doesn't support to even number order magic squares such as 4 X 4, 6 X 6 and etc. can you post for the even number order magic squares.
yes this shit is not working.
@@buddhaeyes you could give some respect for his effort.
I guess for those even-degree cases, the four adjustment cases have some recursion relationship, for example when we violate the 4th case, then i++, j-=2, then we violate 1st, or 2nd case again. Perhaps we need to recursively check the violation until we get a full valid (i, j). Just a guess...
Thanks for your explanation first
but this only works with odd n values, not for even values,
can you make a video on that?
is this algorithm works on 4x4, 5x5?
I have felt this method very as a complicated one.
Well done I hope you will do more good video like this thanks.
Sir try it for 4x4 squares it is not working for 4x4 squares
Very instructive🤔🤔
It will really helpful 👍
HND A Class best class
Only works for the odd squares. Misleading Title.
thank you sir.your teaching skills are amazing.can you please upload video of converting binary tree to sum tree only if values are greater for the relevant node ? recursivley ? it is very confuse . thank you
Nicely explained
Sir please post a video on how to check a magic square
Nice one. Keep making videos like this....
Nice explanation!!!
that was great thank you
Very nice sir
0 1 2 3
0 8 3 9 14 34
1 2 12 13 7 34
2 11 16 6 1 34
3 15 5 4 10 34
58 36 36 32 32 36
With the given rule, I have created this magic square. But all sum is not same. Kindly correct me if I am wrong.
Thank you Vivekanand for the explaination. How did you conclude these formula's?
great explanation!thanks
If im using bfs or dfs can i consider every move a relative(the moves in this video) like (i,j) to (i-1)(j+1)
how do i come with with this from basic brute force solution?
Nice tutorial.
But Explain how you got those steps too
Geeks for geeks but u can't understand by seeing it
This method not working 4*4
Can you give some examples of 4x4 and 5x5 algi=orithm. I think there is some problem in the given algorithm for 4x4 magic square.
very helpful.. Thank you
this is awesome
sir tell me the code if position is occupied...plz... i hope you give the answer shortly
Sir please make a video on how to construct a magic cube of order 3x3x3.
nice explanation
Ok, so I have to pick upper right cell to write next number and if that cell is occupied then pick left cell instead to write next number. Nice.
What is the theory behind it
It is for finding the sum of 15 from all sides will u please tell me that how to make a magic square to get the sum of 45 or 47.
thank you for all
Thank you so much
Best video
thanks very much sir.please explain the code for rotation of matrix.
good sir.will u please make a video on printing all subarray integers in an Array
Please make a video on Page Ranking Algorithm
Share 4 by 4 matrix
Is the video of 4×4 matrix available?
If so please send.
It's not possible to create a magic square of any number except prime.
All the best👍🏻
Thanks a lot.
4:30 how 3/2 is 1?
3/2 isn't 1.5?
division of integer
@@b-designer 👍yup..Thank you bro..
@@AjayKumar-ls8oi u'r welcm
So I'm curious how does "3 by 2 equal 1" 3 minus 2 is 1 but he has a division symbol and 3 divided by 2 is 1.5, not 1. Can someone help me understand this??
Bro we using integer key word that can take only real numbers so 0.5 is neglated
@@yuvarajyv5772 Can take only integers
Who made these rules.
please explain the algorithm how u make these rules
if we have a square 5x5 what is the position for 7 ? I've got (0;0) However 2 already has (0;0) That means 7 has (1;-2) ?
sir please make more videos daily
Excelente... muchas gracias...
Thanks v much
sir, undoubtedly, algorithm explained by you is appreciabble. i am facing problem while costructiong a magic sq. of order 4........
as entry is becoming (2,-2).......what to do at this point ,,,,,,,,,
and one more thingwhn i m matching with the available magic sq., the starting point itself is not correct
@@rahulkumargupta1718 there is no unique magick square
@@rahulkumargupta1718 and algorithm i is only for odd order matrix
Great
Magic square would have explained still better. And this is not the only method. There are more than ten programmable methods.
What is other method will you give please 🥺
This will not work if N is even !!
Thank you
Thank u sir
Thanks. Jai Hind.
I want this code
This is the common method for odd squares, but it doesn't work for even squares.
Tq sir
iska code kha hain
sir can u send the answer for square matrix -4,1,6,3,-1,-5,2,-3,2 for using these numbers