feat: add compose and decompose numbers problem

This commit is contained in:
AlanSilvaaa
2026-05-26 11:26:26 -04:00
parent 801cdee331
commit dacf148a34
7 changed files with 182 additions and 0 deletions

View File

@@ -1,9 +1,16 @@
from fastapi import APIRouter, HTTPException
from app.problems.grade_1.compose_and_decompose_numbers import (
compose_and_decompose_numbers,
)
from app.problems.grade_1.join_pictures_with_quantity import (
join_pictures_with_quantity,
)
from app.problems.grade_1.where_are_more_items import where_are_more_items
from app.schemas.grade_1.compose_and_decompose_numbers import (
ComposeAndDecomposeNumbersProblem,
ComposeAndDecomposeNumbersRequest,
)
from app.schemas.grade_1.join_pictures_with_quantity import (
JoinPicturesWithQuantityProblem,
JoinPicturesWithQuantityRequest,
@@ -16,6 +23,24 @@ from app.schemas.grade_1.where_are_more_items import (
router = APIRouter(prefix="/grade_1", tags=["Grade 1"])
@router.post(
"/compose_and_decompose_numbers",
response_model=ComposeAndDecomposeNumbersProblem,
)
def create_compose_and_decompose_numbers_problem(
request: ComposeAndDecomposeNumbersRequest,
) -> dict:
try:
return compose_and_decompose_numbers(
picture=request.picture.model_dump(),
whole=request.whole,
randomize_rows=request.randomize_rows,
seed=request.seed,
)
except ValueError as exc:
raise HTTPException(status_code=400, detail=str(exc)) from exc
@router.post(
"/join_pictures_with_quantity",
response_model=JoinPicturesWithQuantityProblem,