Simulating Cookie Monster Behavior

Image source: Nick Depree

Every day Cookie Monster gets cookies from the store, and eats cookies from his cookie jar. The following python code simulates his actions from yesterday.

A call to the function cookie_monster_simulation() returns an integer. What is this integer?

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
# Python code example
def cookie_monster_simulation():
    cookies = 100

    cookies = cookies + 1  # get a cookie!
    cookies = cookies - 1  # eat a cookie!
    for i in range(0, 88):
        cookies = cookies + 1  # get a cookie!
        cookies = cookies - 1  # eat a cookie!
        cookies = cookies - 1  # eat a cookie!

    return cookies

Details and assumptions

range(0, 88) = [0, 1, 2, 3, ... 87]

×

Problem Loading...

Note Loading...

Set Loading...