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

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