Played with the golf problem some. I don't get the same answers as listed
but then the text says they may not be correct. Anyway my answers match the
first few terms.
Then I tried to go one power more and J crashes!
golf 7
2 6 12 38 96 290 804
My script:
NB. golf - Extract counts for each order polynomial. ____________
golf=:3 : 0
|.#/.~,([:{.[:I.|)&>}."1 build_poly y
)
NB. build_poly - Build polynomials order from 2 to y with high order
coefficient of 1 and other coefficients 1, 0 or _1. Each order is boxed
list of coefficients. Use check_rou to find roots that are roots of unity.
Drop polynomials without any root of unity.
build_poly=:3 : 0
p=.;<"1&.>([:|."1[:<:3#.^:_1[:][:(+:+i.)3^])&.>>:i.y
c=.check_rou&.>p
(*#&>c)#c,.p
)
NB. check_rou - Select polynomial roots that are roots of unity. Each
selected is returned with the unity power. In polar coordinates a root must
have a radius of 1 and the angle must be a "small" number of rotations to
become a multiple of o.2 . I picked 10000 as "small". Maybe that's too big.
check_rou=:3 : 0
r=.~.;}.p.y
r=.r#~1=|r
m=.10000>s=.*./"1]2 x:(12 o. r)%o.2
m#s,.r
)
NB. ______________________________________________________
If I do "golf 8" J crashes with a Windows message that jqt.exe has stopped
working.
JVERSION
Engine: j701/2011-01-10/11:25
Library: 8.02.09
Qt IDE: 1.1.2/5.3.0
Platform: Win 64
Installer: J802 install
InstallPath: c:/j/j64-802
This is on Windows 7 with 8G of memory.
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm