Back
Close

The Cookie Jar

Statement

 Goal

You are trying to grab cookies out of the cookie jar, but if you grab too many your hand will get stuck.
Print the maximum number of cookies you can grab without getting your hand stuck.
Input
First Line: Diameter of jar: d (float)
Second Line: Hand width: h (float)
Third Line: Number of cookies in the jar: n (int)
Fourth Line: Hand width increase per cookie: s (float)
Output
Int: Maximum number of cookies to retrieve in one grab without getting stuck
(total new hand width <= d)
Constraints
h <= d
0 <= n
0 < s, h, d
Example
Input
6.0
4.0
20
0.5
Output
4

Game modes
FastestShortest

Test cases
Example Test
Input
6.0 4.0 20 0.5
Output
4

Validator 1 Validator
Input
8.0 4.0 20 0.5
Output
8

No Cookies Test
Input
5.0 3.0 0 0.4
Output
0

Validator 2 Validator
Input
4.0 3.5 0 0.6
Output
0

Big Hand Test
Input
5.0 5.0 50 0.7
Output
0

Validator 3 Validator
Input
5.5 5.5 25 0.4
Output
0

Bite Sized Test
Input
6.0 3.5 100 0.05
Output
50

Validator 4 Validator
Input
6.0 3.3 150 0.05
Output
54

Not enough Cookies Test
Input
7.0 3.0 10 0.4
Output
10

Validator 5 Validator
Input
9.0 4.0 8 0.5
Output
8

Just Right Test
Input
6.0 3.5 5 0.5
Output
5

Validator 6 Validator
Input
7.0 4.0 6 0.5
Output
6

Solution language

Solution

Stub generator input
codingame x discord
Join the CodinGame community on Discord to chat about puzzle contributions, challenges, streams, blog articles - all that good stuff!
JOIN US ON DISCORD
Online Participants