September 2017 Update
This commit is contained in:
parent
bba7bfd280
commit
ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions
22
Task/ABC-Problem/Swift/abc-problem-2.swift
Normal file
22
Task/ABC-Problem/Swift/abc-problem-2.swift
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
import Swift
|
||||
|
||||
func canMake(word: String) -> Bool {
|
||||
var blocks = [
|
||||
"BO", "XK", "DQ", "CP", "NA", "GT", "RE", "TG", "QD", "FS",
|
||||
"JW", "HU", "VI", "AN", "OB", "ER", "FS", "LY", "PC", "ZM"
|
||||
]
|
||||
|
||||
for letter in word.uppercased().characters {
|
||||
guard let index = blocks.index(where: { $0.characters.contains(letter) }) else {
|
||||
return false
|
||||
}
|
||||
|
||||
blocks.remove(at: index)
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
let words = ["a", "bARK", "boOK", "TreAt", "CoMmon", "SquAd", "CONFUse"]
|
||||
|
||||
words.forEach { print($0, canMake(word: $0)) }
|
||||
Loading…
Add table
Add a link
Reference in a new issue