python - Reducing a variable on iteration of a loop -
i created following code works out how many rushes heffa lump needs hill. next stage have make every time heffalump rushes hill, becomes tired , rush_height_gain reducded 5% each time.
def num_rushes(slope_height, rush_height_gain, back_sliding): """herbert heffalump""" current_height = 0 rushes = 0 while current_height < slope_height: rushes += 1 current_height += rush_height_gain if current_height >= slope_height: break current_height -= back_sliding return rushes ans = num_rushes(100, 15, 7) print(ans)
this should = 19
i understand part of problem height gain value becomes less slide added line break code when happens. however, cannot life of figure out how make height gain reduced 5% each time
Comments
Post a Comment