Comments on Using environment variables in code golf
Post
Using environment variables in code golf
I wrote a code golf answer which depends on setting an environment variable before running the code. I've assumed that the bytes used to define the environment variable should be added to the score, but I'm not sure if this is covered by existing default rules.
Should setting environment variables:
- Be forbidden?
- Be allowed as competition in the same language, with the additional bytes added to the score?
- Be considered a different language, with the additional bytes added to the score?
- Be considered a different language, with the additional bytes not added to the score?
Similar cases
- In Default Rules: Libraries the consensus is that competing in "language + library" (for any library other than the language's standard libraries) is considered a different language. The bytes required to import the library are added to the score.
- In Default Rules: Flags and Other Compile-Time Options the consensus is that changing the language's behaviour causes it to be considered a different language. The bytes required to set a flag or compile-time option are not added to the score.
Specific details for my example
In my answer, the environment variable is set before running the program:
PYTHONHASHSEED=764
This has 2 independent effects:
- Defining a seed causes the
hash
function to be consistent between runs of the program (which it wouldn't normally be for security reasons). - Choosing the specific value 764 makes the particular hashes used in my answer unique in the final 3 bytes, allowing me to save bytes by hard coding only the final 3 bytes of each relevant hash.
The first of these is like switching on an optional feature. The second is fine tuning the language's behaviour to suit the challenge. Are both acceptable? If I were setting a random seed within a program rather than before running it, I would consider that acceptable, but then those bytes would be included in the score. I mention it here in case it affects your opinion on whether the bytes used to set the environment variable should be added to the score.
The current consensus that the bytes for flags and compile-time options are not added to the score makes me feel that treating that default rule as applying to environment variables would be a loophole. I'm not sure if that's a reason to treat environment variables separately, or to change the flags and compile-time options rule to add the bytes to the score in general.
1 comment thread