npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

nodeforces

v1.0.0

Published

The only codeforces helper you'll ever need

Downloads

10

Readme

nodeforces

Build Status Build status Code Climate Code Climate Greenkeeper badge

The only codeforces helper library you'll ever need.

nodeforces is a library written in node that helps you compile and test your codeforces contest problems on the go.

How it Works

$ nodeforces init 765A.cpp

$ nodeforces test 765A.cpp

And that's all you need to create and test your code.

Features

  • Parse problem sample input and output
  • Source file generation with required template
  • Compile and Execute code
  • Debug lines parser
  • Test your code against sample input and output
  • Support for Java javac and C++ g++

Install

The package can be installed with node.js npm package manager. If you dont have nodejs installed you can download it here

$ npm install -g nodeforces

Note: The -g flag might require sudo permisson.

Usage

The easiest way to get started is typing the below in your favorite shell

$ nodeforces --help

This outputs some useful information like

Usage: nodeforces [command]


Commands:

  version
  init|i [problem_name]  This command initializes a codefile for you to start coding
  test|t [problem_name]  This command (compiles,) runs your code against sample test cases

Options:

  -h, --help     output usage information
  -v, --version  output the version number

Initialize a problem

$ nodeforces init 585C.java

File Created at /home/krishna/585C/585C.java. Get ready to start coding

The above command automatically creats a folder 585C in your home directory and adds the source file 585C.java along with sample input and output files. You can change the directory to store and other options (see Advanced Usage)

See the extension .java. That's what tells the module to compile your code using javac. For specifying compiler options (see Advanced Usage)

Note: If you're using Java make sure to write your main method inside Main class that is not public (something like below)

585C.java

class Main {
    public static void main(String[] args) {
        // your code here.
    }
}

Test your solution

$ nodeforces test 585C.java

The above command automatically compiles and tests your code against sample inputs and outputs. The output might look something like

$ nodeforces test 585C.java


		Reporting Basic Test Results.
	However there are still pretests and finaltests that we cant see :)

  ***Tests for 585C**
    ✓ Case: 1
    1) Case: 2

  1 passing (16ms)
  1 failing

  1) ***Tests for 585C** Case: 2:

      Uncaught AssertionError: expected [] to deeply equal [ 'Impossible' ]
      + expected - actual

      -[]
      +[
      +  "Impossible"
      +]

The output format should be familiar to you if you've used Mocha before. It simply reports all the test results with expected output and your output.

Advanced Usage

Configuration

Advanced users can create a .cfrc file in their home directory for specifying advanced options. The config should be a json file that looks something like

{
    "src": {
        "dir": "/path/to/dir/to/store/problems",
        "fileHeaderPath": "/path/to/file/header/to/include/in/your/source"
    },

    "compiler": {
        "options": ["-std=c++11"]
    }
}

Testing with debug flag

When you need to log something to stdout for debugging purpose, all you need to do is test with the -d flag. The -d flag parses the lines starting with ~ and automatically shows them as the debug log. For instance,

    888A.cpp
    if (case == 1)
        printf("~I am debug line\n");

Now running the below command produces something like,

    $ nodeforces test 888A.cpp -d
    DEBUG output for Case: 1
    I am a debug line
    ***Tests for 585C**
      ✓ Case: 1
      ✓ Case: 2

    2 passing (16ms)

Contributing

  • The project follows gitflow branching model.
  • Branch off of develop into a feature/your_feature branch.
  • Do a npm run test to make sure you're not breaking anything.
  • Send a pull request to develop branch with a meaningful description.