0PricingLogin
Competitive Programming Academy · Lesson

AND, OR, XOR & Shifts

Read and combine bits with confidence.

Bits Are Your Toolkit

Every integer is really a row of bits, just 0s and 1s. Learning to read and combine them gives you fast, clever tricks in contests. 🔧

See the Binary

Use Python's bin() to peek at the bits of any number. The 0b prefix just marks it as binary, the rest is the bit pattern.

print(bin(13))  # 0b1101

All lessons in this course

  1. AND, OR, XOR & Shifts
  2. Set, Clear & Toggle a Bit
  3. Count Bits and Lowest Set Bit
  4. Bitmasks as Tiny Sets
← Back to Competitive Programming Academy