n = 10 +++ Exhausting factors: 0.9 0.8 0.8 0.7 0.7 0.8 0.6 0.5 0.7 0.6 0.5 0.7 0.7 0.5 0.8 0.7 0.8 0.7 0.7 0.7 0.7 0.8 0.5 0.7 0.8 0.6 0.9 0.5 0.9 0.6 0.6 0.5 0.6 0.9 0.7 0.8 0.5 0.5 0.6 0.7 0.6 0.8 0.5 0.9 0.5 0.5 0.8 0.5 0.7 0.5 0.8 0.7 0.9 0.8 0.9 0.9 0.6 0.9 0.9 0.7 0.5 0.5 0.7 0.9 0.5 0.9 0.7 0.5 0.6 0.5 0.9 0.8 0.8 0.6 0.9 0.5 0.7 0.7 0.6 0.6 0.7 0.6 0.5 0.8 0.6 0.5 0.7 0.8 0.6 0.7 +++ Potion positions: 1 1 0 1 0 0 0 1 0 0 0 1 0 0 1 0 0 1 1 0 1 0 0 1 0 0 1 0 0 1 0 1 0 1 1 1 0 1 0 0 0 0 0 0 0 1 1 0 0 0 1 0 0 0 0 1 0 0 1 0 0 0 0 0 1 0 0 0 1 0 1 1 1 1 0 0 1 0 0 0 0 0 0 0 0 0 1 1 1 0 +++ Part 1: Greedy algorithm At (0,0) with energy level = 1.000000 At (1,8) with energy level = 1.708984 At (2,9) with energy level = 1.495361 At (3,9) with energy level = 0.897217 At (4,9) with energy level = 0.628052 At (5,9) with energy level = 0.314026 At (6,9) with energy level = 0.219818 At (7,9) with energy level = 0.109909 At (8,9) with energy level = 0.065945 At (9,9) with energy level = 0.046162 --- Energy level during exit = 0.046162 +++ Part 2: Dynamic-programming algorithm --- Energy level during exit = 0.600928 +++ Part 3: Dynamic-programming algorithm with solution At (0,0) with energy level = 1.000000 At (0,1) with energy level = 1.250000 At (0,2) with energy level = 1.562500 At (1,2) with energy level = 1.250000 At (2,2) with energy level = 0.875000 At (2,3) with energy level = 1.093750 At (3,3) with energy level = 0.765625 At (4,3) with energy level = 0.689063 At (5,3) with energy level = 0.620156 At (5,4) with energy level = 0.620156 At (6,4) with energy level = 0.558141 At (6,5) with energy level = 0.697676 At (7,5) with energy level = 0.627908 At (7,6) with energy level = 0.784885 At (8,6) with energy level = 0.549420 At (9,6) with energy level = 0.384594 At (9,7) with energy level = 0.480742 At (9,8) with energy level = 0.600928 At (9,9) with energy level = 0.600928