-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcodewars11.py
39 lines (26 loc) · 1.1 KB
/
codewars11.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#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 :)
#examples
#Test.assert_equals(hero(10, 5), True)
#Test.assert_equals(hero(7, 4), False)
#Test.assert_equals(hero(4, 5), False)
#Test.assert_equals(hero(100, 40), True)
#Test.assert_equals(hero(1500, 751), False)
#Test.assert_equals(hero(0, 1), False)
def hero(bullets, dragons):
if bullets / dragons < 2:
return False
else:
return True
print(hero(20,11))
#intriguing examples
def hero(bullets, dragons):
return bullets >= dragons * 2
def hero(bullets, dragons):
return dragons <= bullets / 2
def hero(bullets, dragons):
return dragons * 2 <= bullets
def hero(bullets, dragons):
return bullets / dragons >=2 if dragons else False