Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
17
Task/Department-numbers/Swift/department-numbers-1.swift
Normal file
17
Task/Department-numbers/Swift/department-numbers-1.swift
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
let res = [2, 4, 6].map({x in
|
||||
return (1...7)
|
||||
.filter({ $0 != x })
|
||||
.map({y -> (Int, Int, Int)? in
|
||||
let z = 12 - (x + y)
|
||||
|
||||
guard y != z && 1 <= z && z <= 7 else {
|
||||
return nil
|
||||
}
|
||||
|
||||
return (x, y, z)
|
||||
}).compactMap({ $0 })
|
||||
}).flatMap({ $0 })
|
||||
|
||||
for result in res {
|
||||
print(result)
|
||||
}
|
||||
17
Task/Department-numbers/Swift/department-numbers-2.swift
Normal file
17
Task/Department-numbers/Swift/department-numbers-2.swift
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
var res = [(Int, Int, Int)]()
|
||||
|
||||
for x in [2, 4, 6] {
|
||||
for y in 1...7 where x != y {
|
||||
let z = 12 - (x + y)
|
||||
|
||||
guard y != z && 1 <= z && z <= 7 else {
|
||||
continue
|
||||
}
|
||||
|
||||
res.append((x, y, z))
|
||||
}
|
||||
}
|
||||
|
||||
for result in res {
|
||||
print(result)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue