Setting Up: The Forge Editor & How Your Code Gets Graded
You'll learn to
- -Know what a Forge Algorithm Lab level gives you and what you are expected to fill in
- -Understand how a submission is actually graded, end to end
- -Know what the Blacksmith and target complexity are, and when to use them
Tip: the highlighter is on - just select any text below to mark it. Use the highlighter button up top to change color or turn it off, saved just for you on this device.
Before you touch the lab for real, starting later in this course, it is worth knowing exactly what happens when you do. Every Forge level opens in a code editor pre-loaded with starter code: a scenario describing the problem, a function signature you must not rename, and one or more TODO comments marking exactly where your logic belongs. Your job is never to build the whole program from nothing. It is to fill in the gap correctly.
Starter Code and TODOs
A typical starter file looks something like this: a function stub with a docstring describing what it must return, and a placeholder value where your real logic goes.
def analyze_complexity(arr):
"""
TODO: Analyze the time complexity of each function below.
Return a dict with function names as keys and their O() as values.
"""
passThat "pass" (and the TODO above it) is exactly what you replace. The function name and its parameters are part of the contract. The grader calls your function by that exact name with specific arguments, so renaming it or changing what it returns breaks grading even if your logic is otherwise correct.
Hidden Test Cases: How Grading Actually Works
When you hit Submit, your code does not just run once. It runs inside an isolated sandboxed process against a set of test cases, most of which you never see up front. Each test case calls your function with specific inputs and checks the output against an expected value. Passing the visible example in the scenario description is a good sign, but it is not the same as passing every hidden case. Edge cases like empty inputs, duplicates, or unusual orderings are exactly what the hidden tests are there to catch.
- -Your submission is graded on whether every test case passes, not on how the code "looks."
- -A level also shows a target time complexity and target space complexity, a benchmark for how efficient the intended solution is, separate from correctness.
- -Passing all tests with a much worse complexity than the target usually still passes, but it is a signal you have not found the intended approach yet, something you will build real intuition for once Big-O is covered in depth in Phase 2.
The Blacksmith: Getting Unstuck Without Getting the Answer
Every level has a built-in hint system, nicknamed the Blacksmith. It offers a series of progressively more specific nudges, and on some levels AI-generated hints tailored to your actual attempt, that steer you back toward the right idea without just handing you the solution. Reaching for a hint after a genuine attempt is normal, not a failure. The goal is understanding, not a clean first try.
Python First, Java Optional
Every Forge level supports both Python and Java submissions, so if you already know Java you are free to solve levels in it. This course, however, teaches Python from scratch, since it is the primary language of the lab and the friendlier one to learn programming with for the first time. It has fewer ceremony keywords standing between you and the idea you are trying to express.
Nothing in this chapter needs you to open the editor yet. Phase 1 is about learning the language first. Once the Lab Bridges start soon, this is exactly the workflow you will be using for real.
Your Forge submission passes the one visible example in the problem description but fails on Submit. What is actually going on?
"The grader must be broken, since my code already passed the example."
"Passing the visible example only proves my function works for that one input. Submit runs it against a set of mostly hidden test cases specifically designed to catch edge cases, empty inputs, duplicates, unusual orderings, that the one visible example never exercised. I'd go back and think through exactly those categories of input myself rather than assume the grader is wrong."
What is a Forge level's starter code expecting you to do?