Hunter is an easy to use uHunt wrapper to receive information from UVa's online judge.
Hunter is licensed under the MIT License - see the LICENSE file for details.
use Hunter\Hunter;
require "vendor/autoload.php";
$hunter = new Hunter();
echo $hunter->getIdFromUsername("Kaspars");
The easiest and recommended method to install Hunter is via composer.
Use the following command to install with composer.
$ composer require kaspars/hunter
If you wish you can create the following composer.json file and run composer install to install it.
{
"require": {
"kaspars/hunter": "~1.0"
}
}
First of all, you really should use composer.. But if you insist, then just copy the content from src
folder into your project
All data is returned as an associated array.
id
Problem IDnumber
Problem numbertitle
Problem titledacu
Number of distinct accepted usersbestRuntime
Best runtime in milliseconds of an Accepted Submissionverdicts
An array given verdictsHunter\Status::NO_VERDICT
Number of No Verdict Given (can be ignored)Hunter\Status::SUBMISSION_ERROR
Number of Submission ErrorHunter\Status::CANT_BE_JUDGED
Number of Can't be JudgedHunter\Status::IN_QUEUE
Number of In QueueHunter\Status::COMPILATION_ERROR
Number of Compilation ErrorHunter\Status::RESTRICTED_FUNCTION
Number of Restricted FunctionHunter\Status::RUNTIME_ERROR
Number of Runtime ErrorHunter\Status::OUTPUT_LIMIT
Number of Output Limit ExceededHunter\Status::TIME_LIMIT
Number of Time Limit ExceededHunter\Status::MEMORY_LIMIT
Number of Memory Limit ExceededHunter\Status::WRONG_ANSWER
Number of Wrong AnswerHunter\Status::PRESENTATION_ERROR
Number of Presentation ErrorHunter\Status::ACCEPTED
Number of Accepted
limit
Problem runtime limit in millisecondsstatus
Problem StatusHunter\Status::UNAVAILABLE
UnavailableHunter\Status::Normal
NormalHunter\Status::SPECIAL_JUDGE
A special judging program is used.
rejudged
Last time (unix timestamp) the problem was rejudged,null
if never.
id
Submission`s IDuser
User IDname
User's full nameusername
User`s usernameproblem
Problem's IDverdict
Given verdictHunter\Status::SUBMISSION_ERROR
Submission ErrorHunter\Status::CANT_BE_JUDGED
Can't be JudgedHunter\Status::IN_QUEUE
In QueueHunter\Status::COMPILATION_ERROR
Compilation ErrorHunter\Status::RESTRICTED_FUNCTION
Restricted FunctionHunter\Status::RUNTIME_ERROR
Runtime ErrorHunter\Status::OUTPUT_LIMIT
Output Limit ExceededHunter\Status::TIME_LIMIT
Time Limit ExceededHunter\Status::MEMORY_LIMIT
Memory Limit ExceededHunter\Status::WRONG_ANSWER
Wrong AnswerHunter\Status::PRESENTATION_ERROR
Presentation ErrorHunter\Status::ACCEPTED
Accepted
language
Language in which submission was writtenHunter\Language::ANSI_C
Ansi CHunter\Language::Java
JavaHunter\Language::CPLUSPLUS
C++Hunter\Language::PASCAL
PascalHunter\Language::CPLUSPLUS11
C++11Hunter\Language::PYTHON
Python
runtime
Runtime in millisecondsrank
Submission rank, compared to alltime
Submission unix timestamp
id
User`s IDname
User`s nameusername
User`s usernamerank
User's rankaccepted
The number of accepted problemssubmissions
The number of submissionsactivity
Array of user's activityHunter\Activity::DAYS
Activity in the last 2 daysHunter\Activity::WEEK
Activity in the last 7 daysHunter\Activity::MONTH
Activity in the last 31 daysHunter\Activity::QUARTER
Activity in the last 3 monthsHunter\Activity::YEAR
Activity in the last year
#API
##getIdFromUsername(string $username)
Convert the given $username
to a UVa ID.
Returns either the id, or null
if not found
$hunter = new Hunter\Hunter();
echo $hunter->getIdFromUsername("Kaspars"); //343417
echo $hunter->getIdFromUsername("Foobar"); // null
Returns an array of available UVa problems
$hunter = new Hunter\Hunter();
var_dump($hunter->problems());
Retrieved data of a specific problem
$hunter = new Hunter\Hunter();
var_dump($hunter->problem(36));
var_dump($hunter->problem(100, "num"));
View submissions to specific problems on a given submission date range.
$start
and $end
are unix timestamps
$hunter = new Hunter\Hunter();
var_dump($hunter->problemSubmissions(36));
var_dump($hunter->problemSubmissions(array(36,37)));
Returns submissions to a problem ranked from $rank to $rank + $count - 1.
$hunter = new Hunter\Hunter();
var_dump($hunter->problemRanklist(36));
Returns nearby submissions (by runtime) for a particular user submission to a problem.
$hunter = new Hunter\Hunter();
var_dump($hunter->userProblemRanklist(36, 343417));
Returns all of the submissions of a particular user.
if $min
is specified, only submissions with ID larger than $min
will be returned.
$hunter = new Hunter\Hunter();
var_dump($hunter->userSubmissions(343417));
Returns the last $count submissions of a particular user.
$hunter = new Hunter\Hunter();
var_dump($hunter->userLatestSubmissions(343417));
Returns all the submissions of the users on specific problems.
Possible $type
values are id and num. This changes whether you pass problem id's or problem num's as the second argument.
$hunter = new Hunter\Hunter();
var_dump($hunter->userProblemSubmissions(343417, 36);
Get The Bit-Encoded-Problem IDs that Has Been Solved by Some Authors.
$hunter = new Hunter\Hunter();
var_dump($hunter->userSolvedProblems(343417));
Returns the user's ranklist and their closest neighbors.
$hunter = new Hunter\Hunter();
var_dump($hunter->userRanklist(343417, 10, 10));
Global ranklist, starteing from $rank
to $rank+$count
$hunter = new Hunter\Hunter();
var_dump($hunter->ranklist(1, 100));
Change the source of API data. The default is http://uhunt.felix-halim.net/api/, another valid source is http://icpcarchive.ecs.baylor.edu/uhunt/api/. But you can switch to any source that has the same data format.
$hunter = new Hunter\Hunter();
var_dump($hunter->setSource('http://icpcarchive.ecs.baylor.edu/uhunt/api/'));
Returns the current used API source.
$hunter = new Hunter\Hunter();
var_dump($hunter->getSource());