Skip to content

Commit

Permalink
Merge pull request #4 from hugo-morvan/fix_problem_func
Browse files Browse the repository at this point in the history
Changed difficulty parsing in problem()
  • Loading branch information
RussellDash332 authored Nov 11, 2024
2 parents b760704 + 6ac4183 commit 09b6c57
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion autokattis/api/openkattis.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,11 @@ def problem(self, problem_ids, download_files=False, *bc_args):
elif div_text[0] == ProblemMetadataField.MEMORY_LIMIT:
memory = div_text[-1].strip()
elif len(div_text) > 1 and div_text[1] == ProblemMetadataField.DIFFICULTY:
difficulty = float(div_text[0]) if div_text else None
difficulty = float((re.findall('[\d\.]+', columns[ProblemsColumn.DIFFICULTY_CATEGORY].text) or [None])[-1])
# [0] instead of [-1] if we want to take min instead of max
# for example:
# - difficulty 9.1-9.6 -> [9.1, 9.6]
# - difficulty 5.0 -> [5.0]
category = div_text[2].strip() if len(div_text) > 2 else 'N/A'
elif div_text[0] == ProblemMetadataField.SOURCE_LICENSE:
text_links = [(s.text.strip(), [a.get('href').strip('/') for a in s.find_all('a')]) for s in d.find_all('span') if s.text.strip()]
Expand Down

0 comments on commit 09b6c57

Please sign in to comment.