• + 19 comments

    would be brutal for the user if he submits book on jan 1st and expected retun date was 31st dec. 10,000 hackos though should be 15 hackos because technically book is 1 day late.

    • + 3 comments

      Yes that would be unfortunate.

      • + 3 comments

        Maybe you should edit the question to have it actually make sense. This problem is flawed and doesn't make sense in the real world.

        • + 1 comment

          That's true, but I think the question only needed you to come up with straight forward equations for the four statements.

          • + 1 comment

            Exactly!

            • + 0 comments

              Anyone looking for a clean and elegant solution can find it here.

              Hackerrank - Library Fine Solution

        • + 1 comment

          Doesn't really matter if the rules are flawed, programmers just follow them.

          • + 0 comments

            good soldiers follow orders

        • + 1 comment

          The point is to take the problem and find the most concise way to layer conditional logic. That's why this problem is in the "warmup" section.

          • + 1 comment

            this is in implementation section.

            • + 1 comment

              The challenge was moved to another subdomain section after I wrote that comment.

              • + 2 comments

                https://www.hackerrank.com/challenges/library-fine/copy-from/34717423 what is wrong in my logic and how we can think to correct the logic and how we can optimize this code please explain in better manner 5,10,16 test case of this ques does not pass?why?give reason

                • + 2 comments

                  Have you found the correct solution yet? facing the exact same situation

                  • + 1 comment

                    i will not found soln till now if i found soln then i will help you

                    • + 2 comments

                      Test your code for some input like:

                      01 12 2017 
                      01 01 2018
                      

                      The actual date is a month before the expected date, so the fine should be zero.

                      • + 0 comments

                        case 10 also same like this 28 2 2015 15 4 2015 Actually the book was returned before expectedd date so output should be 0 right

                      • + 0 comments

                        Thanks ! It helped

                  • + 1 comment

                    Test your code for some input like:

                    01 12 2017 
                    01 01 2018
                    

                    The actual date is a month before the expected date, so the fine should be zero.

                    • + 0 comments

                      an year before :)

                • + 0 comments

                  Same Situation here, have u found the correct solution?

      • + 5 comments

        Should not the expected output for the input like this be 1000 instead of 1500 as it does not represent 3 full months?

        5 5 2014
        23 2 2014
        

        Ideally, it should consider the library's fee for 2months and 13 days

        • + 0 comments

          Anyone looking for a clean and elegant solution can find it here.

          Hackerrank - Library Fine Solution

        • + 0 comments

          No, because the question explains precisely how the fee is charged

          1º) Year;

          2º) Month;

          3º) Day;

          First is avalued if the year of submit is lower than expected, and then the test is done for month and then for day.

          Considering that question has the same year, the next condition is avalued is the month:

          5 - 2 = 3 month late * 500 (fee month) = 1500

        • + 0 comments

          You are right..I am facing same issue...I don't think anyone should count months like 5 - 2 = 3 whereas it is not actually completed 3 months

        • + 1 comment

          That would make it soooooooo lengthy. You'll have to define days in each month, and then add up days for each month in between. This is an easy/warmup exercise so they shouldn't do it.

          • + 0 comments

            It actually would be straightforward, especially in languages that offer libraries that model dates and allow to count days/months/years between two given instants.

            I don't think that the problem statement is well layed out.

      • + 0 comments

        here is problem solution in java python c++ c and javascript programming.

        HackerRank Library Fine problem solution

    • + 1 comment

      It'll drive him to piracy/warez.

      • + 0 comments

        The money I saved in library fines by resorting to piracy were not worth it as I spent so much on photocopying ;)

    • + 0 comments

      I thought i was the only one for a second. I came up with 15, but the testcase output says 10000.

    • + 0 comments

      altough logically that makes sence, point of this task is testing if programmer knows how to handle DateTime api... I'd suggest not to change anything :)

    • + 0 comments

      yeah man 14th case has such a poor prediction as output .i hope vatsalchanana will sue any student by his liabrary fine calculation logic

    • + 0 comments

      Yes, I think the answer is wrong. It should be 15 hackos.

    • [deleted]
      + 0 comments

      Make sure Hackerrank team does not open a library.

    • + 0 comments

      That's what you get for trying to spend time with your family.

    • + 1 comment

      I agree, actually if we use date functions or api's the result will be 1 day but the test marks that as failed, that's unfortunate for us as participants because the test actually doesn't reflect that we indeed use date functions/api's well enough.

      • + 0 comments

        yes that APi use is discouraged. It's a challenege testing conditional loic.

    • + 0 comments

      haha! lol

    • + 0 comments

      I will not happen though. Most probably the librarian celebrating a holiday and the library is close. Hahahahaha

    • + 0 comments

      Poor library users :-D

    • + 0 comments

      simple python solution

      Fine = [0,(d1-d2)*15,(m1-m2)*500,(y1-y2)*10000] if sum(Fine)<0: return 0 return max(fine)

    • + 0 comments

      dont take any book in the last day of the year!!!

    • + 0 comments

      Yes..

    • + 0 comments

      I made same mistake I think it is deliberate part of task to emphaises attention to details. :/