Class: AOJ::Problem

Inherits:
Object
  • Object
show all
Defined in:
lib/aoj/problem.rb

Constant Summary collapse

ICPC_VOLUMES =
[
  '10', '11', '12', '13', '20', '21', '22', '23', '24', '25', '26'
].freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#availableObject

Returns the value of attribute available.



3
4
5
# File 'lib/aoj/problem.rb', line 3

def available
  @available
end

#idObject

Returns the value of attribute id.



3
4
5
# File 'lib/aoj/problem.rb', line 3

def id
  @id
end

#memory_limitObject

Returns the value of attribute memory_limit.



3
4
5
# File 'lib/aoj/problem.rb', line 3

def memory_limit
  @memory_limit
end

#nameObject

Returns the value of attribute name.



3
4
5
# File 'lib/aoj/problem.rb', line 3

def name
  @name
end

#time_limitObject

Returns the value of attribute time_limit.



3
4
5
# File 'lib/aoj/problem.rb', line 3

def time_limit
  @time_limit
end

Class Method Details

.random_icpc(user_id) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/aoj/problem.rb', line 16

def random_icpc(user_id)
  volumes = ICPC_VOLUMES
  solved_ids = AOJ::API.user(user_id)[:solved_list].map { |s| s[:id] }
  volumes.shuffle.each do |volume|
    problem_list = AOJ::API.problem_list(volume).map { |e| e[:id] } - solved_ids
    unless problem_list.empty?
      problem_id = problem_list.sample
      return AOJ::API.problem_search(problem_id)
    end
  end
  raise AOJ::Error::NoProblemLeftError
end

Instance Method Details

#urlObject



5
6
7
8
9
# File 'lib/aoj/problem.rb', line 5

def url
  base_url = "http://judge.u-aizu.ac.jp/onlinejudge/description.jsp"
  params = { "id" => id }
  base_url + "?" + params.to_query
end