Skip to content
CCC Python Course

Accumulator patterns

Stage
2
Module
M2.4
Lessons
1

In this module

  • Keep a running sum, count, minimum or maximum while looping over input.
  • Track the best-so-far value with an explicit tie-breaking rule.
  • Use a boolean flag to record whether something has happened yet.

Before this module

Lessons

  1. 1Accumulator patterns

Practice

Try these on the judges. Each link opens the problem on WMOJ or DMOJ.

  1. 2021 J2
    Silent Auction (opens on WMOJ in a new tab) WMOJ

    Find the winning bid in a silent auction with several bidders.

  2. 2024 J3
    Bronze Count (opens on WMOJ in a new tab) WMOJ

    Find the third-highest distinct score in a list of contest scores.

  3. 2017 S1
    Sum Game (opens on DMOJ in a new tab) DMOJ

    Find the last day two teams' season totals were tied, or that they never were.

    Why DMOJ: An early Senior problem, included here for extra practice.