Skip to content

Commit

Permalink
Merge pull request keon#112 from mondeja/master
Browse files Browse the repository at this point in the history
Optimized circular_counter code, faster
  • Loading branch information
keon authored Nov 5, 2017
2 parents bf2b096 + fb2702a commit 2884807
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions array/circular_counter.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@
def josepheus(int_list, skip):
skip = skip - 1 #list starts with 0 index
idx = 0
while len(int_list)>0:
idx = (skip+idx)%len(int_list) #hashing to keep changing the index to every 3rd
len_list = (len(int_list))
while len_list>0:
idx = (skip+idx)%len_list #hashing to keep changing the index to every 3rd
print(int_list.pop(idx))
len_list -= 1


josepheus(a,3)
Expand Down

0 comments on commit 2884807

Please sign in to comment.