2
\$\begingroup\$

Some challenges (that I'm currently mulling over with a view to posting) require that the solution produces valid words. Having to embed an entire dictionary in a code-golf entry isn't the point of the challenge, so I'd like answers to be able to depend on access to a word list.

It doesn't matter if answerers don't all have the same list of words, as long as they select only words from the list. Test cases can be given with a small wordlist, for verification of results.

Is there a standard phrase I can use in a question to indicate that answers don't have to embed their own word lists? And if the question doesn't contain any such phrase, what should answerers assume when they need a word list?

\$\endgroup\$
  • \$\begingroup\$ What's the question? \$\endgroup\$ – Peter Taylor Jun 29 '17 at 15:26
  • \$\begingroup\$ @Peter, I've edited to include a specific question - does that help? \$\endgroup\$ – Toby Speight Jun 29 '17 at 15:51
  • 2
    \$\begingroup\$ I don't really see why this needs a standard, can you not just write out what you've said here in your question? If you leave out a lot of the generic stuff it shouldn't take up much room. \$\endgroup\$ – FryAmTheEggman Jun 29 '17 at 16:08
  • \$\begingroup\$ Sure, this has been done before (for example codegolf.stackexchange.com/questions/51871/…). This doesn't need to be standardised \$\endgroup\$ – Beta Decay Jun 30 '17 at 13:12
11
\$\begingroup\$

The word list is an input

No need to reinvent the wheel. We already have defaults for how to take input, so just use those. This includes reading from a file, STDIN, function input, etc.

Decisions like whether the word list is sorted are up to the questioner, who as usual should specify what valid inputs look like. This doesn't come up often enough to warrant a default.

\$\endgroup\$
0
\$\begingroup\$

The word list can be provided in a file

The file may be required by the answer to have a specific name, or the file name may be passed as a parameter:

This answer requires the word list to be in a file called a in the working directory.

The name of the wordlist file should be passed as the second argument to this function.

\$\endgroup\$
0
\$\begingroup\$

The word list can be provided in an array or container datatype

If the language has suitable types, the word list may be supplied as a function argument or named variable

This answer requires the word list to be in a std::vector<std::string> called w.

The word list should be provided in a list as the second argument to this function.

The number of elements may also need to be passed (e.g. in C, where the natural representation is char**,int).

\$\endgroup\$
0
\$\begingroup\$

Answers may not assume the word list is in any particular order

The list is not necessarily sorted, unless the question specifies an ordering. In practice, it's hard to specify any ordering other than the "C" locale's byte-wise ordering.

Unless specified in the question, an answer may assume that the word list is shuffled - for example, this may allow different output on each invocation, without penalty.

\$\endgroup\$

You must log in to answer this question.

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