Михаил Капелько 1 month ago
parent
commit
9a17647cc2
1 changed files with 36 additions and 1 deletions
  1. +36
    -1
      main.kt

+ 36
- 1
main.kt View File

@@ -1,5 +1,40 @@
package my.program


// 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("Hello, World from Kotlin")
println(test_memory_generateConstPlayfield())
}

Loading…
Cancel
Save