Giter Club home page Giter Club logo

single-command-execution-competitive-programming's Introduction

single-command-execution-competitive-programming

Single line bash command for compiling and running a program for Competitive Programming

Languages Supported

  • C++
  • C
  • Java
  • Python

Installation

  • curl and execute the INSTALL.sh file
curl -sS https://raw.githubusercontent.com/Snowden1738/single-command-execution-competitive-programming/master/INSTALL.sh | sh

Install curl if you don't have it installed.

  • Reload the terminal
exec bash -l

Usage

Usage 1

cpr <source file name>

This will compile and run the file with filename <source file name> in the corresponding language's compilation/interpretation and execution command and will redirect to STDIN (STanDard INput) from the file with filename in.txt. in.txt is generally the filename widely used for the default input file.

Usage 2

cpr <source file name> <input file name>

This will compile and run the file with filename <source file name> in the corresponding langauge's compilation/interpretation and execution command and will redirect to STDIN from the file with filename <input file name>. This format is supposed to be used when you have a input file with a different filename. This is to save the time during a contest for renaming your input file's filename to in.txt. Use this mostly when you have multiple input files to test your code with. Otherwise you can copy the input(s) again and again to in.txt and use it according to Usage 1.

Exemplar Usage

The examples folder contains a simple input/output code in the 4 supported languages which scans an integer N in the first line of input and then scans N integers from the second line and prints the sum of these N integers. All the source files have the same name test but different extensions for different languages. The folder also contains two input files: in.txt - the default input file and otherinputfile.txt for demonstrating taking input from a file with filename other than in.txt, the same mentioned in Usage #2.

  • Open the examples folder and right-click on the window and click Open in Terminal.
  • Let's try out the C++ file test.cpp using the default input file in.txt:
cpr test.cpp

Since no input file has been passed as the second argument, it'll accept input from the default input file - in.txt. The file in.txt contains N = 6 integers: 1 9 2 3 5 6. The sum of these integers is 26. Hence, after executing the above command, 26 will be printed to the console.

  • Let's try this out with a different input file - otherinputfile.txt:
cpr test.cpp otherinputfile.txt

Since an input file has been passed as the second argument, it'll accept input from this given file. The file otherinputfile.txt contains N = 5 integers: 1 9 3 5 6. The sum of these integers is 24. Hence, after executing the above command, 24 will be printed to the console.

Note for Java users

The class containing the main(String[] args) method should be named Main. If you make this class public, make sure to make the filename Main.java, although that goes without saying if you've previously coded in Java then you probably know this thing. Anyway, you may change the script according to your needs after downloading as you see fit.

single-command-execution-competitive-programming's People

Contributors

snowden1738 avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.