Wrong Solution?

Back to General discussions forum

anneenna     2020-05-13 04:23:35

Hi,

when I solved the snake arcade I went on to see others' solutions to see if there are any better ways to solve (self-improvement practice) and I happened to come across someone who just wrote '1' in their solution and passed! (what???) I tried looking for a link to message the admin privately (in case I misunderstood things and mistakenly called fraud on the user), but I can't find such a link. so admin, if you're seeing this, let me know how shall I proceed, should I reveal the user's name publicly here or so. Thanks

Srija Rachakonda     2021-06-18 05:20:04

Hi,

when i,m solving quadratic equations problem , it is continuously showing that my answer is wrong even though it is right

Rodion (admin)     2021-06-18 06:06:36
User avatar

Hi Friend!

showing that my answer is wrong even though it is right

Your program is difficult to test as it doesn't use input, instead hardcoding value :(

At first glance, you at least messed up the output format. Don't replace spaces with tabs and don't use more spaces than needed between values. Good luck!

Rodion (admin)     2021-06-18 06:15:42
User avatar

Answering to initial message which I somehow missed, sorry

I happened to come across someone who just wrote '1' in their solution and passed! (what???)

Thanks for bringing this to attention. I agree this behavior is quite unpleasant. However it is the choice we have:

  • either force people to submit solution in one of the known languages, and check that solution
  • or check only answer, allowing to submit solutions mainly for storing it

The first approach is used by many popular web-sites, like CodeForces. However it means people can't use some specific languages (e.g. Factor, Matematika - some of our colleagues prefer them). Also of course it requires much more heavy infrastructure, supporting many compilers on server-side.

Thus we employ second approach for most of tasks. So it is not illegible to send 1 instead of solution (perhaps it is solution in some very esoteric language). Though of course one can't usually get certified with them.

And probably we may want to find a way to exclude them from search...

qwerty     2021-06-18 09:24:35

And probably we may want to find a way to exclude them from search...

Rodion, hi!

I propose the following approach.

First, add field "status" to table where you store code of users. Now, let consider example when user wants to view solutions of problem XXX on language YYY.

The following cases may be:

1) You have the means to interpret/compile the code on language YYY. For example, I know you wrote an amazing Brainfuck interpreter for this site. This case will be described later.

2) You do not have these means for selected language, for example if YYY is "Fortran". This case is simple - simply select some solutions of XXX on YYY at random and show these to user.

Let describe the first case, for example if YYY = "Brainfuck". First, filter out unacceptable solutions:

SELECT [solution_id], [username], [code], [status] FROM [database].[schema].[solutions_table] WHERE [problem_id] = XXX AND [language] = "Brainfuck" AND [status] <> "Not acceptable"

Now, choose some solutions at random and check the value of status field for chosen solutions. Let a be the number of solutions which have status "Verified", and b be the number of solutions which have status "Unchecked" (which is the default status for newly added solutions). If b is not equal to 0, verify these solutions:

1) Generate input data and answer for problem XXX.

2) Compile / interpret the code as written on language YYY. We have YYY = "Brainfuck" for this example, so you use your Brainfuck interpreter.

3) Check if result is the same as expected answer. If so, update your database with status = "Verified" for corresponding [solution_id].

UPDATE [database].[schema].[solutions_table] SET [status] = "Verified" WHERE [solution_id] = <checked_solution_id>

If result do not match answer of program crashed, update your database with status = "Not acceptable" for corresponding [solution_id].

UPDATE [database].[schema].[solutions_table] SET [status] = "Not acceptable" WHERE [solution_id] = <checked_solution_id>

After verification, show buttons for all a solutions and also buttons for those of b solutions which are passed the checks.

Done.

qwerty     2021-06-18 09:28:51

Well, I read again what I have proposed and realized that you never going to implement such complex procedure...

Please, forgive me for bothering you.

Alexandr Milovantsev     2021-06-18 12:15:45

May be it will be acceptable to just hide away such a bogus solutions? For example, all solutions with text length <=3 are marked when posted, and than marked solutions are not showed in the list of other's solutions.

But it shold be shown when requested directly from a user's profile page.

Rodion (admin)     2021-06-20 08:34:53
User avatar

Alexandr, Hi!

For example, all solutions with text length <=3 are marked when posted

Thanks for suggestion! I guess it is the right way. Adding marks into existing db tables is a bit toilsome, but I tried to join lazily with the solutions table and add condition on length - this looks like working without slowdown.

As a test - solution for "Average of an Array" by TestUser shouldn't pop in the search results (easy to see when filtered by language).

qwerty     2021-06-20 14:21:09

Good!

But my usual submission is showing.

Should I resubmit all problems with shorter commentary?

Which is the maximum length I can choose?

Rodion (admin)     2021-06-20 20:06:51
User avatar

Should I resubmit all problems with shorter commentary?

I'm not sure it is worth investing time into such silly activity :) I guess I can nuke them all with some suitable database query... However obviously there is no universal solution - some other person can choose to submit shakespear's poems instead of solution etc...

So I suggest to leave it as is :)

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