Brute Force

What is Brute Forcing?#

A brute-force problem is exactly what it sounds like: simply doing everything possible to eventually reach the answer. Let’s say you were trying to achieve the password to someone’s phone (assume 4 digits from 0 to 9). A brute force solution would be to try every single password possible. This way, it is guaranteed that at one point, the answer would be correct.

  • Pros
    • Easy/Uncomplicated
    • Guarantees a solution
  • Cons
    • Inefficient
    • Not suitable for every problem

Brute Force in the USACO#

It is almost guaranteed that there will be at least one brute force problem in a USACO Bronze contest, and sometimes there will be 2 (and rarely 3).

When taking the USACO, keep in mind that it is a four hour test. That is a small amount of time given as contestants are expected to solve three, very difficult questions. As a contestant, you need to know how to manage your time.

If brute force is possible within the time limit, don’t hesitate. Brute force algorithms are the easiest to type up.

To determine if brute force is doable, learn about time complexity here

Created By: WHS Comp Sci Club Officers

CC-BY-NC-SA 4.0 | WHS CSC 2021