|
12345678910111213141516171819202122232425262728293031323334353637383940 |
- 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(test_memory_generateConstPlayfield())
- }
|