Page 1 of 1

"You are the nth person to solve this problem"

Posted: Thu May 09, 2019 12:02 am
by dkallen78
Is there a way I can see this number? Is it stored? I know it's shown right after completing a problem but is there a way to access it after the fact? I searched for an answer but couldn't find one. Sorry if this has been asked before!

Re: "You are the nth person to solve this problem"

Posted: Thu May 09, 2019 5:21 pm
by euler
Sadly there is no way for you to access this information after you have solved the problem. Due to the way that the "solved" data is stored in each member's profile it is a fairly intensive process; the data is compressed in such a way that is optimised for members to access their own data, not perform, "who has solved problem X and when did they solve it". In fact, the main reason for the delay you see when you solve the problem is the server calculating this position.

Re: "You are the nth person to solve this problem"

Posted: Thu May 09, 2019 5:56 pm
by dkallen78
Thanks for the reply. I was hoping to see what number I was for previous problems (not interested in other peoples' ranks). I figured since there was an award for being one of the first solvers the information must be stored somewhere.

Re: "You are the nth person to solve this problem"

Posted: Sat Oct 03, 2020 1:17 pm
by user202729
euler wrote: Thu May 09, 2019 5:21 pm Sadly there is no way for you to access this information after you have solved the problem. Due to the way that the "solved" data is stored in each member's profile it is a fairly intensive process; the data is compressed in such a way that is optimised for members to access their own data, not perform, "who has solved problem X and when did they solve it". In fact, the main reason for the delay you see when you solve the problem is the server calculating this position.
(I know this thread is old) I don't understand what calculation is necessary.

Isn't it possible to simply store the number of solved people for each problem; then for each people solving a problem, atomically add that problem into that user's solved list, get that number as the number of solved, then increment that number? What am I missing?

(but really, the delay is quite annoying. If there's no way to improve the time, is it possible instead to load the "congratulations" part first, then load the rest with delayed response/JavaScript/iframe?)

Re: "You are the nth person to solve this problem"

Posted: Sun Oct 04, 2020 1:00 pm
by euler
Anomalies can occur and when someone deletes their account or resets progress it means that the overall problem count may no longer be accurately reflected. So when someone solves a problem successfully it is used as an opportunity to synchronise this data. Adding extra data, like the position which it was solved to each member's profile, would not only add additional DB storage overhead, but it is not necessarily a fixed value and over time might begin to become inaccurate due to the reasons already mentioned.

As for the "quite annoying" delay, the short pause is for the benefit of everyone else. You could look at it as a moment of excited anticipation.

Re: "You are the nth person to solve this problem"

Posted: Mon Oct 05, 2020 7:45 pm
by pjt33
euler wrote: Sun Oct 04, 2020 1:00 pm Adding extra data, like the position which it was solved to each member's profile, would not only add additional DB storage overhead, but it is not necessarily a fixed value and over time might begin to become inaccurate due to the reasons already mentioned.
Yes, that would be a bad way of doing it, but I'm surprised that it can't be calculated on the fly extremely fast. I assume that the "solved" table has columns for user ID, problem ID, and successful submission timestamp. No problem currently has a million submissions, and most of them have fewer than a thousand. An index on (user ID, problem ID) and another on (problem ID, timestamp) should be able to respond to a query something like

Code: Select all

SELECT COUNT(*) + 1
FROM solved
WHERE problem_id = %1 AND timestamp < (SELECT timestamp FROM solved WHERE user_id = %2 and problem_id = %1)
efficiently with bisection, and the DB storage overhead of the indexes should be a single-figure percentage of the storage required by the discussion threads. (In fact, the subquery wouldn't be necessary if the calling code still has the timestamp from the INSERT).