########################################################################## # Copyright (C) 2006 Jaap Spies, jaapspies@gmail.com # Copyright (C) 2006 William Stein, wstein@gmail.com # # Distributed under the terms of the GNU General Public License (GPL): # # http://www.gnu.org/licenses/ ########################################################################## def A079911(n): r""" function returns solutions to the Dancing School problem with 6 girls The value is $per(B)$, the permanent of the (0,1)-matrix $B$ of size $6 \times 6+n$ with $b(i,j)=1$ if and only if $i \le j \le i+n$. We use precalculated values for $n = 0, 1, 2, 3$ For $n > 3$ we use the polynomial $n^6 - 9*n^5 + 60*n^4 - 225*n^3 + 555*n^2 - 774*n + 484$ calculated with the function dance. See http://www.jaapspies.nl/mathfiles/dancing.sage See Nieuw Archief voor Wiskunde 5/7 nr. 4 December 2006 p. 285 INPUT: n -- non negative number OUTPUT integer EXAMPLES: sage: A079911(2) 79 sage: A079911(20) 43207004 sage: A079911(10) 523244 sage: A079911(1000) 991059775554226484 AUTHOR: - Jaap Spies (2006-12-10) """ b = [1, 7, 79, 478] if n >= 0 and n <= 3: return b[n] else: return n^6 - 9*n^5 + 60*n^4 - 225*n^3 + 555*n^2 - 774*n + 484 # dance(6) def A079911_list(n): r""" function returns list of solutions to the Dancing School problem with 6 girls We use precalculated values for $n = 0, 1, 2, 3$. For $n > 3$ we use the polynomial $h^6 - 9*h^5 + 60*h^4 - 225*h^3 + 555*h^2 - 774*h + 484$ calculated with the function dance. See http://www.jaapspies.nl/mathfiles/dancing.sage INPUT: n -- non negative number OUTPUT list of integers EXAMPLES: sage: print A079911_list(10) [1, 7, 79, 478, 2108, 7364, 21652, 55532, 127604, 268108, 523244] sage: print A079911_list(1) [1, 7] sage: print A079911_list(0) [1] AUTHOR: - Jaap Spies (2006-12-10) """ h = QQ['h'].gen() b = [1, 7, 79, 478] if n >= 0 and n <= 3: return b[:n+1] else: pol = h^6 - 9*h^5 + 60*h^4 - 225*h^3 + 555*h^2 - 774*h + 484 # dance(6) a = [pol(i) for i in range(4, n+1)] for i in range(4): a.insert(i,b[i]) return a