This commit is contained in:
Михаил Капелько
2024-03-26 22:33:57 +03:00
parent 2891de43a0
commit 650bf410e8
9 changed files with 7 additions and 7 deletions

14
Swift/Memory.Aux.swift Normal file
View File

@@ -0,0 +1,14 @@
func memory_generateConstPlayfield(
_ n: Int
) -> [Int: Int] {
var idGroups = [Int: Int]()
var id = 0
for gid in stride(from: 0, to: n, by: 1) {
idGroups[id] = gid
id += 1
idGroups[id] = gid
id += 1
}
return idGroups
}

14
Swift/Memory.Test.swift Normal file
View File

@@ -0,0 +1,14 @@
func test_memory_generateConstPlayfield() -> String {
let 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"
}

1
Swift/main.swift Normal file
View File

@@ -0,0 +1 @@
print(test_memory_generateConstPlayfield())