ðŸŽ‰ Exercism Research is now launched. Help Exercism, help science and have some fun at
research.exercism.io
ðŸŽ‰
Sign up
Log in
Home
Language tracks
Tcl track
Exercises
Exercises on the Tcl track
Join the Tcl Track
119 exercises to help you master Tcl
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."
arguments
strings
easy
Resistor Color
Convert a resistor band's color to its numeric representation
lists
namespaces
searching
easy
Error Handling
Implement various kinds of error handling and resource management
exception handling
easy
Acronym
Convert a long phrase to its acronym
strings
transforming
easy
High Scores
Manage a player's High Score list
classes
lists
easy
Matrix
Given a string representing a matrix of numbers, return the rows and columns of that matrix.
lists
transforming
easy
Series
Given a string of digits, output all the contiguous substrings of length `n` in that string.
loops
easy
Word Count
Given a phrase, count the occurrences of each word in that phrase.
regular expressions
strings
easy
Hamming
Calculate the Hamming difference between two DNA strands.
input validation
strings
easy
Raindrops
Convert a number to a string, the content of which depends on the number's factors.
conditionals
math
strings
easy
Isogram
Determine if a word or phrase is an isogram.
equality
strings
easy
Scrabble Score
Given a word, compute the Scrabble score for that word.
conditionals
loops
easy
Luhn
Given a number determine whether or not it is valid per the Luhn formula.
conditionals
integers
loops
easy
Clock
Implement a clock that handles times without dates.
classes
math
text formatting
medium
Tournament
Tally the results of a small football competition.
classes
conditionals
loops
maps
text formatting
transforming
easy
Twelve Days
Output the lyrics to 'The Twelve Days of Christmas'
loops
text formatting
easy
Bank Account
Simulate a bank account supporting opening/closing, withdraws, and deposits of money. Watch out for concurrent transactions!
classes
exception handling
threading
easy
Gigasecond
Given a moment, determine the moment that would be after a gigasecond has passed.
datetime
easy
RNA Transcription
Given a DNA strand, return its RNA Complement Transcription.
strings
easy
Leap
Given a year, report if it is a leap year.
booleans
easy
Resistor Color Duo
Convert color codes, as used on resistors, to a numeric value.
lists
namespaces
searching
easy
Resistor Color Trio
Convert color codes, as used on resistors, to a human-readable label.
lists
namespaces
searching
strings
medium
Yacht
Score a single throw of dice in the game Yacht
conditionals
equality
games
integers
sequences
easy
Pangram
Determine if a sentence is a pangram.
strings
easy
Space Age
Given an age in seconds, calculate how old someone is in terms of a given planet's solar years.
math
procedures
text formatting
medium
Rectangles
Count the rectangles in an ASCII diagram.
logic
parsing
pattern recognition
easy
Triangle
Determine if a triangle is equilateral, isosceles, or scalene.
math
easy
Anagram
Given a word and a list of possible anagrams, select the correct sublist.
filtering
sorting
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
easy
Sum Of Multiples
Given a number, find the sum of all the multiples of particular numbers up to but not including that number.
integers
loops
math
medium
Transpose
Take input text and output it transposed.
loops
strings
transforming
medium
Word Search
Create a program to solve a word search puzzle.
games
searching
strings
easy
Armstrong Numbers
Determine if a number is an Armstrong number
integers
loops
math
easy
Flatten Array
Take a nested list and return a single list with all values except nil/null
data structures
lists
recursion
strings
easy
Grains
Calculate the number of grains of wheat on a chessboard given that the number on each square doubles.
math
easy
Phone Number
Clean up user-entered phone numbers so that they can be sent SMS messages.
conditionals
input validation
regular expressions
strings
text formatting
medium
Saddle Points
Detect saddle points in a matrix.
integers
lists
loops
searching
easy
ETL
We are going to do the `Transform` step of an Extract-Transform-Load.
loops
maps
transforming
easy
Nucleotide Count
Given a DNA string, compute how many times each nucleotide occurs in the string.
loops
maps
parsing
strings
medium
Pythagorean Triplet
There exists exactly one Pythagorean triplet for which a + b + c = 1000. Find the product a * b * c.
algorithms
math
easy
Collatz Conjecture
Calculate the number of steps to reach 1 using the Collatz conjecture
conditionals
loops
math
easy
Darts
Write a function that returns the earned points in a single toss of a Darts game
conditionals
math
medium
Palindrome Products
Detect palindrome products in a given range.
algorithms
math
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.
loops
strings
easy
Sieve
Use the Sieve of Eratosthenes to find all the primes from 2 up to a given number.
algorithms
conditionals
lists
loops
math
easy
Sublist
Write a function to determine if a list is a sublist of another list.
lists
loops
searching
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.
callbacks
lists
loops
medium
Alphametics
Write a function to solve alphametics puzzles.
algorithms
transforming
medium
Binary Search
Implement a binary search algorithm.
algorithms
searching
easy
Bob
Bob is a lackadaisical teenager. In conversation, his responses are very limited.
conditionals
strings
easy
Matching Brackets
Make sure the brackets and braces all match.
parsing
stacks
strings
medium
Nth Prime
Given a number n, determine what the nth prime is.
algorithms
conditionals
loops
math
easy
Perfect Numbers
Determine if a number is perfect, abundant, or deficient based on Nicomachus' (60 - 120 CE) classification scheme for positive integers.
algorithms
integers
math
easy
Square Root
Given a natural radicand, return its square root.
algorithms
integers
math
easy
Strain
Implement the `keep` and `discard` operation on collections. Given a collection and a predicate on the collection's elements, `keep` returns a new collection containing those elements where the predicate is true, while `discard` returns a new collection containing those elements where the predicate is false.
conditionals
filtering
loops
medium
Two Bucket
Given two buckets of different size, demonstrate how to measure an exact number of liters.
algorithms
conditionals
searching
easy
All Your Base
Convert a number, represented as a sequence of digits in one base, to any other base.
integers
math
transforming
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
enumeration
medium
Minesweeper
Add the numbers to a minesweeper board
games
lists
loops
transforming
medium
Rail Fence Cipher
Implement encoding and decoding for the rail fence cipher.
cryptography
loops
strings
text formatting
transforming
medium
Robot Simulator
Write a robot simulator.
classes
medium
Run Length Encoding
Implement run-length encoding and decoding.
parsing
strings
transforming
medium
Scale Generator
Generate musical scales, given a starting note and a set of intervals.
lists
strings
easy
Beer Song
Produce the lyrics to that beloved classic, that field-trip favorite: 99 Bottles of Beer on the Wall.
loops
strings
text formatting
medium
Dominoes
Make a chain of dominoes.
lists
recursion
searching
medium
Grade School
Given students' names along with the grade that they are in, create a roster for the school
lists
sorting
medium
List Ops
Implement basic list operations
algorithms
lists
procedures
variables
easy
Pig Latin
Implement a program that translates from English to Pig Latin
conditionals
regular expressions
strings
transforming
easy
Protein Translation
Translate RNA sequences into proteins.
filtering
maps
sequences
medium
Secret Handshake
Given a decimal number, convert it to the appropriate sequence of events for a secret handshake.
bitwise operations
integers
lists
medium
Wordy
Parse and evaluate simple math word problems returning the answer as an integer.
conditionals
math
parsing
strings
easy
Atbash Cipher
Create an implementation of the atbash cipher, an ancient encryption system created in the Middle East.
cryptography
loops
maps
strings
transforming
medium
Binary Search Tree
Insert and search for numbers in a binary tree.
algorithms
classes
recursion
sorting
medium
Change
Correctly determine change to be given using the least number of coins
algorithms
integers
loops
math
medium
Circular Buffer
A data structure that uses a single, fixed-size buffer as if it were connected end-to-end.
conditionals
lists
medium
Crypto Square
Implement the classic method for composing secret messages called a square code.
cryptography
loops
strings
text formatting
transforming
easy
Robot Name
Manage robot factory settings.
classes
randomness
medium
Satellite
Rebuild binary trees from pre-order and in-order traversals.
algorithms
maps
recursion
transforming
easy
Simple Cipher
Implement a simple shift cipher like Caesar and a more secure substitution cipher
algorithms
cryptography
strings
medium
Simple Linked List
Write a simple linked list implementation that uses Elements and a List
classes
loops
easy
Affine Cipher
Create an implementation of the Affine cipher, an ancient encryption algorithm from the Middle East.
cryptography
math
strings
medium
Custom Set
Create a custom set type.
filtering
sets
easy
House
Output the nursery rhyme 'This is the House that Jack Built'.
loops
strings
text formatting
easy
Kindergarten Garden
Given a diagram, determine which plants each child in the kindergarten class is responsible for.
lists
parsing
searching
strings
medium
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
lists
loops
easy
Largest Series Product
Given a string of digits, calculate the largest product for a contiguous substring of digits of length n.
loops
math
medium
Linked List
Implement a doubly linked list
data structures
medium
Poker
Pick the best hand(s) from a list of poker hands.
equality
games
parsing
sequences
easy
Prime Factors
Compute the prime factors of a given natural number.
algorithms
integers
math
easy
Roman Numerals
Write a function to convert from normal numbers to Roman Numerals.
integers
transforming
easy
Rotational Cipher
Create an implementation of the rotational cipher, also sometimes called the Caesar cipher.
cryptography
integers
strings
hard
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
integers
lists
recursion
medium
Connect
Compute the result for a game of Hex / Polygon
games
loops
searching
medium
Food Chain
Generate the lyrics of the song 'I Know an Old Lady Who Swallowed a Fly'
conditionals
loops
maps
strings
text formatting
medium
Pascal's Triangle
Compute Pascal's triangle up to a given number of rows.
algorithms
arrays
math
recursion
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.
booleans
games
input validation
logic
hard
React
Implement a basic reactive system.
algorithms
callbacks
classes
easy
Spiral Matrix
Given the size, return a square matrix of numbers in spiral order.
algorithms
loops
lists
medium
Bowling
Score a bowling game
algorithms
conditionals
games
easy
Complex Numbers
Implement complex numbers.
math
easy
Diamond
Given a letter, print a diamond starting with 'A' with the supplied letter at the widest point.
algorithms
loops
strings
text formatting
medium
Grep
Search a file for lines matching a regular expression pattern. Return the line number and contents of each matching line.
arguments
booleans
conditionals
files
filtering
parsing
regular expressions
strings
text formatting
easy
ISBN Verifier
Check if a given string is a valid ISBN-10 number.
integers
math
easy
Markdown
Refactor a Markdown parser
refactoring
text formatting
easy
Meetup
Calculate the date of meetups.
datetime
searching
medium
OCR Numbers
Given a 3 x 4 grid of pipes, underscores, and spaces, determine which number is represented, or whether it is garbled.
parsing
pattern recognition
strings
transforming
hard
POV
Reparent a graph on a selected node
recursion
searching
medium
Rest API
Implement a RESTful API for tracking IOUs.
parsing
hard
Say
Given a number from 0 to 999,999,999,999, spell out that number in English.
integers
strings
transforming
text formatting
medium
Zipper
Creating a zipper for a binary tree.
data structures
easy
Diffie Hellman
Diffie-Hellman key exchange.
math
easy
D&D Character
Randomly generate Dungeons & Dragons characters
integers
randomness
medium
DOT DSL
Write a Domain Specific Language similar to the Graphviz dot language
domain specific languages
parsing
transforming
medium
Forth
Implement an evaluator for a very simple subset of Forth
domain specific languages
parsing
stacks
transforming
hard
Go Counting
Count the scored points on a Go board.
algorithms
games
medium
Parallel Letter Frequency
Count the frequency of letters in texts using parallel computation.
threading
variables
medium
Rational Numbers
Implement rational numbers.
floating point numbers
math
easy
Variable Length Quantity
Implement variable length quantity encoding and decoding.
algorithms
math