-
Notifications
You must be signed in to change notification settings - Fork 0
/
eggdrp.py
45 lines (29 loc) · 976 Bytes
/
eggdrp.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
40
41
42
43
44
45
def my_function(arg):
# write the body of your function here
return 'running with %s' % arg
# run your function through some test cases here
# remember: debugging is half the battle!
print my_function('test input')
def egg_drop(break_floor):
top = 100
floors_to_jump = 14
current_floor = 14
num_drops = 1
def egg_drop_test():
while current_floor < break_floor:
current_floor += floors_to_jump
floors_to_jump -= 1
num_drops += 1
egg_drop_test()
# we have exceded break_floor - move iteratively from last known break-free
# floor
floors_to_jump = 1
if num drops == 1:
current_floor = 1
while current_floor < break_floor:
current_floor += floors_to_jump
num_drops += 1
egg_drop_test()
return (current_floor, num_drops)
print egg_drop_test(14)
print egg_drop_test(28)