-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path7kyu-boiledEggs.js
27 lines (22 loc) · 1.18 KB
/
7kyu-boiledEggs.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
/*
You are the greatest chef on earth. No one boils eggs like you! Your restaurant is always full of guests, who love your boiled eggs. But when there is a greater order of boiled eggs, you need some time, because you have only one pot for your job. How much time do you need?
Your Task
Implement a function, which takes a non-negative integer, representing the number of eggs to boil. It must return the time in minutes (integer), which it takes to have all the eggs boiled.
Rules
you can put at most 8 eggs into the pot at once
it takes 5 minutes to boil an egg
we assume, that the water is boiling all the time (no time to heat up)
for simplicity we also don't consider the time it takes to put eggs into the pot or get them out of it
Example (Input --> Output)
0 --> 0
5 --> 5
10 --> 10
*/
//P: one input, a positive integer representing the number of eggs to be boiled
//R: return the total time needed to boil the eggs, given the constraints in the instructions
//E: 0 => 0
// 5 => 5
// 10 => 10
//P: we can boil 8 eggs at a time, and each batch takes 5 minutes
// divide input num by 8, round up, and multiply by 5, returning the result
const cookingTime = eggs => Math.ceil(eggs/8)*5