daily pastebin goal


a guest Dec 7th, 2017 135 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #----------------------SPACE WASTING SNAKE------------------------------------------
  2. ###infinite snake in n-dim room which includes all existing vectors
  3. ###in an enumerable-infinity-order, useful for autoproving n-dimensional expressions
  4. ###by Patrick Hammer. Email: patrick.hammer@student.tugraz.at
  5. def existing_vectors_positive(dim, upper_limit=-1): #can be infinite too
  6.     r=1; inv=1; rev=false; step=0
  7.     while upper_limit==-1 or step<upper_limit:
  8.         V=[0 for x in range(dim)]; V[0]=r
  9.         for x in range(1,len(V)):
  10.             Break=false
  11.             for y in range(r):
  12.                 W=list(reversed(V)) if rev else V
  13.                 yield W; V[x]+=1*inv
  14.         inv=inv*(-1);
  15.         for x in range(0,len(V)):
  16.             Break=false
  17.             for y in range(r+1):
  18.                 W=list(reversed(V)) if rev else V
  19.                 yield W; V[x]+=1*inv
  20.                 if(V[x]==0): Break=true
  21.             if Break: break
  22.         r=r+1; inv=inv*(-1); step+=1; rev=not rev
  23. #------------------------------------------------------------------------------------
RAW Paste Data