codetrail

Writing a CodeTrail problem

Every problem is one JSON file in problems/ plus three reference solutions in solutions/, one each in JavaScript, Python and Java. A problem is accepted only when all three references pass every example and test. Write the solutions independently: when they disagree, one of them (or a test) is wrong.

File format

{
  "id": "win-streak",
  "title": "Win Streak",
  "difficulty": "easy",
  "tags": ["strings"],
  "description": "Markdown shown to players.",
  "function": {
    "name": "longestWinStreak",
    "pythonName": "longest_win_streak",
    "params": [{ "name": "results", "type": "string" }],
    "returns": "integer"
  },
  "compare": { "mode": "exact" },
  "examples": [{ "args": ["WWLW"], "expected": 2 }],
  "tests": [{ "args": [""], "expected": 0 }]
}

Checking your problem

From backend/:

node arena/scripts/validate-problems.js --fill my-problem   # fills missing "expected" from the JS reference
npm run validate:problems                                   # every problem, all three languages

--fill only fills values that are missing. Review the filled values: the Python and Java references must then agree with them.

Originality

Problems must be your own work. Do not copy statements or tests from other sites or from any private problem bank.

Public tests and hosted instances

Everything in this repository is public, including tests, so a determined player could hard-code answers. A hosted instance that runs ranked battles should also load a private set of extra tests that is never published.