1. Skip to content

Grab our RSS feed

Scarky.com

This post explains how to write a solution to a programming challenge.

Lets take a look at the Addition challenge (you can also view Confronting a challenge – programming category post – it explains how to solve challenges on example of a slightly more difficult challenge – but it’s sill pretty easy).

In the challenge tab, content of the challenge is displayed. Content of a programming challenge usually consists of:

  • Problem description:

    A+B=?

  • Input description:

    Two integers A, B separated by space. 0<=A,B<100

  • Output description:

    Sum of A and B

  • Input example:
    7 8
  • Output example:
    15

Input and output data used by Scarky judge (info for curious and advanced users: read here about judges or see which judge is used in the Addition challenge) to decide whether your solution is correct or not are set by the challenge inventor and are hidden. Many challenges have tricky test data and that’s why the ability to form you own and comprehensive test cases is very useful.

Now let’s try to solve the challenge problem.

The task is very simple: we have read two numbers from the standard input, calculate the sum and print it to the standard output.

Sample code in C++

#include <iostream>

int main() {
    int a, b;
    std::cin >> a >> b;
    std::cout << a+b;
    return 0;
}


To submit a solution go to the Answer tab and either paste the code into the provided text field or upload the source code a from file. Then pick the language of your submission and click Send solution button.

By the way, what is the password for in the Answer tab? Read about it in the FAQ section.

You will then see a screen with status of your submission. After few moments you will get the result:

1. ACaccepted – your program ran successfully and gave a correct answer
2.
WAwrong answer – your program ran successfully, but gave an incorrect answer
3.
TLEtime limit exceeded – your program was compiled successfully, but it didn’t stop before the time limit
4.
CEcompilation error – your program couldn’t be compiled; please note: only some languages can give CE: syntax errors in interpreted languages can lead to WA (Python – no pre-checking syntax or Perl – CE only after a basic syntax check)
5.
REruntime error – your program was compiled successfully, but it exited with an error; possible codes are:

  • SIGSEGV (signal 11) – most common, segmentation fault – index out of array, etc.
  • SIGXFSZ (signal 25) – output limit exceeded
  • SIGFPE (signal 8)floating point error – like division by zero, etc.
  • SIGABRT (signal 6) – raised by the program itself; C++ STL does it under some conditions
  • NZEC (non-zero exit code) – helps telling crash from WA with interpreted languages
  • other – there are other signals which can cause program to terminate, all remaining are shown as other

I hope you got AC at the first time. If not – don’t worry; you can resubmit your solutions as many times as you wish. Too check how you classify in comparison to other users, go to the Hall of fame tab.

Comments are closed