Syllabus Lesson 126 of 141 · Beat your Ghost
Beat your Ghost

Meet your Ghost

Why it matters Your own defaults are as predictable as the AI's. You just cannot see them from the inside. Your saved solutions can.

Your Ghost is a profile of the moves you make most, counted from the solutions this browser has saved for this course. Only lessons you passed count, and only code that defines a function: a half-finished draft or your Mirror picks are not solutions. Nothing leaves your device.

from creative import context, ghost
history = context.load()             # {"drafts": {lesson: code}, "passed": [lesson, ...], ...}
drafts = {k: v for k, v in history["drafts"].items()
          if k in history["passed"] and "def " in v}
prof = ghost.profile(drafts)
for line in ghost.describe(prof):
    print(line)
ghost.habits_in(code)                  # the habits in one piece of code

The habits it counts: reaching for a cache, wrapping things in a class, importing a library, catching every error, patching a special case, nesting loops and sorting first. Each is counted as present or absent in each solution.

Habit: a move you make without deciding to. None of these is wrong. A cache, a class or a sort is often the right call. A habit is only a problem when it chooses for you.

With fewer than 8 solutions the profile is mostly chance, and describe says so. Read it as a hint. The next four problems each ban one habit, so you practise the other road on purpose.

Recap Count your own moves, pick one to break, and say why.

Your turn

Write rate(drafts, habit): the share of non-empty drafts (skip blank ones) whose code shows habit according to ghost.habits_in, rounded to 2 places (0 if there are none). Build prof = ghost.profile(drafts) from your own solutions (the starter builds drafts for you), print every line of ghost.describe(prof), and set my_top = ghost.top(prof). Then set break_first to the habit key you most want to break and why to one sentence (at least six words) on why.

Spotted a problem in this lesson? Report it · Ask about this lesson

This exercise opens soon

Finish the lesson before it and this one unlocks. The whole course is free, no account needed, and you can read this lesson right now.