Add tasks for all the new languages
This commit is contained in:
parent
9dc3c2bb62
commit
bba7bfd280
13208 changed files with 134745 additions and 0 deletions
15
Task/Run-length-encoding/Swift/run-length-encoding-3.swift
Normal file
15
Task/Run-length-encoding/Swift/run-length-encoding-3.swift
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
// "3W1B2W" -> "WWWBWW"
|
||||
func decode(encoded: String) -> String {
|
||||
let scanner = NSScanner(string: encoded)
|
||||
var char: NSString? = nil
|
||||
var count: Int = 0
|
||||
var out = ""
|
||||
|
||||
while scanner.scanInteger(&count) {
|
||||
while scanner.scanCharactersFromSet(NSCharacterSet.letterCharacterSet(), intoString: &char) {
|
||||
out += String(count: count, repeatedValue: Character(char as! String))
|
||||
}
|
||||
}
|
||||
|
||||
return out
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue