Index

Free, with Google

Keep going, free.

A free account opens lessons 2 and 3 of every track, 33 more lessons, and keeps your progress and review cards on every device.

Start free with Google

A chalk plan

Open everything on chalk.

Every lesson, board, video, lab and paper, and the full review decks. Yearly is $39/year.

See plansStart free instead

Module 08 · DSA · Worked problems, in English · about 17 min to read

Play it as a journeyTutor comes with a plan

Bits the hard way: XOR tricks and bit counting

Thinking in Bits
Thinking in Bits · Open board

: a number as a row of switches, and the moves you can make on the row. This lesson uses those moves in three harder ways: counting switches column by column, walking a tree of switches, and using a whole row as one remembered set.

Lesson 72 of 96 in DSA

The rest of this lesson is part of a plan.

A plan opens every lesson, board, video, lab and paper on chalk. Yearly is $39/year.

See plansAlready a member? Sign in

Or start free: a free account opens lessons 2 and 3 of every track.

In this lesson

  • When the pairs become triples
  • Counting the switches in each column, then taking the rest after dividing by 3
  • Walking a tree of switches: the bit trie
  • One number that remembers a set: the mask state
  • A place and a mask together
  • The column method, precisely
  • The trie, precisely
  • The mask DP, precisely
  • The shortest-walk BFS, precisely
  • The four solutions, run
  • Where this shows up

Terms it explains: three, column, column count mod 3, bit trie, mask state, leftover, (place, mask) state, Common mistakes.

Review DSA