Created 1/5/2022.
Revised 3/27/2022 for clarity and consistency.
Revised 7/4/2022 to add language field and for clarity.
The FastCode Contest API is an extremely simple web service with one endpoint and two methods. It is used to retrieve datasets and submit answers. The interval between request and correct response is the metric this contest measures. So, consider directly retrieving your dataset from this API to save processing time for official runs.
Each challenge describes a dataset format (input), a computation (process), and an answer format (output). Examples of tiny datasets and their corresponding answers are given in the challenge description. The challenge description page also lists the currently available datasets. Correct answers are provided for example datasets. Other datasets are unique to each contestant and answers are not provided.
Requests are authenticated via a header bearer token, which uniquely identifies you as a contestant. This token must not be shared with anyone else. You can find your token on your settings page. If you believe your token has been compromised you may create a new one using the RECREATE button.
To retrieve a dataset, make an authenticated HTTP request to the URL above, where {guid} is one of the dataset identifiers on the challenge description page.
For example, assuming a4971c26-5b26-4551-9837-8d8038cb5c52 is a dataset identifier and 3c0c25e6-6e95-11ec-90d6-0242ac120003 is your authentication token, the following command will create a local copy of the dataset in a file named data.bin.
$ curl https://fastcode.rocks/fast/data/a4971c26-5b26-4551-9837-8d8038cb5c52 \ -H "Authorization: Bearer 3c0c25e6-6e95-11ec-90d6-0242ac120003" \ -L --output data.bin
If the request is successful, the response code will be 302, indicating a redirect. The dataset is available at the URL indicated by the Location response header. The body of a GET request to the new location contains the actual dataset. (Since curl -L automatically follows redirects, this happens automatically in the examples above.) The initial request also "starts the clock" for performance measurement. The time between the initial request and the coresponding answer (see below) is measured to determine the performance of your code.
Redirect locations are ephimeral and expires in 15 minutes. If the data is required after this time, another must be made to obtain another redirect location.
The exact format and contents of the dataset are problem dependent and are defined on the challenge description page for each problem. Example datasets, both small and large, for each problem, with published answers, are also available on the challenge description pages.
Every attempt must be completed by posting the answer, as described below. Only one pending attempt per user is allowed (see errors below). Pending attempts can be manually canceled on the problem description page.
All challenges require a JSON answer; indicate this with this request header: Content-Type: application/json. Answers use the form of the following example.
{ "answer" : "Hello, World.", "hardware" : "Intel Core-i7-4710HQ, 2.50GHz, 4 cores, 8 threads", "language" : "gcc 9.4" }
The specific requirements of the answer field are described in each problem. The hardware and language description fields are optional and will be truncated to 80 and 20 characters respectively. To submit an answer, make an authenticated HTTP request to the URL above, where {guid} is one of the dataset identifiers on the problem description page.
For example, given the situation above and assuming answer.json contains the answer to be submitted, the following command will submit the answer and retreive scoring results.
$ curl https://fastcode.rocks/fast/data/a4971c26-5b26-4551-9837-8d8038cb5c52 \ -H "Authorization: Bearer 3c0c25e6-6e95-11ec-90d6-0242ac120003" \ -H "Content-Type: application/json" \ --data-binary @answer.json
If your submission is successful, the response code will be 200 and the body of the response will contain JSON data indicating whether the submitted answer was correct, and if so the elapsed time for the operation in seconds, as measured on the server from the time of the corresponding GET.
Example response for a correct answer:
{ "correct" : true, "seconds" : 0.089371 } |
Example response for an incorrect answer:
{ "correct" : false } |
Something about your request was incorrect. Most likely, it means a format error. Check that your request is well-formed.
Your request cannot be processed because it could not be authenticated. Verify the correct bearer token and correct dataset identifier are being used. Also check their formats.
Your request cannot be processed because an outstanding request has not yet been answered. Only one outstanding request is allowed. Attempting to retrieve additional datasets produces this error. POST the corresponding answer first, or cancel the outstanding attempt on the challenge page.
You requested an unknown dataset. Check the dataset identifier on the problem description page.
Your request was not processed because the method was wrong. Only GET and POST are allowed.
Your request was not processed because you have a pending attempt or have exceeded your token bucket limit. Pending attempts can be canceled on the problem description page. To avoid incurring additional rate penalties, do not make redundant requests and do not continue to make requests while waiting for your bucket to refill. Check your settings page for your current rate limits.
Requests are limited to an average of 100 requests/day at a maximum rate of 1 request/minute. That is, you may make a request each minute for one hundred minutes, but then you will have to wait most of 24 hours before the server will process your next request. Alternatively, you could make one request every 14.4 minutes indefinitely. Requests which exceed this limit will be denied with the response code 429.
Only previously unseen datasets affect standings. To reduce server load and encourage local testing, requests for additional unseen datasets are additionally limited to 10/day.
In addition, requests which are determined to be malicous or subvertive incur addition throttling penalties. You can check your current rate limits on the your settings page.
Thus, it is strongly recommended that your solution support saving and using local datasets to allow rapid testing without unnecessary server requests.