2016年7月23日土曜日

160723(4)

Ruby


An 型フリーズパターンと多角形の三角形分割(3)

8 角形でやってみた。

def A1(ary)
  m = ary.size
  a_ary = [ary]
  p a_ary[0]
  i = 0
  while i == 0 || a_ary[i] != ary
    a_ary << Array.new(m, 1)
    (m - 2).downto(1){|j| a_ary[i + 1][j] = (a_ary[i][j - 1] * a_ary[i + 1][j + 1] + 1) / a_ary[i][j]}
    p a_ary[i + 1]
    i += 1
  end
  a_ary.uniq!
end

p 8
a = []
[[1, 1, 1, 1, 1, 1, 1],
 [1, 2, 1, 1, 1, 2, 1],
 [1, 1, 1, 2, 1, 1, 1],
 [1, 2, 1, 2, 1, 2, 1],
 [1, 5, 4, 3, 2, 1, 1],
 [1, 1, 2, 3, 4, 5, 1],
 [1, 1, 2, 3, 1, 1, 1],
 [1, 1, 1, 3, 2, 1, 1],
 [1, 1, 1, 1, 2, 1, 1],
 [1, 1, 2, 1, 1, 1, 1],
 [1, 1, 2, 1, 1, 2, 1],
 [1, 2, 1, 1, 2, 1, 1],
 [1, 1, 1, 1, 2, 3, 1],
 [1, 3, 2, 1, 1, 1, 1],
 [1, 2, 1, 1, 2, 3, 1],
 [1, 3, 2, 1, 1, 2, 1],
 [1, 2, 3, 1, 1, 1, 1],
 [1, 1, 1, 1, 3, 2, 1],
 [1, 1, 2, 1, 2, 1, 1]].each{|i|
  a += A1(i)
  p ""
}
p "#{a.uniq.size} = 8 * 14 + 4 * 5"

出力結果
8
[1, 1, 1, 1, 1, 1, 1]
[1, 6, 5, 4, 3, 2, 1]
[1, 1, 5, 4, 3, 2, 1]
[1, 2, 1, 4, 3, 2, 1]
[1, 2, 3, 1, 3, 2, 1]
[1, 2, 3, 4, 1, 2, 1]
[1, 2, 3, 4, 5, 1, 1]
[1, 2, 3, 4, 5, 6, 1]
[1, 1, 1, 1, 1, 1, 1]
""
[1, 2, 1, 1, 1, 2, 1]
[1, 4, 7, 3, 2, 1, 1]
[1, 2, 7, 12, 5, 3, 1]
[1, 1, 1, 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