Problem Set ¡ guide

🛠️ How to Solve and Test

Every problem is a program that reads standard input and writes standard output. That makes them work in any language, and lets one set of test files check every solution.

The workflow

  1. Create a folder for your solutions anywhere (for example solutions/java/).
  2. Write the program. Read the whole input from stdin; print only what the problem asks for — no prompts like "Enter n:".
  3. Try it on an example by hand: python3 e01.py < tests/E01/01.in (any test file works).
  4. Run every test at once with the runner (below), or paste your output into the checker on the problem page.
What counts as “the same output”? Both checkers compare line by line. They ignore Windows/Unix line-ending differences, spaces at the end of a line, and blank lines at the very end. Everything else — spelling, upper/lower case, spaces between values, decimal places — must match exactly.

The test runner

Two equivalent runners live in runner/; use whichever you have installed (Python 3.8+ or Node 18+). Run them from the problems folder and put the command that runs your program after --:

LanguageCommand
Pythonpython3 runner/run-tests.py E01 -- python3 e01.py
JavaScriptnode runner/run-tests.mjs E01 -- node e01.mjs
Javajavac Main.java then python3 runner/run-tests.py E01 -- java Main
C++g++ -std=c++17 -O2 e01.cpp -o e01 then python3 runner/run-tests.py E01 -- ./e01
Anything elseAny command works: -- ruby e01.rb, -- dotnet run, -- go run e01.go, -- ./target/release/e01

Options: --timeout 5 (seconds per test, default 10) and --stop (stop at the first failure). A failing test shows the first line that differs:

The runner's exit code is 0 only when every test passes, so it also works in scripts and CI. Hard problems include large tests: an O(n²) solution may hit the time limit where O(n log n) is expected.

Input/output templates

Each template solves the same demo task (it isn't one of the problems), so you can see how reading and printing work in your language:

Demo task. The first line holds n, the second holds n integers. Print the numbers doubled on one line, then count n. Input 3⏎4 -1 10 → output 8 -2 20⏎count 3.

Reading line by line

Most problems can be read as a stream of tokens. Read whole lines when a line may contain spaces or be empty (e.g. M01 Balanced Brackets, E04 Reverse a String, O13 Text Editor): in Python sys.stdin.read().split("\n"), in JavaScript readFileSync(0, 'utf8').split('\n'), in Java in.readLine(), in C++ getline(cin, line) (after cin >> q, skip the rest of that line first with cin.ignore()).

The OOP command loop

Every object-oriented problem has the same driver: read q, then for each command line, split it into words and call a method on your objects. Keep the driver thin: the classes do the work and return results; the driver only parses and prints.

Demo task. Commands ADD name amount (no output) and SHOW name → name total, or ERROR unknown name. Input 3⏎ADD ana 5⏎SHOW ana⏎SHOW bob → output ana 5⏎ERROR unknown name.

Common pitfalls

A suggested path