Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env ruby
- require "httparty"
- require "nokogiri"
- class ChallengesSolves
- def initialize(user)
- @user = user
- end
- def solves
- @solves ||= Pathname("#{__dir__}/rankk_solves.txt")
- .readlines
- .map(&:chomp)
- .map{|line| line.split("\t")}
- .map{|id, count| [id, count.to_i]}
- .to_h
- end
- def solved_by_user
- @solved_by_user ||= begin
- doc = Nokogiri::HTML(HTTParty.get("https://www.rankk.org/user/#{@user}"))
- doc.css(".solved li").map{|li|
- a, b = li.text[/\S+/].split("/")
- "%d/%02d" % [a, b]
- }
- end
- end
- def call
- solves
- solved_by_user
- report = solves
- .map{|id,count|
- [-count, id, solved_by_user.include?(id) ? "DONE" : ""]
- }
- .sort
- .map{|c,i,s| [-c,i,s] }
- report.each do |row|
- puts row.join("\t")
- end
- end
- end
- ChallengesSolves.new("taw").call
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement