順列生成アルゴリズムによる魔方陣の総当たり探索

Round robin search of magic square by permutation generation algorithm


本稿では順列生成アルゴリズムを作成し、その応用例として魔方陣の総当たり探索を行った。 順列生成アルゴリズムの作成については、数々のウェブページで紹介されているが、 そのほとんどが再帰関数によって作られている。 本稿では再帰関数を用いずに順列の生成を行う方法を考える。

In this report, I made permutation generation algorithm and searched the magic square by round robin method as the applied example. The making of the permutation generation algorithm is introduced in many web pages, but the most are made by recursive function. Therefore, I tried to make the permutation generation algorithm without recursive function.


now printing

図1 順列と魔方陣行列の対応
now printing

図2 魔方陣(4×4)
now printing

図3 組み合わせ爆発のおねえさん
(日本科学未来館「フカシギの数え方」より引用)

  • 本文(PDF DATA)
  • プログラム(SOURCE CODE)
  • 魔方陣(4×4)(1)(SOLUTION-1)
  • 魔方陣(4×4)(2)(SOLUTION-2)
  • 魔方陣(4×4)(3)(SOLUTION-3)
  • 魔方陣(4×4)(4)(SOLUTION-4)


  • 一人の科学トップページ(TOP PAGE)