> For the complete documentation index, see [llms.txt](https://docs.codebattles.ru/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.codebattles.ru/en/your-own-competition/podgotovka-zadach/sozdanie-svoei-zadachi.md).

# Creating your own task

## Task Template Generation

For convenient work with tasks, there is [TestsGeneratorFramework](https://github.com/doctorixx/TestsGeneratorFramework) Download it and go to the main folder where there is ***manager.py***

To generate a task, enter the following in the console ({NAME} is the task name)

```css
python manager.py create {NAME} -f -e
```

On Linux, you may need to run it using the ***python3*** command

```css
python3 manager.py create {NAME} -f -e
```

After that, our folder appears in the programms folder (In the example {NAME} = test)

<figure><img src="/files/7srMJ7JacqoX9DHLMtGY" alt=""><figcaption></figcaption></figure>

| File Name       | Purpose                  |
| --------------- | ------------------------ |
| description.txt | Task Description         |
| in\_data.txt    | Input Data for the Task  |
| name.txt        | Task Name                |
| out\_data.txt   | Output Data for the Task |

| File Name | Purpose                                                                |
| --------- | ---------------------------------------------------------------------- |
| build.py  | File for task assembly. (We will discuss it later)                     |
| main.py   | Reference program for the task (Tests will be generated based on this) |

Now let's look at the contents of the build.py file.

<mark style="color:green;">examples</mark> - dictionary where the key is input data, and the value is output data <mark style="color:green;">input\_data</mark> - list with input values for which tests will be generated

To better understand, let's look at the task page and see what exactly is substituted where. And let's try to create a similar task.

## Your Own Tests for the Program

We will write the examples ourselves, but the input data will be generated using the program. Modify build.py and the reference program

{% code title="main.py" lineNumbers="true" %}

```python
n = int(input())
if n % 2 == 0:
    print("YES")
else:
    print("NO")

```

{% endcode %}

{% code title="build.py" lineNumbers="true" fullWidth="false" %}

```python
from core.runner import Runner
from random import randint

runner = Runner()

examples = {
    "2": "YES",
    "3": "NO",
}

input_data = []

for i in range(30):
    input_data.append(randint(0, 100))

out = runner.run_many(input_data)
runner.save_tests(out, input_data)
runner.save_examples(examples)
runner.build(indent=2)
print("[+] Done")

```

{% endcode %}

## Modifying the Description

{% hint style="info" %}
The system can accept text in ***Markdown*** format. [\[Markdown Examples\]](https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet)
{% endhint %}

We also modify the description, input, and output data. I won't show it because there will be a lot of text. I'll just write *test* everywhere.

<details>

<summary>All Files</summary>

{% code title="name.txt" %}

```
test
```

{% endcode %}

{% code title="description.txt" %}

```
test
```

{% endcode %}

{% code title="in\_data.txt" %}

```
test
```

{% endcode %}

{% code title="out\_data.txt" %}

```
test
```

{% endcode %}

</details>

## Task Generation

After all the steps, run ***build.py***

<details>

<summary>Output</summary>

```
[/] Tests are running
30/30
[+] Tests was built
[/] Building export
[+] Export was built
[+] Done
```

</details>

***

We now have a build.json file. This is our generated task. We will upload it to the platform.

This file contains all data, tests, and examples.

<details>

<summary>build.json</summary>

```json5
{
  "name": "test",
  "description": "test",
  "in": "test",
  "out": "test",
  "examples": [
    ["2", "YES"],
    ["3", "NO"]
  ],
  "tests": [
    [
      "87",
      "NO"
    ],
    [
      "11",
      "NO"
    ],
    [
      "73",
      "NO"
    ],
    [
      "40",
      "YES"
    ],
    [
      "97",
      "NO"
    ],
    [
      "51",
      "NO"
    ],
    [
      "9",
      "NO"
    ],
    [
      "80",
      "YES"
    ],
    [
      "70",
      "YES"
    ],
    [
      "75",
      "NO"
    ],
    [
      "7",
      "NO"
    ],
    [
      "56",
      "YES"
    ],
    [
      "62",
      "YES"
    ],
    [
      "14",
      "YES"
    ],
    [
      "32",
      "YES"
    ],
    [
      "53",
      "NO"
    ],
    [
      "25",
      "NO"
    ],
    [
      "0",
      "YES"
    ],
    [
      "23",
      "NO"
    ],
    [
      "74",
      "YES"
    ],
    [
      "82",
      "YES"
    ],
    [
      "19",
      "NO"
    ],
    [
      "99",
      "NO"
    ],
    [
      "56",
      "YES"
    ],
    [
      "41",
      "NO"
    ],
    [
      "43",
      "NO"
    ],
    [
      "54",
      "YES"
    ],
    [
      "57",
      "NO"
    ],
    [
      "14",
      "YES"
    ],
    [
      "57",
      "NO"
    ]
  ]
}
```

</details>

<mark style="color:green;">**Done!**</mark>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.codebattles.ru/en/your-own-competition/podgotovka-zadach/sozdanie-svoei-zadachi.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
