Problem 113649 · easy · Phase 01 Prerequisites & Setup

Every Fifth Coffee Free

loops · modulo · arithmetic

A cafe loyalty card makes every fifth purchase free: the 5th, 10th, 15th, ... coffee costs nothing, whatever its price. prices lists the prices (in cents) of a customer's coffees in the order they were bought. Return the total amount the customer actually paid.

Examples

Input:  prices = [300, 300, 300, 300, 300, 300]
Output: 1500

Input:  prices = [400, 500, 600, 700, 10000]
Output: 2200

Constraints

  • 0 <= len(prices) <= 1000, 0 <= prices[i] <= 10**5

Goals

  • Use a 1-based position inside a loop to spot every fifth item
  • Sum only the items that must be paid for
Starting Python…