DEV Community

Sagar Medtiya
Sagar Medtiya

Posted on • Originally published at blog.sagarmedtiya.me on

Setting up an Environment for Competitive Programming(CP) on MacπŸš€

img
In this environment, we will use c++ language. So, let's begin setting up by installing homebrew.😊

Step 1 - Install homebrew

/usr/bin/ruby -e $(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Enter fullscreen mode Exit fullscreen mode

Step 2 - ** Install gcc **

brew install gcc

Enter fullscreen mode Exit fullscreen mode

Step 3 - Install gtimout

brew install coreutils

Enter fullscreen mode Exit fullscreen mode

To confirm if has successfully installed gcc, type gcc-11 -v on terminal. At the time of writing this post the version of gcc is 11. After successfully installing gcc and coreutils let's now install sublime for code editor.

Step 4 - Install Sublime

https://www.sublimetext.com/download_thanks?target=mac

Step 5 - Configuring the new build system for the Sublime

  • Go to Tools > Build Systems > New Build System.

  • Copy the code from C++17.sublime-build and paste it ther and save it by any name.

  "cmd" : ["g++-11 $file_name -o $file_base_name && gtimeout 4s ./$file_base_name<inputf.in>outputf.in"], 
  "selector" : "source.c",
  "shell": true,
  "working_dir" : "$file_path"
}

Enter fullscreen mode Exit fullscreen mode
  • Go to Tools > Build Systems and select your new build system.
  • Create 2 files named inputf.in and outputf.in in same directory in which you have your code.
  • Write input in inputf.in, save and run the code in sublime and you will get output in outputf.in .

SuccessHope you've understood and set up the environment successfully.😊 If you've any problem, you can reach out to me via sagarmedtiya31@gmail.com

Thanks.

Top comments (0)