Magic Square Construction Algorithm N × N

แชร์
ฝัง
  • เผยแพร่เมื่อ 19 ต.ค. 2024

ความคิดเห็น • 146

  • @mohamedatef3526
    @mohamedatef3526 3 ปีที่แล้ว +3

    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.

  • @giannizamora7247
    @giannizamora7247 3 ปีที่แล้ว +5

    This was an amazing explanation, thank you!! also the clockwise and counterclockwise visualization helps to memorize the approach to this problem

    • @elianarthur6553
      @elianarthur6553 2 ปีที่แล้ว

      one question why is does n equal 3 ?

    • @abdullahiabdislaan
      @abdullahiabdislaan 2 ปีที่แล้ว

      @@elianarthur6553 n is numeber of row and columns

  • @b-designer
    @b-designer 3 ปีที่แล้ว +3

    thank you soo much for your help, i've been searching for someone who can explain it like you. thx

    • @cesarl.c.847
      @cesarl.c.847 3 ปีที่แล้ว

      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.

  • @patricepavelus4534
    @patricepavelus4534 2 ปีที่แล้ว

    This is a really great video. I really hope that teachers in highschools explained this well. Thank you.

  • @BradenBest
    @BradenBest 5 ปีที่แล้ว +12

    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

    • @BradenBest
      @BradenBest 5 ปีที่แล้ว +2

      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.

  • @personanongrata7976
    @personanongrata7976 5 หลายเดือนก่อน +1

    Well done, sir! And many thanks. Subscribed!

  • @muralinagarajan8305
    @muralinagarajan8305 10 หลายเดือนก่อน

    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 ??

  • @nhlamuloreply5342
    @nhlamuloreply5342 3 ปีที่แล้ว +3

    You have explained this method in a very simple and understanding way, thank you so much Mr

  • @SivaKumar-sw6fb
    @SivaKumar-sw6fb ปีที่แล้ว

    Thank you for amazing explanation. Your teaching skill is very good.

  • @amanwehib8367
    @amanwehib8367 2 ปีที่แล้ว

    You have made it easier to program in computer language. Thank you for that.

  • @sarthakkar5130
    @sarthakkar5130 6 ปีที่แล้ว +9

    For a 3x3 matrix there will be 8 magic squares ,you just explained how to make one.What about the other 7 magic squares?

    • @santhanam2855
      @santhanam2855 6 ปีที่แล้ว +2

      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.

  • @Ankit13555
    @Ankit13555 6 ปีที่แล้ว +17

    Explanation was really good BUT ...........my interest is to know keenly that how you deduce to reach upto this algo///////

  • @kiliankiel1250
    @kiliankiel1250 4 ปีที่แล้ว +2

    Thank you for that very detailed and very precise explanation!

  • @nhanthien36
    @nhanthien36 2 ปีที่แล้ว

    thank teacher, i from VietNam. This video very useful, i love it

  • @VishnuKumar-fo2rl
    @VishnuKumar-fo2rl ปีที่แล้ว

    Thanks for your explanation first
    but this only works with odd n values, not for even values,
    can you make a video on that?

  • @jmvarquez
    @jmvarquez 5 ปีที่แล้ว +2

    I tried the algorithm and it is very well explained(it runs). and I did it 100% ... keep it up

  • @ChanchalDass
    @ChanchalDass ปีที่แล้ว

    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.

  • @saruncse85
    @saruncse85 4 ปีที่แล้ว

    Thank you Vivekanand for the explaination. How did you conclude these formula's?

  • @reelsofharshitha3742
    @reelsofharshitha3742 3 ปีที่แล้ว +1

    is this algorithm works on 4x4, 5x5?

  • @77YuvrajSingh77
    @77YuvrajSingh77 4 ปีที่แล้ว +9

    sir please do a video on algorithm of magic square of even order(eg 4,6,8,etc).

    • @sehajdhawan6619
      @sehajdhawan6619 3 ปีที่แล้ว

      The magic matrix only exist for odd values of n.

  • @ChanchalDass
    @ChanchalDass ปีที่แล้ว

    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.

  • @surajtopal9940
    @surajtopal9940 3 ปีที่แล้ว

    Thanks a lot sir ji , I have learn lot of thing from your channel

  • @zehrxsyed
    @zehrxsyed 4 ปีที่แล้ว +1

    thank you very much for such a good and detailed explanation sir.

  • @ck4721
    @ck4721 2 ปีที่แล้ว

    Wow what a clear explanation 🙏🙏👍👍👍👍👍👍 super super sir 👍👍👍👍

  • @mrkhunt.
    @mrkhunt. 4 ปีที่แล้ว

    Brilliant Algorithm and explanation!

  • @thayaparanselladurai3731
    @thayaparanselladurai3731 6 ปีที่แล้ว +4

    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.

    • @buddhaeyes
      @buddhaeyes 5 ปีที่แล้ว

      yes this shit is not working.

    • @gorgenyilmaz8711
      @gorgenyilmaz8711 4 ปีที่แล้ว +1

      @@buddhaeyes you could give some respect for his effort.

    • @Alexander-io5pl
      @Alexander-io5pl 3 ปีที่แล้ว

      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...

  • @CamilaMartinez-vm4bj
    @CamilaMartinez-vm4bj 3 ปีที่แล้ว

    This was so good, thank you

  • @Atrainn234
    @Atrainn234 หลายเดือนก่อน

    my question now is where did the formulas come from

  • @biswajeet9826
    @biswajeet9826 3 ปีที่แล้ว

    Better presentation and eye contact makes it more interesting.

  • @adnanalkarfan2277
    @adnanalkarfan2277 3 ปีที่แล้ว

    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)

  • @niliba6194
    @niliba6194 4 ปีที่แล้ว +1

    Thank you for the perfect explanation 🙏🏻

    • @cesarl.c.847
      @cesarl.c.847 3 ปีที่แล้ว

      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.

  • @MarkGameDesign
    @MarkGameDesign 2 ปีที่แล้ว

    Very well explained, thank you!

  • @radhakrishna4364
    @radhakrishna4364 ปีที่แล้ว +1

    Sir try it for 4x4 squares it is not working for 4x4 squares

  • @aminhadidchi2817
    @aminhadidchi2817 5 ปีที่แล้ว +4

    thanks ,but this algorithm do not working with 4×4

  • @himanshukhare9285
    @himanshukhare9285 6 ปีที่แล้ว +4

    It is not working for four dimensional matrix please suggest how to do it for 4 dimensional matrix

    • @BradenBest
      @BradenBest 5 ปีที่แล้ว

      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

    • @areebahmadsiddiqui2648
      @areebahmadsiddiqui2648 5 ปีที่แล้ว

      it is for only odd

  • @abdullahiabdislaan
    @abdullahiabdislaan 2 ปีที่แล้ว

    Thanks bro, well expalined.....

  • @ravideshmukh33
    @ravideshmukh33 3 ปีที่แล้ว

    Sir you are teaching simple things in hard manner

  • @opethfloyd9429
    @opethfloyd9429 4 ปีที่แล้ว

    This video was very helpful. Thank you so much.

  • @7736385759
    @7736385759 2 ปีที่แล้ว

    I have felt this method very as a complicated one.

  • @____phenixx_____
    @____phenixx_____ 3 ปีที่แล้ว

    Sir. Very very Tq for this one am not having any word to explain about my happiness tqtqqqq

  • @airineivlad6559
    @airineivlad6559 3 ปีที่แล้ว +1

    God bless you my friend

  • @jimmywere473
    @jimmywere473 5 ปีที่แล้ว +1

    You are a great Teacher. Thank you. Please do a video on dijkstra's algorithm.

  • @tanjil.ahmmed
    @tanjil.ahmmed 2 ปีที่แล้ว

    Loved the video

  • @MegaCreep1234
    @MegaCreep1234 4 ปีที่แล้ว

    nice job bro. It helps me a lot

  • @sarahhakeam9896
    @sarahhakeam9896 ปีที่แล้ว

    that was great thank you

  • @engrsyedadilsardar6047
    @engrsyedadilsardar6047 5 ปีที่แล้ว

    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.

  • @mordiabukarat3985
    @mordiabukarat3985 6 ปีที่แล้ว +1

    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

  • @pratyakshsaini2870
    @pratyakshsaini2870 3 ปีที่แล้ว

    how do i come with with this from basic brute force solution?

  • @esseandessence4421
    @esseandessence4421 4 ปีที่แล้ว

    What is the theory behind it

  • @ishitaarora439
    @ishitaarora439 4 ปีที่แล้ว

    great explanation!thanks

  • @monikaparmar2061
    @monikaparmar2061 4 ปีที่แล้ว +1

    Only works for the odd squares. Misleading Title.

  • @jorawarsanghi1266
    @jorawarsanghi1266 2 ปีที่แล้ว

    Who made these rules.

  • @shivamtyagi3554
    @shivamtyagi3554 4 ปีที่แล้ว

    sir tell me the code if position is occupied...plz... i hope you give the answer shortly

  • @whitegalactico7152
    @whitegalactico7152 4 ปีที่แล้ว

    Superb sir . U r a genius

  • @AjayKumar-ls8oi
    @AjayKumar-ls8oi 3 ปีที่แล้ว +1

    4:30 how 3/2 is 1?
    3/2 isn't 1.5?

    • @b-designer
      @b-designer 3 ปีที่แล้ว +1

      division of integer

    • @AjayKumar-ls8oi
      @AjayKumar-ls8oi 3 ปีที่แล้ว

      @@b-designer 👍yup..Thank you bro..

    • @b-designer
      @b-designer 3 ปีที่แล้ว +1

      @@AjayKumar-ls8oi u'r welcm

  • @rhytham5427
    @rhytham5427 5 ปีที่แล้ว +1

    Sir please post a video on how to check a magic square

  • @hemanthkommaraju1888
    @hemanthkommaraju1888 6 ปีที่แล้ว

    good sir.will u please make a video on printing all subarray integers in an Array

  • @adarshgupta106
    @adarshgupta106 3 ปีที่แล้ว

    Awesome explanation sir

  • @sayantanray9595
    @sayantanray9595 4 ปีที่แล้ว

    Nice explanation!!!

  • @abhishekdeepu2003
    @abhishekdeepu2003 4 ปีที่แล้ว

    Sir please make a video on how to construct a magic cube of order 3x3x3.

  • @narayananseshagirirao2569
    @narayananseshagirirao2569 5 ปีที่แล้ว

    Beautiful explanation. Thanks for the useful information

  • @ramyaj3637
    @ramyaj3637 4 ปีที่แล้ว

    Awesome explanation....

  • @falconhomefalconhome3784
    @falconhomefalconhome3784 5 ปีที่แล้ว

    Well done I hope you will do more good video like this thanks.

  • @rahulkumargupta1718
    @rahulkumargupta1718 5 ปีที่แล้ว

    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 ,,,,,,,,,

    • @rahulkumargupta1718
      @rahulkumargupta1718 5 ปีที่แล้ว

      and one more thingwhn i m matching with the available magic sq., the starting point itself is not correct

    • @ShivaShiva-gj1ib
      @ShivaShiva-gj1ib 4 ปีที่แล้ว

      @@rahulkumargupta1718 there is no unique magick square

    • @ShivaShiva-gj1ib
      @ShivaShiva-gj1ib 4 ปีที่แล้ว

      @@rahulkumargupta1718 and algorithm i is only for odd order matrix

  • @sajidpattakkal1338
    @sajidpattakkal1338 4 ปีที่แล้ว

    Is the video of 4×4 matrix available?
    If so please send.

    • @vikashkumargupta4876
      @vikashkumargupta4876 3 ปีที่แล้ว

      It's not possible to create a magic square of any number except prime.
      All the best👍🏻

  • @geniusjamir9807
    @geniusjamir9807 2 ปีที่แล้ว

    Thank you

  • @mostafashams5280
    @mostafashams5280 3 ปีที่แล้ว

    Thank you so much

  • @SandhyaSingh-zb9sk
    @SandhyaSingh-zb9sk 3 ปีที่แล้ว

    Nicely explained

  • @VeraDongmo-ql1lu
    @VeraDongmo-ql1lu 5 หลายเดือนก่อน

    Very instructive🤔🤔

  • @__DYNAX_Tech__
    @__DYNAX_Tech__ 4 ปีที่แล้ว

    It will really helpful 👍

  • @adityapaithon6499
    @adityapaithon6499 6 ปีที่แล้ว +1

    Nice tutorial.
    But Explain how you got those steps too

    • @abhishekAbhi-rk1li
      @abhishekAbhi-rk1li 5 ปีที่แล้ว

      Geeks for geeks but u can't understand by seeing it

  • @natesh1
    @natesh1 6 ปีที่แล้ว +1

    Nice one. Keep making videos like this....

  • @rocketmik65
    @rocketmik65 2 ปีที่แล้ว +1

    HND A Class best class

  • @selvamani9937
    @selvamani9937 5 ปีที่แล้ว +1

    This method not working 4*4

  • @nsfuntus3698
    @nsfuntus3698 3 ปีที่แล้ว

    this is awesome

  • @koketjosethobja1960
    @koketjosethobja1960 3 ปีที่แล้ว

    Thanks a lot.

  • @hunterofendermen367
    @hunterofendermen367 2 ปีที่แล้ว

    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??

    • @yuvarajyv5772
      @yuvarajyv5772 2 ปีที่แล้ว

      Bro we using integer key word that can take only real numbers so 0.5 is neglated

    • @ChanchalDass
      @ChanchalDass ปีที่แล้ว

      @@yuvarajyv5772 Can take only integers

  • @parulmogre2200
    @parulmogre2200 4 ปีที่แล้ว

    very helpful.. Thank you

  • @menelik1020
    @menelik1020 5 ปีที่แล้ว

    Excelente... muchas gracias...

  • @_inspireverse___
    @_inspireverse___ 4 ปีที่แล้ว

    Very nice sir

  • @abdourashad7555
    @abdourashad7555 3 ปีที่แล้ว

    Thanks v much

  • @tanmaydeo4487
    @tanmaydeo4487 4 ปีที่แล้ว

    Please make a video on Page Ranking Algorithm

  • @prathameshchavan2812
    @prathameshchavan2812 5 ปีที่แล้ว

    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.

  • @yaswanthvysyaraju5319
    @yaswanthvysyaraju5319 6 ปีที่แล้ว

    please explain the algorithm how u make these rules

    • @vitsils6621
      @vitsils6621 6 ปีที่แล้ว

      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) ?

  • @srinidhiii
    @srinidhiii 6 ปีที่แล้ว

    thanks very much sir.please explain the code for rotation of matrix.

  • @amouzoukevo2054
    @amouzoukevo2054 3 ปีที่แล้ว

    thank you for all

  • @scanadith
    @scanadith 3 ปีที่แล้ว

    Great

  • @komalashar6131
    @komalashar6131 5 ปีที่แล้ว +1

    Share 4 by 4 matrix

  • @dhanalakshmisenthilkumar7991
    @dhanalakshmisenthilkumar7991 5 ปีที่แล้ว

    nice explanation

  • @gameelevator1579
    @gameelevator1579 4 ปีที่แล้ว

    Best video

  • @saisrikar7987
    @saisrikar7987 6 ปีที่แล้ว

    sir please make more videos daily

  • @nitishghosh646
    @nitishghosh646 4 ปีที่แล้ว

    Thank u sir

  • @gunachanduappari8983
    @gunachanduappari8983 5 ปีที่แล้ว

    I want this code

  • @dhanalakshmisenthilkumar7991
    @dhanalakshmisenthilkumar7991 5 ปีที่แล้ว

    sir can u send the answer for square matrix -4,1,6,3,-1,-5,2,-3,2 for using these numbers

  • @jobbinejoseph8398
    @jobbinejoseph8398 4 ปีที่แล้ว

    This will not work if N is even !!

  • @johnclawed
    @johnclawed 5 ปีที่แล้ว +1

    This is the common method for odd squares, but it doesn't work for even squares.

  • @JaiChavan
    @JaiChavan 3 ปีที่แล้ว

    Thanks. Jai Hind.

  • @jonchakoyu
    @jonchakoyu 5 ปีที่แล้ว +1

    Magic square would have explained still better. And this is not the only method. There are more than ten programmable methods.

    • @yuvarajyv5772
      @yuvarajyv5772 2 ปีที่แล้ว

      What is other method will you give please 🥺

  • @sarathatchukola4669
    @sarathatchukola4669 4 ปีที่แล้ว

    Tq sir

  • @jahanzaibshahid07
    @jahanzaibshahid07 6 ปีที่แล้ว

    iska code kha hain