Sign up
Log in
Home
Language tracks
Pharo track
Exercises
Exercises on the Pharo track
Join the Pharo Track
42 exercises to help you master Pharo
easy
Hello World
The classical introductory exercise. Just say "Hello, World!"
introduction
strings
easy
Two Fer
Create a sentence of the form "One for X, one for me."
strings
text formatting
refactoring
easy
Leap
Given a year, report if it is a leap year.
conditionals
logic
math
easy
Reverse String
Reverse a string
strings
iteration
easy
Isogram
Determine if a word or phrase is an isogram.
strings
iteration
easy
Grains
Calculate the number of grains of wheat on a chessboard given that the number on each square doubles.
math
recursion
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
medium
Matrix
Given a string representing a matrix of numbers, return the rows and columns of that matrix.
matrices
parsing
medium
Grade School
Given students' names along with the grade that they are in, create a roster for the school
sorting
filtering
lists
object oriented programming
medium
Forth
Implement an evaluator for a very simple subset of Forth
parsing
stacks
easy
Acronym
Convert a long phrase to its acronym
strings
iteration
parsing
easy
Anagram
Given a word and a list of possible anagrams, select the correct sublist.
strings
filtering
easy
Armstrong Numbers
Determine if a number is an Armstrong number
math
integers
easy
Atbash Cipher
Create an implementation of the atbash cipher, an ancient encryption system created in the Middle East.
algorithms
strings
transforming
cryptography
easy
Binary
Convert a binary number, represented as a string (e.g. '101010'), to its decimal equivalent using first principles
strings
iteration
math
medium
Bowling
Score a bowling game
conditionals
object oriented programming
algorithms
easy
Clock
Implement a clock that handles times without dates.
math
classes
structural equality
easy
Collatz Conjecture
Calculate the number of steps to reach 1 using the Collatz conjecture
recursion
control flow
math
easy
Darts
Write a function that returns the earned points in a single toss of a Darts game
conditionals
math
easy
Diamond
Given a letter, print a diamond starting with 'A' with the supplied letter at the widest point.
strings
algorithms
lists
text formatting
easy
Die
A small DSL for dice rolling
math
easy
ETL
We are going to do the `Transform` step of an Extract-Transform-Load.
maps
iteration
transforming
easy
Flatten Array
Take a nested list and return a single list with all values except nil/null
lists
iteration
recursion
transforming
easy
Hamming
Calculate the Hamming difference between two DNA strands.
equality
loops
strings
exception handling
easy
High Scores
Manage a player's High Score list
lists
sorting
filtering
easy
ISBN Verifier
Check if a given string is a valid ISBN-10 number.
characters
collections
validation
medium
Luhn
Given a number determine whether or not it is valid per the Luhn formula.
strings
math
algorithms
medium
Matching Brackets
Make sure the brackets and braces all match.
strings
parsing
stacks
medium
Minesweeper
Add the numbers to a minesweeper board
parsing
iteration
transforming
easy
Pangram
Determine if a sentence is a pangram.
strings
filtering
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.
strings
iteration
easy
Raindrops
Convert a number to a string, the contents of which depend on the number's factors.
strings
conditionals
logic
easy
Resistor Color Duo
Convert color codes, as used on resistors, to a numeric value.
arrays
strings
math
medium
Robot Simulator
Write a robot simulator.
iteration
tuples
object oriented programming
easy
Roman Numerals
Write a function to convert from normal numbers to Roman Numerals.
iteration
maps
transforming
easy
Secret Handshake
Given a decimal number, convert it to the appropriate sequence of events for a secret handshake.
arrays
bitwise operations
easy
Sieve
Use the Sieve of Eratosthenes to find all the primes from 2 up to a given number.
math
lists
loops
easy
Space Age
Given an age in seconds, calculate how old someone is in terms of a given planet's solar years.
dictionaries
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.
iteration
filtering
math
medium
Tournament
Tally the results of a small football competition.
sorting
filtering
iteration
parsing
transforming
object oriented programming
easy
Twelve Days
Output the lyrics to 'The Twelve Days of Christmas'
strings
iteration
text formatting
easy
Word Count
Given a phrase, count the occurrences of each word in that phrase.
strings
iteration
pattern recognition