Allows solutions to TopCoder problems to be written in Python. Provides both a scraper and automated marker for TopCoder problems.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


A scraper for the website

Given a problem number, this script downloads all information about the problem from the website, and creates:

  • A directory with the class name and problem number
  • An file
  • A .json file with all problem information
  • A .html file with all problem information
  • A .py file (with the method header)

The script accepts problem numbers in the form '1,2,3-4'. You can also enter a dash '-', after which you'll be asked how many problems you wish to download. The program will then look through TopCoder problem listings and find problems you do not already have, and download those.

The script needs to be in the subdirectory that contains all the TopCoder problems. It can then, given a problem name or number, automatically run all the tests for that problem.

Includes one TopCoder problem as an example.


  • Python 2.7+
  • BeautifulSoup


  • After parsing, creates a file tc_.json with all problem information
  • Saves all examples and tests in JSON-friendly format
  • Comes with an automated marking script,, which can read the JSON file and mark a problem attempt written in Python
  • Can be used for building Python TopCoder testing suites

Getting started

  1. Download the first 10 problems from TopCoder

    $ -scf 10
  2. Open the corresponding python files for each problem in the ./problems directory
  3. Test each problem using TopCoder's test set. For example, test your code for problem 11777 using:

    $ -t 11777

Tutorial - how to attempt problem 11777

  1. Download problem 11777, overwriting any existing ones, and cleaning the problems directory.

    $ -cf 11777
    2. Open the corresponding file for problem 11777, and add your code to it
    $ cd problems/11777_BuildingReorganization
    $ vim
    1. Test your code
    $ -t 11777


    1. See more help for the script:
    $ --help
    1. Fetch problems 1, 2, 3 and 5 if I don't have them, and save them in the problems directory:
    $ 1-3,5
    1. Fetch problem 11777 and save it in /usr/var/problems:
    $ -o /usr/var/problems 11777
    1. Fetch problems 11777 and 117779, even if I already have them, and overwrite everything, even the python file if it exists already:
    $ 11777,11779 --force
    1. Fetch up to 10 new problems from TopCoder, unless I already have them
    $ 10 --smart
    1. Fetch 10 new problems from TopCoder, downloading them even if I have them already, and overwriting everything:
    $ 10 --smart --force
    1. Fetch all problems between 10 and 50 on the TopCoder listing, overwriting everything:
    $ 10,50 --smart --force
    1. Test problems 8, 9 and 10
    $ 8-10 --test
    1. Test problem 8, cleaning the problems directory first
    $ 8 --test --clean