2020年3月24日火曜日

200324

Python


A140517等

Graphillion を使って計算してみた。

from graphillion import GraphSet
import graphillion.tutorial as tl

def A(points, n):
    if n == 1: return 1
    universe = tl.grid(n - 1, n - 1)
    GraphSet.set_universe(universe)
    cycles = GraphSet.cycles()
    for i in points:
        cycles = cycles.including(i)
    return cycles.len()

print([A([                            ], n) for n in range(2, 10)])

print([A([1                           ], n) for n in range(2, 10)])

print([A([1, n                        ], n) for n in range(2, 10)])
print([A([1,    n * (n - 1) + 1       ], n) for n in range(2, 10)])
print([A([1,                     n * n], n) for n in range(2, 10)])

print([A([1, n, n * (n - 1) + 1       ], n) for n in range(2, 10)])

print([A([1, n, n * (n - 1) + 1, n * n], n) for n in range(2, 10)])

出力結果
[1, 13, 213, 9349, 1222363, 487150371, 603841648931, 2318527339461265]
[1, 7, 97, 4111, 532269, 212372937, 263708907211, 1013068026356375]
[1, 4, 47, 1843, 232905, 92729439, 115234959344, 442748883422394]
[1, 4, 47, 1843, 232905, 92729439, 115234959344, 442748883422394]
[1, 3, 42, 1799, 232094, 92617031, 115156685746, 442641690778179]
[1, 2, 22, 822, 102052, 40504068, 50350960560, 193492369367420]
[1, 1, 11, 373, 44930, 17720400, 22013629316, 84579095455492]

0 件のコメント:

コメントを投稿

注: コメントを投稿できるのは、このブログのメンバーだけです。