Created
March 12, 2016 13:23
-
-
Save el-hoshino/53eaded008ee617cf6d1 to your computer and use it in GitHub Desktop.
ズンドコキヨシ with Swift ref: http://qiita.com/lovee/items/1bfc190a8a221cc6b01c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
let candidates = ["ガルパン", "は", "いい", "ぞ"] | |
var createdPhrase = [String](count: candidates.count, repeatedValue: "") | |
for i in 0 ..< Int.max { | |
if createdPhrase != candidates { | |
let randomNumber = Int(arc4random_uniform(UInt32(candidates.count))) | |
let nextWord = candidates[randomNumber] | |
print(nextWord) | |
createdPhrase.removeFirst() | |
createdPhrase.append(nextWord) | |
} else { | |
print("\(i) times") | |
break | |
} | |
} | |
print(createdPhrase.reduce("", combine: {$0 + $1}) + "!") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//前略 | |
ガルパン | |
ぞ | |
ガルパン | |
ぞ | |
ぞ | |
いい | |
いい | |
ガルパン | |
ガルパン | |
ガルパン | |
ぞ | |
は | |
いい | |
ガルパン | |
は | |
いい | |
ぞ | |
462 times | |
ガルパンはいいぞ! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment