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 :)

Source: codewars | Difficulty: EASY
Tags: Fundamentals

Starter code: def hero(bullets, dragons):
	

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


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


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 True if bullets / 2 >= dragons else False


def hero(bullets: int, dragons: int) -> bool:
	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):
	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):
	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):
	A = int(bullets)
	B = int(dragons)
	if A >= 2 * B:
		return True
	else:
		return False


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


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):
	return bool(dragons * 2 - bullets <= 0)


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


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


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):
	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
	temp_bullets = bullets / 2
	if temp_bullets >= dragons:
		survive = True
	else:
		survive = False
	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):
	x = bullets / dragons
	if x == 2:
		return True
	elif bullets / 2 > dragons:
		return True
	else:
		return False


def hero(bullets, dragons):

	def teki(dragons):
		return 2 * dragons
	if bullets > teki(dragons):
		return True
	elif bullets == teki(dragons):
		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):
	print(bullets, dragons)
	hm = bullets / 2
	print(hm)
	if hm >= dragons:
		return True
	else:
		return False


def hero(bullets, dragons):
	a = bullets / 2
	while a >= dragons:
		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):
	kills = bullets / 2
	print(kills, dragons)
	if dragons > kills:
		return False
	if dragons <= kills:
		return True


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):
	x = int(dragons) * 2
	if int(bullets) < int(x):
		return False
	elif int(bullets) >= int(x):
		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(b, d):
	if d == 0 or b == 0:
		return False
	return d / b * 2 <= 1