Back to General discussions forum
I am having a strange issue with Problem 170 (Binary Search in Array). Whenever I submit my answer, I am getting an error of the form "You are expected to return 5651 country codes!" (replacing 5651 with however many country codes there are supposed to be for that particular set of input data). However, I have checked and I am submitting that exact number of country codes each time. I also am pretty sure I am meeting the time limit (although I would think that would produce a different error message). I am able to find country codes for all of the IPs, and my answer seems to be formatted correctly.
Does anyone know what is going on here?
I will include my code (in Python) for reference. I apologize if there are formatting issues here
I will note that I copied the input data into Notepad, manually removed the first line (which has the number of IP addresses to find country codes for), and then saved it as a text file in the same place I saved my code. I would then run the code and copy the answer string that gets printed out into the answer box in the problem.
// code not necessary anymore, removed by admin
Try removing any trailing space in your answer.
Thanks a lot Quandray, that worked. Not sure why I needed to remove the trailing space.
Hi Friends! Thanks for Quandray for help in sorting this out!
Not sure why I needed to remove the trailing space.
Well, sorry for this, obviously a kind of flaw in a checker. For most problems answer is automatically stripped, but for this checker has some custom code and in this code "strip" is missing. I shall try to fix it (and not break) :(
Thanks for reporting this!
I received the following answer after submitting: "Your answer is correct, but you spent about 472 seconds instead of 60"
How does the checker know the time?
I did binary search as required by the problem. My problem is the time. Any suggestion how I can and where to implement improvements?
Quote: "Problem Statement [...] You will have only 1 minute
to submit the answer".
Reload the page to get a fresh set of test data and reset the timer, and then submit the answer within 1 minute.