Log inBook a Demo
BuildJuniorBackendAuto-graded

Write base64 encode and decode from scratch

Implementing a published standard exactly, edge cases included, without reaching for the built-in shortcut everyone else uses.Implement RFC 4648 base64 — both encode and decode — from scratch, without reaching for the base64 or binascii modules. The version in codec.py looks finished but groups its bits incorrectly and mishandles padding when the input length is not a multiple of three. That remainder case is the whole exercise: getting the one- and two-byte tails to produce exactly what the standard produces, and round-tripping every byte back unchanged.
30 min
python

You're done when

  • Encoding produces exactly the output the standard specifies, for ordinary inputs.
  • Inputs whose length is not a multiple of three are padded correctly — the one- and two-byte tails included.
  • Decoding accepts standard base64 input and returns the original bytes.
  • Any input round-trips: encode then decode returns precisely what you started with.

What it measures

Data structures and algorithmsWorking at the bit level to regroup 8-bit bytes into 6-bit symbols, and handling the remainder cleanly.
Working to a specificationImplementing a published standard exactly, rather than something that merely looks plausible and passes casual inspection.
Debugging and verificationProving correctness by round-tripping and comparing against the standard, instead of trusting that the common cases passing means it is right.

Your environment

Terminal + editorA full shell in the browser
Claude CodePre-authenticated, no key setup
Isolated microVMYours alone, wiped afterwards

Start this lab

30 min
Start labYou'll sign in to Anthropos to start. The lab opens in a private cloud workspace with Claude Code ready to use.
AI Labs is part of Anthropos Workforce. Not on your plan yet? Book a demo