add to gothib
This commit is contained in:
commit
523f45b46a
28 changed files with 419 additions and 0 deletions
24
hacking_grades.py
Normal file
24
hacking_grades.py
Normal file
|
@ -0,0 +1,24 @@
|
|||
courses, points = tuple(map(int, input("").split(" ")))
|
||||
|
||||
numerators = map(int, input("").split(" "))
|
||||
denominators = map(int, input("").split(" "))
|
||||
|
||||
fitness = lambda frac: (frac[0]+1)/(frac[1]+1) - (frac[0]/frac[1])
|
||||
|
||||
fractions = list(sorted(zip(numerators, denominators), key=fitness, reverse=True))
|
||||
|
||||
i = 0
|
||||
|
||||
for point in range(points):
|
||||
# print(fractions[0][0], "/", fractions[0][1], "=", fractions[0][0]/fractions[0][1])
|
||||
fractions[0] = (fractions[i][0]+1, fractions[i][1]+1)
|
||||
|
||||
if len(fractions) >= 2 and fitness(fractions[0]) < fitness(fractions[1]):
|
||||
fractions.sort(key=fitness, reverse=True)
|
||||
|
||||
total = 0
|
||||
|
||||
for (num, denom) in fractions:
|
||||
total += num/denom
|
||||
|
||||
print((total/courses)*100)
|
Loading…
Add table
Add a link
Reference in a new issue