Skip to main content
1 of 2
Peter Taylor
  • 43.4k
  • 4
  • 72
  • 179

CJam, 1831 sequences

{168680-:Zz1320b900b48md:R;H+:QB+2*,:!1_tQWtQ)WtK{[WQW*_(]+1$f=[1R2+R~R4+*2/WR-X$-].*1b+}/J~>ZW>f*} 

This gives correct output for 199 sequences beginning 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 and all sequences in the inclusive ranges [A168680, A169579] and [A170000, A170731]. The bulk of it deals with those two ranges, with a fallback for all-zeroes before the start of the first range.

The two ranges in question have the form

Number of reduced words of length n in Coxeter group on P generators S_i with relations (S_i)^2 = (S_i S_j)^Q = I

for values of P ranging from 3 to 50 and values of Q ranging from 17 to 50. Their generating functions are given in a thoroughly inefficient manner: I found it useful to multiply numerators and denominators by (t - 1) to give g.f.

 t^{Q+1} + t^Q - t - 1 ---------------------------------------------------- (P-2)(P-1)/2 t^{Q+1} - (P-2)(P+1)/2 t^Q + (P-1)t - 1 

although for golfing purposes I'm actually working with R = P + 3.

Peter Taylor
  • 43.4k
  • 4
  • 72
  • 179