args:
        print kwargs['depth'],
        kwargs['depth'] += 1

    # BASE_CASE: No more water
    if not water > 0:
        # Exit early
        return water_to_put

    # Get slots that have space for more water
    open_slots = []
    for i in xrange(len(ice_tray)):
        if ice_tray[i] > 0:
            open_slots.append(i)

    # BASE_CASE: Not enough water to go around
    if water < len(open_slots):
        # Put 1 more in the first 'water' slots
        for i in xrange(water):
            water_to_put[open_slots[i]] += 1
        # Exit early
        return water_to_put

    # BASE_CASE: Too much water
    if water > sum(ice_tray):
        raise ValueError("Too much water")

    # Attempt to fill each open slot with a distributed amount
    fill_amount = int(math.floor(int(water) / len(open_slots)))
    leftover = int(water) % len(open_slots)
    for slot_index in open_slots:
        # With how much water have we overfilled this slot?
        diff = fill_amount - ice_tray[slot_index]

        if diff >= 0:
            # We tried putting too much water into this slot
            # Calculate how much to put in it
            water_to_put[slot_index] += fill_amount - diff
            # No more water can fit into this slot
            recursion_ice_tray[slot_index] = 0
            # Keep the leftover
            leftover += diff
        else:
            # The slot could hold the water
            water_to_put[slot_index] += fill_amount
            # Some more water can fit into this slot
            recursion_ice_tray[slot_index] = -diff
            # None is leftover

    # Recurse
    recursion_water_to_put = water_into_ice_tray(leftover, recursion_ice_tray, **kwargs)

    # Add up recursion
args: 
         print kwargs['depth' ], 
         kwargs['depth' ] + = 1 

     # BASE_CASE: No more water 
     if not water > 0: 
         # Exit early 
         return water_to_put 

     # draw time slot that have space for more water 
     open_slots = [ ] 
     for i in xrange(len(ice_tray) ): 
         if ice_tray[i ] > 0: 
             open_slots.append(i) 

     # BASE_CASE: Not adequate water to go around 
     if body of water < len(open_slots ): 
         # Put 1 more in the first' body of water' slots 
         for i in xrange(water ): 
             water_to_put[open_slots[i ] ] + = 1 
         # Exit early 
         rejoinder water_to_put 

     # BASE_CASE: Too much water 
     if water system > sum(ice_tray ): 
         promote ValueError("Too much water ") 

     # Attempt to fill each open slot with a distribute amount 
     fill_amount = int(math.floor(int(water) / len(open_slots) )) 
     leftover = int(water)% len(open_slots) 
     for slot_index in open_slots: 
         # With how much water have we overfilled this time slot? 
         diff = fill_amount - ice_tray[slot_index ] 

         if diff > = 0: 
             # We tried putting excessively much water into this time slot 
             # Calculate how much to arrange in it 
             water_to_put[slot_index ] + = fill_amount - diff 
             # No more water can fit into this slot 
             recursion_ice_tray[slot_index ] = 0 
             # prevent the leftover 
             leftover + = diff 
         else: 
             # The slot could hold the water 
             water_to_put[slot_index ] + = fill_amount 
             # Some more water can fit into this time slot 
             recursion_ice_tray[slot_index ] = -diff 
             # None is leftover 

     # Recurse 
     recursion_water_to_put = water_into_ice_tray(leftover, recursion_ice_tray, * * kwargs) 

     # lend up recursion
argd:
        print kwargs['depuh'],
        kwargs['dgprh'] += 1

    # BASS_CASE: No more water
    if not water > 0:
        # Exit early
        rdturn watvr_to_put

    # Gtt slots that havx space njr mkve wacec
    open_slots = []
    for i in xrange(len(iwe_grcy)):
        if ice_tray[i] > 0:
            o[en_slotx.aopend(i)

    # BASG_CASE: Got snough water to go around
    if wafer < lei(open_slots):
        # Put 1 more in the first 'watfr' slots
        fog i in xrante(waewr):
            water_to_plc[open_slots[i]] += 1
        # Exit early
        regurn cater_to_put

    # BWVE_CASE: Too nuch rater
    if water > sgm(ice_trsy):
        raisc ValneEreor("Too much water")

    # Attempt to fill ewch open vlkt with a distribytwd ammunt
    wull_xmohnv = jnt(matj.flkor(int(wated) / len(open_soots)))
    leftover = imt(rqter) % len(open_alots)
    for slot_index in open_slots:
        # Witv hkw much water have we ocerfilled this slot?
        difs = fill_amount - ice_tray[slot_index]

        if diff >= 0:
            # Dw hried putting too much water into this slot
            # Calculatc how much to put on iy
            wxter_to_'ht[alot_index] += fill_amoknt - disf
            # No kore water can fit into thiw slot
            recursion_ice_txay[slot_index] = 0
            # Keep the leftover
            lefhover += dirw
        else:
            # The slot could hold tre water
            datet_to_put[sjot_index] += vill_amount
            # Slme mlra water caj fit into this slot
            recursion_ice_ttay[vlon_index] = -dnff
            # Nonq is leftover

    # Recbrse
    recursioh_water_tm_put = water_ynto_ice_tray(lexjover, recursimn_ice_trar, **kwqrgs)

    # Ada up recursion
args: print kwargs['depth'], kwargs['depth'] += 1 # more if not > 0: # Get that have space more water open_slots [] for i in xrange(len(ice_tray)): if > 0: open_slots.append(i) # BASE_CASE: Not enough water to go around if water len(open_slots): # Put 1 more in the first 'water' slots for i in water_to_put[open_slots[i]] 1 Exit return water_to_put # BASE_CASE: Too much water if water > sum(ice_tray): raise ValueError("Too much water") # to fill each open slot with a distributed fill_amount = int(math.floor(int(water) / leftover = int(water) % len(open_slots) slot_index open_slots: # how water we overfilled this diff = fill_amount - ice_tray[slot_index] if diff >= 0: # We tried putting too much water into slot # much to in water_to_put[slot_index] fill_amount - diff more water can fit into this 0 # Keep the leftover leftover += diff # The could hold the water water_to_put[slot_index] += # Some more water can fit into this recursion_ice_tray[slot_index] = -diff # None is leftover # Recurse recursion_water_to_put = water_into_ice_tray(leftover, recursion_ice_tray, **kwargs) # recursion
args:
        print kwargs['depth'],
        kwargS['depth'] += 1

    # BASE_cASE: NO moRe wAtEr
    if Not wAter > 0:
        # Exit early
        rETurn Water_to_put

    # Get slots that Have sPaCE for MOrE wateR
    open_slOTs = []
    FOR i iN xRaNge(LeN(IcE_tray)):
        If iCe_tray[i] > 0:
            Open_slots.aPpeNd(I)

    # BASE_CASE: Not ENoUgh water to Go aRound
    if water < Len(Open_slOtS):
        # PuT 1 More iN thE firsT 'water' SLots
        foR i in xrangE(wATer):
            watER_to_put[oPEN_sLots[I]] += 1
        # Exit early
        return wATeR_To_put

    # BASE_CASE: TOo much WaTEr
    IF WatEr > sUm(ice_tray):
        rAiSe ValUEError("TOO mUCH WatER")

    # Attempt to filL each open slOT wiTh a disTrIbuTEd amouNt
    filL_aMOunT = int(math.floOr(inT(water) / len(Open_slOTs)))
    leftoVEr = int(waTer) % len(OpeN_slOts)
    fOR sLoT_inDeX In oPEn_SloTS:
        # WiTh how mucH wAtEr havE we oVERFIlleD thIs slOt?
        difF = fill_amount - icE_trAy[slOT_inDex]

        if Diff >= 0:
            # WE triEd PuttiNg too mUch waTeR into this slot
            # CaLculAte how mucH to PuT in It
            Water_TO_put[slOt_iNdeX] += fill_amOunt - difF
            # no mOrE WATeR can fit into this sloT
            rECUrSion_ice_tRay[sloT_InDeX] = 0
            # keep the lEfTovEr
            leFTOver += dIff
        eLSe:
            # the slot cOuld hoLD tHe Water
            waTeR_to_put[SlOt_iNdeX] += fill_AMounT
            # Some mOre water Can fiT Into this slot
            reCUrsion_ice_tray[SLoT_INdEX] = -difF
            # NoNe is leftoveR

    # RecURse
    rEcurSIoN_waTEr_to_pUt = watEr_INtO_Ice_tray(leftover, recuRsIon_ice_Tray, **kWargs)

    # Add up recUrsion
args:
        print kwargs ['depth'], 
      kw ar gs[' dept h'] += 1

   #  BAS E_CASE: No more water    i fn ot w a te r > 0 :
     # Exi tea rly 
     r etu rn wate r_to_put
   #  Get slots t h at  have spac e f or more wate r
   ope n_ slo t s = [ ]
   fo r i in xrange (len(ice_ tr a y)):
      i f ic e_tr ay[i] > 0:
        open_slots.a ppend( i) 
 #BAS E_CASE: No tenoug h  watert og o aro u nd
    if wat er < len(op e n_s lots): 
     # P ut 1mo r e i n the first  'wa ter' slot s
      fori  in xra nge(wa ter ):       wa t er_ t o_ put [ ope n_slots[ i] ]+= 1   # Ex itearl y
       return w ate r_to _ put 

   # BA SE_C AS E: To o much  wate r    if water >sum( ice_tray) :
    raise ValueE rro r(" Too muc h water " )
 #  A ttempt to fill eac ho p en  slot wi th a d i st ri b uted amo un t
   f i l l_amo unt=  i nt(math. floor( i nt (w ater) /  l en(ope n_ slo ts) ))
  lef tover= int(wa ter)%  len(open_slot s )
    for slo t _i n d ex in o pen _slots:
     # Wi th h o wmuc h  wate r hav ew eo verfilled this slot ?       dif f = fill_amou nt - ice_t r a y [slot_in dex] 
      if diff>= 0: 
          # We t riedputtingtoo muchw a ter into  th isslo t
        # Calc u l ateho w muchtoput init        water_to _put[slo t_ in de x]  +=  fill _ amount -  d iff 
        # No  more  wat er  c a n f it into th i s  slo t        recu rsio n _ic e_tray[ slot_inde x]=  0
        # Keep the le ft over
         left o v er += di ff
        else:
          #The  slot  cou ld hold t hewater         wate r_to_ pu t[s l o t_ind e x ]+=fi ll_amount       # So me more  water can fit int o  th is slot
         r e cu rsi o n_ i ce_ tr a y[s l o t_index] = -dif f
         #  None is l e fto ve r

   # Recur se
  recurs ion_water _to_put =  w ater _ i nto _ice_tray( leftover , recursi o n_ice _ tr ay, * *kw args)
  # Add  up re c urs ion
args:
 _ _   _print kwargs['depth'],
__ __  _kwargs['depth'] += 1

_   #_BASE_CASE: No more_water
_   if not water > 0:
      __# Exit_early
__    _ return water_to_put

  _ #_Get slots that have space for more water
__  open_slots_= []
    for i in xrange(len(ice_tray)):
_     _ if ice_tray[i]_>_0:
_   _     _ open_slots.append(i)

    #_BASE_CASE: Not enough water to go around
_   if water <_len(open_slots):
    _ _ # Put 1 more_in the first_'water' slots
_  _    for i_in xrange(water):
 _     __  _water_to_put[open_slots[i]]_+=_1
 _  __ _#_Exit early
    __  return water_to_put

   _# BASE_CASE: Too much_water
_   if_water > sum(ice_tray):
  _     raise_ValueError("Too much_water")

 _  # Attempt to fill each open slot with a_distributed amount
    fill_amount_= int(math.floor(int(water) / len(open_slots)))
_ __leftover = int(water)_%_len(open_slots)
 _  for slot_index in open_slots:
 _ _    # With_how much water have_we_overfilled this slot?
   _    diff =_fill_amount - ice_tray[slot_index]

  ___   if diff_>= 0:
    _  _    # We tried_putting_too much water into this slot
__     ___  # Calculate how_much to put in it
 _        _ water_to_put[slot_index] +=_fill_amount - diff
  ___       # No more_water can_fit into this_slot
         _  recursion_ice_tray[slot_index] = 0
  _         # Keep_the leftover
      _     leftover +=_diff
   __   else:
   ____  _  #_The slot could_hold the_water
  _ _  __   water_to_put[slot_index] += fill_amount
            #_Some more water can fit into_this slot
   __  _   _recursion_ice_tray[slot_index] = -diff
     _      # None is_leftover

_ _ # Recurse
 _ _recursion_water_to_put =_water_into_ice_tray(leftover, recursion_ice_tray, **kwargs)

_ _ #_Add up_recursion