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

compe

v1.12.0

Published

Congrats! You just saved yourself hours of work by bootstrapping this project with TSDX. Let’s get you oriented with what’s here and how to use it.

Downloads

14

Readme

Compe.js

A CLIxLibrary for Competitive Programming with JavaScript/Node.js

Requirements

  • Node v12.x or higher (preferably v16.x+)
  • Set node modules to path variable to use cli

Installation

For the package:

npm i compe

For the cli, you can:

npm i -g compe minify

You can add the prefix npx after every command as an alternative where you want to avoid installing global package. Enable intellisense to get the best experience. We will continue as you haven't installed it globally.

Getting your first AC

Go to the folder where you want to do the coding. Then type:

npx compe i s main.js

This will initialize all the config, and you will do all the coing in main.js file. Your main.js file now should look like this:

const { proc } = require('compe');
// DO NOT EDIT ABOVE THIS LINE //
function main() {
  // Write your code here
    
}
proc(main, __filename);

Here, you will do all the coding below the // DO NOT EDIT ABOVE THIS LINE // and above the proc(main, __filename);. Except for the parts being called from the library, which should stay in the same bracket with proc, you should not write anything else above the warning line since they will be replaced with the actual library for submission later. The part below proc will be the input.

There are some global functions that responsible for reading and writing where we will show in the following example.

Sample code for printing sum and minimum value of a n x m matrix after init:

const { proc } = require('compe');
// DO NOT EDIT ABOVE THIS LINE //
function main() {
  // Read the 2 dimensions of the matrix
  let [n, m] = rnum(2);

  // Initialize the matrix with cell values of 0
  let a = array(0, n, m);

  // Initialize the sum and minimum value
  let sum = 0, minVal = Number.MAX_SAFE_INTEGER;

  // For each row
  for (let i = 0; i < n; i ++) {

    // Read the m elements of that row
    a[i] = rnum(m);
    
    // Update the sum for every elements
    for (let value of a[i]) {
      sum += value;
    }
    
    // Update the minimum value with the minimum of that row
    minVal = min(minVal, minElement(a[i]).res);
  }

  // Print the sum and minimum value, seperated by space
  print(sum, " ", minVal);
}
proc(main, __filename);
/* BELOW THIS LINE IS YOUR INPUT
3 4
1 2 3 4
4 -3 1 3
5 7 0 3
*/

If you are trying to solve in a leetcode format, you will definitely need to import and use setGlobalBuiltin() in your solution function to make the builtin functions work.

Documentation

Platforms supported

  • Leetcode
  • Codeforces
  • Atcoder, Hackerrank, ...

Resources