Practice Arena

Python Coding Challenges

Write real Python in the browser. Instant feedback. From beginner to expert.

467 challenges 330 easy 120 medium 17 hard
Lists & Arrays medium

Partition Array

Implement a function that finds a contiguous partition of a list into k groups, minimizing the maximum sum of the groups.

arrays partition contiguous
+25 pts 25m
Dicts & Sets medium

Hash map merge

Write a function that merges two dictionaries recursively, combining values and preserving structure.

dictionaries recursion merging
+15 pts 15m
Functions & Closures medium

Memoize decorator

Implement a @memoize decorator that caches results of a function.

decorators closures caching
1
+25 pts 20m
Functions & Closures medium

Function composition

Return a function that applies f after g: compose(f, g)(x) == f(g(x)).

functional closures higher-order
+20 pts 18m
OOP & Classes medium

Linked list reversal

Implement a singly linked list and a function to reverse it in place.

linked-list OOP pointers
+28 pts 25m
OOP & Classes medium

Reentrant Lock Manager

Implement a ReentrantLock class with acquire, release, locked, owner, and helper functions that test thread-safety with real threads.

threading locking reentrant
+20 pts 20m
Data Structures & Algorithms medium

Count inversions lite

Implement a function that counts inversions in a list of numbers efficiently.

inversions sorting merge sort
+25 pts 25m
Data Structures & Algorithms medium

Find Peak Element

Implement a function that returns the index of any peak element in an integer array.

arrays search binary-search
+20 pts 25m
Advanced Python medium

Retry decorator

Implement @retry(times=3) that retries a function on exception.

decorators error-handling
+28 pts 25m
Iterators & Generators medium

Prime Sieve Generator

Implement a generator function that yields prime numbers from 2 up to a specified limit, using an efficient sieve approach.

generators prime sieve
+20 pts 20m
Decorators & Context Managers medium

Memoize with TTL

Implement a decorator that caches function results for a limited time, returning cached values within the TTL and recomputing after expiry.

decorators memoization caching
+20 pts 20m
Decorators & Context Managers medium

LRU Memoize

Implement an LRU memoization decorator that caches results for a fixed number of arguments.

decorators caching lru
+30 pts 25m
Decorators & Context Managers medium

Rate Limit Decorator

Implement a decorator that enforces a maximum number of calls per second for any function.

decorator time rate-limiting
+20 pts 20m
Decorators & Context Managers medium

Cache result decorator

Create a decorator that stores results of function calls keyed by positional arguments.

decorators memoization functools
+20 pts 20m
Decorators & Context Managers medium

Profile time decorator

Create a decorator that tracks how many times a function is called and its cumulative execution time.

decorators timing profiling
+20 pts 20m
Regular Expressions medium

Validate Email Regex

Implement a function that validates email addresses using regex with specific rules.

regex email validation
+20 pts 25m
Regular Expressions medium

Match Credit Card Pattern

Write a function that validates a credit card number string against a set of formatting rules.

regex validation credit-card
+25 pts 25m
Math & Number Theory medium

Smith Number Check

Write a function to check if a number is a Smith number by comparing digit sums of the number and its prime factorization.

prime factors digit sum number theory
+20 pts 25m
Bit Manipulation medium

Bit Mask Permissions

Implement helper functions to compose bit masks and check permission bits using bitwise operators.

bitwise bitmasks permissions
+15 pts 20m
Dynamic Programming medium

Bell number

Implement a function to compute the Bell number B(n) using dynamic programming.

dp combinatorics math
+25 pts 25m
Dynamic Programming medium

Target Sum Subsets

Write a function that counts the number of subsets of a list of positive integers that sum exactly to a target.

subset-sum dp counting
+25 pts 30m
Dynamic Programming medium

Word Break DP

Implement a function to check if a string can be segmented into space-separated dictionary words.

dynamic-programming strings word-break
+20 pts 25m
Trees & Binary Trees medium

Lowest Common Ancestor in a Binary Tree

Implement a function to find the lowest common ancestor (LCA) of two nodes in a binary tree.

binary-tree dfs recursion
+30 pts 30m
Trees & Binary Trees medium

Delete Node in BST

Implement a function that deletes a key from a binary search tree and returns the new root.

binary-search-tree tree-traversal recursion
+20 pts 20m
Trees & Binary Trees medium

Trim BST to range

Implement a function to trim a BST to only retain nodes with values in a given inclusive range.

bst recursion tree-pruning
+25 pts 25m
Graphs & Graph Algorithms medium

Articulation Points

Implement a function that returns the articulation points of an undirected graph.

graphs dfs bridges
+25 pts 30m
Graphs & Graph Algorithms medium

Bridges in Graph

Implement a function that returns all bridges in an undirected graph.

graph dfs bridges
+30 pts 30m
Graphs & Graph Algorithms medium

Hamiltonian Path Check

Implement a function that checks whether an undirected graph has a Hamiltonian path using DFS and backtracking.

graph dfs backtracking
+30 pts 30m
Graphs & Graph Algorithms medium

Bipartite Graph Check

Implement a function to check if an undirected graph is bipartite using graph coloring.

graphs bfs coloring
+25 pts 30m
Graphs & Graph Algorithms medium

Cheapest Flights Within K Stops

Implement a function to compute the cheapest flight price from source to destination with at most K stops in a directed weighted graph.

graphs shortest-path dp
+30 pts 30m
Recursion & Backtracking medium

Combination Generator

Write a recursive function that returns all combinations of length k from a list of distinct integers.

recursion backtracking combinations
+25 pts 25m
Binary Search medium

Ternary Search

Implement ternary search to locate the maximum of a discrete unimodal function.

ternary-search binary-search unimodal
+25 pts 30m

Showing 32 challenges · medium

Guide: free Python coding challenges

Practice Python by solving problems

PythonSkillset challenges are hands-on coding exercises from beginner to advanced. Open a challenge, read the problem, write Python in the split-pane editor, and run tests with Pyodide — no install required.

How to use the arena

  1. Pick a category — basics, algorithms, strings, and more
  2. Open a challenge, read the statement, and edit the starter code
  3. Run tests, fix failures, then try a related quiz or tutorial lesson

Challenges vs tutorials and quizzes

Challenges test what you can build under constraints. For guided teaching, use our Python tutorials. For quick checks, try quizzes or copy snippets from code samples.