Loading exercise...

Exercise: Redirect a Wrong Turn

Before you start, here’s a quick look at how coding exercises work.

How Coding Exercises Work

A coding exercise runs right here in your browser, with no agent and nothing to install. You change the file in the editor above, then click Run Tests or press Ctrl+Enter (Cmd+Enter on macOS). Automated tests check your file and mark each test as passed or failed.

In this exercise, the file holds your answers instead of a program. The top of the file gives you a task, its run, three sessions and some notes, as data, and the bottom holds your answers, each a "?" to replace. The tests read each answer and tell you whether it holds up, and why not when it doesn’t.

Run the tests early and often, even before you change anything. A failing test’s message tells you what it found and what it expected, so read it before you edit. Fix the first failing test, then run the tests again. A different failing test usually means you made progress!

Getting stuck is normal. The Hints tab nudges you one step at a time, so see whether one hint is enough to get you going. Thinking it through yourself is where most of the learning happens. You can also ask your mentor about the exercise and your answers at any time.

Some exercises mark tests as Bonus. Those are extra challenges, and you’ve solved the exercise once the other tests pass.

For more room, click Full screen or press T while you’re not typing in the editor. When you’re done, open the Solution tab to compare your answers and read the notes.

Once the tests pass, carry on with Break Out of a Fix Loop, which starts the section on debugging with your agent.

Become a Member to join the conversation.