Hidden pattern in the output for code golf challenges
You should not post a challenge in which an essential part is to find a pattern in the required output, which is not stated in the challenge but which greatly simplifies the code. That kind of challenges are essentially a puzzle in disguise.
As an example of a non-valid challenge, consider one that simply requires to
Produce this fixed string:
without further explanation. The code will be much shorter if one realizes that the string is the first 80 decimals of
0 replaced by
The reasons why these challenges should be avoided are:
- The actual complexity is in finding a hidden pattern, rather than in coding or programming. This is of little interest on this site, and possibly off-topic (consider posting on https://puzzling.stackexchange.com).
- Once an answer finds out the pattern, all other answers can do the same. If the pattern is going to be eventually known anyway, it is better to describe it upfront in the challenge.
So, you should state the pattern in the challenge text. If you feel that makes the challenge "less interesting", consider modifying it in some other way.
Note, however, that the challenge is not expected to describe all possible characterizations or patterns that the output satisfies. Including one (or maybe several) is enough. There is no requirement to be exhaustive.
For example, this would be valid as a challenge (adding further rules for output format etc):
Determine if the input is a triangular number, that is, if it can be expressed as
1+2+···+k, or equivalently as
k*(k+1)/2, for some positive integer
The pattern is embodied by the definition of triangular numbers (
1+2+...+k), which is included in the challenge. The challenge also contains another equivalent characterization (
k*(k+1)/2). Now, an answer may find and exploit some other characterization, such as
A positive integer
n is triangular if and only if
8*n+1 is a square.
It is totally fine if the challenge text does not include that information (which might have even been unknown to the challenge writer).