Re: How many pictures calculator

new topic     » goto parent     » topic index » view thread      » older message » newer message

Here is the code I’m using to produce all the pictures

 
include misc.e 
include get.e 
 
constant NUMOFBITS=16 
constant START=0 
constant TARGET=1 
 
sequence bits 
bits=repeat(0,NUMOFBITS) 
 
integer fn 
fn=open("data.txt","w") 
 
integer pos1 
pos1=NUMOFBITS 
 
sequence result 
result=repeat(TARGET,NUMOFBITS) 
 
while 1 do 
   
  puts(fn,sprint(bits)&"\n") 
 
  if equal(bits,result) then 
    exit 
  end if 
 
  bits[pos1]+=1 
 
  if bits[pos1]>TARGET then 
    bits[pos1]=START 
    pos1-=1 
  
    for i=pos1 to 1 by -1 do 
      bits[i]+=1 
      if bits[i]>TARGET then 
        bits[i]=START 
      else 
        pos1=NUMOFBITS 
        exit 
      end if 
    end for 
  end if 
 
end while 
 
close(fn) 
new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu