# Tag Info

49

No, invalid inputs may result in undefined behavior Requiring input validation only adds extraneous code to the answer and takes away from the challenge.

33

Programs may assume that input is empty I believe that the requirement The program has to ignore the standard input, that is, it should work regardless of what is given as input. is too strong. There are (mostly esoteric) languages which automatically read all input there is. These languages would always have to include some code to get rid of that ...

33

I propose that each commonly-used language have a separate explanation of the rules that most pertain to it, with code examples. I think this is more digestible that a big general FAQ, especially to new users. (Meta post to try to make this happen.) Different languages consider different rules important. For example, allowing curried functions is central ...

31

Unless specified otherwise, strings are case-sensitive. More generally, unless specified otherwise, strings are just sequences of characters with no semantics attached to any specific characters. This should also be the least surprising default for users who are not aware of this post. I'd also urge challenge authors to think twice before making a ...

29

vim answers can be run from the command line as such: $echo 'Input' > file.txt$ vim -u NONE '+normal (enter keystrokes here...)' '+wq' file.txt \$ cat file.txt # output Furthermore, vim interprets Ctrl+<letter> by bytes in the lower portion of the ASCII table (with A-Z encoded as 1-26, ex. Ctrl+C is \x03), Esc as \x1b, and some other Ctrl ...

26

Yes, on PPCG a language is defined by its implementation. In case your program is not portable you should specify the interpreter or compiler.

22

Yes, and it does not necessarily have to be a separate language. There's no problem with using your own library as long as it doesn't violate the standard loopholes. In answers where you use it, you should put "Python 3 + <name> library" in the header. If you go for the library route, you do need to count the import in any answers with it.

22

I do consider them built-ins. Just because you sort of have to update your language (or language's standard library) before you can use them for the first time, doesn't mean you're fetching the result from the internet. Once Mathematica has downloaded the data from Wolfram Research, it's just part of the language and can be reused (even after restarting ...

20

I have created this very complex infographic; I hope my hours of effort will solve this problem. The only possible exception is if the answer in question is exhibiting one or more obvious loopholes that the user who posted the question clearly meant to close.

20

No (with caveats) -- Language-specific challenges are on-topic Challenge authors are allowed to add other arbitrary restrictions (banning built-ins, banning capital letters, requiring out to be base-10 integers, etc.), and so requiring all answers to be in one language should be treated no different; it's just another method of restricting answers. That said ...

17

... could you just use common sense? If you seriously actually need an enumeration of why exactly this is invalid (which I doubt): you need to provide a working, freely available interpreter, which means solving every single challenge on the site languages (including versions of languages) created after the challenge are invalid it's cheating (obviously) ...

17

Chat bots (that post messages) have no place in TNB. Since TNB is for discussion of code-golf and PPCG related topics, having bots in the room would be distracting and obnoxious, and would overtake more important conversations. The reason that this is not officially mentioned in the chatiquette is because this isn't a frequent or reoccurring issue. You could ...

16

In my opinion, such answers should be valid unless the OP states otherwise. These answers often reflect a different slant to the problem, and we all like variety, don't we? I don't think we should remove this dimension of creativity by default, but if the OP doesn't want such answers, they can of course say so. From the perspective of a code golfer, I like ...

16

Only allow challenges to restrict languages indirectly via requirements The one good reason for a challenge to restrict languages is that the spec makes sense only for languages with certain features or properties. So, let specs have requirements that not all languages meet, but don't allow them to whitelist or blacklist languages by name. For example, if ...

16

Haskell Basic IO In Haskell, a valid answer is usually a function, unless a full program is required by the challenge. Even if a challenge requires you to output an infinite stream of data (like all prime numbers), you can just write a function that returns an infinite list or string. Functions These kinds of functions are valid answers in a code golf ...

15

Let it be. Codegolf questions on SO get deleted apparently at random, so there's no telling how long that one will be there. However, it might be a good idea to link to it from your question and to state that if people want to copy answers then they should credit the original poster, make their answers community wiki, and be prepared to delete them if the ...

15

Answers that use a language (or a feature thereof) that postdates the challenge should be labeled non-competing. From Can I ever answer with a language invented after the challenge was posted?: These answers can still be posted but should not be considered as a candidate for the accepted answer. But if a language is specifically designed to have a clear ...

15

One consistent, and one non-consistent The thing I like about Truthy and Falsy is that often you may do things like output 0 for falsy and everything else for truthy. For example this brain-flak answer outputs nothing for even numbers and the input for odd numbers. It could be argued that this is an exploit, I think this gives the opportunity for some ...

14

I would say no. ECMAScript 6 is sufficiently different from its previous versions that I would consider it a new language. (By the same logic, you could technically say that using C++11 would require a +10 character count because of the -std=c++11 compilation flag, and then you could include all sorts of goodies like the object file names and whatnot, which ...

14

Our defaults say that submissions have to be full programs or functions. REPL "programs" are also allowed, but they have to be labeled as such, and still have to conform to the defaults regarding input and output (which usually boils down to taking input from a prompt and displaying the results on the screen). For the specific case you mention, I'd argue ...

14

The language would have been created on the date at which the book was bookmarked for the first time The Library of Babel is basically an encoding scheme: any possible string will exist somewhere in the Library, and the string itself is specified by a book location and page number. For example, the book you linked is located at: Hexagon ...

13

No People need to be able to actually run your entry. Just as you can't write code with syntax errors, you can't write code that your interpreter won't compile because it's not encoded in a certain way. If you need a certain encoding for a language, write your own interpreter, even if it just converts encodings and delegates to the real one (as @ThomasKwa ...

13

By default valid input is guaranteed If it's not, some behaviour should be specified: Any behaviour (but why specify this when it's defeult?) Handle it in some way and produce a specific value Produce any value in finite time without exceptions Produce any value or exception in finite time

12

As elaborated in the comments, the complete list of rules (which applies to libraries too) of which I am aware are: The language (or library) must have existed prior to the challenge. This is to prevent the no-longer-funny loophole where you factor-out your entire program and call it a new language. An interpreter/compiler should be freely available. This ...

12

In my opinion, yes. Typically, anything that happens during the compilation stage is ignored. For example, a C/C++ program that produces warnings doesn't make any difference as long the executable runs without errors. You can see this in the text you quoted: (emphasis added) Your program must run without erroring out or crashing. Warnings (and other ...

11

Yes. But: According to what I see from the comments and previous relevant questions, the consensus is that you may, however, you must do the following things: - Define it as not a clean copy. This means declaring it as "<Original Language> + <Library Name (with link)>" - Provide a link to the library. This is common sense. - Explain ...

11

Attribution First and foremost, I have no idea why one of the comments suggested editing the attribution out. If a challenge is taken from elsewhere (with minor modifications), full attribution is required. Downvotes Taking a challenge from elsewhere and posting it here with nearly identical rules will rarely go well. You're scoring by length in ...

11

Python General I/O Your submission should be a program or a function. It should print the output or return it. These example submissions compute the factorial: # Program that prints n=input();p=1 for i in range(1,n+1):p*=i print p # Defined function that outputs or prints def f(n): p=1 for i in range(1,n+1):p*=i print p # Lambda function, no name ...

Only top voted, non community-wiki answers of a minimum length are eligible