Ad-free passes

Write code · Medium · §10.2 Filling a one-dimensional table

On a video social network, you need a pass to watch without ads. A one-day pass costs price1 won and can be used only on the day it is bought. A one-week pass costs price7 won and can be used for 7 days starting on the day it is bought. For example, a one-week pass bought on day 3 lets you watch without ads from day 3 to day 9.

days holds the numbers of the days on which you will watch videos this year, from smallest to largest. You buy passes so that you watch without ads on every one of those days. Complete the function solution, which returns the smallest amount of money you have to spend. You may buy a pass on any day.

Function

solution(days, price1, price7)

Constraints

Examples

daysprice1price7result
[2, 3, 4, 9, 10, 11, 12, 25]31022
[3, 4, 5, 6]41010

Starter code

def solution(days, price1, price7):
    answer = 0
    return answer

Solve this problem in your browser

Python runs in your browser and checks your answer right away. Hints and the answer are on the problem page.