Skip to content

Instantly share code, notes, and snippets.

@masaha03
Created January 20, 2014 05:59
Show Gist options
  • Save masaha03/8515617 to your computer and use it in GitHub Desktop.
Save masaha03/8515617 to your computer and use it in GitHub Desktop.
otoshidama <- function(x) {
rank <- c("一等?", "二等?", "三等!", "三等!", "外れ")
tosen <- c(97085, 2344, 72, 74)
result <- NULL
for (i in x) {
tmp <- grep(sprintf(".*%s$", i), tosen)
tmp <- ifelse(length(tmp) == 0, 5, tmp)
  result <- c(result, tmp)
}
cat("当選番号:", tosen, fill=TRUE)
cat(rank[result], sep="\n")
}
# 下二桁を入力
otoshidama(c(72, 11, 85, 35, 44))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment