LA home
  N-Queens 3D

also see

A necklace of length ‘n’ over an alphabet of ‘a’ beads is invariant under rotation (but not necessarily under reflection, that's bracelets apparently). We want to enumerate non-equivalent necklaces so we might as well enumerate the lexicographically least representative of each equivalence class.

Form, |alphabet|≥1

n=[] a=[]
op:[] total=[] necklaces

Note that ‘p)’ indicates a periodic solution, and ‘squo; indicates a dead-end has been encountered.

CRSMS algorithm

function CRSMS(n, a, s, pos, p)
// s[1..pos-1] is the partial solution, NB. 1..
 { if( pos <= n )
    { s[pos] = s[pos-p];
      CRSMS(n, a, s, pos+1, p);
      for( s[pos]++; s[pos] < a; s[pos]++ )
      CRSMS(n, a, s, pos+1, pos);
   else // pos > n, done
    { if( n % p == 0 )
       { var j, ln = new Array();
         for(j=1; j < pos; j++) ln[j-1] = s[j];
	     //without the leading 0 of s[]
         document.theForm.opt.value += (Count > 0 ? '\n' : '') + ln + ' ';
         document.theForm.Count.value = Count;
      else document.theForm.opt.value += '.';

CRSMS(n, a, s, 1, 1);  //start


Search for
Cattell c2000
or for
-- L.A.
www #ad:

↑ © L. Allison,   (or as otherwise indicated).
Created with "vi (Linux)",  charset=iso-8859-1,   fetched Thursday, 15-Apr-2021 09:26:39 EDT.

Free: Linux, Ubuntu operating-sys, OpenOffice office-suite, The GIMP ~photoshop, Firefox web-browser, FlashBlock flash on/off.