DEV Community

Discussion on: Daily Challenge #58 - Smelting Iron Ingots

Collapse
 
matrossuch profile image
Mat-R-Such

Python

def fuel(a):
    a = a * 11
    i= 0
    tab = []
    t1 = [800,120,80,15,1]
    t2 = ['lava','blazeRod','coal','wood','stick']
    while a > 0:
        if  a > t1[i]:
            if a % t1[i] == 0:
                tab.append([t2[i],  a // t1[i]])
                a = 0
            else:
                tab.append([t2[i], a // t1[i]])
                a = a % t1[i]
        else:
            tab.append([t2[i],  0])
        i+=1
    if i < 5:
        while i <5:
            tab.append([t2[i],  0])
            i+=1
    return tab