Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from __future__ import division, print_function
- def ratio(length):
- number_concurrent_3s = 0
- the_two_we_are_before = 1
- threes_that_should_be_before_this_two = {1: 3}
- number_3s = 0
- number_2s = 0
- for index in xrange(1, length + 1):
- if number_concurrent_3s == threes_that_should_be_before_this_two[the_two_we_are_before]:
- number_2s += 1
- the_two_we_are_before += 1
- threes_that_should_be_before_this_two[index] = 2
- number_concurrent_3s = 0
- else:
- number_3s += 1
- threes_that_should_be_before_this_two[index] = 3
- number_concurrent_3s += 1
- return number_3s / number_2s
- if __name__ == '__main__':
- print(ratio(1000000))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement