Research portable Memory game | Исследовать портируемую игру Память
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

41 行
734B

  1. package my.program
  2. // L4: Function.
  3. fun memory_generateConstPlayfield(
  4. n: Int
  5. ): Map<Int, Int> {
  6. var idGroups: MutableMap<Int, Int> = mutableMapOf()
  7. var id = 0
  8. for (gid in 0..<n) {
  9. idGroups[id] = gid
  10. id += 1
  11. idGroups[id] = gid
  12. id += 1
  13. }
  14. return idGroups
  15. }
  16. // L20: Test.
  17. fun test_memory_generateConstPlayfield(): String {
  18. val idGroups = memory_generateConstPlayfield(2)
  19. if (
  20. idGroups.count() == 4 &&
  21. idGroups[0] == 0 &&
  22. idGroups[1] == 0 &&
  23. idGroups[2] == 1 &&
  24. idGroups[3] == 1
  25. ) {
  26. return "OK: memory_generateConstPlayfield"
  27. }
  28. return "ERR: memory_generateConstPlayfield"
  29. }
  30. // L36: Run.
  31. fun main(args: Array<String>) {
  32. println(test_memory_generateConstPlayfield())
  33. }