Advertisement
Guest User

Untitled

a guest
Aug 21st, 2017
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. from __future__ import division, print_function
  2.  
  3. def ratio(length):
  4.  
  5. number_concurrent_3s = 0
  6. the_two_we_are_before = 1
  7.  
  8. threes_that_should_be_before_this_two = {1: 3}
  9.  
  10. number_3s = 0
  11. number_2s = 0
  12.  
  13. for index in xrange(1, length + 1):
  14. if number_concurrent_3s == threes_that_should_be_before_this_two[the_two_we_are_before]:
  15. number_2s += 1
  16. the_two_we_are_before += 1
  17. threes_that_should_be_before_this_two[index] = 2
  18. number_concurrent_3s = 0
  19. else:
  20. number_3s += 1
  21. threes_that_should_be_before_this_two[index] = 3
  22. number_concurrent_3s += 1
  23.  
  24. return number_3s / number_2s
  25.  
  26. if __name__ == '__main__':
  27. print(ratio(1000000))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement