Hot answers tagged

13

Sidestepping in a theorem-proving challenge A theorem-proving challenge is about proving a statement (= constructing a value of the given type) given in a specific host language (designed for theorem proving, most likely Lean or Coq). One problem with this is that the host language may have various utilities that allow writing a "proof" that is not ...


12

Keep them ...assuming they've shown any sort of effort. As caird coinheringaahing mentions, a serious contender is one that: ...makes a serious effort towards optimizing the submission's score within the chosen language(s) and other choices (such as algorithm choice or optional restrictions/bonuses taken). [emphasis added] I would argue that the answer in ...


10

Use the sandbox to "defend" your challenge The sandbox is meant to be an aid to improve the challenge. But once posted to the main site, the quality of the challenge is entirely the poster's responsibility. Regardless of the sandbox, the challenge on the main site should be solid and well specified. If you post to the main site and the challenge is ...


8

An array may be represented as a buffer terminated with a sentinel value This can be applied to both inputs and outputs for languages such as C and assembly. This is the default for C strings (a buffer of char, terminated with 0), but can be applied to any other data type. As a more concrete example: An input array of positive integers can be taken as a ...


7

Vim submissions can be valid in any mode if the output is displayed In Aaron Miller's mentioned answer, the required output is shown in insert mode, and hence it is valid. However, if a change of mode/other motion is required for output, like in the V quine 2i2i, then it is required to be valid.


7

Yes, a Vim submission is valid if it ends in Insert mode. Once the intended text has been outputted, the question has been answered. The insert mode is simply another command mode in which most keys are simply commands that output that character. For example, there are commands specific to Insert mode, as well as commands shared between Insert and Normal ...


6

A program or function taking input by reference may output by modifying the input value in place A complement to this For example, in rust, one might write fn a(v:&mut Vec<i32>){v.push(7);} instead of fn b(mut v: Vec<i32>)->Vec<i32>{v.push(7);return v;} or fn c(v:&mut Vec<i32>)->&mut Vec<i32>{v.push(7);return ...


6

Bypassing restricted-source by storing data in the file name Consensus says that it is perfectly fine to store data in the file name as long as that is added to the byte count. However, this doesn't seem entirely appropriate in restricted-source questions, since it could bypass the restrictions. An example (which is what spurred me to write this) is this ...


5

Think twice if you're writing a challenge around an algorithm you found on the Internet Simply put, it will never work as you expect, (though it could work as "a challenge") unless you pick your algorithm and the problem very carefully. If you make it a plain code-golf without any restrictions, answers are free to choose brute force (which works ...


5

Multipart challenges with unrelated sub-tasks In general, a challenge on Code Golf should focus on a single core task. Challenges with multiple sub-tasks are discouraged, especially when the sub-tasks have zero or very little interaction or common aspects. If the answer to at least one of the following questions is "yes", your challenge has a high ...


4

Mappings may be used in place of functions (Discussion in The Nineteenth byte) Whenever a function is expected, a mapping such as a dictionary/hashmap or array may be used instead. Arguments for: in many languages, there is no syntax difference (K, MATLAB, Ruby - a Proc can be used with the same [] syntax as a Hash) disallowing it borders on an unobservable ...


4

This I/O format is fair for many languages – it should be corrected because it isn't fair for all languages, but is normally being used in good faith and we can easily modify answers in languages where it works I think it's worth thinking about why people use this I/O format in the first place (on other sites). It isn't necessarily a "natural" I/O ...


3

All variables are set to 0 before your code runs


3

You may assume that the input is valid When parsing an input, you may assume that the input is already valid. You are not required to validate it unless the challenge is specifically about testing whether the input is valid or not.


2

In stack-based languages, inputs may be pushed onto the stack at the start of the program, and the output may be the top element on the stack at the end of the program This has already been proposed for functions, but it should also be allowed for full programs.


2

A natural number may be represented as a collection of n empty collections, and a string as a collection of such numbers In languages that do not have numbers or strings but do have lists, stacks, or other collections, a natural number (including 0) may be represented by a collection of empty collections, where the length of the outer collection represents ...


2

The green flag will be clicked once Unlike traditional programming languages, Scratch code does not execute immediately upon the interpreter reading it - it must be ran by a hat block. Using when gf clicked for this seems to be undisputed precedent, so you may assume that the green flag will be clicked once.


2

The program is not running in Turbo Mode (Scratch normally waits for the screen to refresh in between running each block. In Turbo Mode, it doesn't do this.)


2

There will be no human interaction with the program while it is running Exception: you may assume that there will be a response to an ask [] and wait prompt if the challenge requires input.


2

Yes - I think that new language should be allowed to win. The initial intention of language itself is to provide smooth way to express, simplify, shorten, improve how code or communication looks like. If language itself takes a fresh approach on how to better adapt to problem, context, program - that should be encouraged, not rejected. However - creating new ...


1

Count imports only if the function definitely doesn't work without directly importing it Using the OP's Fraction code as an example: from fractions import* f = lambda x,y:x+y f(Fraction(1, 2), Fraction(1, 3)) What if I change the example function call to the following? It imports a hypothetical third-party library frac_consts which contains definitions of ...


1

Assumptions about the stage/sprite You may either: Assume that your code is running in the stage. Assume that your code is running in a sprite. You may either: make no assumptions about the sprite assume that your code is running in the default cat sprite, and it is in the state it is in upon the creation of a new project (visible, on costume 1, has no ...


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