Welcome to ORAC! If you've never programmed before, or would like to get started with programming, this guide is for you. Within, we'll show you how to get started with both Python and C++ as programming languages, with the aim being to help you get prepared to tackle the starter problems on ORAC. This guide will have instructions for Windows, Linux and Mac so that you and all your friends can join in on the fun!


Python is an ideal language to learn if you've never programmed before. Much of the syntax resembles plain old English, and the language relies heavily on whitespace (spaces and/or tabs) to give you an easy way to understand your code.


The best way to get started in Python for windows is to use IDLE (we suggest you download the Windows MSI installer that corresponds to your system; if you're on 64 bit system (which you most likely are, if you're on a computer that has Windows 7 or greater) you should use the X86-64 installer, otherwise download the X86 installer). These installers will require administrator privileges to run, so if you're installing Python on your school computer you may need to ask your friendly IT staff for help.

Once the installer has completed, simply search for IDLE in the start bar and open it. Finally, open a new window by either clicking File->New Window or pressing Ctrl+N.

How to open a new window

How to open a new window

Once you've completed this step, skip to the writing a program guide!


While a Linux guide is difficult to write due to the many flavours of Linux, we'll assume you're on a Debian-based system (Debian, Ubuntu, Mint, ...) where the default package manager is apt-get. If you use a different system, you may have to tailor the following guide to suit your system.

First of all, you'll need to install python. This will be achieved using your system's terminal -- on Ubuntu, gnome-terminal -- to issue the following command-line instruction:

sudo apt-get install python-dev

Note that superuser rights are required to use apt-get. Further, your system should already have gedit installed, however if you have another preferred editor you should make sure to have it installed. This guide will assume you use gedit

At this point, open a gedit window (and keep your terminal open) and proceed to the writing a program guide.


Python comes pre-installed on all Mac computers, however it's often many years old (and the recommendation is to install a newer version, which is the path we'll take). However, if you would rather not, you can go to Applications->Terminal and simply type python to get started -- though if this is the path you're taking, we suggest you use Editor and simply keep the terminal handy.

To install a newer version of python on a Mac, download IDLE by selecting the appropriate installer for your Mac from the list. Once you complete the installation process, open IDLE and open a new window by either clicking the New Window button or using the keyboard shortcut.

How to open a new window in Mac

How to open a new window in Mac

Programming in Python

At this point, you've installed an editor on your system and are ready to get started programming! To make sure everything is working, at this point we'll write the customary first program: Hello world.

In Python, this is one of the easiest tasks imaginable! In your text editor, simply type

print "Hello, World!"

If you're using IDLE or gedit, you'll see the word print highlight as you write it, as well as the string "Hello, World!". This is because the word print is a keyword in python, and a string is default type. The highlighting is also exceptionally pretty!

Those of you using IDLE should now go ahead and click Run->Run Module (or press F5). You'll see the interactive interpreter pop up with something like the following appearing. The module printed "Hello, World!" just liked we wanted -- cool!

The hello world program, with the source code on the left and the module output on the right

The hello world program, with the source code on the left and the module output on the right

If you're using a terminal, we suggest you save your source code in your home directory (on Linux, /home/, on Mac /Users/) as hello_world.py, and then, in your terminal, type

python hello_world.py

You should see something similar to the following:

ben@comenius ~ $ python hello_world.py 
Hello, World!
ben@comenius ~ $

The first line is the command I issued, and the second line is what python gave me in return -- exactly what I asked to be printed!

You can now go ahead and start working your way through the training site! If you've never programmed in Python before, a good place to start is at the Codeacademy tutorial


C++ is one of the three official languages of the International Olympiad in Informatics (the IOI), the pinnacle of high-school computing contests. It has a slightly steeper learning curve than Python, though many of its language constructs are comparable (or the same).


To get started programming in C++ on Windows, download Code::Blocks. If you have administrator access to the computer you're installing Code::Blocks on, use the regular installer, otherwise you should use the installer marked _user. Also, be sure to download the version with mingw in the name (approximately 95MB file), since mingw allows Code::Blocks to compile! When installing, just accept the default options.

After the installation process has completed, you should see a window like this:

The Code::Blocks starting window.

From File, open a new source file by either following the picture or issuing the shortcut Ctrl+Shift+N.

Opening a new source file in Code::Blocks

Opening a new source file in Code::Blocks

Well done! You should now proceed to writing programs in C++


Getting started on Linux is fairly straightforward. Again, we'll assume your distribution is Debian-based and thus the package manager is apt-get, and if it's not you may have to adjust the following commands. Open up a terminal (on Ubuntu, this is gnome-terminal)

sudo apt-get install build-essential g++

After you provide your superuser password, this will install g++ for you. Now, open your favourite editor (Ubuntu has gedit installed by default) and skip to the section writing programs in C++


To get started in Mac, you need to install g++ by installing XCode. Follow the links for the free XCode download, enter your AppleID and download/install XCode.

While you're able to program in XCode, we suggest using the terminal and TextEdit to get started. Open up a terminal and a TextEdit window and let's get ready to write a C++ program!

Programming in C++

In C++, we'll again write the hello world program, but this time it will not be as straightforward as the Python version. While this may slightly deter you, do not let it! C++ is a significantly more powerful language than Python is, and is well worth the time investment to learn.

In the text editor you have open, copy the following code (we'll dissect it in a minute):

#include <iostream>
using namespace std;

int main() {
    cout << "Hello, World!\n";
    return 0;

C++ code has very different structure to python code. We'll start, perhaps confusingly, from int main(). This declares a function named main, which takes no arguments (hence the brackets are empty), which returns an integer value. What follows between the curly braces {...} is the body of the function. Every C++ program must have a main function, and this is where execution starts.

This function simply takes the C++ output stream (cout), and writes the words "Hello, World!" to this stream. \n is a special character, designed to tell the stream that it should write a newline here.

Finally, our function returns the integer 0 -- it is customary to return 0 when main() completes successfully. What about the line that reads #include, though?

In C++, you don't get the ability to print by default. The only way we can print is if we know where the print functions are -- and they're placed in the iostream library, within the std namespace. Thus, to use cout, we need to #include <iostream>, as well as tell our program that it should use the std namespace.

Now, save your program as hello_world.cpp. If you're on Windows, either press F5 or press the following menu button.

How to run a program in Code::Blocks.

If you're on Linux or Mac, issue the following instruction in your terminal:

g++ hello_world.cpp -o hello_world

This tells g++, the c++ compiler, to compile the file hello_world.cpp and output it as the binary hello_world. The following line executes this binary.

You should see output similar to the following, on Linux:

ben@comenius ~ $ ./hello_world 
Hello, World!
ben@comenius ~ $

For windows, you should see a picture similar to this:

Executing your first program in Code::Blocks

Executing your first program in Code::Blocks

Well done! You've successfully written your first C++ program. Doesn't it feel great?

You can now go ahead and start working your way through the training site! If you've never programmed in C++ before, a good place to start is at the cplusplus tutorial

You can also always get help at the forums or on the unofficial IRC channel. Happy programming!