Sign up
Log in
Home
Language tracks
C++ track
Exercises
Exercises on the C++ track
Join the C++ Track
42 exercises to help you master C++
easy
Hello World
The classical introductory exercise. Just say "Hello, World!"
strings
easy
Leap
Given a year, report if it is a leap year.
control flow conditionals
logic
easy
Reverse String
Reverse a string
strings
easy
Gigasecond
Given a moment, determine the moment that would be after a gigasecond has passed.
dates
interfaces
easy
Hamming
Calculate the Hamming difference between two DNA strands.
control flow loops
strings
medium
Bob
Bob is a lackadaisical teenager. In conversation, his responses are very limited.
control flow conditionals
parsing
strings
medium
Anagram
Given a word and a list of possible anagrams, select the correct sublist.
arrays
filtering
strings
easy
ETL
We are going to do the `Transform` step of an Extract-Transform-Load.
arrays
control flow loops
maps
medium
Word Count
Given a phrase, count the occurrences of each word in that phrase.
arrays
maps
parsing
strings
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.
control flow loops
math
easy
Nucleotide Count
Given a DNA string, compute how many times each nucleotide occurs in the string.
parsing
strings
medium
Food Chain
Generate the lyrics of the song 'I Know an Old Lady Who Swallowed a Fly'
control flow loops
pattern recognition
strings
medium
Phone Number
Clean up user-entered phone numbers so that they can be sent SMS messages.
parsing
strings
easy
Grade School
Given students' names along with the grade that they are in, create a roster for the school
arrays
parsing
medium
Robot Name
Manage robot factory settings.
randomness
strings
easy
Sum Of Multiples
Given a number, find the sum of all the multiples of particular numbers up to but not including that number.
math
easy
Space Age
Given an age in seconds, calculate how old someone is in terms of a given planet's solar years.
functions
medium
Meetup
Calculate the date of meetups.
functions
interfaces
easy
Scrabble Score
Given a word, compute the scrabble score for that word.
maps
strings
easy
Triangle
Determine if a triangle is equilateral, isosceles, or scalene.
control flow conditionals
easy
Grains
Calculate the number of grains of wheat on a chessboard given that the number on each square doubles.
bitwise operations
easy
Raindrops
Convert a number to a string, the contents of which depend on the number's factors.
strings
medium
Roman Numerals
Write a function to convert from normal numbers to Roman Numerals.
strings
easy
Binary
Convert a binary number, represented as a string (e.g. '101010'), to its decimal equivalent using first principles
strings
math
medium
Prime Factors
Compute the prime factors of a given natural number.
control flow loops
math
medium
Crypto Square
Implement the classic method for composing secret messages called a square code.
filtering
strings
text formatting
easy
Trinary
Convert a trinary number, represented as a string (e.g. '102012'), to its decimal equivalent using first principles.
strings
math
easy
RNA Transcription
Given a DNA strand, return its RNA Complement Transcription.
strings
easy
Acronym
Convert a long phrase to its acronym
regular expressions
strings
hard
Say
Given a number from 0 to 999,999,999,999, spell out that number in English.
logic
strings
text formatting
medium
Sieve
Use the Sieve of Eratosthenes to find all the primes from 2 up to a given number.
control flow loops
math
medium
Series
Given a string of digits, output all the contiguous substrings of length `n` in that string.
arrays
logic
strings
medium
Clock
Implement a clock that handles times without dates.
classes
time
medium
Beer Song
Produce the lyrics to that beloved classic, that field-trip favorite: 99 Bottles of Beer on the Wall.
strings
text formatting
medium
Nth Prime
Given a number n, determine what the nth prime is.
math
easy
Hexadecimal
Convert a hexadecimal number, represented as a string (e.g. "10af8c"), to its decimal equivalent using first principles (i.e. no, you may not use built-in or external libraries to accomplish the conversion).
strings
math
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.
control flow loops
logic
easy
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 operations
filtering
easy
Atbash Cipher
Create an implementation of the atbash cipher, an ancient encryption system created in the Middle East.
algorithms
strings
easy
Bracket Push
Make sure the brackets and braces all match.
pattern matching
stacks
easy
Pangram
Determine if a sentence is a pangram.
control flow loops
strings
medium
All Your Base
Convert a number, represented as a sequence of digits in one base, to any other base.
algorithms
integers
loops
mathematics