This commit is contained in:
Михаил Капелько
2024-03-28 22:31:54 +03:00
parent 77bd59e50b
commit 9a17647cc2

39
main.kt
View File

@@ -1,5 +1,40 @@
package my.program package my.program
fun main(args: Array<String>) {
println("Hello, World from Kotlin") // L4: Function.
fun memory_generateConstPlayfield(
n: Int
): Map<Int, Int> {
var idGroups: MutableMap<Int, Int> = mutableMapOf()
var id = 0
for (gid in 0..<n) {
idGroups[id] = gid
id += 1
idGroups[id] = gid
id += 1
}
return idGroups
}
// L20: Test.
fun test_memory_generateConstPlayfield(): String {
val idGroups = memory_generateConstPlayfield(2)
if (
idGroups.count() == 4 &&
idGroups[0] == 0 &&
idGroups[1] == 0 &&
idGroups[2] == 1 &&
idGroups[3] == 1
) {
return "OK: memory_generateConstPlayfield"
}
return "ERR: memory_generateConstPlayfield"
}
// L36: Run.
fun main(args: Array<String>) {
println(test_memory_generateConstPlayfield())
} }