> 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="https://3530347106-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNmxNebGSoyvcFD4st7Ia%2Fuploads%2Fgit-blob-14aa8f2fd503c6304553f4f8308ac9a4a4f19c2a%2Fimage%20(11)%20(1).png?alt=media" 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>
