KADR's blog

By KADR, 14 years ago, translation, In English
There are regular after-contest competitions on Topcoder named shortest code competitions. Sometimes it is very interesting to see how the code of some easy task can be compressed to weird and unreadable one, but at the same time this code passes all the test cases. I suggest to hold such competitions here.

I will start from task C from Codeforces Beta Round #24. The rules are simple: each next code should be shorter than previous one. The winner is the person whose code is not beaten by anyone else. Length of the code is the number of non-whitespace characthers in it. Of course, the code should be AC on at least one of the allowed compilers. As far as I know, defines are not used on Topcoder shortest code competitions, so I suggest not to use them here either.

There are some special features in different languages, so I suggest to have different standings for different languages, because I doubt that C++ or Pascal can compete with Haskell or Python.

214:
#include <iostream>
__int64 n,k,x,y,a['   '],b['   '],d;
int main()
{
std::cin>>n>>k>>x>>y;
for(k%=2*n;d<n;d++) std::cin>>a[d]>>b[d],d<k?x=2*a[d]-x,y=2*b[d]-y:0;
for (d=0,k-=n;k>0;--k,++d) x=2*a[d]-x,y=2*b[d]-y;
std::cout<<x<<" "<<y;
}
  • Vote: I like it
  • +5
  • Vote: I do not like it

14 years ago, # |
  Vote: I like it 0 Vote: I do not like it
164:
#include <iostream>
__int64 n,k,x,y,a['   '],b['   '],d,i;
main()
{
    std::cin>>n>>k>>x>>y;
    for(k%=2*n;d<k;d++) std::cin>>a[d]>>b[d],x=2*a[d%n]-x,y=2*b[d%n]-y;
    std::cout<<x<<" "<<y;
}
  • 9 years ago, # ^ |
    Rev. 2   Vote: I like it 0 Vote: I do not like it

    I like the idea of having winners per language, especially difficult to compete with Java :-D

    But seriously, you can use code formatting... Is there a tool counting length? You know, I'm wondering if b[' '] is 5 characters or 8...

    edit: Ok, I found that you cannot use code formatting — in the comment above, 3 spaces were replaced with 1, hm HTML...

»
9 years ago, # |
  Vote: I like it -28 Vote: I do not like it

These shortest code competitions really rub me the wrong way, to an extent I can hardly convey. I have spent well over twenty years honing my skill at writing code that would win no prizes for either length or brevity, by merely for clarity. Code clarity reigns supreme in my book. Not cleverness, brevity, or obfuscation. A shortest code competition to me is like a competition to see who can make love in the shortest time. Well, if that's what you are into, enjoy. But my priorities are completely different.

  • »
    »
    9 years ago, # ^ |
    Rev. 2   Vote: I like it +15 Vote: I do not like it

    Well this is just for having fun no need to be so serious :O

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

      And he even revived a 4-year old blog post to say that. Talk about serious business.

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

        O_o

        4 years old

        I didn't look at the posting time and thought it was a new thing, purely because of how many such things there have been in CF recently (achievements, stats, Polygon updates...)

      • »
        »
        »
        »
        9 years ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        I didn't realize too. And I was wondering why such old contest :-D

  • »
    »
    9 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Programmers are doing "strange" things to have some fun :-D

    This is what I discovered recently — JSFuck.

    disclaimer: no I'm not a fun of such things, but comparing with code above, this is "advanced level"...

  • »
    »
    9 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    The point of these competitions are exploiting the language and just playing around with code. It's your opinion but i feel that being clever and knowing the language will definitely make you a better programmer. Code clarity is no big deal. If you find this obfuscated, look at languages like Brainfuck or Intercal.

»
9 years ago, # |
Rev. 3   Vote: I like it -20 Vote: I do not like it

>I doubt that C++ or Pascal can compete with Haskell or Python

or Perl

"There was this bug running on my keyboard, I tried to hit it but the little bitch always dodged... and look, I wrote a Perl script!"

If we consider CF problems, then there should be general limitations concerning bizzare languages.

UPD: number of downvotes: 7, number of replies: 0. How impressive.

UPD2: oh, it's 4 years old. Maybe that's why (but I probably shouldn't try to find logic in CF downvotes).

  • »
    »
    9 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    What do you mean "general limitations"?

    • »
      »
      »
      9 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      Dunno exactly, maybe making separate categories for some languages. Or restricting the set of usable languages. But a code for a non-DS-heavy problem in Java can't compete with a code in Perl, purely to the languages' syntax verbosity.