%! % Find binary words of length n having k ones in them % by Don Lancaster % ================================== % Copyright c 2020 by Don Lancaster and Synergetics, Box 640, 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. %Send .psl file to Distiller via "//acrodist /F" from command line. % Uses brute force method of generating all "n" binary words and testing for k of them. % Results appear in .PDF file, companion .log file and in Distiller report. % Code should be triply Distiller-GhostScript-GoogleDrive compatible as shown, BUT % you can NOT ask for a log file ( or use = =)in Google Drive(set flag below) AND % GhostScript may truncate a long log file unless header buffer adjusted. % Note further that Google Drive demands our .psl files start with %! and NO SPACES! % ======== Simple page reporter ========= % Use our Gonzo Utilities and Tutorial instead for serious apps % https://www.tinaja.com/pssamp1.shtml /Helvetica findfont 10 scalefont setfont /xleft 10 store /ytop 700 store /stepswide 8 store /yinc 12 store /xpos xleft store /ypos ytop store /posn 0 store /usingGoogleDrive true store % make this false for log output when valid % otherwise, Google Drive chokes % note that Ghostscript may truncate a log file! xpos ypos moveto /showbits { usingGoogleDrive not {dup == } if % show only IF log page not barfed show ( ) show % show on .pdf file /posn posn 1 add store posn stepswide ge {/xpos xleft store /posn 0 store /ypos ypos yinc sub store xpos ypos moveto } if } store %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /onesinword 5 store /wordsize 10 store /maxsize 2 wordsize exp cvi store /counter 0 store maxsize 1 maxsize 2 mul 1 sub {2 20 string cvrs 1 wordsize getinterval % flush the leading 1, leaving leading 0's /cur exch store mark 0 cur {48 sub} forall ] /ar1 exch store 0 ar1 {add} forall onesinword eq {cur showbits /counter counter 1 add store } if } for ( Binomial Count Total:) showbits counter 10 string cvs showbits showpage % EOF