From 78e80dfceab35a458b8f1c0f52bab3510e46d195 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 10 Oct 2023 11:27:13 +0000 Subject: [PATCH] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- greedy_methods/assign_cookies.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/greedy_methods/assign_cookies.py b/greedy_methods/assign_cookies.py index bea964155..bb489ce3d 100644 --- a/greedy_methods/assign_cookies.py +++ b/greedy_methods/assign_cookies.py @@ -1,6 +1,6 @@ """ -You're a caring parent, and you want to give your children cookies. Each child has a specific cookie size they like (their "greed factor"). -You have different-sized cookies. Your goal is to give cookies to as many children as possible by matching the cookie size to +You're a caring parent, and you want to give your children cookies. Each child has a specific cookie size they like (their "greed factor"). +You have different-sized cookies. Your goal is to give cookies to as many children as possible by matching the cookie size to each child's greed factor. How many children can you make happy? Example: g = [1,2,3], s = [1,1], where g is the greed factor and s is the cookie size. @@ -24,6 +24,7 @@ This method ensures that you maximize the number of happy children efficiently." """ from typing import List + def max_happy_children(greed_factors: List[int], cookie_sizes: List[int]) -> int: """ Calculate the maximum number of happy children by distributing cookies. @@ -44,10 +45,10 @@ def max_happy_children(greed_factors: List[int], cookie_sizes: List[int]) -> int """ greed_factors.sort() cookie_sizes.sort() - + child = 0 for cookie in cookie_sizes: if child < len(greed_factors) and cookie >= greed_factors[child]: child += 1 - - return child \ No newline at end of file + + return child