Sort by

recency

|

780 Discussions

|

  • + 0 comments
    import datetime
    
    def book_fee(due_date: datetime.date, return_date: datetime.date) -> int:
        if return_date < due_date:
            return 0
    
        if (return_date.month, return_date.year) == (due_date.month, due_date.year):
            return 15 * (return_date.day - due_date.day)
    
        if due_date.year == return_date.year:
            return 500 * (return_date.month - due_date.month)
    
        return 10000
    
    
    return_date = datetime.date(
        **dict(
            zip(["day", "month", "year"], [int(_) for _ in input().split(" ")])
        )
    )
    due_date = datetime.date(
        **dict(
            zip(["day", "month", "year"], [int(_) for _ in input().split(" ")])
        )
    )
    
    print(book_fee(due_date, return_date))
    
  • + 0 comments
    from datetime import datetime
    def fine(returned,due):
        if int(returned[2])<1000:
            returned[2] = returned[2].zfill(4)
        if int(due[2])<1000:
            due[2] = due[2].zfill(4)
        
        due = datetime.strptime(" ".join(due),"%d %m %Y").date()
        returned = datetime.strptime(" ".join(returned),"%d %m %Y").date()
        if returned > due:
           if returned.year > due.year:
               return 10000
           if returned.month > due.month:
    
               return 500*(returned.month - due.month)
           if returned.day > due.day:
               return 15 * (returned.day - due.day)
        else:
           return 0
           
    print(fine(input().split(" "),input().split(" ")))
    
  • + 0 comments

    My python code I know my algorythm is kinda trash, but it works efficiently I guess... Pwese don't tell me to use map()

    from datetime import datetime
    import math
    
    zwrocona = input().split()
    doKiedy = input().split()
    
    def kara(zwrocona, doKiedy):
        Dz = int(zwrocona[0])
        Mz = int(zwrocona[1])
        Rz = int(zwrocona[2])
        Dk = int(doKiedy[0])
        Mk = int(doKiedy[1])
        Rk = int(doKiedy[2])
        
        date1 = datetime(Rk, Mk, Dk)
        date2 = datetime(Rz, Mz, Dz)
        
        diff1 = date2 - date1
        
        diff = diff1.days
        
        if diff <= 0:
            return 0
        elif Mz == Mk and Rz == Rk:
            return diff * 15
        elif Rz == Rk and Mz != Mk:
            return math.floor(diff/30) * 500
        elif Rz != Rk:
            return 10000
        
    if len(zwrocona) == 3 and len(doKiedy) == 3:
        print(kara(zwrocona, doKiedy))
    
    
        
    
  • + 0 comments

    Python3

    dr, mr, yr = map(int, input().split())
    dd, md, yd = map(int, input().split())
    fine = 0
    if yr > yd:
        fine = 10000
    elif yr == yd:
        if mr > md:
            fine = 500 * (mr-md)
        elif mr == md:
            if dr > dd:
                fine = 15 * (dr-dd)
    print(fine)
    
  • + 1 comment
    #python
    
    date_returned = str(input()).split()
    date_due = str(input()).split()
    delta = [
        int(date_returned[2]) - int(date_due[2]),
        int(date_returned[1]) - int(date_due[1]),
        int(date_returned[0]) - int(date_due[0])
    ]
    
    if delta[0] > 0:
        print(10000)
    elif delta[1] > 0 and delta[0] == 0:
        print(500*(delta[1]))
    elif delta[2] > 0 and delta[1] == 0:
        print(15*delta[2])
    else:
        print(0)