himadri765's blog

By himadri765, history, 3 years ago, In English

Wouldn't be nice to have, once in a while, debugging contests on codeforces?
Rules: like a normal contest (old problems can be reused), but you are given a code with some bugs and you have to correct it (you can only submit solutions whose edit distance from the starting code is $$$\leq k$$$).

  • Vote: I like it
  • +64
  • Vote: I do not like it

| Write comment?
»
3 years ago, # |
  Vote: I like it 0 Vote: I do not like it

That's a unique idea ,but I guess most people don't like debugging.

»
3 years ago, # |
Rev. 3   Vote: I like it +27 Vote: I do not like it

This might be an interesting format.

In my opinion, limiting edit distance from source code is definitely a bad rule. Because sometimes debugging should lead to considerably large amount of changes that will keep code consistent instead of adding a small but very tricky hacks that will keep you code running fine, but it will cause problems with every next change you want to make. You can say that competitive programming is not great place for best practices, refactoring and clean code overall, but it is definitely a place for some practices. And these practices vary significantly from coder to coder, everyone has his own definition of consistency and chooses practices, templates and patterns that suits him better. So in some situations it might turn out that is it simplier to reimplement something from scratch rather than fix something and prove that it will consistently work after these fixes. So with this limitation challenge "How to fix this?" can quickly turn into "What problemsetter exactly wanted from you?" and this challenge will not be so fun (if it will be fun at all).

And also large amount of changes is not always time consuming. Common refactoring methods are automated well, sometimes you can apply "Extract method" or "Rename" to change hundreds of lines of code within seconds.

In this format I would like to see given corrupted solution as a source of ideas and unreliable blocks of code, but not as a restriction. Just imagine receiving specificly obfuscated and unreadable code for a really simple problem without being able to change it significantly. Or imagine getting very tight resriction on $$$k$$$, say $$$k=2$$$. How do you even approach this? Most reasonable approach I see is to automatically apply all possible changes, try to compile changed codes and find ones that actually pass some tests.

»
3 years ago, # |
  Vote: I like it +11 Vote: I do not like it

Idea: if the plag checker says that the submitted solution coincides with the given buggy code, then the solution is considered a bug fix.

»
3 years ago, # |
  Vote: I like it +15 Vote: I do not like it

I took part in this contest where you had to write a failing test case for the code, which seems like a much better way of doing such a contest as compared to minimizing edit distance.

  • »
    »
    3 years ago, # ^ |
      Vote: I like it +1 Vote: I do not like it

    Isn't it hacking?

    • »
      »
      »
      3 years ago, # ^ |
        Vote: I like it +20 Vote: I do not like it

      Sure, but the contest authors write the problems and code — so everyone competes to hack that code (which was much more readable for me than a random person's code in general).

»
3 years ago, # |
  Vote: I like it +19 Vote: I do not like it

I don't like this idea. People have their own codestyle. Their speed and quality of code reading depend on the features of the code. These are familiar and unfamiliar macros, some strange language constructions (like while (p[i++] == a[--j]) or " \n"[i == n - 1]), STL classes and functions (clamp or numeric_limits), code formatting and so on.

In general, there are many people, that don't use C++. Codeforces allows to use many languages in contests and your suggestion requires only one language in which the codes would be written.