Technology moves fast! ⚑ Don't get left behind.🚢 Subscribe to our mailing list to keep up with latest and greatest in open source projects! πŸ†


Subscribe to our mailing list

kotlin-koans

Kotlin workshop

Subscribe to updates I use kotlin-koans


Statistics on kotlin-koans

Number of watchers on Github 1730
Number of open issues 29
Average time to close an issue 18 days
Main language Kotlin
Average time to merge a PR 5 days
Open pull requests 14+
Closed pull requests 30+
Last commit over 1 year ago
Repo Created about 5 years ago
Repo Last Updated about 1 year ago
Size 6.5 MB
Organization / Authorkotlin
Contributors18
Page Updated
Do you use kotlin-koans? Leave a review!
View open issues (29)
View kotlin-koans activity
View TODOs for kotlin-koans (86)
View on github
Fresh, new opensource launches πŸš€πŸš€πŸš€
Trendy new open source projects in your inbox! View examples

Subscribe to our mailing list

Evaluating kotlin-koans for your project? Score Explanation
Commits Score (?)
Issues & PR Score (?)

official JetBrains project

Kotlin Koans

Kotlin Koans Workshop is a series of exercises to get you familiar with the Kotlin Syntax. Each exercise is created as a failing unit test and your job is to make it pass.

How to build and run tests

Working with the project using Intellij IDEA or Android Studio:
  1. Import the project as Gradle project.
  2. To build the project and run tests use test task on Gradle panel.

Here https://www.jetbrains.com/help/idea/gradle.html you can read how to work with Gradle projects in IntelliJ IDEA.

Working with the commandline

You can also build the project and run all tests in the terminal:

./gradlew test

But since running all the tests tend to take longer and the output can be cluttered, it's more ideal to run selected tests only:

$ ./gradlew test --tests i_*          # run tests in part 1
$ ./gradlew test --tests ii_*         # run tests in part 2
$ ./gradlew test --tests ii_*22*      # run test number 22 in part 2

How to check yourself

The repository has two branches, master which contains the exercises for you to do and resolutions which contains the resolved exercises. Make sure you dont cheat!

How the tasks are organized

You have 42 tasks to do. Each task lives in its own function: from task0 to task41. For each task, there is an associated unit test that checks your solution.

You may navigate to the corresponding test automatically when you read the task. Open the source file with the task and use the action Navigate -> Test to open the test file. You may also use Navigate -> Test Subject for reversed navigation.

Individual tasks generally require you to change the function taskX by completely replacing the body of the function. Your goal is to solve the problem and allow the associated unit test to pass. If you run the unit test for a task that is not correct, the unit test results will be displayed. If you have not yet made any changes to a task, the exception will be thrown and the task's TODO message will be displayed.

In the first example, this means replacing the code

fun task0(): String {
    return todoTask0()
}

with the correct, meaningful code in order to solve the problem and allow the associated unit test to pass, such as:

fun task0() = "OK"

The resolutions branch contains all the solutions. It's a good idea to check the proposed solution after completing each task. Open the file with your solution, call the Compare with branch... action and choose the resolutions branch.
You can find here how to call an action.

Other ways to solve Koans

You can solve the similar tasks using Educational Plugin or in the browser:

  • EduTools Plugin https://plugins.jetbrains.com/plugin/10081-edutools
  • online version of koans http://try.kotl.in

The koans tasks for web-demo and educational plugin can be found here: https://github.com/Kotlin/kotlin-koans-edu

kotlin-koans open issues Ask a question     (View All Issues)
  • almost 3 years Mavenize and remove Eclipse project files?
kotlin-koans open pull requests (View All Pulls)
  • IntelliJ -> IntelliJ IDEA
  • Fix package name of first koan
  • Started writing the task TODO descriptions so that make more sense to…
  • Use Kotlin way in addTimeIntervals
  • Clarify task i_5 a bit
  • Changed from named single elements in varargs
  • Fix inconsistent encoding of months
  • Use spread operator for named vararg
  • Using latest Gradle release
  • Remove un-used lib/*.jar (as these are pulled by Gradle now)
  • Improve .gitignore
  • Add eclipse plugin with correct configuration to build.gradle
  • Task 4: use it convention instead of declaring the parameter explicitly
  • Fix leap year definition
kotlin-koans list of languages used
Other projects in Kotlin