Sign up
Log in
Home
Language tracks
Rust track
Exercises
Exercises on the Rust track
Join the Rust Track
92 exercises to help you master Rust
easy
Hello World
The classical introductory exercise. Just say "Hello, World!"
strings
test driven development
easy
Leap
Given a year, report if it is a leap year.
booleans
conditionals
easy
Raindrops
Convert a number to a string, the content of which depends on the number's factors.
conditionals
strings
type conversion
variables
easy
Nth Prime
Given a number n, determine what the nth prime is.
loops
primes
math
easy
Beer Song
Produce the lyrics to that beloved classic, that field-trip favorite: 99 Bottles of Beer on the Wall.
case
strings
loops
vectors
easy
Proverb
For want of a horseshoe nail, a kingdom was lost, or so the saying goes. Output the full text of this proverbial rhyme.
format
easy
Difference Of Squares
Find the difference between the square of the sum and the sum of the squares of the first N natural numbers.
fold
map
math
easy
Sum Of Multiples
Given a number, find the sum of all the multiples of particular numbers up to but not including that number.
borrowing
math
algorithms
easy
Grains
Calculate the number of grains of wheat on a chessboard given that the number on each square doubles.
panic
easy
Prime Factors
Compute the prime factors of a given natural number.
math
easy
Armstrong Numbers
Determine if a number is an Armstrong number
math
easy
Reverse String
Reverse a string
str vs string
strings
iterators
easy
Gigasecond
Given a moment, determine the moment that would be after a gigasecond has passed.
crates
easy
High Scores
Manage a player's High Score list
iterators
lifetimes
vectors
easy
Bob
Bob is a lackadaisical teenager. In conversation, his responses are very limited.
chars
strings
easy
Matching Brackets
Make sure the brackets and braces all match.
stack or recursion
medium
Clock
Implement a clock that handles times without dates.
derive
traits
structs
medium
DOT DSL
Write a Domain Specific Language similar to the Graphviz dot language
builder pattern
derive
modules
structs
medium
Simple Linked List
Write a simple linked list implementation that uses Elements and a List
lists
type conversion
structs
medium
Pascal's Triangle
Compute Pascal's triangle up to a given number of rows.
math
index
vectors
medium
PaaS I/O
Report network IO statistics
io
traits
medium
Nucleotide Count
Given a DNA string, compute how many times each nucleotide occurs in the string.
entry api
filter
match
mutability
result type
medium
ETL
We are going to do the `Transform` step of an Extract-Transform-Load.
btree
medium
Acronym
Convert a long phrase to its acronym
filter
flat map
loops
map
vectors
medium
Sieve
Use the Sieve of Eratosthenes to find all the primes from 2 up to a given number.
map
math
vectors
while let
medium
RNA Transcription
Given a DNA strand, return its RNA Complement Transcription.
match
str vs string
strings
result type
structs
medium
Triangle
Determine if a triangle is equilateral, isosceles, or scalene.
structs
medium
Grade School
Given students' names along with the grade that they are in, create a roster for the school
entry api
option type
structs
vectors
medium
Binary Search
Implement a binary search algorithm.
slices
option type
traits
medium
Robot Simulator
Write a robot simulator.
immutability
enums
medium
Queen Attack
Given the position of two queens on a chess board, indicate whether or not they are positioned so that they can attack each other.
result type
structs
traits
medium
Bowling
Score a bowling game
goofy bowling logic
result type
structs
medium
Tournament
Tally the results of a small football competition.
sorting
structs
enums
hashmaps
medium
Alphametics
Write a function to solve alphametics puzzles.
combinations
parsing
strings
external crates
medium
Two Bucket
Given two buckets of different size, demonstrate how to measure an exact number of liters.
loops
algorithms
medium
Spiral Matrix
Given the size, return a square matrix of numbers in spiral order.
matrix
nested structures
medium
Palindrome Products
Detect palindrome products in a given range.
calculation
structs
math
strings
medium
Saddle Points
Detect saddle points in a matrix.
iterators
vectors
medium
Isogram
Determine if a word or phrase is an isogram.
chars
iterators
strings
medium
Say
Given a number from 0 to 999,999,999,999, spell out that number in English.
modulus
strings
medium
Run Length Encoding
Implement run-length encoding and decoding.
int string conversion
strings
chars
loops
medium
ISBN Verifier
Check if a given string is a valid ISBN-10 number.
int string conversion
loops
medium
Perfect Numbers
Determine if a number is perfect, abundant, or deficient based on Nicomachus' (60 - 120 CE) classification scheme for natural numbers.
math
medium
Hamming
Calculate the Hamming difference between two DNA strands.
option type
medium
Scrabble Score
Given a word, compute the Scrabble score for that word.
higher order functions
hashmaps
medium
Pangram
Determine if a sentence is a pangram.
filter
ascii
medium
All Your Base
Convert a number, represented as a sequence of digits in one base, to any other base.
enumerate
fold
map
math
result type
medium
Allergies
Given a person's allergy score, determine whether or not they're allergic to a given item, and their full list of allergies.
filter
vectors
bitwise
enums
structs
medium
Affine Cipher
Create an implementation of the Affine cipher, an ancient encryption algorithm from the Middle East.
ascii
chars
iterators
primitive types
str vs string
strings
medium
Variable Length Quantity
Implement variable length quantity encoding and decoding.
bitwise
encodings
slices
result type
medium
Pig Latin
Implement a program that translates from English to Pig Latin
ascii
regular expressions
strings
medium
Atbash Cipher
Create an implementation of the atbash cipher, an ancient encryption system created in the Middle East.
ascii
chars
iterators
primitive types
str vs string
strings
medium
Crypto Square
Implement the classic method for composing secret messages called a square code.
arrays
ascii
chars
iterators
primitive types
str vs string
transforming
strings
medium
Rotational Cipher
Create an implementation of the rotational cipher, also sometimes called the Caesar cipher.
ascii
chars
iterators
primitive types
str vs string
strings
medium
Simple Cipher
Implement a simple shift cipher like Caesar and a more secure substitution cipher
ascii
chars
str vs string
strings
medium
Rail Fence Cipher
Implement encoding and decoding for the rail fence cipher.
chars
cipher
strings
medium
Anagram
Given a word and a list of possible anagrams, select the correct sublist.
lifetimes
loops
str vs string
strings
iterators
vectors
medium
Protein Translation
Translate RNA sequences into proteins.
lifetimes
hashmaps
result type
structs
medium
Robot Name
Manage robot factory settings.
lifetimes
randomness
slices
mutability
structs
hard
OCR Numbers
Given a 3 x 4 grid of pipes, underscores, and spaces, determine which number is represented, or whether it is garbled.
chunks
lines
slices
hard
React
Implement a basic reactive system.
closures
generics
lifetimes
medium
Space Age
Given an age in seconds, calculate how old someone is in terms of a given planet's solar years.
from trait
trait implementation
traits
medium
Wordy
Parse and evaluate simple math word problems returning the answer as an integer.
parsing
strings
operators
result type
medium
Sublist
Write a function to determine if a list is a sublist of another list.
generic over type
enums
medium
Custom Set
Create a custom set type.
equality
generic over type
structs
vectors
medium
Minesweeper
Add the numbers to a minesweeper board
board state
hard
Rectangles
Count the rectangles in an ASCII diagram.
structs
traits
algorithms
enums
hard
Circular Buffer
A data structure that uses a single, fixed-size buffer as if it were connected end-to-end.
generics
buffers
medium
Luhn
Given a number determine whether or not it is valid per the Luhn formula.
higher order functions
iterators
str to digits
medium
Luhn From
Luhn: Using the From Trait
from trait
higher order functions
iterators
str to digits
medium
Luhn Trait
Luhn: Using a Custom Trait
higher order functions
iterators
str to digits
traits
medium
Largest Series Product
Given a string of digits, calculate the largest product for a contiguous substring of digits of length n.
higher order functions
windows
math
chars
result type
medium
Word Count
Given a phrase, count the occurrences of each word in that phrase.
chars
entry api
str vs string
strings
hashmaps
medium
Phone Number
Clean up user-entered phone numbers so that they can be sent SMS messages.
format
match
unwrap or
iterators
option type
medium
Diamond
Given a letter, print a diamond starting with 'A' with the supplied letter at the widest point.
parsing
str vs string
strings
medium
Accumulate
Implement the `accumulate` operation, which, given a collection and an operation to perform on each element of the collection, returns a new collection containing the result of applying that operation to each element of the input collection.
generics
higher order functions
move semantics
medium
Fizzy
Implement FizzBuzz using advanced generics
generics
impl trait
iterators
medium
Roman Numerals
Write a function to convert from normal numbers to Roman Numerals.
loops
traits
mutability
result type
structs
medium
Pythagorean Triplet
There exists exactly one Pythagorean triplet for which a + b + c = 1000. Find the product a * b * c.
math
easy
Series
Given a string of digits, output all the contiguous substrings of length `n` in that string.
strings
vectors
easy
Collatz Conjecture
Calculate the number of steps to reach 1 using the Collatz conjecture
math
option type
easy
Diffie Hellman
Diffie-Hellman key exchange.
math
hard
Parallel Letter Frequency
Count the frequency of letters in texts using parallel computation.
multi threading
hard
Macros
Implement a macro using macros-by-example
macros
macros by example
hashmaps
hard
Poker
Pick the best hand(s) from a list of poker hands.
lifetimes
traits
parsing
strings
enums
structs
medium
Grep
Search a file for lines matching a regular expression pattern. Return the line number and contents of each matching line.
conditionals
failure crate
file io
utf
parsing
strings
result type
medium
Scale Generator
Generate musical scales, given a starting note and a set of intervals.
enums
from primitive
music theory
to primitive
traits
medium
Decimal
Implement a Decimal type
bigint
traits
parsing
strings
external crates
structs
medium
Book Store
To try and encourage more sales of different books from a popular 5 book series, a bookshop has decided to offer discounts of multiple-book purchases.
algorithms
groups
set theory
hard
Dominoes
Make a chain of dominoes.
graph theory
searching
hard
Forth
Implement an evaluator for a very simple subset of Forth
parsing
hard
Doubly Linked List
linked-list
generics
lists
unsafe