awesome-everything RU
↑ Back to the climb

Base CS from zero

What a computer is: build a bits-to-arithmetic toolkit

Crux Build a tiny 'bits to arithmetic' toolkit by hand and in code: convert numbers, decode an encoding, and simulate gates up to a half-adder.
Your altitude — climbing toward senior
ZeroJuniorMiddleSenior
You are at middle altitude — in the sky
◷ 210 min

You have read how bits become numbers, letters, truth values, and arithmetic. Now build the whole ladder yourself — small, by hand first and then in code — so the chain from a two-state switch to a working adder is something you have constructed, not just watched.

Goal

Turn the unit’s mental model into a working toolkit: convert between binary and decimal, decode a byte under more than one encoding, and simulate boolean gates well enough to add two bits with a half-adder you built from AND, OR, and NOT.

Project
0 of 6
Objective

Build a small command-line toolkit (any language) that takes raw bits and walks them up the unit's ladder — number, then encoded character, then a gate-level half-adder — proving at each rung that you can produce the result by hand and confirm it in code.

Requirements
Acceptance criteria
  • binary-to-decimal and decimal-to-binary round-trip correctly on every test value (e.g. 0, 13, 90, 180, 255), shown as printed before/after pairs.
  • The byte decoder prints, for example, 65 as both the number 65 and the character 'A', and a one-line note states that the meaning came from the chosen encoding, not the bits.
  • All three gate truth tables and the XOR and half-adder tables print correctly and match the tables in the unit lessons exactly.
  • The half-adder gives sum 0 / carry 1 for inputs 1 and 1, and the hand-check sheet shows the same result derived on paper.
Senior stretch
  • Extend the byte decoder to a third reading: treat three consecutive bytes as an RGB pixel and print the (R, G, B) triple, noting it is the same bits under yet another encoding.
  • Chain two half-adders and an OR gate into a full-adder, then chain four full-adders to add two 4-bit numbers; verify a few sums against decimal arithmetic.
  • Rebuild not_gate, and_gate, and or_gate using only a single nand(a, b) primitive, demonstrating that NAND alone is functionally complete.
  • Add a tiny test harness that asserts every truth table and every round-trip automatically, so the whole toolkit passes or fails in one run.
Recap

Building this toolkit makes the unit concrete: you converted bits to numbers by place value and back by halving, you saw one byte mean a number and a letter under different encodings, and you composed AND, OR, NOT into XOR and then a half-adder that adds two bits correctly. That is the entire arc — two-state switches, through encodings and boolean logic, up to arithmetic — assembled by your own hand.

Continue the climb ↑Addressable cells
shortcuts expand
search
K
prev piece
k
next piece
j
cycle tier
t
this menu
?
sources2
expand
  1. 01
  2. 02

Trademarks belong to their respective owners. Editorial reference only.