

This will open the online editor, which shows the following information: There, you can click on the "Open in editor" button. To start doing that, go to the website, join a track and go to the exercise's page. Such an implementation is known as a solution.

The goal of each exercise is to create an implementation that passes all the tests. With the online editor, you don't have to install anything on your local machine, everything works within the browser (including running the tests). Note that the code you provide would be generated as a nested class (inside the script).Solving exercises online using the website's online editor allows you to quickly get started with a track. Here's a Java project which demonstrates this (code would be cleaner in Kotlin): to generate a jar file that can then be loaded). KotlinScript can be used to compile Kotlin source code (e.g.

I'm not aware of a clean solution for this, Kotlin was not designed to be run like like PHP / JavaScript / Python which just interprets text dynamically, it has to compile to bytecode first before it can do anything on the JVM so in each scenario, you will need to compile that code first in one way or another, whether to bytecode or to javascript and in both cases load it into you application using the Java Classloader or Rhino.

Runtime.getRuntime().exec(""" "kotlin code here" > blah.kts | sh""") So once again, you'll have an eval(kotlin-code-string-here) method which will dump the content to a blah.kt file, then you would use a Kotlin2JS compiler to compile it to JavaScript and directly execute the JavaScript inside Kotlin using Rhino which is not great either.Īnother option is to make use of Kotlin Scripting or an external Kotlin compiler (in both cases, the Kotlin compiler will have to start up) and doing something like this will also allow you to execute dynamically, albeit, only on Unix systems. You might want to look at Kotlin Scripting, see Īlternatively, you'll need to write your own eval(kotlin-code-string-here) method which will dump the text inside blah.kt file for example, compile it using an external Kotlin compiler into blah.class then dynamically load those classes into the runtime using the Java Classloader doing something like this: ("圜lass")Īnother no so great option is to make use of Rhino and run JavaScript inside your Kotlin code.
