Sign up
Log in
Home
Language tracks
Rust track
Exercises
Exercises on the Rust track
Join the Rust Track
91 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
loop
vector optional
strings
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.
algorithm
borrowing
math
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
iterator
str vs string
strings
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
struct
traits
medium
DOT DSL
Write a Domain Specific Language similar to the Graphviz dot language
builder pattern
derive
modules
struct
medium
Simple Linked List
Write a simple linked list implementation that uses Elements and a List
lists
struct
type conversion
medium
Pascal's Triangle
Compute Pascal's triangle up to a given number of rows.
index optional
vec
math
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
mutablity
result
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
vec
medium
Sieve
Use the Sieve of Eratosthenes to find all the primes from 2 up to a given number.
map
vector
while let optional
math
medium
RNA Transcription
Given a DNA strand, return its RNA Complement Transcription.
match
result
str vs string
struct
strings
medium
Triangle
Determine if a triangle is equilateral, isosceles, or scalene.
struct
medium
Grade School
Given students' names along with the grade that they are in, create a roster for the school
entry api
option
struct
vec
medium
Binary Search
Implement a binary search algorithm.
option
slices
trait optional
medium
Robot Simulator
Write a robot simulator.
enum
immutability
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
struct
trait optional
medium
Bowling
Score a bowling game
goofy bowling logic
result
struct
medium
Tournament
Tally the results of a small football competition.
enum
hashmap
sorting
structs
medium
Alphametics
Write a function to solve alphametics puzzles.
combinations
external crates optional
parsing
strings
medium
Two Bucket
Given two buckets of different size, demonstrate how to measure an exact number of liters.
algorithm
loops
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.
loop
use of primitive char
int string conversion
strings
medium
ISBN Verifier
Check if a given string is a valid ISBN-10 number.
loop
int string conversion
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
medium
Scrabble Score
Given a word, compute the Scrabble score for that word.
hashmap optional
higher order functions
medium
Pangram
Determine if a sentence is a pangram.
ascii optional
filter
medium
All Your Base
Convert a number, represented as a sequence of digits in one base, to any other base.
enumerate
fold
map
result
math
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.
bitwise probably
enum
filter
struct
vectors
medium
Variable Length Quantity
Implement variable length quantity encoding and decoding.
bitwise
encodings
result
slices
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.
iter
lifetimes
loops
str vs string
vector
strings
medium
Protein Translation
Translate RNA sequences into proteins.
hash map
lifetimes
result
struct
medium
Robot Name
Manage robot factory settings.
lifetimes
randomness
self mut
slices
struct
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.
custom trait
from trait
trait implementation
medium
Wordy
Parse and evaluate simple math word problems returning the answer as an integer.
operators optional
result
parsing
strings
medium
Sublist
Write a function to determine if a list is a sublist of another list.
enum
generic over type
medium
Custom Set
Create a custom set type.
equality
generic over type
struct
vector
medium
Minesweeper
Add the numbers to a minesweeper board
board state
hard
Rectangles
Count the rectangles in an ASCII diagram.
algorithm
enum
structs
traits
hard
Circular Buffer
A data structure that uses a single, fixed-size buffer as if it were connected end-to-end.
buffer reimplementation
generics
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
custom trait
higher order functions
iterators
str to digits
medium
Largest Series Product
Given a string of digits, calculate the largest product for a contiguous substring of digits of length n.
char
higher order functions
result
windows
math
medium
Word Count
Given a phrase, count the occurrences of each word in that phrase.
chars
entry api
hashmap
str vs string
strings
medium
Phone Number
Clean up user-entered phone numbers so that they can be sent SMS messages.
format
iters
match
option
unwrap or
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
mutable
results
struct
traits
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
option
math
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
hashmap
macros
macros by example
hard
Poker
Pick the best hand(s) from a list of poker hands.
enum
lifetimes
struct
traits
parsing
strings
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
result
utf
parsing
strings
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
external crates optional
struct
traits
parsing
strings
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
parser reimplementation
hard
Doubly Linked List
linked-list
generics
lists
unsafe