A hero is on his way to the castle to complete his mission. However, he's been told that the castle is surrounded with a couple of powerful dragons! each dragon takes 2 bullets to be defeated, our hero has no idea how many bullets he should carry.. Assuming he's gonna grab a specific given number of bullets and move forward to fight another specific given number of dragons, will he survive?

Return True if yes, False otherwise :)

Difficulty: introductory

Starter code:

def hero(bullets, dragons):
	

Solutions:
def hero(bullets, dragons):
    return bullets >= dragons * 2

def hero(bullets, dragons):
    '''
    Ascertains if hero can survive
    Parameters:
        bullets: (int) - number of bullets hero has
        dragons: (int) - number of dragons
    Returns:
        True (Survive) or False (Hero gets killed)
    '''
    if bullets >= 2*dragons:
        return True
    elif bullets < 2*dragons:
        return False


def hero(bullets, dragons):
    return dragons <= bullets / 2

def hero(bullets, dragons):
    return bullets >= 2*dragons

def hero(bullets, dragons):
    return bullets / 2 >= dragons

def hero(bullets, dragons):
    return dragons * 2 <= bullets

hero = lambda b,d: 2*d<=b


def hero(bullets, dragons):
    return (bullets / dragons) >= 2 if dragons > 0 else False

def hero(bullets, dragons):
    return bullets / dragons >=2 if dragons else False


def hero(bullets, dragons):
    return True if bullets / 2 >= dragons else False

def hero(bullets, dragons):
    dead_dragons = bullets/2
    if dragons > dead_dragons:
        return False
    else:
        return True

def hero(bullets: int, dragons: int) -> bool:
    """
    Can the hero survive?
        It takes 2 bullets to kill a dragon
    Parameters:
        bullets (int): number of bullets
        dragons (int): number of dragons
    Returns:
        True (Lives) or False (Dies)
    """
    return bullets >= (dragons * 2)

hero = lambda _,__:__*2<=_

def hero(bullets, dragons):
    while bullets >0:
        if bullets / dragons >= 2:
            return True
        break
    return False

def hero(bullets, dragons):
    if bullets >= 2*dragons:
        return(True)
        pass
    else:
        return(False)
        pass

def hero(bullets, dragons):
    survival = None
    if dragons == 0:
        survival = True
    elif bullets/dragons >= 2:
        survival = True
    else:
        survival = False
    return survival

hero = lambda b,d: b/2-d>=0

hero = lambda b,d: b-d*2>-1

def hero(b, d):
    return b >= 2 * d

def hero(bullets, dragons):
    if bullets/dragons >= 2:
        return True
    else:
        return False

def hero(bullets, dragons):
    if dragons * 2 > bullets:
        return False
    else:
        return True

def hero(bullets, dragons):
     if bullets  >= dragons *2:
            return True 
     else: 

                return False

def hero(bullets, dragons):
    return bullets - dragons >= dragons

def hero(bullets, dragons):
    p = bullets >= 2*dragons
    return p

def hero(bullets, dragons):
    return bullets >= dragons + dragons

def hero(bullets, dragons):
    if dragons==0: return False
    if bullets/dragons>2 or bullets/dragons==2 or dragons==0 : return True
    else: return False

def hero(bullets, dragons):
    try:
        return bullets / dragons >= 2
    except ZeroDivisionError:
        return True

def hero(bullets, dragons):
    return bullets // 2 >= dragons

def hero(bullets, dragons):
    return

def hero(bullets, dragons): 
    return bullets / 2 >= dragons

def hero(bullets, dragons):           
    if int(bullets) / int(dragons) >= 2:
        return True
    else:
        return False  

def hero(bullets, dragons):
          
        
    A =int(bullets)
    B =int(dragons)
    if A >= 2*B:
        
            return True 
     
    else:
            
            return False

def hero(bullets, dragons):
    if bullets > dragons:
        if bullets//dragons >=2:
            return True
        else:
            return False
    else:
        return False

def hero(bullets, dragons):
    required = dragons * 2
    if required > bullets:
        return False
    else:
        return True


def hero(bullets, dragons):
    for i in range(dragons):
        bullets -= 2
    return bullets >= 0

def hero(bullets, dragons):
    shots = bullets // 2
    if shots >= dragons:
        return True
    else:
        return False

def hero(bullets, dragons):
    result = False
    if bullets >= dragons * 2:
        return True  
     
    return result
        
    


def hero(bulets, dragons):
  if (bulets/2)>=dragons: 
    return True 
  else: 
    return False



def hero(bullets, dragons):
    
    try:
    
        devide = bullets // dragons
    
    except:
        pass
    
    if devide >= 2:
        
        return True
    
    else:
        
        return False



hero(10, 5)

def hero(b, d):
    if b-2*d>=0 and b%d>=0:
        return True
    else:
        return False

def hero(bullets, dragons):
    if bullets == 0 or dragons == 0 :
        return False
    if (bullets/dragons) < 2:
        return False
    return True

def hero(bullets, dragons):
    return bool( dragons * 2 - bullets <= 0)

def hero(bullets, dragons):
    return bullets >= 2*dragons

print (hero(6,3)) 

def hero(bullets, dragons):
    if bullets >= dragons * 2:
        a = True
    else:
        a = False
    return a

def hero(bullets, dragons):
    x = bullets
    y = dragons
    if x/2 >= y:
        return True
    else:
        return False


def hero(bullets, dragons):
    if dragons != 0:
        return bullets / dragons >= 2
    elif bullets != 0:
        return False
    return True

bullets = [*range(0, 10)]
dragons = [*range(0, 10)]
def hero(bullets, dragons):
    if bullets / dragons >= 2:
        return True
    else: return False

def hero(bullets, dragons):
    return bool(bullets/2-dragons >= 0)

def hero(bullets, dragons):
    return bullets>dragons*2-1 

def hero(bullets, dragons):
    if (bullets != 0 and bullets % dragons == 0) or (bullets != 0 and (bullets - 2 * dragons)) > 0:
        return True
    else:
        return False

def hero(bullets, dragons):
    if bullets >= (dragons*2):
        survival = True
    else: 
        survival = False
    return survival

def hero(bullets, dragons):
    while True:
        bullets -= 2 
        dragons -= 1 
        if bullets >= 0 and dragons == 0:
            return True
        elif bullets < 0 or dragons < 0:
            return False

def hero(bullets, dragons):
    survive = True #survive check
    temp_bullets = bullets / 2 #div bullets shott one dragon
    if temp_bullets >= dragons: #if avalible bullets >= dragons then hero win else loose
        survive = True
    else:
        survive = False
    return survive    #return survive 
    
    


def hero(bullets, dragons):
    if (bullets / 2) > dragons :
        return True
    elif bullets == 0:
        return False
    else:
        return bullets % dragons == 0 and bullets / dragons == 2

def hero(bullets, dragons):
    if dragons > 0:
        if bullets // dragons >= 2:
            return True
    
    return False

def hero(bullets, dragons):
    if bullets > dragons and bullets >= dragons * 2:
        return True
    else:
        return False 

def hero(bullets, dragons):
    x=bullets/dragons
    if x==2:
        return True
    else:
        if (bullets/2) > dragons:
            return True
        else:
            return False


def hero(bullets, dragons):
    if bullets>dragons *2 -1:
        return (True)
    else:
        return (False)

def hero(bullets, dragons):

    def teki(dragons):
        return 2*dragons

    if bullets > teki(dragons):
        return True
    else:
        if bullets == teki(dragons):
            return True
        else:
            return False

def hero(bullets, dragons):
    x = bullets 
    y = dragons
    if x >= (2 * y):
        return True
    else:
        return False

def hero(bullets, dragons):
    dragons!=0
    if bullets/dragons < 2: 
        result=False
    else :
        result=True
    return result;

def hero(bullets, dragons):
    return dragons == 0 or bullets/(2*dragons) >= 1

def hero(bullets, dragons):
    if dragons != 0:
        return (bullets / dragons) >= 2
    else:
        return False

def hero(bullets, dragons):
    print(bullets, dragons)
    hm = bullets/2
    print(hm)
    if hm >= dragons:
        return True
    else:
        return False

def hero(bullets, dragons):
    if bullets > 2*dragons or bullets == 2*dragons :
        return True
    else :
        return False

def hero(bullets, dragons):
    alive = True
    if dragons*2 > bullets:
        alive = False
    else:
        alive = True
    return alive

def hero(bullets, dragons):
    survive = True
    if bullets / 2 >= dragons:
        survive = True
    else:
        survive = False
    return survive

def hero(bullets, dragons):
    try:
        return bullets // dragons >= 2
    except ZeroDivisionError:
        return True

def hero(bullets, dragons):
    return bool(bullets//2 >= dragons)

def hero(bullets, dragons):
    a = bullets/2
    while a >= dragons:
        return True
    else:
        return False

def hero(bullets, dragons):
    if bullets >= dragons * 2:
        return True
    if bullets == None:
        return False
    else:
        return False

def hero(bullets, dragons): #function
    if bullets >= dragons * 2: #number of bullets should be greater than or equal to twice the number of dragons
        return True
    else:
        return False

def hero(bullets, dragons):
    res = bullets / dragons
    if res >= 2:
        return True
    else:
        return False

def hero(bullets, dragons):
    print(('bullets are {} and dragons are {}'.format(bullets,dragons)))
    if bullets < 2:
        return False
    
    bulletsNeeded = dragons * 2
    
    if bullets - bulletsNeeded >= 0:
        return True
    else:
        return False


def hero(b, d):
    if b/2 < d:
        return False
    elif b/2 >= d:
        return True

def hero(bullets, dragons):
    return False if dragons == 0 else True if bullets / dragons >= 2 else False

def hero(bullets, dragons):
    if bullets//dragons >= 2 and dragons != 0:
        return True
    else:
        return False

def hero(bullets, dragons):
    kills= bullets/2
    print(kills, dragons)
    if dragons > kills: 
        return False
    if dragons <= kills:
        return True

def hero(bullets, dragons):
    if bullets >= dragons * 2 :
        return True
    if bullets <= dragons * 2 :
        return False

def hero(bullets, dragons):
    if bullets/dragons >=2 and dragons!=0:
        return True
    else:
        return False
    if dragons==0:
        return True

def hero(bullets, dragons):
    
    return dragons<1 or bullets//dragons>=2

def hero(bullets, dragons):
    if dragons:
        return True if bullets / dragons >= 2.0 else False
    else:
        return True

def hero(bullets, dragons):
    if bullets // 2 >= dragons: 
        return True
    else:
        return False
    #pogchamp


def hero(bullets = 0, dragons = 1):
    if bullets >= dragons*2:
        return True
    else:
        return False

hero = lambda bul, drg: True if bul/drg >= 2 else False

def hero(bullets, dragons):
    '''
    Dadas una cantidad de balas <bullets> y una cantidad de dragones <dragons>,
    devueve con True o False si esa cantidad de balas puede matar a esa cantidad de dragones.
    El numero necesario para matar un dragon son dos balas.
    '''
    if ( bullets >= 2 * dragons ):
        return True
    else:
        return False

def hero(bullets,dragons) :
    x=int(dragons)*2
    if int(bullets)<int(x) :
        return False
    elif int(bullets)>=int(x) :
        return True


def hero(bullets, dragons):
    x = True
    if dragons*2 <= bullets:
        return x
    else:
        return False

def hero(bullets, dragons):

    if bullets >= dragons*2:
        return True
    else:
        return False
    return True

def hero(bullets, dragons):
    if bullets == 0:
        return False
    if bullets < dragons*2:
        return False
    return True


def hero(bullets, dragons):
    return False if dragons << 1 > bullets else True

def hero(bullets, dragons):
    if dragons >= bullets:
        return False
    elif bullets >= dragons+dragons:
        return True
    else:
        return False

def hero(bullets, dragons):
    return bullets // (dragons * 2)  >= 1

def hero(bullets, dragons):
    if bullets == 0:
        return False
    return bullets/dragons >= 2

def hero(bullets, dragons):
    if(bullets/dragons >=2):
        b = True
    else:
        b = False
    
    return b

def hero(bullets, dragons):
    f = dragons * 2
    return bullets >= f  

def hero(bullets, dragons):
    return False if dragons == 0 or bullets / dragons < 2 else True

def hero(bullets, dragons):
    #if there are twice as many bullets as dragons, or more;
    if bullets >= 2 * dragons :
        return True
    else :
        return False

def hero(b, d):
    if d == 0 or b == 0: return False
    return d/(b)*2 <= 1

def hero(bullets, dragons):
    if dragons == 0:
        return True
    return True if bullets // dragons >= 2 else False

def hero(bullets, dragons):

    x = dragons * 2
    if x <= bullets:
        return True
    else:
        return False