feat: Aufgaben a-01 bis a-03 und b-04 bis b-06

Aufgaben unter tasks/ mit prompt.md, task.toml, start/ und check.sh.
Musterlösungen bestehen die Checks, eine leere Lösung scheitert. b-06
erkennt fünf Mutationen; behoben: veralteter Bytecode in Mutantenkopien.
Echter Lauf mit qwen3:0.6b auf srv04: 0 von 6 bestanden. Ein Repo-Test
prüft die Gültigkeit der Aufgaben.

Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-06 20:01:24 +01:00
parent d49e4cfd05
commit a9fb334bca
27 changed files with 202 additions and 2 deletions

3
tasks/A/a-01/check.sh Executable file
View File

@ -0,0 +1,3 @@
#!/bin/sh
# Erwartet: ergebnis.txt enthält genau 4711 (Zeilenumbruch am Ende erlaubt).
[ "$(tr -d ' \n' < /work/ergebnis.txt)" = "4711" ]

1
tasks/A/a-01/prompt.md Normal file
View File

@ -0,0 +1 @@
Im Ordner /work liegt die Datei info.txt. Lies sie und schreibe nur den Projektcode (die Zahl hinter "Projektcode:") in die neue Datei ergebnis.txt. Keine weiteren Zeichen. Rufe danach done auf.

View File

@ -0,0 +1,2 @@
Projektcode: 4711
Status: offen

6
tasks/A/a-01/task.toml Normal file
View File

@ -0,0 +1,6 @@
id = "a-01"
title = "Information aus Datei in neue Datei übertragen"
group = "A"
image = "cb-python:latest"
max_steps = 10
timeout_s = 300

4
tasks/A/a-02/check.sh Executable file
View File

@ -0,0 +1,4 @@
#!/bin/sh
# Erwartet: neu.txt = 1,2,30,4,30 und anzahl.txt enthält 5.
[ "$(tr -d ' \r' < /work/neu.txt | paste -sd, -)" = "1,2,30,4,30" ] || exit 1
[ "$(tr -d ' \n' < /work/anzahl.txt)" = "5" ]

6
tasks/A/a-02/prompt.md Normal file
View File

@ -0,0 +1,6 @@
Im Ordner /work liegt die Datei zahlen.txt mit einer Zahl pro Zeile.
1. Liste den Inhalt von /work auf.
2. Lies zahlen.txt.
3. Ersetze in jeder Zeile, die genau "3" lautet, durch "30". Schreibe das Ergebnis in neu.txt (eine Zahl pro Zeile).
4. Zähle die Zeilen von neu.txt mit einem Shell-Befehl und schreibe die Zahl in anzahl.txt.
Rufe danach done auf.

View File

@ -0,0 +1,5 @@
1
2
3
4
3

6
tasks/A/a-02/task.toml Normal file
View File

@ -0,0 +1,6 @@
id = "a-02"
title = "Mehrere Werkzeuge nacheinander: auflisten, lesen, ändern, ausführen"
group = "A"
image = "cb-python:latest"
max_steps = 15
timeout_s = 420

3
tasks/A/a-03/check.sh Executable file
View File

@ -0,0 +1,3 @@
#!/bin/sh
# Erwartet: name.txt enthält genau coding.
[ "$(tr -d ' \n' < /work/name.txt)" = "coding" ]

1
tasks/A/a-03/prompt.md Normal file
View File

@ -0,0 +1 @@
Im Ordner /work soll der Wert des Schlüssels "name" aus der Konfiguration in die Datei name.txt geschrieben werden. Achtung: Die Datei config.json existiert nicht. Die richtige Datei heißt settings.json. Lies sie und schreibe nur den Wert (ohne Anführungszeichen) in name.txt. Rufe danach done auf.

View File

@ -0,0 +1 @@
{"name": "coding"}

6
tasks/A/a-03/task.toml Normal file
View File

@ -0,0 +1,6 @@
id = "a-03"
title = "Auf Tool-Fehler reagieren und korrigieren"
group = "A"
image = "cb-python:latest"
max_steps = 12
timeout_s = 360

20
tasks/B/b-04/check.sh Executable file
View File

@ -0,0 +1,20 @@
#!/bin/sh
# Prüft fib gegen die Spezifikation mit festen Testfällen.
mkdir -p /checks
cat > /checks/test_fib.py <<'PY'
import sys
sys.path.insert(0, "/work")
import pytest
from mathe import fib
def test_werte():
assert [fib(n) for n in range(10)] == [0, 1, 1, 2, 3, 5, 8, 13, 21, 34]
def test_gross():
assert fib(90) == 2880067194370816120
def test_negativ():
with pytest.raises(ValueError):
fib(-1)
PY
cd /work && python3 -m pytest -q -p no:cacheprovider /checks/test_fib.py

3
tasks/B/b-04/prompt.md Normal file
View File

@ -0,0 +1,3 @@
In /work liegt mathe.py mit einer leeren Funktion fib(n).
Spezifikation: fib(n) gibt die n-te Fibonacci-Zahl zurück, mit fib(0) = 0 und fib(1) = 1. Für n < 0 wirft sie ValueError. Für große n (etwa 90) soll sie schnell sein.
Implementiere fib in mathe.py. Ändere nichts anderes. Rufe danach done auf.

View File

@ -0,0 +1,2 @@
def fib(n):
raise NotImplementedError

6
tasks/B/b-04/task.toml Normal file
View File

@ -0,0 +1,6 @@
id = "b-04"
title = "Funktion nach Spezifikation schreiben"
group = "B"
image = "cb-python:latest"
max_steps = 20
timeout_s = 480

18
tasks/B/b-05/check.sh Executable file
View File

@ -0,0 +1,18 @@
#!/bin/sh
# Prüft parse_kv mit Fällen, die den Fehler aufdecken.
mkdir -p /checks
cat > /checks/test_parser.py <<'PY'
import sys
sys.path.insert(0, "/work")
from parser import parse_kv
def test_einfach():
assert parse_kv("a=1") == ("a", "1")
def test_gleichheitszeichen_im_wert():
assert parse_kv("a=b=c") == ("a", "b=c")
def test_leerzeichen():
assert parse_kv(" name = x = y ") == ("name", "x = y")
PY
cd /work && python3 -m pytest -q -p no:cacheprovider /checks/test_parser.py

1
tasks/B/b-05/prompt.md Normal file
View File

@ -0,0 +1 @@
In /work liegt parser.py mit der Funktion parse_kv(line). Sie soll 'schluessel=wert' in (schluessel, wert) zerlegen. Ein Wert, der selbst '=' enthält, wird dabei falsch behandelt. Finde den Fehler und behebe ihn in parser.py. Die Docstring-Beschreibung gilt als Spezifikation. Rufe danach done auf.

View File

@ -0,0 +1,8 @@
def parse_kv(line):
"""Zerlegt 'schluessel=wert' in (schluessel, wert).
Der Wert darf selbst '=' enthalten: parse_kv('a=b=c') ergibt ('a', 'b=c').
Leerzeichen um Schlüssel und Wert werden entfernt.
"""
parts = line.split("=")
return parts[0].strip(), parts[1].strip()

6
tasks/B/b-05/task.toml Normal file
View File

@ -0,0 +1,6 @@
id = "b-05"
title = "Fehler in der Parser-Funktion finden und beheben"
group = "B"
image = "cb-python:latest"
max_steps = 20
timeout_s = 480

19
tasks/B/b-06/check.sh Executable file
View File

@ -0,0 +1,19 @@
#!/bin/sh
# Score: 0.5 für grüne Tests auf dem Original, weitere 0.5 wenn die Tests
# eingebaute Fehler (Mutationen) erkennen. Letzte Zeile ist JSON.
cd /work || { echo '{"score": 0.0, "notes": "kein /work"}'; exit 0; }
# Kein Bytecode-Cache: sonst nutzt Python bei gleicher Größe und Zeit veralteten Code der Mutation.
export PYTHONDONTWRITEBYTECODE=1
[ -f test_rechner.py ] || { echo '{"score": 0.0, "notes": "test_rechner.py fehlt"}'; exit 0; }
python3 -m pytest -q -p no:cacheprovider test_rechner.py >/tmp/orig.log 2>&1 || { echo '{"score": 0.0, "notes": "Tests auf dem Original rot"}'; exit 0; }
caught=0; total=0
for m in 's/a + b/a - b/' 's/a - b/a + b/' 's/a \* b/a + b/' 's/return a \/ b/return a \/\/ b/' 's/if b == 0:/if b == 1:/'; do
total=$((total+1))
rm -rf /checks/mut && mkdir -p /checks/mut && cp -r /work/. /checks/mut/ && rm -rf /checks/mut/__pycache__
sed -i "$m" /checks/mut/rechner.py
if ! (cd /checks/mut && python3 -m pytest -q -p no:cacheprovider test_rechner.py >/dev/null 2>&1); then
caught=$((caught+1))
fi
done
score=$(python3 -c "print(round(0.5 + 0.5*$caught/$total, 2))")
echo "{\"score\": $score, \"notes\": \"Mutationen erkannt: $caught von $total\"}"

2
tasks/B/b-06/prompt.md Normal file
View File

@ -0,0 +1,2 @@
In /work liegt rechner.py mit vier Funktionen: addiere, subtrahiere, multipliziere, dividiere. Dividiere wirft ZeroDivisionError bei b = 0.
Schreibe Tests in die Datei test_rechner.py (pytest). Die Tests sollen den Code vollständig prüfen, auch den Fehlerfall. Sie müssen mit dem vorhandenen Code grün sein. Rufe danach done auf.

View File

@ -0,0 +1,13 @@
def addiere(a, b):
return a + b
def subtrahiere(a, b):
return a - b
def multipliziere(a, b):
return a * b
def dividiere(a, b):
if b == 0:
raise ZeroDivisionError("Division durch null")
return a / b

7
tasks/B/b-06/task.toml Normal file
View File

@ -0,0 +1,7 @@
id = "b-06"
title = "Tests für vorhandenen Code schreiben"
group = "B"
image = "cb-python:latest"
max_steps = 25
timeout_s = 600
check_timeout_s = 180