Skip to content

Instantly share code, notes, and snippets.

@hanksims
Created September 25, 2012 17:28
Show Gist options
  • Save hanksims/3783304 to your computer and use it in GitHub Desktop.
Save hanksims/3783304 to your computer and use it in GitHub Desktop.
from __future__ import division
from decimal import Decimal
import time
TARGETS = set([
float(34.4),
float(9.1),
float(6.8),
float(3.2),
])
i = 0
def one_decimal(x):
return round((x/i) * 100, 1)
while True:
i = i + 1
numbers = range(i)
ratios = set(
map(
lambda x: one_decimal(x),
numbers
)
)
if TARGETS.issubset(ratios):
print('NUMBER OF VOTES = %s' % i)
print('===============')
for j in TARGETS:
print('%s ---> %s' % (j, int(round(Decimal(j/100) * i))))
break
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment