Skip to content

Instantly share code, notes, and snippets.

@Eeyore741
Last active July 9, 2018 13:51
Show Gist options
  • Save Eeyore741/f56bafe0f8804fa388ff9a63ddd60c24 to your computer and use it in GitHub Desktop.
Save Eeyore741/f56bafe0f8804fa388ff9a63ddd60c24 to your computer and use it in GitHub Desktop.
private func pineappleCountForRussian(count: UInt) -> String{
if (count == 0) return "У Джона нет ананасов"
if (count % 10 == 1
&&
count % 100 != 11) {
return String.init(format: "У Джона %u ананас", count)
}
else
if ((count % 10 >= 2 && count % 10 <= 4)
&&
!(count % 100 >= 12 && count % 100 <= 14)) {
return String.init(format: "У Джона %u ананаса", count)
}
else
if (count % 10 == 0
||
(count % 10 >= 5 && count % 10 <= 9)
||
(count % 100 >= 11 && count % 100 <= 14)) {
return String.init(format: "У Джона %u ананасов", count)
}
return "Oops!";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment