I like this approach from https://play.kotlinlang.org/koans/overview
“Kotlin Koans is a series of exercises to get you familiar with the Kotlin syntax and some idioms. Each exercise is created as a failing unit test, and your job is to make it pass. Here you can play with Koans online, but the same version of exercises is also available via JetBrains educational plugin right inside IntelliJ IDEA or Android Studio.”
Giving a set of code fragments that fail tests and asking students to fix it is a brilliant idea. In fact, a similar technique used in a version of the book “Learn Python the Hardway”.