We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
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.
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.
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.
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 :)
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.
Library Fine
You are viewing a single comment's thread. Return to all 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.
Yes that would be unfortunate.
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.
That's true, but I think the question only needed you to come up with straight forward equations for the four statements.
Exactly!
Anyone looking for a clean and elegant solution can find it here.
Hackerrank - Library Fine Solution
Doesn't really matter if the rules are flawed, programmers just follow them.
good soldiers follow orders
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.
this is in implementation section.
The challenge was moved to another subdomain section after I wrote that comment.
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
Have you found the correct solution yet? facing the exact same situation
i will not found soln till now if i found soln then i will help you
Test your code for some input like:
The actual date is a month before the expected date, so the fine should be zero.
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
Thanks ! It helped
Test your code for some input like:
The actual date is a month before the expected date, so the fine should be zero.
an year before :)
Same Situation here, have u found the correct solution?
Should not the expected output for the input like this be
1000
instead of1500
as it does not represent 3 full months?Ideally, it should consider the library's fee for 2months and 13 days
Anyone looking for a clean and elegant solution can find it here.
Hackerrank - Library Fine Solution
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
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
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.
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.
here is problem solution in java python c++ c and javascript programming.
HackerRank Library Fine problem solution
It'll drive him to piracy/warez.
The money I saved in library fines by resorting to piracy were not worth it as I spent so much on photocopying ;)
I thought i was the only one for a second. I came up with 15, but the testcase output says 10000.
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 :)
yeah man 14th case has such a poor prediction as output .i hope vatsalchanana will sue any student by his liabrary fine calculation logic
Yes, I think the answer is wrong. It should be 15 hackos.
Make sure Hackerrank team does not open a library.
That's what you get for trying to spend time with your family.
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.
yes that APi use is discouraged. It's a challenege testing conditional loic.
haha! lol
I will not happen though. Most probably the librarian celebrating a holiday and the library is close. Hahahahaha
Poor library users :-D
simple python solution
Fine = [0,(d1-d2)*15,(m1-m2)*500,(y1-y2)*10000] if sum(Fine)<0: return 0 return max(fine)
dont take any book in the last day of the year!!!
Yes..
I made same mistake I think it is deliberate part of task to emphaises attention to details. :/