Python advanced challenges
You solve demanding challenges without guidance that test your performance, concurrency, parsing and secure coding skills.
Level 401 · 15 lessons · 18 practice labs
Lessons
Parsing and algorithms
- Challenge: an expression parser for arithmetic
- Challenge: a line-based diff tool
- Challenge: autocomplete with a prefix tree
- Challenge: find a cycle in a dependency graph
- Short task: a simple rule engine
Systems challenges
- Challenge: an asynchronous service inventory of the lab network
- Challenge: follow a rotating log without missing lines
- Challenge: summarise 5 GB of data within 100 MB of memory
- Challenge: a file-based distributed lock
- Short task: a job scheduler with dependencies
Security challenges
- Challenge: find five security flaws in a code base
- Challenge: a signed token system
- Challenge: a safe configuration interpreter
- Short task: a patch and a regression test for a flawed service
Capstone
- Capstone: a small key-value database that writes to disk
Practice labs
- Evaluating reverse Polish notation: Write a function that evaluates a space-separated reverse Polish expression with a stack and gives a clear error on a missing operand.
- A parser for boolean filter expressions: Turn filter expressions with and, or, not and parentheses into a tree with precedence rules and evaluate them over record dictionaries.
- A small template language with loops and conditions: Interpret a small template language with variable, condition and loop tags without eval and pass the nested-block and bad-tag tests.
- City suggestions with a prefix tree: Insert city names into a prefix tree and return the first five names matching a typed prefix in alphabetical order.
- Deriving a build order from dependencies: Produce a valid install order from package dependencies and, if there is a cycle, report the packages forming it in order.
- A three-way settings merge: Merge two modified settings files against their common ancestor line by line, mark conflicting regions and pass the tests with randomly generated versions.
- Counting a huge file chunk by chunk: Compute the line and byte counts of a file too large for memory in fixed-size chunks without breaking lines at chunk borders.
- Following a rotating log without missing lines: Write a follower that finishes the rest of the old file and moves to the new one when the log is renamed and reopened, and prove no line is lost.
- Taking a service inventory of the lab network: Collect the open services and greeting lines of allow-listed lab addresses with a concurrency limit and timeouts and produce a JSON inventory.
- Making a token comparison constant-time: Replace the == comparison in a token check with hmac.compare_digest and test that an empty token is rejected.
- A signed token with expiry and key id: Add an expiry time and key id to an HMAC-signed token and show old tokens still verify after key rotation until they expire.
- A patch and regression test for a flawed service: Find and close the authorisation flaw that returns someone else's record in Poyrazlı Enerji's meter service and write a test that breaks if it returns.
- Finding and reporting dependency cycles: Find the cycles in a package dependency graph, print the shortest path for each cycle and list every package affected by one, staying within the time limit on thousands of nodes.
- Sorting a file that does not fit in memory: Sort a record file larger than the memory limit by splitting it into sorted chunks and lazily merging them into one sorted output, deleting temporary files when done.
- Deep-merging nested settings: Write a function that deep-merges two nested settings dictionaries, with the second taking precedence, lists replaced and the inputs left unmodified.
- Extracting and applying a settings diff: Extract the added, removed and changed paths between two nested settings dictionaries as a diff list and show that applying it to the old dictionary yields the new one.
- Checking open ports on the lab target asynchronously: Try timed connections to a given port list on the lab target with asyncio and report open, closed and unresponsive ports separately.
- Collecting lab service banners with bounded concurrency: Collect the greeting lines of services on the lab network with at most ten connections at once, without unresponsive services holding up the job and with results returned sorted by address.
About this course
You solve demanding challenges without guidance that test your performance, concurrency, parsing and secure coding skills.
What you will learn
- Parsing and algorithms
- Systems challenges
- Security challenges
- Capstone
Prerequisites
You should have practised the topics of the same path up to level 301.
Lab environment
Lessons run in your own Kali Linux terminal in the browser, connected to a private lab network. Nothing to install.
Frequently asked questions
- Is this course right for my level?
- The course is at level 401; it assumes you know the topics of the lower-level courses.
- Is there anything to install?
- No. Every lesson runs in your own lab environment that opens in the browser.
- How do lessons work?
- Each lesson has 8 to 10 steps and a short quiz. Early steps show the command to type, later steps give less help; if two attempts fail, the solution opens.
- Can I try it for free?
- Yes. The first three lessons of every course are free.