Skip to main content

A Python Helper CLI for Competitive Programming

Project description

FastSnake

Python Package Pypi License Platforms Python Version Downloads

Tired of having to copy and paste your code from your personal library into every solution you write? Or always having to copy and paste test cases from contests? FastSnake is a command-line tool that allows you to easily create, expand, run, and test Python solutions for competitive programming problems.

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.

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.4.22.tar.gz (23.1 kB view details)

Uploaded Source

Built Distribution

fastsnake-1.4.22-py3-none-any.whl (26.6 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for fastsnake-1.4.22.tar.gz
Algorithm Hash digest
SHA256 ee336bbd4278059503222f37d77390e60402e7d56c3d89812873442acfe3d29a
MD5 9cd1b3ab2914dd48e8cab84ed37f342d
BLAKE2b-256 1d2715f4174d97f99b6df12e9e302a87b9b062bfdefffac4dcd520636a7df0fa

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fastsnake-1.4.22-py3-none-any.whl
  • Upload date:
  • Size: 26.6 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.4.22-py3-none-any.whl
Algorithm Hash digest
SHA256 643755958da9eacbea401d0f6204aca8d443e2fac24c3f6d71d7a3fc1ec71105
MD5 40daa0841c1a65cf275015ba634498ea
BLAKE2b-256 88a2af9d25e2787c9fb3ce273cf629b1f1ef9f079d0b01dbb25200668625b5a9

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