%! % Bionomial Goes Binary % by Don Lancaster % ================================== % Copyright c 1996 by Don Lancaster and Synergetics, Box 809, Thatcher, AZ, 85552 % (520) 428-4073 https://www.tinaja.com email: synergetics@tinaja.com % All commercial rights and all electronic media rights are **FULLY** reserved. % Reposting is expressly forbidden. % Consulting services available on concepts shown. % v1.4 October 1996 Revised October 2020 % PostScript utility to generate all binary words of length "n" % having "k" ones in them. Send to a PostScript device with recordable % two-way com. Output is presented as a text string, LSB last. % Copyright c 1996 by Don Lancaster's Synergetics, Box 809, Thatcher, % AZ, 85552. don@tinaja.com % All commercial and all electronic media rights *fully* reserved. % Send to Distiller via command line //acrodist /F /bitsinword 10 def % set the number of bits in the word /ws0 bitsinword string def % generate a workstring /kproc0 {ws0 == flush} def % define a proc that uses the string. /0k0{kproc0} def /1k0{false exch 1 ws0 length 1 sub{dup 3 -1 roll{1 sub ws0 exch 48 put} {pop ws0 dup length 1 sub 48 put}ifelse ws0 exch 49 put kproc0 true} for pop} bind def /2k0{false exch 1 ws0 length 2 sub{dup dup 4 -1 roll{1 sub ws0 exch 48 put} {pop ws0 dup length 2 sub 48 put}ifelse ws0 exch 49 put 1 add 1k0 true} for pop} bind def /3k0{false exch 1 ws0 length 3 sub{dup dup 4 -1 roll{1 sub ws0 exch 48 put} {pop ws0 dup length 3 sub 48 put}ifelse ws0 exch 49 put 1 add 2k0 true} for pop} bind def /4k0{false exch 1 ws0 length 4 sub{dup dup 4 -1 roll{1 sub ws0 exch 48 put} {pop ws0 dup length 4 sub 48 put}ifelse ws0 exch 49 put 1 add 3k0 true} for pop} bind def /5k0{false exch 1 ws0 length 5 sub{dup dup 4 -1 roll{1 sub ws0 exch 48 put} {pop ws0 dup length 5 sub 48 put}ifelse ws0 exch 49 put 1 add 4k0 true} for pop} bind def /6k0{false exch 1 ws0 length 6 sub{dup dup 4 -1 roll{1 sub ws0 exch 48 put} {pop ws0 dup length 6 sub 48 put}ifelse ws0 exch 49 put 1 add 5k0 true} for pop} bind def /7k0{false exch 1 ws0 length 7 sub{dup dup 4 -1 roll{1 sub ws0 exch 48 put} {pop ws0 dup length 7 sub 48 put}ifelse ws0 exch 49 put 1 add 6k0 true} for pop} bind def /8k0{false exch 1 ws0 length 8 sub{dup dup 4 -1 roll{1 sub ws0 exch 48 put} {pop ws0 dup length 8 sub 48 put}ifelse ws0 exch 49 put 1 add 7k0 true} for pop} bind def % (( procs for higher numbers of ones can be added here if needed. )) % (( procs for additional strings can be defined as 5k1, 5k2 etc.. )) % //// demo - remove or alter before reuse. //// % to generate all TEN bit words having FIVE ones in them... 0 5k0 % call five ones entry point, preceeded by zero % ==================================== % Demo program should return 252 strings in the following sequence... % (1111100000) % (1111010000) % ... % (1100001011) % ... % (0000101111) % (0000011111) Additional details on magic sinewaves appear on www.tinaja.com Additional details on bionomial coefficients in MUSE102.PDF Copyright c 1996 by Don Lancaster and Synergetics, Box 809, Thatcher, AZ, 85552 (520) 428-4073 https://www.tinaja.com email: synergetics@tinaja.com All commercial rights and all electronic media rights are **FULLY** reserved.