Skip to content
CCC Python Course

Brute force and complete search

Stage
2
Module
M2.5
Lessons
1

In this module

  • Try every candidate answer with nested loops when the input is small enough.
  • Enumerate every pair, triple or subset systematically, without missing or repeating one.
  • Recognize when a candidate can be ruled out before it is fully built, without changing which candidates count.
  • Recognize when the number of candidates is small enough for this to finish in time.

Before this module

Lessons

  1. 1Brute force and complete search

Practice

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

  1. 2022 S1
    Good Fours and Good Fives (opens on WMOJ in a new tab) WMOJ

    Find how many ways a number can be written as a sum of 4s and 5s.

  2. 2016 J3
    Hidden Palindrome (opens on DMOJ in a new tab) DMOJ

    Find the length of the longest palindrome hidden inside a word.

    Why DMOJ: A short Junior problem, included here for extra practice.

  3. 2020 J4
    Cyclic Shifts (opens on DMOJ in a new tab) DMOJ

    Decide whether any rotation of one string appears inside another.

    Why DMOJ: A Junior problem, included here for extra practice.