Skip to main content

A Python Helper CLI for Competitive Programming

Project description

FastSnake

Python Package Pypi License Platforms Python Version Downloads

FastSnake is a command-line tool that allows you to easily create, expand, run, and test Python / C++ solutions for competitive programming problems, besides automatically downloading test cases from the best contest platforms.

This project provides useful CLI tools for competitive programming, such as test case generators, algorithms and data structures, tools for platforms Codeforces and AtCoder, and other features that assist you during the development and testing of solutions.

Installing FastSnake:

$ pip install FastSnake

Use one of the commands below to check if the installation was successful.

$ fastsnake -v

or

$ python3 -m fastsnake -v

Basic Usage:

Starting a contest from Codeforces...

$ fastsnake codeforces -sc <contest_id>

Note: The contest ID can be found at contest URL https://codeforces.com/contest/<id>

Once you have written your solution, test it.

$ fastsnake test <problem>

You can also create your own generator, at test_generators folder, to bruteforce your solution.

$ fastsnake test <problem> -g <n_tests>

Note: By default, FastSnake will analyze the output with case sensitivity. However, you can enable case-insensitive analysis by using the --case-insensitive flag.

Starting a Custom Contest

Use the command below to start your own contest.

$ fastsnake start-custom-contest <n_problems>

Algorithms and Structures

FastSnake provides some algorithms and structures that can be injected to your final solution. See the sample below:

Python Solution:

from fastsnake.algorithms.min_coins import *

coins = []

for x in input().split():
    coins.append(int(x))

value = int(input())

result = min_coins(coins, value)
print(result)

Use the argument --list <algorithms | structures | external> to see all algorithms and structures provided by FastSnake.

Injecting the algorithm to the final solution...

$ fastsnake compile main.py

Check out the code of the generated Python module.

Testing and Compiling

You may test and compile your solution using the command below:

$ fastsnake test <problem> -c

If the solution was accepted at all test cases, it will be compiled.

Adding External Modules

You may also add your own modules to the external package of fastsnake.

$ fastsnake add-external <path | url> --name <module_name> [--url]

For downloading the module from web, use the flag --url.

Step Counter

The --step-counter flag of the command test can be used to count the approximate number of steps executed by your solution.

By default, it analyzes the entire code, but you can set a starting point by adding the following comment on the line:

# [START STEP COUNTER]
...

Note: The step counter only analyzes the code that has been required for testing. This means that if you don't compile your code before testing using the --compile-before flag, it won't consider fastsnake algorithms and structures.

Support for C++ Language

You may use C++ language to solve contests by using the flag --cpp when starting a contest.

However, some features available in the Python language won't yet be available for C++.

More Information

Use the following command for more information about FastSnake CLI:

$ fastsnake -h

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fastsnake-1.5.4.tar.gz (30.6 kB view details)

Uploaded Source

Built Distribution

fastsnake-1.5.4-py3-none-any.whl (31.3 kB view details)

Uploaded Python 3

File details

Details for the file fastsnake-1.5.4.tar.gz.

File metadata

  • Download URL: fastsnake-1.5.4.tar.gz
  • Upload date:
  • Size: 30.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.10.6

File hashes

Hashes for fastsnake-1.5.4.tar.gz
Algorithm Hash digest
SHA256 58c2406c292b3ccc6789efb3399beff2d56f5af9de12b135e0fda1d2e38f0759
MD5 983aa0e8207ea9a11510800abbdbac57
BLAKE2b-256 e4d61cd372fa3c3f415cc3312dca81eb85a26277e5e3135eae27b61d85a70b99

See more details on using hashes here.

File details

Details for the file fastsnake-1.5.4-py3-none-any.whl.

File metadata

  • Download URL: fastsnake-1.5.4-py3-none-any.whl
  • Upload date:
  • Size: 31.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.10.6

File hashes

Hashes for fastsnake-1.5.4-py3-none-any.whl
Algorithm Hash digest
SHA256 10c01a39fb71f115a35c299d01ca0cd91adcd19d64c2ea7a539a49c341311d37
MD5 6fff05e7f0281610ea52310fb002f308
BLAKE2b-256 6099bb3f4ed628cf8a83647ca061b766277919b4de7b7f6755e232f4cc1856b5

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page