Install, run and share command line challenges. Perfect for learning, practicing or teaching others how to code.
You will need to install node.js. Once done, you can use
npm to install the module globally and use the command line interface.
npm install -g code-challenge
challenge select # Select a challange to usechallenge exercise # Select an exercise to runchallenge print # Print the currently selected exercisechallenge run [args] # Run your solution in a test environmentchallenge verify [args] # Check your solution is correctchallenge help # Help menuchallenge reset # Reset everythingchallenge next # Move to the next exercisechallenge prev # Move to the previous exercise
To get started, try installing your first challenge. I'd recommend Project Euler using
npm install -g code-challenge-euler.
To create a custom challenge pack to share, you'll need to create a new npm module and add
code-challenge as a dependency. The module name must be prefixed with
code-challenge- to automatically be loaded. The modules main file should require
code-challenge, set the challenge title and add exercises.
var assert = ;var challenge = ;challengetitle = 'Example Challenge';challenge;...challenge;
Challenge comes with a
renderFile method that supports rending content from a file with standard syntax highlighting and colours.
Challenge support executing most programming languages based on the file name automatically. By using the
spawnFile methods, your challenge will be future proof and support all possible languages.
When running the verification task, you can throw an error, reject a promise, error in a stream or pass an error as the first parameter of the callback to provide feedback.