Last active
January 15, 2016 05:49
-
-
Save motokiee/dca6b599bd83c3f64063 to your computer and use it in GitHub Desktop.
けさ書いたゾロ目判定処理。もうちょっとうまく書けたりするかな #CodePiece
This file contains hidden or 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
func isZorome(number:Int) -> Bool { | |
let numString = String(number) | |
guard numString.characters.count > 1, let first = numString.characters.first else { | |
return false | |
} | |
let bools = numString.characters.map { $0 == first }.reduce(true) { (a, b) -> Bool in | |
a&&b | |
} | |
return bools | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment