There's a **"3 for 2"** (or **"2+1"** if you like) offer on mangoes. For a given quantity and price (per mango), calculate the total cost of the mangoes.

### Examples
```python
mango(3, 3) ==> 6    # 2 mangoes for 3 = 6; +1 mango for free
mango(9, 5) ==> 30   # 6 mangoes for 5 = 30; +3 mangoes for free
```

Difficulty: introductory

Starter code:

def mango(quantity, price):
	

Solutions:
def mango(quantity, price):
    return (quantity - quantity // 3) * price

def mango(quantity, price):
    return ((quantity - int(quantity/3))  * price)

def mango(quantity, price):
  batch = quantity//3 
  total = (batch * 2 + quantity%3 ) * price 
  return total

def mango(quantity, price):
    return price * (quantity - (quantity // 3))

def mango(quantity, price):
    print(quantity)
    return (quantity-quantity//3)*price

def mango(quantity, price):
    return ((quantity/ 3) * (2 * price)) + (quantity % 3 * price)

def mango(quantity, price):
    a, b = divmod(quantity, 3)
    return price * (a * 2 + b)

mango = lambda q,p: p*(q-q//3)

mango = lambda count, price: (count - count // 3) * price

def mango(quantity: int, price: int) -> int:
    """
    Calculate the total cost of the mangoes for a given quantity and price.
    Rule: "3 for 2" (or "2+1" if you like) offer on mangoes.
    """
    return (quantity - (quantity // 3)) * price

from math import ceil; mango=lambda q, p: ceil(q/3*2)*p

mango = lambda q, p: (q // 3 * 2 + q % 3) * p;

def mango(quantity, price):
    free = 0
    for i in range(1, quantity +1):
        if i%3 == 0:
            free += 1
    return price * (quantity - free)

def mango(quantity, price):
    q,r = divmod(quantity,3)
    return price*(2*q+r)

mango=lambda q,p:(q-q/3)*p

mango=lambda q,p:q//3*2*p+q%3*p

def mango(quantity, price):
    quantity = quantity - quantity // 3
    return quantity * price

def mango(quantity, price):
    groups_of_three = quantity // 3
    remainding = quantity % 3
    
    return groups_of_three * 2 * price + remainding * price

def mango(quantity, price):
    return (quantity * price) - (price * (quantity // 3)) 

def mango(quantity, price):
    if quantity % 3 == 0:
        return (quantity * 2 * price // 3)
    else:
        return (quantity // 3 * 2 * price + quantity % 3 * price)

def mango(quantity, price):
    a = quantity - quantity//3
    return a*price

def mango(quantity, price):
    if quantity == 2 or quantity ==3:
        return 2 * quantity
    else:
        free = quantity // 3
        return (quantity - free) * price


import numpy as np
def mango(quantity, price):
    return (quantity-(np.floor(quantity/3)))*price

def mango(quant, price):
    return (quant - (quant // 3)) * price

def mango(q, p):
    return sum(map(lambda x,y: x*y, [q//3, q%3],[2*p, p]))

def mango(quantity, price):
    remaining = quantity%3
    quantity = (quantity - remaining) *2/3
    return quantity*price + remaining*price

def mango(quantity, price):
    non_discounted_mangos = quantity % 3
    discounted_mangos = quantity - non_discounted_mangos
    return (((discounted_mangos / 3) * 2) * price) + (non_discounted_mangos * price)

def mango(quantity, price):
    s, e = divmod(quantity, 3)  # set of three + extra
    return price*((2*s)+e)  # 3 for 2 + extra


def mango(quantity, price):
        special_price_lots = quantity // 3
        full_price_mangoes = quantity - special_price_lots * 3
        return (special_price_lots * 2 + full_price_mangoes) * price

def mango(quantity, price):
    if quantity / 3 == 1:
        return (quantity - 1) * price 
    else:
        actual_quantity = quantity // 3
        return (quantity - actual_quantity) * price

def mango(q, price):

    return price*(q-q//3)

def mango(quantity, price):
    return 2 * price if quantity == 3 else (quantity - (quantity // 3)) * price


import math
def mango(quantity, price):
    n=math.ceil(quantity*(2/3))
    return price*n

def mango(quantity, price):
    a = int(quantity / 3)
    quantity -= a
    return price * quantity

def mango(quantity, price):
    if quantity % 3 == 0:
        return quantity * 2 / 3 * price
    else:
        return (quantity - quantity // 3) * price

def mango(quantity, price):

    free = quantity//3
    res = (quantity - free) * price
    return res

from math import ceil
def mango(quantity, price):
    x = quantity // 3
    return (quantity-x) * price

def mango(q,p):
    """mangos are three for two
    """
    return (2 * (q // 3) + (q % 3))*p


import math
def mango(quantity, price):
    actual=math.floor(quantity/3)
    return (quantity-actual)*price

def mango(quantity, price):
    total_cost = price * (quantity - quantity // 3)
    return total_cost

def mango(quantity, price):
    return (quantity - quantity//3)*price if quantity > 3 else 6

def mango(quantity, price):
    return price * (quantity // 3) * 2 + price * (quantity % 3)

def mango(quantity, price):
    grupos = quantity//3
    residuo = quantity%3
    precio = (grupos*2 * price)

    if residuo == 0:
        return precio
    elif residuo == 1:
        return precio+price
    elif residuo == 2:
        return precio+(price*2)

def mango(quantity, price):
    discount = quantity // 3
    return ((quantity - discount) * price)

def mango(quantity, price):
    return price * round((quantity * 2)/3 + 0.5)


import math

def mango(quantity, price):
    free_mangos = math.floor(quantity / 3)
    return (quantity - free_mangos) * price


def mango(quantity, price):
    free = quantity - (quantity // 3)
    return free * price

def mango(quantity, price):
    pass
    
    c = (quantity-quantity//3)*price
    
    return c

import math
def mango(quantity, price):
    return ((quantity // 3) + (quantity - ((quantity // 3) * 2))) * price


def mango(quantity, price):
    
    q = quantity
    p = price
    
    return (q - (q // 3)) * p

mango = lambda quantity, price: (quantity - quantity//3) * price

def mango(quantity, price):
    print(quantity, price)
    if not quantity%3==2:
      return price*(quantity*2//3)+price*(quantity%3) 
    else:
      return price*(quantity*2//3)+price*(quantity%3)/2

def mango(quantity, price):
    if quantity % 3 == 0:
        return quantity*2/3 * price
    elif quantity % 3 == 1:
        return (quantity-1) * 2/3 * price + price
    elif quantity % 3 == 2:
        return (quantity-2) * 2/3 * price + 2 * price

import math
def mango(quantity, price):
    return (quantity - (quantity // 3)) * price

def mango(quantity, price):
    buy = 0
    bill = 0
    while buy<quantity:
        buy+=3
        bill+=price*2
    
    if buy==quantity:
        return bill
    elif buy-quantity==1:
        return bill
    elif buy-quantity==2:
        return bill-price

def mango(quantity, price):
    n = 0
    all_price = 0
    if quantity <= 2:
        return quantity * price
    elif quantity > 2:
        while n < quantity:
            n += 1
            all_price += price
            if n % 3 == 0:
                all_price -= price
    return all_price
                
        
            
            
    pass

def mango(quantity, price):
    deal = int(quantity/3)    
    no_deal = quantity - deal*3
    return deal*2*price + no_deal*price

def mango(quantity, price):
   real_quant = quantity - (quantity //3)
   return real_quant * price

def mango(quantity, price):
    if quantity % 3 == 0:
        a = (quantity / 3) * 2
        return a * price
    elif quantity % 3 != 0:
        b = quantity % 3
        c = ((quantity - b) / 3) * 2
        d = (c + b) 
        return d * price


def mango(quantity, price):
    total = 0
    for each in range(1,quantity +1):
        if each % 3 != 0:
            total += price
    return total


def mango(quantity, price):
    pass
    x=quantity//3
    y=quantity%3
    return (2*x+y)*price

# def mango(quantity, price):
# #     if quantity % 3 == 0:
# #         return (quantity//3)*2*price
# #     # if quantity % 3 == 1:
# #     else:
# #         return ((quantity//3)*2 + 1)*price
def mango(quantity, price):
    return (quantity - quantity // 3) * price

import math
def mango(quantity, price):
    return quantity * price - math.floor(quantity/3) * price

from math import floor
def mango(q,p): return (q-floor(q/3))*p

def mango(q,p):
    price = 0
    while q % 3 != 0:
        price += p
        q -= 1
    return price+q*(2/3)*p

def mango(quantity, price):
    return (int(quantity * 2 / 3) + (1 if quantity % 3 else 0)) * price

import math
def mango(quantity, price):
    print(quantity, price)
    
    return math.ceil(quantity / 3 * 2) * price

def mango(q, p):
    return (q -(q // 3)) * p
    # Flez    


def mango(q, p):
    print((q, p))
    return (q * p) - ((q // 3) * p)
    # Flez


def mango(quantity, price):
    groups_three = quantity // 3
    extra = quantity % 3
    cost = 0
    cost = cost + groups_three * (price * 2)
    cost = cost + extra * price
    return cost

def mango(quantity, price):
    groupsOfThree = quantity // 3
    remainder = quantity - groupsOfThree * 3
    return groupsOfThree * price * 2 + remainder * price

from math import ceil
def mango(quantity, price):
    return ceil(quantity / 3 * 2) * price

def mango(q, p):
    Q = q/3*2
    Q = int(Q) if Q%1==0 else int(Q)+1
    return Q*p

def mango(quantity, price):
    total = 0
    for i in range(1, quantity + 1):
        if i % 3 != 0:
            total += price
        else:
            pass
    return total

def mango(quantity, price):
    return int((quantity - int(quantity / 3)) * price)

def mango(quantity, price):
    q = quantity // 3 * 2
    q += quantity - (q * 1.5)
    return q * price

def mango(quantity, price):
      return round((quantity//3)*2 * price + quantity%3 * price) 


def mango(quantity, price):
    return (quantity % 3 * price) + (int(quantity - (quantity % 3))) / 3 * 2 * price

def mango(q, pr):
    return ((q // 3) * 2 * pr) + ((q-q//3*3) * pr)

from operator import mod


def mango(quantity, price):
    x = int((quantity / 3)) * 2
    r = mod(quantity, 3)
    return x * price + (r * price)

def mango(q, price):
    return (2 * (q // 3) + q % 3) * price

def mango(quantity, price):
    total = 0

    for count in range(1, quantity + 1):
        if count % 3 == 0:
            continue
        total += price

    return total

def mango(quantity, price):
    priceOfTwo = quantity  // 3 
    remaining = quantity-priceOfTwo*3
    return (priceOfTwo * price * 2) + (remaining * price)

def mango(quantity, price):
    p2 = price * 2
    calc  = divmod(quantity,3)
  
    calc2 = calc[0] * p2
    return calc2 + (calc[1] * price)



def mango(quantity, price):
    ost = quantity % 3
    return ((quantity-ost) * 2 / 3 + ost) * price

def mango(quantity, price):
    return (int(quantity/3)*price*2) + (quantity - (int(quantity/3)*3))*price

def mango(q, p):
    return q//3*2*p if q % 3 == 0 else q//3*2*p + (q%3)*p


def mango(q, p):
    return (q-q//3)*p
#Solved on 30th Sept, 2019 at 01:08 AM.


import math
def mango(quantity, price):
    a = math.floor(quantity/3)
    return math.floor((quantity-a)*price)

def mango(a,b):
    return(((a//3)*2)*b+(a%3)*b)

def mango(quantity, price):
    return (2/3*(quantity - quantity%3)+quantity%3)*price

from math import floor

def mango(quantity, price):
    return (quantity-floor(quantity/3))*price

def mango(quantity, price):
    paid_mangos = ((quantity - quantity % 3) // 3 * 2) + quantity % 3
    return paid_mangos * price


def mango(total_quantity, price_per_mango):

    quantity_of_set_3 = int(total_quantity/3)
    remaining_mangoes = total_quantity%3
    
    price_per_two_mangoes = price_per_mango*2
    cost_of_set3 = quantity_of_set_3*price_per_two_mangoes
    
    cost_remaining_mangoes = remaining_mangoes*price_per_mango
    total_cost = cost_of_set3 + cost_remaining_mangoes
    
    return total_cost

    


def mango(quantity, price):
    return (quantity-quantity//3)*price  #I solved this Kata on  8/30/2019  01:07 AM...#Hussam'sCodingDiary


def mango(quantity, price):
    x = quantity // 3
    return (quantity - x) * price

def mango(quantity, price):
    sum = 0
    
    while quantity > 2:
        quantity = quantity - 3
        sum = sum + price * 2
    
    return sum + price * quantity

def mango(quantity, price):
    result = divmod(quantity,3)
    return result[0]*2*price + result[1] * price

def mango(quantity, price):
    a = quantity%3
    b = quantity - a
    c = 2*b/3
    d = c*price + a*price
    return d

def mango(quantity, price):
    print("==>> ",quantity, price)
    num_3 = int(quantity / 3)
    print("Num_3: ",num_3)
    output = (quantity-num_3)*price
    return output