All puzzles › AI Search and Planning
AI Search and Planning Practice Problems
25 puzzles (4 easy, 12 medium, 9 hard), 6 free, in Python, JavaScript and C++.
Search, planning, reasoning and the classic algorithms of intelligent agents.
The puzzles, easiest first
- Nudge the Estimate (Easy, free): Q-learning keeps a number for each action: how good it expects that action to be.
- Greedy Action (Easy): Given a list of action values, return the index of the best one.
- Manhattan Heuristic (Easy): Given two grid cells as [row, col], return the Manhattan distance between them: the row difference plus the column difference, both as absolute values.
- Tokenize Text (Easy): Given a sentence, return its words in lowercase.
- Cross Off What Cannot Work (Medium, free): Before a solver guesses, it removes values that could never be part of an answer.
- Let the Reward Spread (Medium, free): An agent walks a row of cells, and each cell pays a reward that is never negative.
- Bag-of-Words Cosine (Medium): Given two lists of words, return their bag-of-words cosine similarity, rounded to 3 decimals.
- BFS Distances (Medium): Given a graph as an adjacency list and a start node, return how many hops each node is from the start, or -1 if you can't reach it.
- Bigram Counts (Medium): Given a list of words, return a map from each pair of neighboring words to how many times that pair appears.
- Detect Dependency Cycle (Medium): Given a directed graph as an adjacency list, return true if it has a cycle.
- Flood Fill (Medium): Given a grid, a starting cell, and a new color, recolor the starting cell and every same-colored cell connected to it, up, down, left, or right.
- Intersection over Union (Medium): Given two boxes as [x1, y1, x2, y2], return their intersection over union, rounded to 3 decimals.
- Is Target Reachable? (Medium): Given a directed graph as an adjacency list, a start, and a target, return true if there's any path from start to target.
- Jaccard Similarity (Medium): Given two lists, return their Jaccard similarity, rounded to 3 decimals: how many values they share, divided by how many different values there are in total.
- Markov Next State (Medium): Given a grid of transition counts and the current state, return the most likely next state.
- Minimax Game Value (Medium): Given the scores at the bottom of a game tree and whether the first player is maximizing, return the game's value.
- Only One Choice Left (Hard, free): A formula is a list of clauses, and each clause is a list of literals: 3 means variable 3 is true, -3 means it is false.
- Stop Looking When It Cannot Matter (Hard, free): Minimax looks at every position in a game tree.
- Uncross the Route (Hard, free): The best tour through a set of cities is too hard to find exactly, so solvers improve a tour they already have.
- 0/1 Knapsack (Hard): Given item weights, item values, and a weight limit, return the most value you can carry.
- Coin Change (Fewest) (Hard): Given coin values and an amount, return the fewest coins that add up to it exactly, or -1 if you can't.
- Dijkstra Shortest Path (Hard): Given a weighted graph, where each node lists [neighbor, cost] pairs, return the cheapest total cost from src to target, or -1 if you can't get there.
- Edit Distance (Hard): Given two words, return the fewest single-letter inserts, deletes, or swaps that turn one into the other.
- Shortest Path (BFS) (Hard): Given a grid where 0 is open and 1 is a wall, a start, and an end, return the fewest steps from start to end, moving up, down, left, or right.
- Topological Order (Hard): Given a directed graph as an adjacency list, return an order where every node comes before the nodes it points to.
Practice another pattern
Or browse by subject
Browse all 676 puzzles