<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def average_balance_recharges(user, **kwargs):
 """ Return the average daily balance estimated from all recharges. We assume a linear usage between two recharges, and an empty balance before a recharge. The average balance can be seen as the area under the curve delimited by all recharges. """


    balance = 0
    for r1, r2 in pairwise(user.recharges):
        # If the range is less than 1 day, cap at 1
        balance += r1.amount * min(1, (r2.datetime - r1.datetime).days) / 2

    first_recharge = user.recharges[0]
    last_recharge = user.recharges[-1]
    duration = (last_recharge.datetime - first_recharge.datetime).days
    return balance / min(1, duration)