Challenge

sealed class Challenge

Base class for an individual programming challenge.

A challenge corresponds to a single source file containing a function and its test invocations. When loaded, the source code is parsed to extract the function body (shown to the user), the invocations (used as test cases), and the correct answers (computed by evaluating the code via a JSR-223 script engine).

Challenges are created within a ChallengeGroup via the challenge("name") { } DSL block or automatically through includeFiles / includeFilesWithType patterns.

This is a sealed class with language-specific subclasses: JavaChallenge, KotlinChallenge, and PythonChallenge.

Inheritors

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

the parent group containing this challenge

Link copied to clipboard

the challenge identifier, typically matching the source file name

Link copied to clipboard

Optional URL or identifier for the equivalent CodingBat problem.

Link copied to clipboard

The list of correct answers for each invocation, computed by evaluating the challenge source code.

Link copied to clipboard

Optional Markdown description displayed above the challenge. Can also be set via @desc comments in the source.

Link copied to clipboard

Source file name. Defaults to challengeName.suffix but can be overridden in the DSL.

Link copied to clipboard

whether this challenge can be replaced by a later definition with the same name

Functions

Link copied to clipboard

Retrieves or computes the FunctionInfo for this challenge. Results are cached when running in production or test mode. Source code is fetched from the configured repo (local or remote).

Link copied to clipboard
fun md5(): String

Computes an MD5 hash uniquely identifying this challenge by its language, group, and name.

fun md5(invocation: Invocation): String

Computes an MD5 hash uniquely identifying a specific invocation of this challenge.

Link copied to clipboard
open override fun toString(): String