Sort by

recency

|

1019 Discussions

|

  • + 0 comments
    
    

    public static int libraryFine(int d1, int m1, int y1, int d2, int m2, int y2) {

         if(y1<y2) return 0;
         if(d1>d2 && m1<m2 && y1<=y2) return 0;
         if(d1>d2 && m1<=m2 && y1<=y1) return 15*(d1-d2);
         if(m1>m2 && y1<=y2) return 500*(m1-m2);
         if(d1<=d2 && m1<=m2 && y1<=y2) return 0;
         return 10000;
    
    }
    
    
    
  • + 0 comments

    My C code 😎😁

    int libraryFine(int d1, int m1, int y1, int d2, int m2, int y2) {
        if(y1 > y2){
            return 10000;
        }
        if(d1>d2 && m1 == m2 && y1 == y2){
            int fine = (d1 - d2)*15;
            return fine;
        }
        if(m1 > m2 && y1 == y2){
            int fine = 500*(m1 - m2);
            return fine;
        }
        return 0;
    }
    
  • + 0 comments
    #!/bin/python3
    
    import math
    import os
    import random
    import re
    import sys
    
    #
    # Complete the 'libraryFine' function below.
    #
    # The function is expected to return an INTEGER.
    # The function accepts following parameters:
    #  1. INTEGER d1
    #  2. INTEGER m1
    #  3. INTEGER y1
    #  4. INTEGER d2
    #  5. INTEGER m2
    #  6. INTEGER y2
    #
    
    def libraryFine(d1, m1, y1, d2, m2, y2):
        if y1 > y2:
            return 10000
        elif y1 < y2:
            return 0
        
        if m1 > m2:
            return (m1 - m2) * 500
        elif m1 < m2:
            return 0
        
        if d1 > d2:
            return (d1 - d2) * 15
        else:
            return 0
    
    if __name__ == '__main__':
        fptr = open(os.environ['OUTPUT_PATH'], 'w')
    
        first_multiple_input = input().rstrip().split()
    
        d1 = int(first_multiple_input[0])
    
        m1 = int(first_multiple_input[1])
    
        y1 = int(first_multiple_input[2])
    
        second_multiple_input = input().rstrip().split()
    
        d2 = int(second_multiple_input[0])
    
        m2 = int(second_multiple_input[1])
    
        y2 = int(second_multiple_input[2])
    
        result = libraryFine(d1, m1, y1, d2, m2, y2)
    
        fptr.write(str(result) + '\n')
    
        fptr.close()
    
  • + 0 comments

    Here is my c++ solution, you can watch the explanation here : https://youtu.be/EhPgZkwwx4Y

    int libraryFine(int d1, int m1, int y1, int d2, int m2, int y2) {
        int res = 0;
        if(y1<y2 || (y1 == y2 && m1<m2) || (y1 == y2 && m2 == m1 && d1<=d2)) return 0;
        if(y2 == y1){
            if(m1 == m2) return 15 * (d1 - d2);
            else return (m1 - m2) * 500;
        }
        else return 10000;
        return 0;
    }
    
  • + 0 comments

    Just a friendly reminder to return those library books on time to avoid those pesky fines! And if you need a little help sprucing up your space, don’t forget about Ryans Professional Cleaning for top-notch upholstery cleaning services.