7
\$\begingroup\$

I would like to make a code challenge (or a new type of challenge), which is based on code size, but in a "dual" way to code-golf: code size is limited, and the winner is whoever makes the best code (with some objective definition of "best").

Something like this challenge (which was awesome) but with an objective winning criterion and without language restrictions.

To allow verbose languages like Java, I would like to make the codesize limit large enough (400 bytes?). However, with this code size, code in languages like Golfscript would have a vast advantage. This is not bad by itself, but I think Golfscript code larger than 100 bytes cannot be awesome because it's too complex.

Therefore, I am asking this question, which attempts to set reasonable codesize limits for different languages. How can we make such a list (for all possible programming languages)? How big can it be? Is it a good idea at all?

(I am thinking about taking the 20 highest-voted codegolf questions with answers in many languages, and somehow averaging the best codegolf scores for each language)

\$\endgroup\$
  • 4
    \$\begingroup\$ I like this idea; just wanted to offer a slight pushback: Granted that long GolfScript programs are hard to understand and also have a big advantage. However, IMO, anybody who can write a working 400-byte GS program almost deserves my upvote just for the effort. Add a good explanation of the code, and I don't see why such a post "cannot be awesome." \$\endgroup\$ – DLosc Mar 5 '15 at 2:15
  • 4
    \$\begingroup\$ There's no need to insult GolfScript programmers. I have about 30 GS programs of 100 chars or more on this site, and I think that at the very least this and this deserve consideration for being awesome. \$\endgroup\$ – Peter Taylor Mar 9 '15 at 9:12
3
\$\begingroup\$

Here are some existing examples, with limits from 10 to 5000 bytes. it depends on the complexity of the problem. The first two are very similar in concept.

Largest number in ten bytes of code

Khinchin's constant to as many decimal places as possible in 64 bytes or less

2048 Bot Challenge

Build the busiest beaver in x86 machine code in 32 bytes or less

In other cases the maximum seems to have been added just to stop hardcoding:

Calculate 500 digits of pi

Find 10 large prime numbers with n digits

Also, this is similar to the tweetable art:

Encode Images into Tweets (Extreme Image Compression Edition)

I agree with trichoplax that setting different limits for different languages doesn't seem a good idea. The subject has been discussed for the codegolf tag and the conclusion is always the same. Just make sure that the size is sufficient to allow languages of normal verbosity to complete, and if golfing languages (golfscript, cjam, J? ,APL? where do you draw the line?) have an advantage it doesn't matter.

\$\endgroup\$
4
\$\begingroup\$

I like the idea of size limit questions, and I like the idea of setting a number of different guideline sizes based on problem type so people have an optional starting point when setting their own questions. However, I do not think setting different limits for different languages is a good idea.

The advantage that one language has over another varies from one problem to the next, and an innovative approach may swing this balance wildly in one direction or another even within a single question. Trying to take account of this in advance of the question being answered is almost meaningless.

What might be more useful in order to promote healthy competition between different languages is to measure size in a different way. For example, counting tokens instead of bytes, for some useful definition of tokens (perhaps keywords, code blocks and bytes of data, with delimiters for code blocks and data not counted - that could be a separate meta question...).

This can still have problems where it is unclear how to apply that measurement to a language that stands out as an exception. In many cases, I would expect the simplest approach to work perfectly well. Just restrict the total number of bytes, regardless of language. Bear in mind that despite the disadvantage, most golf questions still have answers in a variety of verbose languages, not just the golfing languages. People like competing, whether they have a chance to win overall or not.

\$\endgroup\$
  • 3
    \$\begingroup\$ Counting tokens has a whole lot of other problems we haven't sorted out yet. Mostly the abuse of arbitrary-size tokens (strings, integers, variable names) to encode data. \$\endgroup\$ – Martin Ender Mar 4 '15 at 12:50
  • \$\begingroup\$ @MartinBüttner I guessed there would be problems but I hadn't thought of that one - interesting. \$\endgroup\$ – trichoplax Mar 4 '15 at 17:21
  • \$\begingroup\$ My personal preference is just to have a byte limit per question that applies equally to all languages \$\endgroup\$ – trichoplax Mar 4 '15 at 17:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .