Week 1 · lesson

Maps, strings, runes

Work safely with maps and Unicode text instead of assuming every character is one byte.

mapsstringsunicode

Today’s outcome

  • Explain the central idea in your own words.
  • Predict the behavior of a small example before running it.
  • Implement the warm-up and core tasks, then verify them.

Build the mental model first

Go rewards a small number of ideas applied consistently: keep ownership clear, make failure explicit, and prefer code whose behavior is easy to test. Today’s focus is maps, strings, runes. Begin by connecting it to code you already understand, then isolate one behavior at a time.

Work safely with maps and Unicode text instead of assuming every character is one byte. Read the example slowly. Predict the result before running it, name the rule that produced it, and change one input. That short loop turns documentation into working knowledge.

Gotcha — familiarity is not recall.

If an example looks obvious, close it and reproduce it from memory. The gap between recognizing code and writing it is where the useful practice lives.

Use the toolchain as feedback

Format early, run focused tests, and read the complete failure before editing. Go’s compiler and standard tools are part of the learning environment. A short, repeatable loop beats a large untested change.

Try · predict before you run

example 1.goOpen Playground ↗
package main

import "fmt"

func main() {
	fmt.Println("Maps, strings, runes")
}
example 2.goOpen Playground ↗
// Make the smallest behavior observable.
// Then add one edge case and run it again.
example 3.goOpen Playground ↗
// Local workflow
// gofmt -w .
// go test ./...
// go vet ./...

Check the model

Quick review

Score 70% or higher. Your best score is saved.

1. What is the main goal of today’s Maps, strings, runes lesson?
2. Which practice best supports clear maps code?
3. What should you do before claiming a program works?
4. What is the most useful response to a failing test?
5. Which design usually makes Go code easier to maintain?
6. How should you approach the Maps, strings, runes coding task?
7. Why does the course include a reflection note?
8. When should you use the Go documentation?

Make it yours

Coding tasks

Character frequency

warmup

Solve a small, direct version. Keep the function pure and test an empty input.

Hint

Write the smallest example first. Use its result to decide the next case.

Unicode-safe anagram

core

Implement the central behavior and cover normal, empty and boundary cases.

Hint

Write the smallest example first. Use its result to decide the next case.

Run-length codec

stretch

Optional: improve the design or complexity and explain the tradeoff.

Hint

Write the smallest example first. Use its result to decide the next case.

Reflect

What clicked? What still feels fuzzy?