Files
wehub-resource-sync dde272c4b8
i18n - Build Validation / Validate i18n Builds (24) (push) Has been cancelled
CI - Node.js / Lint (24) (push) Has been cancelled
CI - Node.js / Build (24) (push) Has been cancelled
CI - Node.js / Test (24) (push) Has been cancelled
CI - Node.js / Test - Upcoming Changes (24) (push) Has been cancelled
CI - Node.js / Test - i18n (italian, 24) (push) Has been cancelled
CI - Node.js / Test - i18n (portuguese, 24) (push) Has been cancelled
CD - Docker - GHCR Images / Build and Push Images (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 11:55:53 +08:00

2.0 KiB

id, title, challengeType, dashedName
id title challengeType dashedName
69f8c998d78ad3171a0713bd Challenge 290: Pizza Party 29 challenge-290

--description--

Given an array of hours worked today per person, return the number of pizzas to order for a pizza party.

  • Divide each person's hours worked by 3 to get their slice count.
  • You can't eat a partial slice, so round each person's slice count up to the nearest whole number.
  • Each person gets a minimum of two slices.
  • Each pizza has 8 slices. Round the total number of pizzas up to the nearest whole pizza.

--hints--

get_pizzas_to_order([8, 8, 8]) should return 2.

({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(get_pizzas_to_order([8, 8, 8]), 2)`)
}})

get_pizzas_to_order([10, 9, 8, 2, 2, 6, 10]) should return 3.

({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(get_pizzas_to_order([10, 9, 8, 2, 2, 6, 10]), 3)`)
}})

get_pizzas_to_order([1, 2, 3, 4, 5]) should return 2.

({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(get_pizzas_to_order([1, 2, 3, 4, 5]), 2)`)
}})

get_pizzas_to_order([8, 8, 8, 8, 8, 8, 8, 8]) should return 3.

({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(get_pizzas_to_order([8, 8, 8, 8, 8, 8, 8, 8]), 3)`)
}})

get_pizzas_to_order([9, 9, 6]) should return 1.

({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(get_pizzas_to_order([9, 9, 6]), 1)`)
}})

get_pizzas_to_order([10, 12, 16, 9, 8, 11, 15, 8, 0]) should return 5.

({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(get_pizzas_to_order([10, 12, 16, 9, 8, 11, 15, 8, 0]), 5)`)
}})

--seed--

--seed-contents--

def get_pizzas_to_order(hours_worked):

    return hours_worked

--solutions--

import math

def get_pizzas_to_order(hours_worked):
    total_slices = sum(max(math.ceil(h / 3), 2) for h in hours_worked)
    return math.ceil(total_slices / 8)