612+ problems and growing — inspired by real stories. Solve them, clean them up, then optimize. Same problem, three levels of mastery.
Researchers track elephants by name. Write a function `reverse_name(name)` that reverses an elephant's name. For example, `reverse_name("Ranga")` should return `"agnaR"`.
The Girl Who Spoke to Elephants
A sunset is described by a string of color codes: R (red), O (orange), Y (yellow), P (pink). Write `count_colors(sky)` that returns a dictionary counting each color.
Why Assam's Sunsets Are Orange
Given a list of windspeed readings (in km/h) from a cyclone tracker, write `max_windspeed(readings)` that returns the highest windspeed recorded.
The Fisherman's Daughter and the Storm
A muga silkworm spins thread in a pattern that follows the Fibonacci sequence. Write `silk_fibonacci(n)` that returns the first `n` Fibonacci numbers.
Why the Muga Silk Is Golden
Fireflies on Majuli synchronize their flashes. Given a list of flash times (in ms), write `are_synced(times, tolerance)` that returns True if all flashes are within `tolerance` ms of each other.
The Firefly Festival of Majuli
The Brahmaputra has sandbars represented as a 2D grid: 1 = land, 0 = water. Write `count_islands(grid)` that counts how many separate islands exist. Two 1s are part of the same island if they are adjacent horizontally or vertically.
Temperature drops roughly 6.5°C per 1000m of altitude. Given a list of (altitude, temperature) readings sorted by altitude, write `find_temperature(readings, altitude)` that uses binary search to find the closest reading.
The Snow Leopard's Promise
A banyan tree's root system can be modeled as a nested dictionary. Write `tree_depth(tree)` that returns the maximum depth. An empty dict `{}` has depth 0. `{"root": {"left": {}}}` has depth 2.
The Old Banyan Tree's Stories
Write `distance(p1, p2)` that calculates the Euclidean distance between two coordinate points (x1, y1) and (x2, y2).
The Map Maker's Granddaughter
River dolphins use sonar to detect fish at different distances. Given a list of distances (in meters), write `sonar_sort(distances)` that returns them sorted from nearest to farthest.
The River Dolphin's Secret
Villages are connected by living root bridges. Given a dictionary of connections `{village: [(neighbor, distance), ...]}`, write `shortest_path(graph, start, end)` that returns the shortest total distance.
The Bridge That Grew
A tea garden plot is represented as an N\u00D7N matrix. Write `rotate_garden(matrix)` that rotates it 90 degrees clockwise.
The Girl Who Painted Rain
Given a list of orchid sightings as `(species, location)` tuples, write `group_by_species(sightings)` that returns a dictionary mapping each species to a list of locations.
The Wild Orchids in the Trees
Given yearly population counts, write `population_trend(counts)` that returns "growing", "declining", or "stable".
Rhino tracking codes should be palindromes for easy radio communication. Write `is_palindrome(code)` that checks if a string reads the same forwards and backwards (case-insensitive, ignoring spaces).
The One-Horned Guardian
Bamboo grows in bursts. Given daily growth measurements (in cm), write `longest_growth_streak(measurements)` that returns the length of the longest consecutive streak of positive growth.
The Dancing Deer of Kaziranga
A weaving pattern is a string of "U" (up) and "D" (down) threads. A valid pattern must have matching up/down counts and never go below zero downs at any point. Write `is_valid_pattern(pattern)` that checks validity.
The Cloud Weaver of Tawang
Festival lights follow a pattern. Given a sequence like [1, 3, 5, 7], write `next_in_sequence(seq, n)` that predicts the next `n` numbers.
The Festival of Lights Nobody Saw
A pottery profile is a list of widths at each height. Write `is_symmetric(profile)` that checks if the pottery is symmetric (reads the same from top to bottom as bottom to top).
The Potter Who Made Music
Given daily rainfall data (in mm), write `moving_average(data, window)` that calculates a moving average with the given window size.
The House That Breathed with the Monsoon
Count the vowels (a, e, i, o, u) in a bird name. Write `count_vowels(text)` that returns the count, case-insensitive.
The Kingfisher Who Loved Blue
A tea leaf is roughly elliptical. Write `leaf_area(length, width)` that returns the area using the formula: area = pi * (length/2) * (width/2).
The Boy Who Grew a Forest
Filter a census list to find rhinos above a given weight. Write `heavy_rhinos(weights, threshold)` returning weights above the threshold.
A root bridge can hold 500 kg. Given a list of person weights, write `can_cross(weights, capacity)` that returns how many people can cross before exceeding capacity.
Sign up free to unlock medium problems and more tiers