Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #The second part of what I do is this:
- puzzleInput = 347992
- lijst = [A list that is the side of square 81 where my puzzleInput resides but is too long to post]
- def binarySearch(alist, item):
- first = 0
- last = len(alist)-1
- found = False
- while first<=last and not found:
- midpoint = (first + last)//2
- if alist[midpoint] == item:
- found = True
- else:
- if item < alist[midpoint]:
- last = midpoint-1
- else:
- first = midpoint+1
- return midpoint
- #print(binarySearch(lijst,puzzleInput))
- plek = binarySearch(lijst,puzzleInput)
- midden = (len(lijst)-1)//2
- if plek > puzzleInput:
- stap1 = midden - puzzleInput
- if plek < puzzleInput:
- stap1 = puzzleInput - midden
- antwoord = stap1 + 81
- print(antwoord)
Advertisement
Add Comment
Please, Sign In to add comment