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.
Your test case though it makes a valid point but you'll not encounter such test cases in hackerrank or any other competitive programming sites. If you read the Input Format closely you'll realize that it's guaranteed that only N lines will follow after the first line which contains the input N. So your test case will be given like this,
1
1
This certainty in Input Format and and the range of Constraints is why we can afford to skip the all these I/O and constraints checks in our program while taking input. That's a luxury that you can afford in competitive programming but in real life programming we have to check each and every input value and it's range before using them in computation because nobody guarantees the consistency of test data. So I would definitely add in the necessary checks in the code if I will use it outside such platforms. Thanks for pointing it out!
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Compute the Average
You are viewing a single comment's thread. Return to all comments →
Your test case though it makes a valid point but you'll not encounter such test cases in hackerrank or any other competitive programming sites. If you read the Input Format closely you'll realize that it's guaranteed that only N lines will follow after the first line which contains the input N. So your test case will be given like this,
1
1
This certainty in Input Format and and the range of Constraints is why we can afford to skip the all these I/O and constraints checks in our program while taking input. That's a luxury that you can afford in competitive programming but in real life programming we have to check each and every input value and it's range before using them in computation because nobody guarantees the consistency of test data. So I would definitely add in the necessary checks in the code if I will use it outside such platforms. Thanks for pointing it out!