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
Python Basics easy

Min of three numbers

Write a function that returns the minimum of three integers.

min comparison function
+5 pts 5m
Python Basics easy

Seconds to Hours Minutes Seconds

Convert total seconds into a zero-padded HH:MM:SS format.

arithmetic divmod formatting
+8 pts 10m
Python Basics easy

Minutes to Hours: Time Conversion Helper

Write a function that converts minutes into a human-readable 'Xh Ym' string, with special cases for zero and whole hours.

arithmetic formatting conditionals
+8 pts 10m
Python Basics easy

Find Minimum Value

Write a function that returns the minimum integer from a given list.

min list loop
+10 pts 10m
Python Basics easy

Range of values

Calculate the range (max minus min) of a list of numbers. Empty list returns 0.

min max numbers
+10 pts 10m
Strings & Text easy

Is pangram

Write a function that determines whether a given string is a pangram, ignoring case and non-letter characters.

strings sets algorithm
+8 pts 12m
Strings & Text easy

Is isogram

Implement a function that determines whether a string is an isogram (no repeated letters, case-insensitive).

strings case-insensitive validation
+10 pts 10m
Strings & Text easy

Is rotation of another string

Write a function to determine if one string is a rotation of another string.

strings rotation membership
+10 pts 15m
Strings & Text easy

Hamming Distance

Implement a function that computes the Hamming distance between two strings of equal length.

strings character-comparison distance
+10 pts 15m
Lists & Arrays easy

Average excluding min and max

Return the average of a list after discarding the lowest and highest elements, handling edge cases.

lists statistics sorting
+7 pts 10m
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 easy

Merge dicts summing values

Write a function that merges two dictionaries by summing values for duplicated keys.

dicts merge sum
+10 pts 10m
Dicts & Sets easy

Count Pairs with Sum

Implement a function that counts the number of distinct pairs in a list summing to a target.

dictionary pair-counting hash-map
+10 pts 15m
Dicts & Sets easy

Ransom Note Builder

Given two strings, determine if the ransom note can be formed from the words in the magazine.

dictionary counting strings
+10 pts 15m
OOP & Classes medium

Class Method Factory

Create a class method factory that dynamically adds methods to a class based on a mapping of names to behaviors.

oop metaprogramming factory
+20 pts 25m
Data Structures & Algorithms medium

Coin change (DP)

Find the minimum number of coins to make exactly the target amount.

dp greedy
+30 pts 28m
Data Structures & Algorithms hard

Median of Two Sorted Arrays

Given two sorted arrays, return the median of the combined sorted array in O(log(min(n,m))) time.

median binary search arrays
+45 pts 40m
Data Structures & Algorithms medium

Decode Ways

Count the number of ways to decode a numeric string into letters using the mapping A=1 to Z=26.

dynamic programming strings counting
+20 pts 25m
Data Structures & Algorithms medium

Redundant Connection

Given a list of edges forming a tree plus one extra edge, return the edge that appears last in the input and creates a cycle.

graphs union-find cycle-detection
+25 pts 25m
Decorators & Context Managers easy

Timing Decorator

Implement a decorator that prints the execution time of a function.

decorators time performance
+10 pts 15m
Decorators & Context Managers easy

Context Manager Class

Implement a context manager class that measures execution time and sets duration, with None if an exception occurred.

context-manager classes timing
+8 pts 12m
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
Decorators & Context Managers easy

Timer Context Manager

Implement a context manager that measures execution time of a with block and stores it.

context-manager timing measurement
+10 pts 15m
Decorators & Context Managers easy

Context Decorator Dual

Implement a timing decorator and a context manager that both record elapsed time in seconds.

decorator context-manager time
+10 pts 15m
Regular Expressions easy

Validate phone number

Write a function that uses regular expressions to determine if a given string is a valid US phone number.

regex validation phone
+10 pts 15m
Math & Number Theory easy

Catalan number

Implement a function that returns the nth Catalan number using dynamic programming.

math dynamic-programming combinatorics
+10 pts 15m
Math & Number Theory easy

Stirling number

Implement a function to compute Stirling numbers of the second kind S(n,k).

stirling-numbers dynamic-programming combinatorics
+10 pts 15m
Math & Number Theory easy

Lucas Sequence

Implement a function to compute the n-th Lucas number using iteration or recursion with memoization.

math sequence dynamic programming
+10 pts 15m
Bit Manipulation easy

Add without plus

Implement a function that adds two integers using only bitwise operations, no arithmetic plus or minus.

bitwise addition xor
+10 pts 15m
Dynamic Programming medium

Levenshtein Distance

Implement the classic Levenshtein distance algorithm to measure string similarity.

strings dynamic-programming edit-distance
+30 pts 30m
Dynamic Programming medium

Max Profit from Selling Twice

Compute the maximum profit that can be achieved by completing at most two buy-sell transactions on a given price array.

dynamic programming arrays stock
+28 pts 30m
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 easy

Min cost climbing stairs

Compute the minimum total cost to reach the top of a staircase, given you can climb 1 or 2 steps at a time.

dynamic programming memoization array
+10 pts 15m
Dynamic Programming easy

House Robber

Given a list of house values, return the maximum sum you can rob without robbing two adjacent houses.

dynamic-programming arrays optimization
+10 pts 15m
Dynamic Programming medium

House Robber Circular

Solve the House Robber problem with houses arranged in a circle.

dynamic-programming arrays circular
+25 pts 30m
Dynamic Programming easy

Unique Paths in a Grid

Count the number of unique paths from the top-left corner to the bottom-right corner of a grid, moving only right and down.

dynamic-programming grid counting
+15 pts 20m
Dynamic Programming medium

Unique Paths with Obstacles

Given a 2D grid with obstacles, count the unique paths from top-left to bottom-right moving only down or right.

dynamic-programming grid 2d-array
+25 pts 25m
Dynamic Programming easy

Triangle Minimum Path

Compute the minimum path sum from top to bottom of a triangle given as a list of lists.

dynamic-programming bottom-up arrays
+12 pts 20m
Dynamic Programming medium

Maximal square

Given a 2D binary matrix of 0s and 1s, compute the area of the largest square containing only 1s.

dynamic-programming matrix maximal-square
+30 pts 30m
Dynamic Programming medium

Longest Common Subsequence

Given two strings, compute the length of the longest subsequence common to both.

dynamic-programming strings lcs
+30 pts 30m
Dynamic Programming medium

Longest Palindromic Subsequence

Compute the length of the longest palindromic subsequence in a given string.

strings dp subsequence
+25 pts 30m
Dynamic Programming medium

Edit Distance (Levenshtein Distance)

Implement the classic edit distance algorithm to find the minimum number of single-character edits required to transform one string into another.

dynamic-programming strings levenshtein-distance
+25 pts 30m
Dynamic Programming medium

0/1 Knapsack

Implement the classic 0/1 Knapsack dynamic programming solution to maximize value under a weight capacity.

dynamic-programming knapsack optimization
+30 pts 25m
Dynamic Programming medium

Unbounded Knapsack

Given item weights and values with unlimited copies, find the maximum total value that fits in a knapsack capacity.

dynamic-programming knapsack optimization
+30 pts 25m
Dynamic Programming medium

Partition Equal Subset

Determine whether a given list of positive integers can be partitioned into two subsets with equal sum.

dynamic-programming subset-sum memoization
+30 pts 25m
Dynamic Programming medium

Coin Change Minimum

Given coin denominations and a target amount, compute the minimum number of coins needed or -1 if impossible.

dynamic-programming coins minimum
+30 pts 25m
Dynamic Programming medium

Coin Change Ways

Count the number of distinct combinations of coins that sum to a target amount.

dynamic programming coins counting
+30 pts 25m
Dynamic Programming medium

Perfect Squares Sum

Given a positive integer n, return the least number of perfect squares (e.g., 1, 4, 9, 16, ...) that sum to n.

dynamic-programming math optimization
+25 pts 25m
Dynamic Programming medium

Integer Break Product

Given a positive integer n, break it into at least two positive integers that sum to n and maximize their product.

integer-break dynamic-programming max-product
+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
Dynamic Programming hard

Palindrome Partitioning Minimum Cuts

Given a string, return the minimum number of cuts needed such that every substring in the partition is a palindrome.

dynamic-programming palindrome strings
+40 pts 35m
Dynamic Programming hard

Egg Drop Puzzle

Given k eggs and n floors, compute the minimum number of attempts required in the worst case to find the highest safe floor.

dynamic-programming optimization classic-puzzle
+45 pts 35m
Dynamic Programming medium

Paint House Colors

Given a cost matrix, compute the minimum total cost to paint all houses with no two adjacent houses having the same color.

dynamic-programming optimization arrays
+20 pts 25m
Dynamic Programming medium

Buy Sell Stock with Cooldown (DP)

Given daily stock prices, compute the maximum profit you can achieve if you must wait one day after selling before buying again.

dynamic-programming state-machine stocks
+25 pts 25m
Trees & Binary Trees easy

Minimum Depth of Tree

Given a binary tree, compute the minimum depth from the root to the nearest leaf node.

binary-tree depth traversal
+10 pts 15m
Graphs & Graph Algorithms hard

Minimum Cut

Given an undirected graph in adjacency-list form, return the size of the minimum edge cut that disconnects the graph.

graphs max-flow min-cut
+40 pts 35m
Graphs & Graph Algorithms medium

Graph Coloring

Given an undirected graph, determine if it can be colored with two colors such that adjacent vertices have different colors.

graph bipartite bfs
+20 pts 20m
Graphs & Graph Algorithms medium

Graph Valid Tree

Determine if n nodes and an edge list form a valid tree (connected and acyclic).

graph dfs bfs
+25 pts 30m
Graphs & Graph Algorithms medium

Network Delay Time

Given a directed weighted graph and a starting node, find the minimum time for a signal to reach all nodes, or -1 if unreachable.

dijkstra shortest-path graph
+25 pts 30m
Two Pointers & Sliding Window easy

Best Time to Buy and Sell Stock

Given a list of daily stock prices, determine the maximum profit achievable by buying on one day and selling on a later day.

arrays sliding-window profit
+10 pts 15m
Two Pointers & Sliding Window hard

Minimum Window Substring

Implement a sliding window algorithm to find the minimum window substring containing all characters of a given pattern.

sliding-window two-pointers strings
+45 pts 35m
Two Pointers & Sliding Window medium

Permutation in String

Determine if any permutation of a shorter string appears as a contiguous substring in a longer string using an efficient sliding window.

sliding-window two-pointers hash-map
+25 pts 25m
Heaps & Priority Queues easy

Min Heap Class

Build a MinHeap class with push, pop, peek, and size methods that maintain a valid min-heap.

heap priority-queue class
+10 pts 15m
Matrix & 2D Arrays easy

Valid Sudoku Board

Determine if a 9x9 Sudoku board is valid by checking rows, columns, and 3x3 sub-boxes.

matrix set validation
+10 pts 15m
Matrix & 2D Arrays medium

Rotting Oranges Time

Given a grid of fresh, rotten, and empty cells, compute the minimum minutes until all fresh oranges rot, or -1 if some are unreachable.

bfs grid simulation
+25 pts 25m

Showing 65 challenges

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.