Exercism v3 launches on Sept 1st 2021.
Learn more!
ðŸš€ðŸš€ðŸš€
Sign up
Log in
Home
Language tracks
Bash track
Exercises
Exercises on the Bash track
Join the Bash Track
88 exercises to help you master Bash
easy
Hello World
The classical introductory exercise. Just say "Hello, World!"
strings
easy
Two Fer
Create a sentence of the form "One for X, one for me."
control flow conditionals
strings
text formatting
easy
Error Handling
Implement various kinds of error handling and resource management
error handling
input validation
strings
easy
Raindrops
Convert a number to a string, the content of which depends on the number's factors.
control flow conditionals
input validation
strings
easy
Hamming
Calculate the Hamming difference between two DNA strands.
control flow loops
string comparison
easy
Acronym
Convert a long phrase to its acronym
input validation
string transformation
strings
easy
Armstrong Numbers
Determine if a number is an Armstrong number
integers
math
easy
Pangram
Determine if a sentence is a pangram.
string transformation
strings
easy
Bob
Bob is a lackadaisical teenager. In conversation, his responses are very limited.
control flow conditionals
strings
easy
Scrabble Score
Given a word, compute the Scrabble score for that word.
games
integers
easy
Grains
Calculate the number of grains of wheat on a chessboard given that the number on each square doubles.
control flow conditionals
input validation
integers
math
easy
Reverse String
Reverse a string
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 conditionals
control flow loops
math
easy
Leap
Given a year, report if it is a leap year.
boolean logic
control flow conditionals
input validation
easy
RNA Transcription
Given a DNA strand, return its RNA Complement Transcription.
associative arrays
control flow loops
error handling
easy
Anagram
Given a word and a list of possible anagrams, select the correct sublist.
control flow conditionals
control flow loops
string transformation
strings
easy
Collatz Conjecture
Calculate the number of steps to reach 1 using the Collatz conjecture
control flow conditionals
input validation
integers
math
easy
Nucleotide Count
Given a DNA string, compute how many times each nucleotide occurs in the string.
control flow loops
error handling
string comparison
easy
Phone Number
Clean up user-entered phone numbers so that they can be sent SMS messages.
control flow conditionals
error handling
string comparison
string transformation
easy
Triangle
Determine if a triangle is equilateral, isosceles, or scalene.
boolean logic
error handling
input validation
number comparison
easy
Word Count
Given a phrase, count the occurrences of each word in that phrase.
control flow loops
string comparison
strings
medium
Gigasecond
Given a moment, determine the moment that would be after a gigasecond has passed.
dates
medium
Luhn
Given a number determine whether or not it is valid per the Luhn formula.
algorithms
control flow conditionals
integers
medium
Atbash Cipher
Create an implementation of the atbash cipher, an ancient encryption system created in the Middle East.
cryptography
pattern matching
strings
medium
Roman Numerals
Write a function to convert from normal numbers to Roman Numerals.
integers
logic
loops
strings
medium
Affine Cipher
Create an implementation of the Affine cipher, an ancient encryption algorithm from the Middle East.
cryptography
math
strings
easy
Isogram
Determine if a word or phrase is an isogram.
strings
regexp
medium
Diamond
Given a letter, print a diamond starting with 'A' with the supplied letter at the widest point.
loops
strings
string transformation
medium
ISBN Verifier
Check if a given string is a valid ISBN-10 number.
algorithms
integers
string transformation
medium
All Your Base
Convert a number, represented as a sequence of digits in one base, to any other base.
integers
math
transforming
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
arrays
easy
Beer Song
Produce the lyrics to that beloved classic, that field-trip favorite: 99 Bottles of Beer on the Wall.
text formatting
control flow loops
medium
Food Chain
Generate the lyrics of the song 'I Know an Old Lady Who Swallowed a Fly'
text formatting
control flow loops
medium
Forth
Implement an evaluator for a very simple subset of Forth
arrays
control flow conditionals
error handling
input validation
string comparison
easy
Resistor Color Duo
Convert color codes, as used on resistors, to a numeric value.
arrays
control flow conditionals
easy
Resistor Color Trio
Convert color codes, as used on resistors, to a human-readable label.
arrays
control flow conditionals
math
medium
Binary Search
Implement a binary search algorithm.
arrays
math
medium
Say
Given a number from 0 to 999,999,999,999, spell out that number in English.
recursion
text formatting
easy
Space Age
Given an age in seconds, calculate how old someone is in terms of a given planet's solar years.
math
easy
Matching Brackets
Make sure the brackets and braces all match.
control flow loops
strings
easy
House
Output the nursery rhyme 'This is the House that Jack Built'.
arrays
control flow conditionals
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.
text formatting
control flow loops
easy
Twelve Days
Output the lyrics to 'The Twelve Days of Christmas'
text formatting
control flow loops
hard
Change
Correctly determine change to be given using the least number of coins
arrays
algorithms
logic
medium
Grep
Search a file for lines matching a regular expression pattern. Return the line number and contents of each matching line.
conditionals
parsing
regular expressions
medium
Diffie Hellman
Diffie-Hellman key exchange.
math
randomness
hard
Two Bucket
Given two buckets of different size, demonstrate how to measure an exact number of liters.
associative arrays
control flow conditionals
medium
Pig Latin
Implement a program that translates from English to Pig Latin
regular expressions
conditionals
easy
Prime Factors
Compute the prime factors of a given natural number.
math
control flow conditionals
control flow loops
medium
Run Length Encoding
Implement run-length encoding and decoding.
string transformation
easy
Secret Handshake
Given a decimal number, convert it to the appropriate sequence of events for a secret handshake.
bitwise operations
easy
Series
Given a string of digits, output all the contiguous substrings of length `n` in that string.
strings
loops
easy
Sieve
Use the Sieve of Eratosthenes to find all the primes from 2 up to a given number.
arrays
control flow conditionals
easy
Rotational Cipher
Create an implementation of the rotational cipher, also sometimes called the Caesar cipher.
string transformation
associative arrays
easy
Largest Series Product
Given a string of digits, calculate the largest product for a contiguous substring of digits of length n.
math
control flow loops
medium
Yacht
Score a single throw of dice in the game Yacht
math
conditionals
medium
Rational Numbers
Implement rational numbers.
math
strings
easy
Perfect Numbers
Determine if a number is perfect, abundant, or deficient based on Nicomachus' (60 - 120 CE) classification scheme for positive integers.
math
conditionals
easy
Protein Translation
Translate RNA sequences into proteins.
associative arrays
control flow loops
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
control flow loops
medium
Pascal's Triangle
Compute Pascal's triangle up to a given number of rows.
math
text formatting
arrays
medium
Bowling
Score a bowling game
error handling
conditionals
variables
medium
Kindergarten Garden
Given a diagram, determine which plants each child in the kindergarten class is responsible for.
strings
arrays
parsing
medium
Palindrome Products
Detect palindrome products in a given range.
math
loops
conditionals
medium
Nth Prime
Given a number n, determine what the nth prime is.
math
conditionals
loops
medium
Wordy
Parse and evaluate simple math word problems returning the answer as an integer.
parsing
strings
control flow loops
medium
Simple Cipher
Implement a simple shift cipher like Caesar and a more secure substitution cipher
strings
parsing
math
medium
Variable Length Quantity
Implement variable length quantity encoding and decoding.
integers
base conversion
bitwise operations
medium
Pythagorean Triplet
There exists exactly one Pythagorean triplet for which a + b + c = 1000. Find the product a * b * c.
control flow conditionals
control flow loops
math
medium
Markdown
Refactor a Markdown parser
control flow conditionals
control flow loops
strings
text formatting
medium
OCR Numbers
Given a 3 x 4 grid of pipes, underscores, and spaces, determine which number is represented, or whether it is garbled.
input validation
string transformation
medium
Transpose
Take input text and output it transposed.
string transformation
medium
Robot Simulator
Write a robot simulator.
control flow conditionals
control flow loops
input validation
medium
Tournament
Tally the results of a small football competition.
arrays
sorting
text formatting
medium
Spiral Matrix
Given the size, return a square matrix of numbers in spiral order.
arrays
control flow loops
text formatting
easy
Clock
Implement a clock that handles times without dates.
math
text formatting
easy
Sublist
Write a function to determine if a list is a sublist of another list.
equality
strings
transforming
medium
Meetup
Calculate the date of meetups.
control flow conditionals
external commands
easy
D&D Character
Randomly generate Dungeons & Dragons characters
math
randomness
hard
Knapsack
Given a knapsack that can only carry a certain weight, determine which items to put in the knapsack in order to maximize their combined value.
algorithms
arrays
control flow loops
easy
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 conditionals
error handling
input validation
hard
Poker
Pick the best hand(s) from a list of poker hands.
arrays
control flow conditionals
integers
sorting
strings
hard
Rail Fence Cipher
Implement encoding and decoding for the rail fence cipher.
control flow conditionals
control flow loops
cryptography
input validation
transformation
medium
Crypto Square
Implement the classic method for composing secret messages called a square code.
arrays
cryptography
math
transformation
hard
Rectangles
Count the rectangles in an ASCII diagram.
control flow conditionals
control flow loops
strings
easy
Darts
Write a function that returns the earned points in a single toss of a Darts game
control flow conditionals
math
medium
Satellite
Rebuild binary trees from pre-order and in-order traversals.
algorithms
arrays
input validation
parsing
recursion
strings
transforming
easy
Square Root
Given a natural radicand, return its square root.
algorithms
math