I made this tool which recommends problems based upon the problems already solved by the user. It can also be used to find problems similar to any given problem.
created
last reply
- 5
replies
- 1.2k
views
- 3
users
- 2
links
I made this tool which recommends problems based upon the problems already solved by the user. It can also be used to find problems similar to any given problem.
It doesn't work for challenge problems because I have been scraping data from the plaintext history by looking for "AC"s. Thanks for pointing this out, I will try to get it fixed sometime within the next few days.
My code is available on Github, but it is a little messy right now. github.com/vikhyat/spojtool3
Basically, I get a list of problems solved by several users, and then invert this data to get a list of users who have solved each problem. Then I compute the similarity of problems. (I am using the Sørensen index currently.) For each problem, I compute the similarity with every other problem I know of and store the top few matches. (This data is in similarities.rb.) Once I have the similarities, it is quite straightforward to recommend problems:
def recommendations(user)
scores = {}
my_problems = solved_problems(user)
my_problems.each do |problem|
similar = $similarities[problem.to_sym]
for i,j in similar # i is the problem code, j is the similarity
next if my_problems.include? i.to_s
scores[i] ||= 0
scores[i] += j
end
end
scores.sort_by {|k,v| v }.reverse.map {|x| x[0] }[0..19]
end