Files
aji/docs/evaluation/dev-tasks/dev-intervals/prompt.md
T
dev e3fc896a0a wip: shield index relations, dev evaluation tasks, Q-063 audit notes
Verifier borrow/provenance work, new phase3 shield_index conformance cases,
dev-intervals/dev-lru/dev-shards tasks with evaluate.py harness, and agent skill/hook config.
2026-10-17 12:30:37 +03:00

58 lines
2.5 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Task: interval set
Development task (dev set). Its results are not evidence about any language.
Write a program that maintains a set of non-negative integers, described as half-open intervals, and answers queries about it. The program reads commands from standard input, one per line, and writes its answers to standard output.
## Input
The input is a sequence of lines separated by `\n`. If the input ends with `\n`, that final `\n` does not start another line. The input is at most 24 KiB and has at most 2000 lines. It may be empty.
A **number** is written in decimal with the ASCII digits `0`–`9`. It has no sign, no leading zeros (except the number `0` itself), and is less than 2^63 = 9223372036854775808.
A line is a valid command when it is exactly one of the forms below: the command word, then the stated number of arguments, each separated by exactly one space. There are no other spaces or characters.
| Command | Meaning | Output |
|---|---|---|
| `add A B` | requires `A < B`; adds every integer x with A ≤ x < B to the set | nothing |
| `remove A B` | requires `A < B`; removes every integer x with A ≤ x < B from the set | nothing |
| `covered X` | is X in the set? | `yes` or `no` |
| `count` | the number of maximal intervals the set consists of | the number |
| `total` | how many integers the set contains | the number |
| `list` | the maximal intervals in increasing order | `A-B` for each maximal interval [A, B), separated by single spaces; `empty` if the set is empty |
A **maximal interval** is a half-open interval [A, B) contained in the set such that neither A − 1 nor B is in the set. For example, after `add 1 3` and `add 3 5`, the set consists of one maximal interval, `1-5`.
Any other line, including an empty line, an unknown command, a wrong number of arguments, a malformed number, a number of 2^63 or more, and `add` or `remove` with `A ≥ B`, is **invalid**. For an invalid line the program writes `error` and leaves the set unchanged.
## Output
One output line for each command that produces output and for each invalid line, in input order. Every output line ends with `\n`. Nothing else is written to standard output.
## Example
Input:
```text
add 10 20
add 20 25
covered 24
remove 12 14
list
count
total
add 5 5
```
Output:
```text
yes
10-12 14-25
2
13
error
```
The repository contains a README with the program's interface for this language and a public test script, `sh test.sh`, which must pass. Hidden tests check the requirements above, including invalid input.