Mary wrote a recipe book and is about to publish it, but because of a new European law, she needs to update and include all measures in grams.

Given all the measures in tablespoon (`tbsp`) and in teaspoon (`tsp`), considering `1 tbsp = 15g` and `1 tsp = 5g`, append to the end of the measurement the biggest equivalent integer (rounding up).

## Examples

```
"2 tbsp of butter"    -->  "2 tbsp (30g) of butter"

"1/2 tbsp of oregano" -->  "1/2 tbsp (8g) of oregano"

"1/2 tsp of salt"     -->  "1/2 tbsp (3g) of salt"

"Add to the mixing bowl and coat well with 1 tbsp of olive oil & 1/2 tbsp of dried dill" -->
"Add to the mixing bowl and coat well with 1 tbsp (15g) of olive oil & 1/2 tbsp (8g) of dried dill"
```

Difficulty: introductory

Starter code:

def convert_recipe(recipe):
	

Solutions:
import re, math

def convert_recipe(recipe):
    
    def repl(m):
        ratio = 15 if m.group(2) == "tbsp" else 5
        return m.group(0) + " (%sg)" % math.ceil(eval(m.group(1)) * ratio)
    
    return re.sub("([0-9/]+) (tb?sp)", repl, recipe)

import re
import math
def convert_recipe(recipe):
    return re.sub(r'(\d+\/\d+|\d+) (tbsp|tsp)', lambda x: x.group(1)+' '+x.group(2)+' '+'('+ str(math.ceil(eval(x.group(1)) * {'tbsp':15,'tsp':5}[x.group(2)]))+'g)', recipe)

import re
from math import ceil
from fractions import Fraction

def convert(m, units={'tbsp': 15, 'tsp': 5}):
    amount, unit = m.groups()
    gram = int(ceil(Fraction(amount) * units[unit]))
    return f'{m.group()} ({gram}g)'

def convert_recipe(recipe):
    return re.sub('(\S+) (tb?sp)', convert, recipe)

import re
from math import ceil

P_RECIPE = re.compile(r'([\d/]+) (tb?sp)')

def convert_recipe(recipe): return P_RECIPE.sub(update, recipe)
    
def update(m):
    toGrams = ceil(eval(m.group(1)) * (15 if m.group(2)=='tbsp' else 5))
    return "{} {} ({}g)".format(m.group(1), m.group(2), toGrams)

from math import ceil
import re


def convert_recipe(recipe):
    spoons = set(re.findall(r"[^ ]+ tb?sp", recipe))
    for spoon in spoons:
        qty, typ = spoon.split(" ")
        wgt = ceil({"tsp": 5, "tbsp": 15}[typ] * eval(qty))
        recipe = re.sub(f"(^| ){spoon}", f"\g<1>{spoon} ({wgt}g)", recipe)
    return recipe

import re,math
def convert_recipe(recipe):
    r=re.sub('((\\d+(/\\d+)?) tbsp)',tbsp,recipe)    
    r=re.sub('((\\d+(/\\d+)?) tsp)',tsp,r)
    return r
    
def tbsp(m):
    return m.group(1)+" ("+str(math.ceil(eval('15*'+m.group(2))))+"g)"
    
def tsp(m):
    return m.group(1)+" ("+str(math.ceil(eval('5*'+m.group(2))))+"g)"

from math import ceil
def convert_recipe(recipe):
    l = []
    l_recipe = recipe.split()
    for num, i in enumerate(l_recipe):
        if i == 'tbsp':
            tmp = l_recipe[num - 1]
            weight  = ceil(eval(tmp) * 15)  if '/' in tmp else int(tmp) * 15
            l.append('tbsp ({}g)'.format(weight))
        elif i == 'tsp':
            tmp = l_recipe[num - 1]
            weight  = ceil(eval(tmp) * 5)  if '/' in tmp else int(tmp) * 5
            l.append('tsp ({}g)'.format(weight))    
        else:
            l.append(i)   
    return ' '.join(l)        
            


from math import ceil

def f(number, spoon): 
    measure = 15 if spoon=='tbsp' else 5
    grams = ceil(eval(f'{measure} * {number}'))
    return f'({grams}g)'

def convert_recipe(recipe):
    seq = recipe.split()
    res = []
    for i, word in enumerate(seq): 
        res.append(word)
        if word in ('tbsp', 'tsp'): 
            res.append(f(seq[i-1], word))
    return ' '.join(res)

import re
from math import *

def convert_recipe(s):
    d = {'tsp': 5, 'tbsp': 15}
    matches = re.findall('\d*/?\d+ tbsp|\d*/?\d+ tsp', s)
    for m in matches:
        v,k = m.split()
        x = eval(f'ceil({d.get(k)} * {v})')
        s = s.replace(m, f'{m} ({x}g)', 1)
    return s

def convert_recipe(recipe):
    import math
    out=[]
    for x in recipe.split(" "):
        if x in ["tbsp", "tsp"]:
            calc = math.ceil(eval("{}*{}".format(out[-1], "15" if x == "tbsp" else "5")))
            out.append(x)
            out.append("({}g)".format(calc))
        else:
            out.append(x)
    return " ".join(out)