Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from math import floor, ceil
- b = 3
- def func(a, x):
- return float(a*x**b)
- def round_to(num, string='round', cutoff=0):
- try:
- 1/float(cutoff)
- except:
- digits = len(str(int(floor(num))))
- cutoff = 5**(max(digits-1,1))
- if string == 'round':
- return int(cutoff*round(num/float(cutoff)))
- elif string == 'ceil':
- return int(cutoff*ceil(num/float(cutoff)))
- elif string == 'floor':
- return int(cutoff*floor(num/float(cutoff)))
- def R(a, N):
- if N == 1:
- return 0
- return round_to(func(a, N+1))
- def find_a(num):
- return max(round_to(num, 'floor'), 3500)/float(26**b)
- if __name__ == '__main__':
- # Apner en tekstfil med gjeldende grenser og navn
- with open('grenser.txt') as f:
- mylist = [tuple(map(str, i.rstrip('\n').split(' '))) for i in f]
- # Bestemmer verdien av a, hvis femteplass > 3500.
- femte_plass = 3870
- a = find_a(femte_plass)
- for i, elem in enumerate(mylist):
- print elem[0], R(a, i+1)
- print "Tittel", R(a, (i+1)+1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement