Skip to main content

Code Faster

Cross-platform command line utility for bootstrapping online codes (especially codeforces) and running with automatic testing.

Index


Uses

This package installs two commands:

  • cfetch

    This will fetches the code from given url.

    usage: cfetch [-h] [-l {cpp,java,py}] [-d DIR] url
    positional arguments:
    url                   url of the code
    
    optional arguments:
    -h, --help                    show this help message and exit
    -l, --language {cpp,java,py}  default is cpp
    -d, --dir DIR             if given then uses this dir and language flag will be ignored.
    

    If dir is provided (language flag will be ignored) then it'll copy the contents of your sample dir into the created one. Using this you can use your own template for any language whatsoever. However, runner will still work only on supported languages.

    example:

    cfetch http://codeforces.com/problemset/problem/1/A
    

    This will create a folder named CF1-A in the current directory with sample test cases and main.cpp file.

  • crun This will run the file and if there are test cases present in the file's directory it will run them too.

    crun <file-path> [args]
    

    Where args are compiler args for compiled languages like c++ and java.

    example:

    crun CF1-A\main.cpp
    

    This will create a folder for binaries in the file's directory with the output of sample tests. It will also generates the test report.

    You can manually create more test files. Supported formats are:

    Input Output
    .i.txt .o.txt
    .i .o
    .input .output

Example

First we will fetch a problem from codeforces.com

> cfetch http://codeforces.com/problemset/problem/1/A
CF1-A created
test_1 created
main.cpp created

Now we will try to run it with our sample generated code.

> crun CF1-A\main.cpp
g++  -o CF1-A\bin\main.exe CF1-A\main.cpp
========================================
test_1 FAILED
---------------------------------------- [output]
6
---------------------------------------- [answer]
4
========================================
:( 0/1 passed.

Now fix the main.cpp file to solve the problem.

int main() {
    using namespace std;

    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int n, m, a;
    cin >> n >> m >> a;

    int r = ((n + a - 1) / a) * ((m + a - 1) / a);
    cout << r << '\n';
}
> crun CF1-A\main.cpp
g++  -o CF1-A\bin\main.exe CF1-A\main.cpp
========================================
test_1 PASSED
========================================
:) 1/1 passed.

Installing

You can install from pypi.

pip install code-faster -U

Or, you can install directly from the repository using pip.

pip install git+https://github.com/rahulsrma26/code_faster

Setting up with VSCode

You can set keyboard shortcuts to any editor basically. There are plenty of extensions in VSCode that can do that but for demonstration we will be using Code Runner

For code-runner, edit settings.json file in .vscode folder.

{
    "code-runner.fileDirectoryAsCwd": true,
    "code-runner.runInTerminal": true,
    "code-runner.saveFileBeforeRun": true,
    "code-runner.executorMap": {
        "cpp": "crun $fileName",
        "java": "crun $fileName",
        "python": "crun $fileName"
    }
}

Now to run a file just open it and press control+option+n (on mac) or control+alt+n (on pc).

Note: If you are using conda environments and if it's not added to the path environments (or bash). Then crun may be unaccessible in the terminal by default. So, you either need to activate it in the terminal, or you need to update the shell args.

"terminal.integrated.shellArgs.windows": ["/K", "<conda-install-path>/Scripts/activate && conda activate <your-env>"]

For linux you can change terminal.integrated.shellArgs.linux and for mac change terminal.integrated.shellArgs.osx

Release files for code-faster 0.4.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for code-faster 0.4.1
File Size Uploaded
code_faster-0.4.1.tar.gz 12.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for code-faster 0.4.1
File Interpreter ABI Platform
code_faster-0.4.1-py3-none-any.whl Python 3 none any Details

Total release size: 26.5 kB

Release files / code_faster-0.4.1.tar.gz

Download URL code_faster-0.4.1.tar.gz
Size 12.8 kB
Tags Source
SHA-256 checksum
How to use checksums
7e3515ff86c962f63594a0a7729a864de7b49c9422ccda28b81f5e4d29473324
BLAKE2b-256 checksum
How to use checksums
365bb8401116f2b0e2ddab1f1173761c922b93c7c901095ac035c801068a0b01
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2.post20191203 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.6.9

Release files / code_faster-0.4.1-py3-none-any.whl

Download URL code_faster-0.4.1-py3-none-any.whl
Size 13.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
eb62005c162337dfe88a3fc6443dfeef68bfbb0d65e1d3d694c57df86b723e8a
BLAKE2b-256 checksum
How to use checksums
8fcdacfadc6c6762252a450da718027d20f6a561c312bce85177bc2ef6d02a6b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2.post20191203 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.6.9

Release history Release notifications | RSS feed

This release

0.4.1 This release

2 release files

0.4.0

2 release files

0.3.1

2 release files

0.3.0

1 release file

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.2

2 release files

0.1.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page