Last active
December 31, 2017 14:55
-
-
Save yutailang0119/130ab77ce755423ca5538181cf2b4485 to your computer and use it in GitHub Desktop.
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 | |
enum Phrase: Int, CustomStringConvertible { | |
case zun = 0 | |
case doko = 1 | |
var description: String { | |
switch self { | |
case .zun: | |
return "ずん" | |
case .doko: | |
return "どこ" | |
} | |
} | |
} | |
func kiyoshiNoZundokoBushi() { | |
for _ in 0..<INT_MAX { | |
let phrases: [Phrase] = Array(0..<5).flatMap({ _ in Phrase(rawValue: Int(arc4random_uniform(2))) }) | |
let string: String = phrases.reduce("", { (result, phrase) in | |
return result + phrase.description | |
}) | |
if phrases == [.zun, .zun, .zun, .zun, .doko] { | |
print(string + "きよし!") | |
break | |
} else { | |
print(string) | |
} | |
} | |
} | |
kiyoshiNoZundokoBushi() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment