Issue with Problem 170 (Binary Search in Array)

Back to General discussions forum

PatrickQuirk     2021-11-09 20:28:03

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
Quandray     2021-11-10 07:16:53
User avatar

Try removing any trailing space in your answer.

PatrickQuirk     2021-11-10 17:04:37

Thanks a lot Quandray, that worked. Not sure why I needed to remove the trailing space.

Rodion (admin)     2021-11-11 12:58:24
User avatar

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!

omsarmiento1953     2023-03-29 19:24:42

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?

gardengnome     2023-03-30 03:14:29
User avatar

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.

Please login and solve 5 problems to be able to post at forum