🎉 Exercism Research is now launched. Help Exercism, help science and have some fun at
research.exercism.io
🎉
Sign up
Log in
Home
Language tracks
Lua track
Exercises
Exercises on the Lua track
Join the Lua Track
82 exercises to help you master Lua
easy
Hello World
The classical introductory exercise. Just say "Hello, World!"
control flow if statements
optional values
text formatting
easy
Hamming
Calculate the Hamming difference between two DNA strands.
control flow loops
strings
easy
Resistor Color Trio
Convert color codes, as used on resistors, to a human-readable label.
hash tables
easy
House
Output the nursery rhyme 'This is the House that Jack Built'.
control flow loops
strings
text formatting
easy
Raindrops
Convert a number to a string, the content of which depends on the number's factors.
control flow if else statements
strings
easy
Bob
Bob is a lackadaisical teenager. In conversation, his responses are very limited.
control flow if else statements
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.
math
medium
Variable Length Quantity
Implement variable length quantity encoding and decoding.
arrays
bitwise operations
control flow if else statements
control flow loops
medium
Anagram
Given a word and a list of possible anagrams, select the correct sublist.
algorithms
control flow if else statements
control flow loops
strings
medium
Octal
Convert a octal number, represented as a string (e.g. '1735263'), to its decimal equivalent using first principles (i.e. no, you may not use built-in or external libraries to accomplish the conversion).
bitwise operations
control flow if else statements
control flow loops
strings
math
medium
Binary Search
Implement a binary search algorithm.
algorithms
arrays
control flow if else statements
control flow loops
searching
medium
Matching Brackets
Make sure the brackets and braces all match.
algorithms
control flow if else statements
control flow loops
stacks
strings
medium
Flatten Array
Take a nested list and return a single list with all values except nil/null
algorithms
arrays
control flow if else statements
control flow loops
recursion
easy
Word Count
Given a phrase, count the occurrences of each word in that phrase.
control flow loops
strings
easy
Pangram
Determine if a sentence is a pangram.
control flow if else statements
control flow loops
strings
easy
Matrix
Given a string representing a matrix of numbers, return the rows and columns of that matrix.
arrays
control flow loops
matrices
easy
Beer Song
Produce the lyrics to that beloved classic, that field-trip favorite: 99 Bottles of Beer on the Wall.
control flow if else statements
control flow loops
strings
text formatting
easy
Isogram
Determine if a word or phrase is an isogram.
control flow if else statements
control flow loops
strings
easy
Perfect Numbers
Determine if a number is perfect, abundant, or deficient based on Nicomachus' (60 - 120 CE) classification scheme for positive integers.
control flow if else statements
control flow loops
math
easy
ETL
We are going to do the `Transform` step of an Extract-Transform-Load.
control flow loops
transforming
easy
Nucleotide Count
Given a DNA string, compute how many times each nucleotide occurs in the string.
control flow loops
exception handling
strings
easy
Food Chain
Generate the lyrics of the song 'I Know an Old Lady Who Swallowed a Fly'
control flow if else statements
control flow loops
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.
control flow if else statements
control flow loops
math
easy
RNA Transcription
Given a DNA strand, return its RNA Complement Transcription.
control flow loops
strings
transforming
easy
Phone Number
Clean up user-entered phone numbers so that they can be sent SMS messages.
control flow if else statements
strings
text formatting
easy
Bank Account
Simulate a bank account supporting opening/closing, withdraws, and deposits of money. Watch out for concurrent transactions!
classes
control flow if else statements
easy
Protein Translation
Translate RNA sequences into proteins.
control flow if else statements
control flow loops
exception handling
strings
medium
Grade School
Given students' names along with the grade that they are in, create a roster for the school
classes
control flow if else statements
medium
Nth Prime
Given a number n, determine what the nth prime is.
control flow if else statements
control flow loops
exception handling
math
medium
Diamond
Given a letter, print a diamond starting with 'A' with the supplied letter at the widest point.
algorithms
control flow loops
strings
text formatting
medium
Run Length Encoding
Implement run-length encoding and decoding.
algorithms
control flow if else statements
control flow loops
strings
text formatting
medium
Sublist
Write a function to determine if a list is a sublist of another list.
arrays
control flow if else statements
control flow loops
medium
Robot Name
Manage robot factory settings.
randomness
strings
text formatting
easy
Robot Simulator
Write a robot simulator.
classes
exception handling
strings
easy
Pythagorean Triplet
There exists exactly one Pythagorean triplet for which a + b + c = 1000. Find the product a * b * c.
control flow if else statements
control flow loops
math
easy
Leap
Given a year, report if it is a leap year.
control flow if else statements
logic
easy
Space Age
Given an age in seconds, calculate how old someone is in terms of a given planet's solar years.
classes
medium
Pascal's Triangle
Compute Pascal's triangle up to a given number of rows.
control flow loops
math
medium
Sieve
Use the Sieve of Eratosthenes to find all the primes from 2 up to a given number.
control flow if else statements
control flow loops
math
easy
Grains
Calculate the number of grains of wheat on a chessboard given that the number on each square doubles.
control flow loops
medium
Kindergarten Garden
Given a diagram, determine which plants each child in the kindergarten class is responsible for.
control flow if else statements
control flow loops
strings
medium
Custom Set
Create a custom set type.
classes
control flow if else statements
control flow loops
sets
easy
Gigasecond
Given a moment, determine the moment that would be after a gigasecond has passed.
time
medium
Word Search
Create a program to solve a word search puzzle.
control flow if else statements
control flow loops
strings
medium
Luhn
Given a number determine whether or not it is valid per the Luhn formula.
control flow if else statements
control flow loops
strings
easy
Triangle
Determine if a triangle is equilateral, isosceles, or scalene.
control flow if else statements
exception handling
easy
Clock
Implement a clock that handles times without dates.
classes
medium
Series
Given a string of digits, output all the contiguous substrings of length `n` in that string.
arrays
control flow loops
coroutines
medium
Linked List
Implement a doubly linked list
classes
control flow if else statements
control flow loops
medium
OCR Numbers
Given a 3 x 4 grid of pipes, underscores, and spaces, determine which number is represented, or whether it is garbled.
control flow loops
strings
medium
Pig Latin
Implement a program that translates from English to Pig Latin
control flow if else statements
control flow loops
strings
text formatting
medium
Minesweeper
Add the numbers to a minesweeper board
arrays
control flow if else statements
control flow loops
exception handling
strings
medium
Crypto Square
Implement the classic method for composing secret messages called a square code.
control flow loops
strings
text formatting
medium
List Ops
Implement basic list operations
arrays
control flow loops
filtering
medium
Meetup
Calculate the date of meetups.
control flow if statements
control flow loops
time
easy
Atbash Cipher
Create an implementation of the atbash cipher, an ancient encryption system created in the Middle East.
control flow loops
strings
text formatting
easy
Scrabble Score
Given a word, compute the Scrabble score for that word.
control flow loops
strings
medium
Largest Series Product
Given a string of digits, calculate the largest product for a contiguous substring of digits of length n.
control flow loops
exception handling
math
medium
Rail Fence Cipher
Implement encoding and decoding for the rail fence cipher.
control flow if else statements
control flow loops
strings
text formatting
medium
Roman Numerals
Write a function to convert from normal numbers to Roman Numerals.
control flow loops
strings
text formatting
medium
Transpose
Take input text and output it transposed.
algorithms
control flow loops
strings
medium
Tournament
Tally the results of a small football competition.
arrays
control flow loops
strings
text formatting
text parsing
medium
Circular Buffer
A data structure that uses a single, fixed-size buffer as if it were connected end-to-end.
classes
control flow if else statements
exception handling
medium
Binary Search Tree
Insert and search for numbers in a binary tree.
algorithms
coroutines
exception handling
recursion
searching
trees
medium
Bowling
Score a bowling game
algorithms
control flow if else statements
exception handling
easy
Binary
Convert a binary number, represented as a string (e.g. '101010'), to its decimal equivalent using first principles
bitwise operations
control flow if else statements
control flow loops
strings
math
hard
Alphametics
Write a function to solve alphametics puzzles.
algorithms
control flow if else statements
control flow loops
performance
strings
medium
Prime Factors
Compute the prime factors of a given natural number.
control flow if else statements
control flow loops
math
medium
Acronym
Convert a long phrase to its acronym
control flow loops
strings
medium
All Your Base
Convert a number, represented as a sequence of digits in one base, to any other base.
arrays
control flow loops
math
hard
Rectangles
Count the rectangles in an ASCII diagram.
algorithms
control flow if else statements
control flow loops
performance
strings
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 operations
control flow if else statements
control flow loops
medium
Say
Given a number from 0 to 999,999,999,999, spell out that number in English.
control flow loops
strings
text formatting
hard
POV
Reparent a graph on a selected node
algorithms
control flow if else statements
control flow loops
exception handling
graphs
medium
Change
Correctly determine change to be given using the least number of coins
control flow if else statements
control flow loops
easy
Secret Handshake
Given a decimal number, convert it to the appropriate sequence of events for a secret handshake.
arrays
bitwise operations
control flow if else statements
hard
React
Implement a basic reactive system.
control flow if else statements
control flow loops
functions
graphs
easy
Collatz Conjecture
Calculate the number of steps to reach 1 using the Collatz conjecture
control flow if else statements
control flow loops
math
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.
misc
easy
ISBN Verifier
Check if a given string is a valid ISBN-10 number.
control flow loops
strings
easy
Reverse String
Reverse a string
arrays
strings
medium
Rational Numbers
Implement rational numbers.
math
structs