// Collection of code snippets by Arne Vajhøj // (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) using System; class MainClass { public static void Main(string[] args) { int n = 1; bool fnd; do { int[] a = new int[n]; for(int i = 0; i < n; i++) a[i] = 0; for(int j = 0; j < 32; j++) a[((uint)(1 << j)) % n]++; fnd = true; for(int i = 0; i < n; i++) if(a[i] > 1) fnd = false; if(!fnd) n++; } while(!fnd); Console.WriteLine(n); int[] ztable = new int[n]; for(int i = 0; i < n; i++) ztable[i] = -1; for(int j = 0; j < 32; j++) { ztable[(((uint)(1 << j)) % n)] = j + 1; } for(int i = 0; i < n; i++) { Console.Write(" " + ztable[i] + ","); } Console.WriteLine(); } }