Skip to main content

Accenture

Accenture OA-14 2024

Problem Description

You are stuck on an island where they sell and eat coconut sweets only. A person can buy at most 1 box per day with each box containing N pieces. To remain alive, you must consume E coconut sweets daily for D days, but the catch is that you cannot purchase sweets on Sundays. Your task is to find and return an integer value representing the minimum number of times you have to buy coconut sweets in order to stay alive. If not possible, return -1.

Note: The day starts from Monday.

Input Format:

  • input1: An integer value N, representing the number of coconut sweets per box.
  • input2: An integer value E, representing the number of coconut sweets needed daily.
  • input3: An integer value D, representing the number of days you need to survive.

Output Format:

Return an integer value representing the minimum number of times you have to buy coconut sweets to survive. If it's not possible, return -1.

Constraints:

  • 1≤N≤10^3: The number of sweets in each box.
  • 1≤E≤10^3: The number of sweets you need to consume each day.
  • 1≤D≤10^3: The number of days you need to survive.

Example

Sample Input:

N = 5
E = 3
D = 7

Sample Output:

3

Explanation:
You need to consume 3 sweets every day for 7 days, totalling 21 sweets. Since you can buy a maximum of 1 box per day (excluding Sundays), you'll need to buy at least 3 boxes to have enough sweets.