Home‎ > ‎ProgComp‎ > ‎Progcomp 2017‎ > ‎Task 0. Junior Task‎ > ‎

0. Junior Task. Fitness Friend - Suggested Solution



#-------------------------------------------------------------------------------
# Name:        Fitness Friend
# Purpose:
#
# Author:      jlai
#
# Created:     27/05/2020
# Copyright:   (c) jlai 2020
# Licence:     <your licence>
#-------------------------------------------------------------------------------

def main():
    with open("FitnessFriend1.txt",'r') as f:
        inp = f.readline().split(' ')
        #print(inp)
        M = int(inp[0])
        T = int(inp[1].strip())
        d = 0
        total = 0
        x = 0
        while True:
            print(T, end=" ")
            S = f.readline()
            if int(S)<0:
                break
            d +=1
            S = int(S)
            k = M/100
            if S>=T:
                T = T + (k**2) * (S-T)
                x +=1
            else:
                T = T + (1-k)**2 * (S-T)
            T=int(T)
            total += S
            #print(total,S,d)
        mean = int(total/d)
        goal = int(x/d*100)
        print(f"\nMotivation {M}, days {d}, mean steps {mean}, goal reached {goal:.0f}%. Final Target {T}" )

if __name__ == '__main__':
    main()

ċ
Joseph Lai,
4 Jun 2020, 19:36
ċ
Joseph Lai,
4 Jun 2020, 19:36
Comments