Skip to content

Instantly share code, notes, and snippets.

@badbye
Created January 10, 2015 12:13
Show Gist options
  • Save badbye/1e2524362ab36f569784 to your computer and use it in GitHub Desktop.
Save badbye/1e2524362ab36f569784 to your computer and use it in GitHub Desktop.
coursera(machine learning: score)
getScore = function(checkBox = 0){
result = c()
multi = 5 * checkBox
Single = 20 - checkBox
for (i in 0:Single){
for (j in 0:multi){
result = c(result, i, j, 20*i - 5*(Single-i) + j*4 - 4*(multi-j))
}
}
result = matrix(result, ncol=3, byrow = T)
result = data.frame(result)
colnames(result) = c('single', 'multi', 'score')
result[order(result$score), ]
}
getScore(5)
findScore = function(box, Score){
re = getScore(box)
subset(re, score == Score)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment