Java and Kotlin programming challenges for the ReadingBat platform. This repository defines challenge content that the ReadingBat server renders as interactive coding exercises.
Requires JDK 17+.
./gradlew build -x test # Compile
./gradlew run # Start the content server on http://localhost:8080
./gradlew --rerun-tasks check # Run all tests
./gradlew test --tests "ContentTests" # Run a single test class
./gradlew test -Dkotest.filter.tests="<name>" # Filter Kotest cases by name
make uberjar # Build fat jar at build/libs/server.jarWhen running locally, challenge files are loaded directly from disk (via FileSystemSource), so edits are picked up on reload without a rebuild. Production builds load content from this GitHub repository.
Each challenge is a standalone source file with a main() that prints expected outputs. Those output lines become the answer key for the exercise.
Java (src/main/java/<package>/):
// @desc Determine if one value is less than another with the **<** operator.
public class LessThan {
public static boolean compare(int val1, int val2) {
return val1 < val2;
}
public static void main(String[] args) {
System.out.println(compare(4, 6)); // true
System.out.println(compare(12, 8)); // false
}
}Kotlin (src/main/kotlin/<package>/):
fun doubleIt(i: Int): Int = i * 2
fun main() {
println(doubleIt(5)) // 10
println(doubleIt(10)) // 20
}All challenges are registered in src/main/kotlin/Content.kt using the readingBatContent DSL.