feat: add where are more items problem

This commit is contained in:
AlanSilvaaa
2026-05-26 09:58:49 -04:00
parent 494ff27c06
commit 801cdee331
8 changed files with 244 additions and 4 deletions

View File

@@ -3,10 +3,15 @@ from fastapi import APIRouter, HTTPException
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.join_pictures_with_quantity import (
JoinPicturesWithQuantityProblem,
JoinPicturesWithQuantityRequest,
)
from app.schemas.grade_1.where_are_more_items import (
WhereAreMoreItemsProblem,
WhereAreMoreItemsRequest,
)
router = APIRouter(prefix="/grade_1", tags=["Grade 1"])
@@ -30,3 +35,24 @@ def create_join_pictures_with_quantity_problem(
)
except ValueError as exc:
raise HTTPException(status_code=400, detail=str(exc)) from exc
@router.post(
"/where_are_more_items",
response_model=WhereAreMoreItemsProblem,
)
def create_where_are_more_items_problem(
request: WhereAreMoreItemsRequest,
) -> dict:
try:
return where_are_more_items(
available_pictures=[
picture.model_dump() for picture in request.available_pictures
],
comparison_count=request.comparison_count,
min_quantity=request.min_quantity,
max_quantity=request.max_quantity,
seed=request.seed,
)
except ValueError as exc:
raise HTTPException(status_code=400, detail=str(exc)) from exc