"You are the nth person to solve this problem"
-
dkallen78
- Posts: 2
- Joined: Wed May 08, 2019 9:29 pm
"You are the nth person to solve this problem"
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!
- euler
- Administrator
- Posts: 5095
- Joined: Sun Mar 05, 2006 4:49 pm
- Location: Cheshire, England
- Contact:
Re: "You are the nth person to solve this problem"
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.

impudens simia et macrologus profundus fabulae
-
dkallen78
- Posts: 2
- Joined: Wed May 08, 2019 9:29 pm
Re: "You are the nth person to solve this problem"
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.
-
user202729
- Posts: 18
- Joined: Tue Dec 29, 2015 2:58 pm
Re: "You are the nth person to solve this problem"
(I know this thread is old) I don't understand what calculation is necessary.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.
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?)
- euler
- Administrator
- Posts: 5095
- Joined: Sun Mar 05, 2006 4:49 pm
- Location: Cheshire, England
- Contact:
Re: "You are the nth person to solve this problem"
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.
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.

impudens simia et macrologus profundus fabulae
-
pjt33
- Posts: 140
- Joined: Mon Oct 06, 2008 6:14 pm
Re: "You are the nth person to solve this problem"
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 likeeuler 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.
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)