Skip to content

Instantly share code, notes, and snippets.

@motokiee
Last active January 15, 2016 05:49
Show Gist options
  • Save motokiee/dca6b599bd83c3f64063 to your computer and use it in GitHub Desktop.
Save motokiee/dca6b599bd83c3f64063 to your computer and use it in GitHub Desktop.
けさ書いたゾロ目判定処理。もうちょっとうまく書けたりするかな #CodePiece
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