Pythonで「四角に切れ」を解く>長方形のサイズ
#! /usr/bin/env python
# -*- coding: utf-8 -*-
FList = [\
[],
[(1,1)],
[(1,2),(2,1)],
[(1,3),(3,1)],
[(1,4),(2,2),(4,1)],
[(1,5),(5,1)],
[(1,6),(2,3),(3,2),(6,1)],
[(1,7),(7,1)],
[(1,8),(2,4),(4,2),(8,1)],
[(1,9),(3,3),(9,1)],
[(1,10),(2,5),(5,2),(10,1)],
[(1,11),(11,1)],
[(1,12),(2,6),(3,4),(4,3),(6,2),(12,1)],
[(1,13),(13,1)],
[(1,14),(2,7),(7,2),(14,1)],
[(1,15),(3,5),(5,3),(15,1)],
[(1,16),(2,8),(4,4),(8,2),(16,1)],
[(1,17),(17,1)],
[(1,18),(2,9),(3,6),(6,3),(9,2),(18,1)],
[(1,19),(19,1)],
[(1,20),(2,10),(4,5),(5,4),(10,2),(20,1)],
[(1,21),(3,7),(7,3),(21,1)],
[(1,22),(2,11),(11,2),(22,1)],
[(1,23),(23,1)],
[(1,24),(2,12),(3,8),(4,6),(6,4),(8,3),(12,2),(24,1)],
[(1,25),(5,5),(25,1)],
[(1,26),(2,13),(13,2),(26,1)],
[(1,27),(3,9),(9,3),(27,1)],
[(1,28),(2,14),(4,7),(7,4),(14,2),(28,1)],
[(1,29),(29,1)],
[(1,30),(2,15),(3,10),(5,6),(6,5),(10,3),(15,2),(30,1)],
[(1,31),(31,1)],
[(1,32),(2,16),(4,8),(8,4),(16,2),(32,1)],
[(1,33),(3,11),(11,3),(33,1)],
[(1,34),(2,17),(17,2),(34,1)],
[(1,35),(5,7),(7,5),(35,1)],
[(1,36),(2,18),(3,12),(4,9),(6,6),(9,4),(12,3),(18,2),(36,1)],
[(1,37),(37,1)],
[(1,38),(2,19),(19,2),(38,1)],
[(1,39),(3,13),(13,3),(39,1)],
[(1,40),(2,20),(4,10),(5,8),(8,5),(10,4),(20,2),(40,1)],
[(1,41),(41,1)],
[(1,42),(2,21),(3,14),(6,7),(7,6),(14,3),(21,2),(42,1)],
[(1,43),(43,1)],
[(1,44),(2,22),(4,11),(11,4),(22,2),(44,1)],
[(1,45),(3,15),(5,9),(9,5),(15,3),(45,1)],
[(1,46),(2,23),(23,2),(46,1)],
[(1,47),(47,1)],
[(1,48),(2,24),(3,16),(4,12),(6,8),(8,6),(12,4),(16,3),(24,2),(48,1)],
[(1,49),(7,7),(49,1)],
[(1,50),(2,25),(5,10),(10,5),(25,2),(50,1)],
[(1,51),(3,17),(17,3),(51,1)],
[(1,52),(2,26),(4,13),(13,4),(26,2),(52,1)],
[(1,53),(53,1)],
[(1,54),(2,27),(3,18),(6,9),(9,6),(18,3),(27,2),(54,1)],
[(1,55),(5,11),(11,5),(55,1)],
[(1,56),(2,28),(4,14),(7,8),(8,7),(14,4),(28,2),(56,1)],
[(1,57),(3,19),(19,3),(57,1)],
[(1,58),(2,29),(29,2),(58,1)],
[(1,59),(59,1)],
[(1,60),(2,30),(3,20),(4,15),(5,12),(6,10),(10,6),(12,5),(15,4),(20,3),(30,2),(60,1)],
[(1,61),(61,1)],
[(1,62),(2,31),(31,2),(62,1)],
[(1,63),(3,21),(7,9),(9,7),(21,3),(63,1)],
[(1,64),(2,32),(4,16),(8,8),(16,4),(32,2),(64,1)],
[(1,65),(5,13),(13,5),(65,1)],
[(1,66),(2,33),(3,22),(6,11),(11,6),(22,3),(33,2),(66,1)],
[(1,67),(67,1)],
[(1,68),(2,34),(4,17),(17,4),(34,2),(68,1)],
[(1,69),(3,23),(23,3),(69,1)],
[(1,70),(2,35),(5,14),(7,10),(10,7),(14,5),(35,2),(70,1)],
[(1,71),(71,1)],
[(1,72),(2,36),(3,24),(4,18),(6,12),(8,9),(9,8),(12,6),(18,4),(24,3),(36,2),(72,1)],
[(1,73),(73,1)],
[(1,74),(2,37),(37,2),(74,1)],
[(1,75),(3,25),(5,15),(15,5),(25,3),(75,1)],
[(1,76),(2,38),(4,19),(19,4),(38,2),(76,1)],
[(1,77),(7,11),(11,7),(77,1)],
[(1,78),(2,39),(3,26),(6,13),(13,6),(26,3),(39,2),(78,1)],
[(1,79),(79,1)],
[(1,80),(2,40),(4,20),(5,16),(8,10),(10,8),(16,5),(20,4),(40,2),(80,1)],
[(1,81),(3,27),(9,9),(27,3),(81,1)],
[(1,82),(2,41),(41,2),(82,1)],
[(1,83),(83,1)],
[(1,84),(2,42),(3,28),(4,21),(6,14),(7,12),(12,7),(14,6),(21,4),(28,3),(42,2),(84,1)],
[(1,85),(5,17),(17,5),(85,1)],
[(1,86),(2,43),(43,2),(86,1)],
[(1,87),(3,29),(29,3),(87,1)],
[(1,88),(2,44),(4,22),(8,11),(11,8),(22,4),(44,2),(88,1)],
[(1,89),(89,1)],
[(1,90),(2,45),(3,30),(5,18),(6,15),(9,10),(10,9),(15,6),(18,5),(30,3),(45,2),(90,1)],
[(1,91),(7,13),(13,7),(91,1)],
[(1,92),(2,46),(4,23),(23,4),(46,2),(92,1)],
[(1,93),(3,31),(31,3),(93,1)],
[(1,94),(2,47),(47,2),(94,1)],
[(1,95),(5,19),(19,5),(95,1)],
[(1,96),(2,48),(3,32),(4,24),(6,16),(8,12),(12,8),(16,6),(24,4),(32,3),(48,2),(96,1)],
[(1,97),(97,1)],
[(1,98),(2,49),(7,14),(14,7),(49,2),(98,1)],
[(1,99),(3,33),(9,11),(11,9),(33,3),(99,1)],
]
0〜99の範囲で、数字に対して長方形の縦横の長さの表です。
巨大なパズルが出されると99以上の数字が設定される可能性はありますが、ほぼないでしょうから、これでよしとします。
Pythonは、1行が長すぎて途中で改行する場合、改行前に"\"を入れる必要があります。
が、リストの途中など入れなくてもいい場合があります。
こういった例外、どこで出てくるか、よくわかりません。
戻る |