tintin10

1d spiral

Dec 26th, 2017
246
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.40 KB | None | 0 0
  1. '''
  2. 37-36-35-34-33-32-31
  3. 38-17-16-15-14-13-30
  4. 39-18-5--4--3--12-29
  5. 40-19-6--1--2--11-28
  6. 41-20-7--8--9--10-27
  7. 42-21-22-23-24-25-26
  8. 43-44-45-46-47-48-49-50
  9. '''
  10. puzzleInput = 347991
  11. #input 81 to generate a big enough spiral
  12.  
  13. def rightUp(lijstInput,iInput):
  14.     global id
  15.     id += 1
  16.     lijstInput.append(iInput)
  17.     lijstInput.append("<<<-"+str(id))
  18.     return lijstInput
  19.    
  20. def rightDown(lijstInput,iInput):
  21.     global id
  22.     id += 1
  23.     lijstInput.append(iInput)
  24.     lijstInput.append("^^^-"+str(id))
  25.     return lijstInput    
  26.    
  27. def leftUp(lijstInput,iInput):
  28.     global id
  29.     id += 1
  30.     lijstInput.append(iInput)
  31.     lijstInput.append("VVV-"+str(id))
  32.     return lijstInput    
  33.    
  34. def leftDown(lijstInput,iInput):
  35.     global id
  36.     id += 1
  37.     lijstInput.append(iInput)
  38.     lijstInput.append(">>>-"+str(id))
  39.     return lijstInput
  40.  
  41. while True:
  42.     lijst = [1,2,"^^^1",3,"<<<2",4,5,"VVV3",6,7,">>>4",8]
  43.     circleID = 0
  44.     conersToDo = 0
  45.     skip = 3
  46.     skipCounter = 2
  47.     skipPlus = 1
  48.     i = 9
  49.     id = 4
  50.  
  51.     limiet = 1
  52.     circleLimiet = int(input("CircleLimiet:"))
  53.    
  54.     while circleID < circleLimiet: #i < 347992
  55.         skipCounter += 1
  56.         if skipCounter == skip:
  57.             if conersToDo == 1:
  58.                 lijst = leftDown(lijst,i)
  59.                 i += 1
  60.             elif conersToDo == 2:
  61.                 lijst = leftUp(lijst,i)
  62.                 i += 1
  63.             elif conersToDo == 3:
  64.                 lijst = rightUp(lijst,i)
  65.                 i += 1
  66.             skipCounter = 0
  67.             if conersToDo == 0:
  68.                 skip += skipPlus
  69.                 conersToDo = 4
  70.                 skipCounter = skipPlus-1
  71.                 skipPlus += 1
  72.                 lijst.append(i)
  73.                 i += 1
  74.                 lijst = rightDown(lijst,i)
  75.                 i += 1
  76.                 circleID += 1
  77.             conersToDo -= 1
  78.             print(circleID)
  79.         else:
  80.             lijst.append(i)
  81.             i += 1
  82.         if i == 11:
  83.             skipCounter +=1
  84.         #print("skip:",skip," skipCounter:",skipCounter," skipPlus:",skipPlus," conersToDo:",conersToDo," i:",i," circleID:",circleID,sep="")
  85.     with open('C:\\Users\\Quinten\\OneDrive\\Documenten\\python\\advent_of_code\\dump.txt', 'w') as f:
  86.         f.write(str(lijst))
  87.         f.write("\n")
  88.         f.write("Last CircleID: ")
  89.         f.write(str(circleID))
  90.         f.close()
Advertisement
Add Comment
Please, Sign In to add comment