Skip to content

Commit

Permalink
Merge pull request soapyigu#152 from soapyigu/String
Browse files Browse the repository at this point in the history
[String] optimize code style for Flip Game
  • Loading branch information
soapyigu authored Dec 7, 2016
2 parents 0f1f024 + 03b52c6 commit 1621482
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions String/FlipGame.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,16 @@
class FlipGame {
func generatePossibleNextMoves(s: String) -> [String] {
var res = [String]()
var sChars = [Character](s.characters)
var sChars = Array(s.characters)

guard sChars.count > 1 else {
return res
}

for i in 0 ..< sChars.count - 1 {
if sChars[i] == "+" && sChars[i + 1] == "+" {
var temp = [Character](sChars)
temp[i] = "-"
temp[i + 1] = "-"
var temp = sChars
(temp[i], temp[i + 1]) = ("-", "-")
res.append(String(temp))
}
}
Expand Down

0 comments on commit 1621482

Please sign in to comment.