Skip to content

feat(tutorial): add the half adder and full adder stages - #102

Merged
Rn86222 merged 6 commits into
mainfrom
feat/adder-stages
Nov 19, 2026
Merged

Rn86222 merged 6 commits into
mainfrom
feat/adder-stages

Conversation

@Rn86222

@Rn86222 Rn86222 commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

Summary

The tutorial now reaches arithmetic. Stage 4 is where binary is taught, and stage 5 builds on its part, as the later adder, counter and stopwatch stages will. Since these stages ask to read outputs as binary digits, their tables are written in 1 and 0.

  • Stage 4, "Adding one digit" (half adder): inputs A and B, outputs C and S, from And and Xor. The goal says that from here on ON is 1 and OFF is 0, compares binary carrying with 9 + 1 becoming 10, and asks for the left digit (twos) in C and the right digit (ones) in S.
  • Stage 5, "Adding with a carry" (full adder): inputs A, B and Cin, outputs C and S, from Or and stage 4's part. The goal says to add A and B with one half adder, then Cin to its S with another.
  • Tables in 1 and 0: a stage says how its tables write a bit (tableNotation). From stage 4 on, every table on the stage page uses 1 and 0, including the side panel's info popover, with "In the tables, 1 is ON and 0 is OFF." under the goal table. Stages 1 to 3 and the free mode keep ON and OFF. A test pins down that the switch happens at the stage that teaches binary.
  • Stage factory: defineStage no longer assumes two switches and one lamp, and both adder stages share one check (addingCheck).
  • Fixes on the way:
    • The underline of a truth table's first output column was black and looked thicker. In that header cell, a border shorthand reset the colour.
    • The English message on a wrong output now lists three inputs as "A, B and Cin".

Not in this PR

  • The message on a wrong output keeps ON and OFF on stages 4 and 5. It is compared with the switches and lamps in play mode, which show ON and OFF.
  • The part summaries ("ON only when both inputs are ON") keep ON and OFF next to tables in 1 and 0. The legend under the goal table ties them together.

Testing

  • npx vitest run (196 tests), npx tsc -p . and npx biome check src pass. New tests cover:
    • both stages cleared by their reference solutions, made only of the parts they offer
    • a goal table with two outputs in the order the stage names them
    • tables in digits from the stage that teaches binary on
    • the message on a wrong output with two and three inputs, in English and Japanese
  • Checked in the browser:
    • stages 4 and 5 in the list, and both cleared
    • the tables on stage 4 in 1 and 0 with the legend, and stage 3 still in ON and OFF
    • the half adder's inside, opened from stage 5, laid out without overlaps
    • the full adder's table with every header underline the same

🤖 Generated with Claude Code

Rn86222 and others added 6 commits November 20, 2026 00:37
Stage 4, "Adding one digit", introduces binary: ON is 1 and OFF is 0, and A + B
is output as the twos digit C and the ones digit S, from And and Xor.
Stage 5, "Adding with a carry", adds Cin too, from Or and two of stage 4's part.

The stage factory no longer assumes the two switches and one lamp of the first
stages.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…der is built

- Stage 4 compares binary carrying with 9 + 1 becoming 10.
- Stage 5 says to add A and B with one half adder, then Cin with another.
- The English failure message lists three inputs as "A, B and Cin".
- Both adder stages share one check, and stage 5's solution is laid out with Or
  level with C.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… divider colour

In that header cell, the colour of the left border came before the bottom
border, whose shorthand reset its colour to black. Each border now carries its
colour.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ches binary

From stage 4 on, the goal asks to read C and S as a binary number, so ON and OFF
in the tables had to be translated in the head. A stage now says how its tables
write a bit, and the stage page passes it to every table on it, including the
side panel's. A line under the goal table says that 1 is ON and 0 is OFF.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…there

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… the review

- Stage 4 says the twos digit is the left one and the ones digit the right one.
- The English legend speaks of the tables, as a page has several.
- The message on a wrong output is tested in both languages, with two and three
  inputs.
- The notation context lives in its own file, so the table keeps fast refresh.
- The play-mode value uses bitDigit, and two comments that went stale or only
  restated the code are trimmed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying create-cpu-c8345196-9409-4cce-afc4-389f413ad8ee with  Cloudflare Pages  Cloudflare Pages

Latest commit: cbe02bc
Status: ✅  Deploy successful!
Preview URL: https://73c014fe.create-cpu-c8345196-9409-4cce-afc4-389f413ad8ee.pages.dev
Branch Preview URL: https://feat-adder-stages.create-cpu-c8345196-9409-4cce-afc4-389f413ad8ee.pages.dev

View logs

@Rn86222
Rn86222 merged commit 57622dc into main Nov 19, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant