***************************************************************************** * www.FindStat.org - The Combinatorial Statistic Finder * * * * Copyright (C) 2019 The FindStatCrew * * * * This information is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * ***************************************************************************** ----------------------------------------------------------------------------- Statistic identifier: St000752 ----------------------------------------------------------------------------- Collection: Integer partitions ----------------------------------------------------------------------------- Description: The Grundy value for the game 'Couples are forever' on an integer partition. Two players alternately choose a part of the partition greater than two, and split it into two parts. The player facing a partition with all parts at most two looses. ----------------------------------------------------------------------------- References: [1] Caines, I., Gates, C., Guy, R. K., Nowakowski, R. J. Unsolved Problems: Periods in Taking and Splitting Games [[MathSciNet:1543453]] ----------------------------------------------------------------------------- Code: @cached_function def statistic(la): """Return the Grundy value of the partition for the game 'couples are forever'. """ def children(la): for i in range(len(la)): p = la[i] if p > 2: mu = la[:i] + la[i+1:] for k in range(1, (p+2)//2): yield Partition(sorted(mu + [p-k, k], reverse=True)) l = [statistic(mu) for mu in children(la)] i = 0 while i in l: i += 1 return i ----------------------------------------------------------------------------- Statistic values: [] => 0 [1] => 0 [2] => 0 [1,1] => 0 [3] => 1 [2,1] => 0 [1,1,1] => 0 [4] => 2 [3,1] => 1 [2,2] => 0 [2,1,1] => 0 [1,1,1,1] => 0 [5] => 0 [4,1] => 2 [3,2] => 1 [3,1,1] => 1 [2,2,1] => 0 [2,1,1,1] => 0 [1,1,1,1,1] => 0 [6] => 1 [5,1] => 0 [4,2] => 2 [4,1,1] => 2 [3,3] => 0 [3,2,1] => 1 [3,1,1,1] => 1 [2,2,2] => 0 [2,2,1,1] => 0 [2,1,1,1,1] => 0 [1,1,1,1,1,1] => 0 [7] => 2 [6,1] => 1 [5,2] => 0 [5,1,1] => 0 [4,3] => 3 [4,2,1] => 2 [4,1,1,1] => 2 [3,3,1] => 0 [3,2,2] => 1 [3,2,1,1] => 1 [3,1,1,1,1] => 1 [2,2,2,1] => 0 [2,2,1,1,1] => 0 [2,1,1,1,1,1] => 0 [1,1,1,1,1,1,1] => 0 [8] => 3 [7,1] => 2 [6,2] => 1 [6,1,1] => 1 [5,3] => 1 [5,2,1] => 0 [5,1,1,1] => 0 [4,4] => 0 [4,3,1] => 3 [4,2,2] => 2 [4,2,1,1] => 2 [4,1,1,1,1] => 2 [3,3,2] => 0 [3,3,1,1] => 0 [3,2,2,1] => 1 [3,2,1,1,1] => 1 [3,1,1,1,1,1] => 1 [2,2,2,2] => 0 [2,2,2,1,1] => 0 [2,2,1,1,1,1] => 0 [2,1,1,1,1,1,1] => 0 [1,1,1,1,1,1,1,1] => 0 [9] => 1 [8,1] => 3 [7,2] => 2 [7,1,1] => 2 [6,3] => 0 [6,2,1] => 1 [6,1,1,1] => 1 [5,4] => 2 [5,3,1] => 1 [5,2,2] => 0 [5,2,1,1] => 0 [5,1,1,1,1] => 0 [4,4,1] => 0 [4,3,2] => 3 [4,3,1,1] => 3 [4,2,2,1] => 2 [4,2,1,1,1] => 2 [4,1,1,1,1,1] => 2 [3,3,3] => 1 [3,3,2,1] => 0 [3,3,1,1,1] => 0 [3,2,2,2] => 1 [3,2,2,1,1] => 1 [3,2,1,1,1,1] => 1 [3,1,1,1,1,1,1] => 1 [2,2,2,2,1] => 0 [2,2,2,1,1,1] => 0 [2,2,1,1,1,1,1] => 0 [2,1,1,1,1,1,1,1] => 0 [1,1,1,1,1,1,1,1,1] => 0 [10] => 2 [9,1] => 1 [8,2] => 3 [8,1,1] => 3 [7,3] => 3 [7,2,1] => 2 [7,1,1,1] => 2 [6,4] => 3 [6,3,1] => 0 [6,2,2] => 1 [6,2,1,1] => 1 [6,1,1,1,1] => 1 [5,5] => 0 [5,4,1] => 2 [5,3,2] => 1 [5,3,1,1] => 1 [5,2,2,1] => 0 [5,2,1,1,1] => 0 [5,1,1,1,1,1] => 0 [4,4,2] => 0 [4,4,1,1] => 0 [4,3,3] => 2 [4,3,2,1] => 3 [4,3,1,1,1] => 3 [4,2,2,2] => 2 [4,2,2,1,1] => 2 [4,2,1,1,1,1] => 2 [4,1,1,1,1,1,1] => 2 [3,3,3,1] => 1 [3,3,2,2] => 0 [3,3,2,1,1] => 0 [3,3,1,1,1,1] => 0 [3,2,2,2,1] => 1 [3,2,2,1,1,1] => 1 [3,2,1,1,1,1,1] => 1 [3,1,1,1,1,1,1,1] => 1 [2,2,2,2,2] => 0 [2,2,2,2,1,1] => 0 [2,2,2,1,1,1,1] => 0 [2,2,1,1,1,1,1,1] => 0 [2,1,1,1,1,1,1,1,1] => 0 [1,1,1,1,1,1,1,1,1,1] => 0 [11] => 3 [10,1] => 2 [9,2] => 1 [9,1,1] => 1 [8,3] => 2 [8,2,1] => 3 [8,1,1,1] => 3 [7,4] => 0 [7,3,1] => 3 [7,2,2] => 2 [7,2,1,1] => 2 [7,1,1,1,1] => 2 [6,5] => 1 [6,4,1] => 3 [6,3,2] => 0 [6,3,1,1] => 0 [6,2,2,1] => 1 [6,2,1,1,1] => 1 [6,1,1,1,1,1] => 1 [5,5,1] => 0 [5,4,2] => 2 [5,4,1,1] => 2 [5,3,3] => 0 [5,3,2,1] => 1 [5,3,1,1,1] => 1 [5,2,2,2] => 0 [5,2,2,1,1] => 0 [5,2,1,1,1,1] => 0 [5,1,1,1,1,1,1] => 0 [4,4,3] => 1 [4,4,2,1] => 0 [4,4,1,1,1] => 0 [4,3,3,1] => 2 [4,3,2,2] => 3 [4,3,2,1,1] => 3 [4,3,1,1,1,1] => 3 [4,2,2,2,1] => 2 [4,2,2,1,1,1] => 2 [4,2,1,1,1,1,1] => 2 [4,1,1,1,1,1,1,1] => 2 [3,3,3,2] => 1 [3,3,3,1,1] => 1 [3,3,2,2,1] => 0 [3,3,2,1,1,1] => 0 [3,3,1,1,1,1,1] => 0 [3,2,2,2,2] => 1 [3,2,2,2,1,1] => 1 [3,2,2,1,1,1,1] => 1 [3,2,1,1,1,1,1,1] => 1 [3,1,1,1,1,1,1,1,1] => 1 [2,2,2,2,2,1] => 0 [2,2,2,2,1,1,1] => 0 [2,2,2,1,1,1,1,1] => 0 [2,2,1,1,1,1,1,1,1] => 0 [2,1,1,1,1,1,1,1,1,1] => 0 [1,1,1,1,1,1,1,1,1,1,1] => 0 [12] => 4 [11,1] => 3 [10,2] => 2 [10,1,1] => 2 [9,3] => 0 [9,2,1] => 1 [9,1,1,1] => 1 [8,4] => 1 [8,3,1] => 2 [8,2,2] => 3 [8,2,1,1] => 3 [8,1,1,1,1] => 3 [7,5] => 2 [7,4,1] => 0 [7,3,2] => 3 [7,3,1,1] => 3 [7,2,2,1] => 2 [7,2,1,1,1] => 2 [7,1,1,1,1,1] => 2 [6,6] => 0 [6,5,1] => 1 [6,4,2] => 3 [6,4,1,1] => 3 [6,3,3] => 1 [6,3,2,1] => 0 [6,3,1,1,1] => 0 [6,2,2,2] => 1 [6,2,2,1,1] => 1 [6,2,1,1,1,1] => 1 [6,1,1,1,1,1,1] => 1 [5,5,2] => 0 [5,5,1,1] => 0 [5,4,3] => 3 [5,4,2,1] => 2 [5,4,1,1,1] => 2 [5,3,3,1] => 0 [5,3,2,2] => 1 [5,3,2,1,1] => 1 [5,3,1,1,1,1] => 1 [5,2,2,2,1] => 0 [5,2,2,1,1,1] => 0 [5,2,1,1,1,1,1] => 0 [5,1,1,1,1,1,1,1] => 0 [4,4,4] => 2 [4,4,3,1] => 1 [4,4,2,2] => 0 [4,4,2,1,1] => 0 [4,4,1,1,1,1] => 0 [4,3,3,2] => 2 [4,3,3,1,1] => 2 [4,3,2,2,1] => 3 [4,3,2,1,1,1] => 3 [4,3,1,1,1,1,1] => 3 [4,2,2,2,2] => 2 [4,2,2,2,1,1] => 2 [4,2,2,1,1,1,1] => 2 [4,2,1,1,1,1,1,1] => 2 [4,1,1,1,1,1,1,1,1] => 2 [3,3,3,3] => 0 [3,3,3,2,1] => 1 [3,3,3,1,1,1] => 1 [3,3,2,2,2] => 0 [3,3,2,2,1,1] => 0 [3,3,2,1,1,1,1] => 0 [3,3,1,1,1,1,1,1] => 0 [3,2,2,2,2,1] => 1 [3,2,2,2,1,1,1] => 1 [3,2,2,1,1,1,1,1] => 1 [3,2,1,1,1,1,1,1,1] => 1 [3,1,1,1,1,1,1,1,1,1] => 1 [2,2,2,2,2,2] => 0 [2,2,2,2,2,1,1] => 0 [2,2,2,2,1,1,1,1] => 0 [2,2,2,1,1,1,1,1,1] => 0 [2,2,1,1,1,1,1,1,1,1] => 0 [2,1,1,1,1,1,1,1,1,1,1] => 0 [1,1,1,1,1,1,1,1,1,1,1,1] => 0 [5,4,3,1] => 3 [5,4,2,2] => 2 [5,4,2,1,1] => 2 [5,3,3,2] => 0 [5,3,3,1,1] => 0 [5,3,2,2,1] => 1 [4,4,3,2] => 1 [4,4,3,1,1] => 1 [4,4,2,2,1] => 0 [4,3,3,2,1] => 2 [5,4,3,2] => 3 [5,4,3,1,1] => 3 [5,4,2,2,1] => 2 [5,3,3,2,1] => 0 [4,4,3,2,1] => 1 [5,4,3,2,1] => 3 ----------------------------------------------------------------------------- Created: Apr 06, 2017 at 23:39 by Martin Rubey ----------------------------------------------------------------------------- Last Updated: Dec 31, 2017 at 14:08 by Martin Rubey