learningto/pass

Prompting & Context Windows

EasyConcepts

You have typed the same question into a chat window twice, gotten two different answers, and watched a third rewording produce a third answer. Nothing about the model changed between those calls. What changed was the wording - and the wording is close to the whole input the model ever sees. That input is the prompt: the entire text sent with each call, your question plus every instruction and worked example around it. It matters because a model reads a fixed amount of text per call, called the context window, counted in tokens, the word-sized pieces models are measured in at roughly 4 characters each; everything you send counts against the window, and so does everything the model writes, and when the count runs out the oldest text drops silently, exactly like a capped log buffer, with no error anywhere. Two skills inside prompting carry the interview weight. One is format control: a program can only route on replies whose shape it can read, and there are two ways to get the shape, describing the rule in prose, which models follow loosely, and few-shot examples, worked question and answer pairs shown instead of described, which anchor the format at the price of tokens carried on every call. The other is the skill interviewers probe hardest: when you change the wording, prove the change made it better before anyone ships it, the same fixed question set graded under the old wording and the new - show me you would not ship a prompt change on vibes. The three challenges below build exactly that: the swap audit that catches what a single pass rate hides, the packing rule that keeps the most recent turns inside the window, and the label contract that shows what format control has to survive.

AVG TIME
SPACE
BEST
WORST

Key Concepts

  • 1The prompt is the entire text sent with each call - the question, the instructions around it, and any worked examples - and every word of it is input; there is no channel where the question matters and the surrounding text does not
  • 2The context window is the fixed amount of text a model can read per call, counted in tokens at roughly 4 characters each; what the prompt sends and what the model writes back both count against it, and overflow drops the oldest text silently
  • 3The same question under different wording gets different answers because the wording is the input - which makes an unmeasured prompt change exactly as dangerous as an unmeasured code change
  • 4Few-shot examples pin the output shape where a described rule leaves it loose: worked pairs show the format models copy, and the price is that their tokens are carried on every single call
  • 5The interview-ready habit is the fixed question set: grade the old wording and the new wording on the same examples, compare the pass rates, and always name the questions the change broke

Swap the prompt and watch what changes

The prompting walkthrough

You have typed the same question into a chat window twice and gotten two different answers, and it felt like the model was being moody. It was reading: the wording you sent is the input the model acts on, and every word of it counts. That whole send is the prompt - the question, the instructions around it, and any worked examples - and the model reads a fixed amount of text per call, called the context window (text is counted in tokens, the word-sized pieces models measure at roughly 4 characters each).

Below is one support desk routing real questions to refund handling: eight questions, three prompt variants, and a dial for how many worked examples the few-shot variant shows. The desk grades two things on every reply - can our code read it at all (the first word has to be a label the desk expects), and did the label come out right. Nothing here is scripted: every reply, count, and token estimate comes out of the same arithmetic a real feature change would run, at toy scale. The lesson this setup earns: adding examples moved the desk's score 6, then 5, then 7, then 8 - down before it ever went up, which is exactly why you measure instead of guessing.

Step 1 - forward a question raw

The cheapest prompt is no prompt at all: send the question in alone and let the chat model do whatever it usually does. Route the desk's worst question through it and see what comes back.

Step 2 - swap the prompt, keep the questions fixed

The question is forwarded with no instructions at all. Whatever the model usually does, the desk gets. The worked pairs: an invoice question answered no-refund, a double-billing question answered refund, and a late-delivery question answered refund - the refund lean in those pairs is deliberate, and the reveal names what it costs.

0 of 8 right

0 of 8 parse

35 tokens per call

every answer parsesmiss0 of 8 replies opened with a label
verdicts clear the barmiss0 of 8 labeled the right way
prompt inside the call budgetpass35 tokens against a 120-token reading limit

Step 3 - turn the example dial

The dial belongs to the few-shot prompt: example counts shape the shared block that rides along on every call. Swap to the few-shot prompt to turn it.

Step 4 - audit the swap the way an interviewer asks for it

An interviewer will not ask what makes a good prompt. They ask how you would prove a wording change was an improvement - and the answer is the audit below: the same fixed questions graded both ways, with the questions that flipped to broken counted, never averaged away.

Python Implementation

example.py
Loading...
Now try it yourself
3 challenges with test cases and AI feedback
Practice Now

Complexity Analysis

1481216n²nlog n1n (input size)
COMMON OPERATIONS
Array
Access:O(1)
Search:O(n)
Insert end:O(1)*
Insert mid:O(n)
Hash Map
Get/Set:O(1)*
Delete:O(1)*
Search value:O(n)
Iterate:O(n)
Linked List
Access:O(n)
Search:O(n)
Insert head:O(1)
Delete known:O(1)
Binary Search
Search:O(log n)
Insert:O(log n)
Balanced BST
Search:O(log n)
Insert:O(log n)
Delete:O(log n)
Heap
Peek min/max:O(1)
Push:O(log n)
Pop:O(log n)
Heapify:O(n)
Graph (BFS/DFS)
Traversal:O(V+E)
Dijkstra (heap):O((V+E) log V)
Merge / Quick Sort
Sort:O(n log n)
Space (merge):O(n)
Space (quick):O(log n)

* amortized average case

READY TO TEST YOURSELF?

Put Prompting & Context Windows into practice

The best way to lock in what you've learned is to write code. Solve real interview-style problems right now.

Prompting & Context Windows
Next: RAG System Design in Production