Skip to content

Examples

Each example is a small exercise solved in Nomi, with a test file that holds every case the exercise defines. The editor opens on the solution, and the test file is the next tab. Running the example runs the tests and shows the report. Edit either file and the tests run again, so you can break a case and see how the failure reads, or try another way to write the solution.

Every example leans on Testing and Modules & Imports. The table lists the other chapters each solution uses, and the sidebar groups the examples by subject.

The exercises come from exercism/problem-specifications, MIT licence, Copyright (c) 2014, 2019, 2021 Exercism.

ExampleSubjectWhat it doesChapters
Acronym Strings & Text Build an acronym from the first letter of each word of a phrase, treating hyphens as word separators and ignoring other punctuation. Functions & Lambdas, Pipes, Scalars & Strings, Iteration & Loops
Affine Cipher Encoding & Ciphers Encode and decode text with the affine cipher, which maps letter number `i` to `(a * i + b) mod 26`. Bindings & Expressions, Functions & Lambdas, Pipes, Scalars & Strings, Collections, Iteration & Loops, Structs, Enums, Distinct Types, Pattern Matching
All Your Base Numbers & Math Convert a number written as digits in one base into its digits in another. Scalars & Strings, Structs, Enums, Distinct Types
Allergies Numbers & Math Decode an allergy score into the allergens it includes. Functions & Lambdas, Pipes, Scalars & Strings, Iteration & Loops, Structs, Enums, Distinct Types, Pattern Matching, Interfaces & Dispatch
Alphametics Collections & Algorithms Solve a letter-sum puzzle such as `SEND + MORE == MONEY`: give each letter a different digit so the sum is true, with no word of more than one letter starting with zero. Bindings & Expressions, Functions & Lambdas, Pipes, Scalars & Strings, Collections, Iteration & Loops, Structs, Enums, Distinct Types
Anagram Strings & Text Pick out the candidates that are anagrams of a word, ignoring case, where a word is not an anagram of itself. Functions & Lambdas, Pipes, Scalars & Strings, Iteration & Loops
Armstrong Numbers Numbers & Math Decide whether a number equals the sum of its digits, each raised to the power of the digit count. Bindings & Expressions, Functions & Lambdas, Pipes, Scalars & Strings, Iteration & Loops
Atbash Cipher Encoding & Ciphers Encode and decode text by swapping each letter with its mirror in the alphabet. Bindings & Expressions, Pipes, Scalars & Strings, Collections, Iteration & Loops
Baffling Birthdays Dates & Time Find whether two people in a group share a birthday, draw random groups of birthdates, and estimate how likely a shared birthday is by simulation. Bindings & Expressions, Functions & Lambdas, Pipes, Scalars & Strings, Collections, Iteration & Loops, Pattern Matching
Bank Account Games & Simulation A bank account that can be opened, closed, paid into and drawn from, by many tasks at once, without its balance going wrong. Bindings & Expressions, Functions & Lambdas, Pipes, Iteration & Loops, Structs, Enums, Distinct Types, Pattern Matching, Generics, Interfaces & Dispatch
Binary Search Collections & Algorithms Find a value's index in a sorted array by repeatedly halving the range it could be in. Bindings & Expressions, Pipes, Collections, Pattern Matching, Generics
Binary Search Tree Collections & Algorithms Insert values into a binary search tree, check the shape it builds, and read its values back in sorted order. Collections, Iteration & Loops, Structs, Enums, Distinct Types, Pattern Matching, Generics
Bob Strings & Text Answer a remark the way a lackadaisical teenager would, depending on whether it is a question, a shout, both, or silence. Bindings & Expressions, Pipes, Scalars & Strings, Pattern Matching
Book Store Collections & Algorithms Price a basket of books from a five-book series, where each group of different titles earns a discount that grows with the group, choosing the groups that cost least. Functions & Lambdas, Pipes, Scalars & Strings, Collections, Iteration & Loops, Pattern Matching
Bottle Song Strings & Text Recite the counting song "Ten Green Bottles", from a given number of bottles down, for a given number of verses. Bindings & Expressions, Functions & Lambdas, Pipes, Scalars & Strings, Collections, Iteration & Loops
Bowling Games & Simulation Score a game of ten-pin bowling roll by roll, refusing rolls the rules do not allow and a score before the game is over. Bindings & Expressions, Pipes, Scalars & Strings, Collections, Iteration & Loops, Structs, Enums, Distinct Types, Pattern Matching
Camicia Games & Simulation Play out a game of Camicia, a beggar-my-neighbour card game, from two starting decks, and report whether it finishes or loops, how many cards were played and how many tricks were taken. Bindings & Expressions, Functions & Lambdas, Pipes, Collections, Iteration & Loops, Structs, Enums, Distinct Types, Pattern Matching
Change Collections & Algorithms Find the fewest coins, from an unlimited supply of given values, that add up to an amount of change. Bindings & Expressions, Functions & Lambdas, Pipes, Collections, Iteration & Loops, Structs, Enums, Distinct Types, Pattern Matching
Circular Buffer Collections & Algorithms A fixed-capacity buffer that is read oldest first: writes fail when it is full, reads fail when it is empty, and an overwrite drops the oldest item to make room. Bindings & Expressions, Pipes, Collections, Iteration & Loops, Structs, Enums, Distinct Types, Pattern Matching, Generics
Clock Dates & Time A time of day without a date that wraps when minutes are added or taken away. Bindings & Expressions, Pipes, Scalars & Strings, Structs, Enums, Distinct Types, Interfaces & Dispatch
Collatz Conjecture Numbers & Math Count the Collatz steps that take a positive integer to 1. Bindings & Expressions, Functions & Lambdas, Pipes, Scalars & Strings, Iteration & Loops
Complex Numbers Numbers & Math Implement complex numbers: their parts, arithmetic, absolute value, conjugate and exponential, and arithmetic between a complex number and a real one. Scalars & Strings, Collections, Structs, Enums, Distinct Types, Interfaces & Dispatch
Connect Grids & Matrices Find the winner of a game of Hex: `X` wins by joining the left edge to the right, `O` by joining the top edge to the bottom. Bindings & Expressions, Functions & Lambdas, Pipes, Scalars & Strings, Collections, Iteration & Loops, Structs, Enums, Distinct Types, Pattern Matching
Crypto Square Encoding & Ciphers Encode a message by writing its letters and digits in the rows of a near-square rectangle and reading it down the columns. Bindings & Expressions, Functions & Lambdas, Pipes, Scalars & Strings, Iteration & Loops
Custom Set Collections & Algorithms Build a set type of your own: membership, subsets, disjointness, equality, adding, intersection, difference and union. Functions & Lambdas, Pipes, Scalars & Strings, Collections, Iteration & Loops, Structs, Enums, Distinct Types, Pattern Matching, Generics
Darts Games & Simulation Score a dart by how far from the centre of the target it lands. Pattern Matching
Diamond Strings & Text Draw a diamond of letters from `A` out to a given letter and back. Bindings & Expressions, Functions & Lambdas, Pipes, Scalars & Strings, Collections, Iteration & Loops
Difference of Squares Numbers & Math Find the difference between the square of the sum and the sum of the squares of the first N natural numbers. Functions & Lambdas, Pipes, Scalars & Strings, Collections, Iteration & Loops
D&D Character Games & Simulation Roll a Dungeons & Dragons character: six abilities, each the best three of four dice, and hitpoints from the constitution's modifier. Functions & Lambdas, Pipes, Scalars & Strings, Collections, Iteration & Loops, Structs, Enums, Distinct Types
Dominoes Collections & Algorithms Lay a set of domino stones in a ring, turning each as needed, so that touching halves match and the two free ends match each other. Bindings & Expressions, Functions & Lambdas, Pipes, Scalars & Strings, Collections, Iteration & Loops, Pattern Matching
DOT DSL Parsing & Validation Read a small part of Graphviz's DOT language into a graph of nodes, edges and attributes, refusing malformed graphs, edges and attributes. Bindings & Expressions, Functions & Lambdas, Pipes, Scalars & Strings, Collections, Iteration & Loops, Structs, Enums, Distinct Types, Pattern Matching, Generics, Interfaces & Dispatch
Eliud's Eggs Numbers & Math Count the 1 bits in the binary form of a number, without a built-in bit count. Functions & Lambdas, Pipes, Scalars & Strings, Iteration & Loops
Error Handling Parsing & Validation Report failure in the ways the language offers, and release a resource whichever way the work using it ends. Functions & Lambdas, Pipes, Scalars & Strings, Structs, Enums, Distinct Types, Pattern Matching
ETL Collections & Algorithms Turn a Scrabble score table keyed by score into one keyed by lower-case letter. Functions & Lambdas, Pipes, Scalars & Strings, Iteration & Loops
Flatten Array Collections & Algorithms Flatten an arbitrarily nested array of integers into one flat list, leaving out nulls. Pipes, Iteration & Loops, Structs, Enums, Distinct Types, Pattern Matching
Flower Field Grids & Matrices Write the count of adjacent flowers into each empty square of a garden. Bindings & Expressions, Functions & Lambdas, Pipes, Scalars & Strings, Collections, Iteration & Loops
Food Chain Strings & Text Recite the cumulative song about the old lady who swallowed a fly, where each verse swallows a bigger animal to catch the one before. Bindings & Expressions, Functions & Lambdas, Pipes, Scalars & Strings, Collections, Iteration & Loops, Structs, Enums, Distinct Types
Forth Parsing & Validation Evaluate a small subset of Forth: integer arithmetic, `DUP`, `DROP`, `SWAP` and `OVER`, and words the program defines with `: name ... ;`. Bindings & Expressions, Functions & Lambdas, Pipes, Scalars & Strings, Collections, Iteration & Loops, Structs, Enums, Distinct Types, Pattern Matching
Game of Life Grids & Matrices Compute the next generation of a Conway's Game of Life board. Bindings & Expressions, Functions & Lambdas, Pipes, Scalars & Strings, Collections, Iteration & Loops, Pattern Matching
Gigasecond Dates & Time Find the moment one gigasecond, a thousand million seconds, after a given moment. Bindings & Expressions
Go Counting Grids & Matrices Count the territory on a Go board: the empty points that only one player's stones enclose. Bindings & Expressions, Functions & Lambdas, Pipes, Collections, Iteration & Loops, Structs, Enums, Distinct Types, Pattern Matching
Grade School Collections & Algorithms Keep a school's roster: enroll each student in one grade, list the students in a grade, and list the whole school by grade and then by name. Bindings & Expressions, Functions & Lambdas, Pipes, Collections, Iteration & Loops, Structs, Enums, Distinct Types
Grains Numbers & Math Count the grains of wheat on a chessboard square, doubling from one grain on the first, and on the whole board. Bindings & Expressions, Pipes, Scalars & Strings, Collections, Iteration & Loops
Grep Strings & Text Search files for lines that contain a string, with grep's `-n`, `-l`, `-i`, `-v` and `-x` flags. Bindings & Expressions, Functions & Lambdas, Pipes, Scalars & Strings, Collections, Iteration & Loops, Structs, Enums, Distinct Types, Pattern Matching
Hamming Strings & Text Count the positions at which two DNA strands differ; strands of different lengths are an error. Bindings & Expressions, Functions & Lambdas, Pipes, Scalars & Strings, Iteration & Loops
Hello World Strings & Text Answer the greeting "Hello, World!".
High Scores Collections & Algorithms Read a player's list of game scores: all of them, the latest, the best, and the top three. Pipes, Iteration & Loops
House Strings & Text Recite "This is the House that Jack Built", where each verse embeds every phrase of the verse before. Bindings & Expressions, Pipes, Scalars & Strings, Collections, Iteration & Loops
Intergalactic Transmission Encoding & Ciphers Send a message seven bits to a byte, each byte ending in a parity bit that makes its count of ones even, and decode a transmission back, rejecting a byte whose parity is wrong. Bindings & Expressions, Functions & Lambdas, Pipes, Scalars & Strings, Collections, Iteration & Loops, Pattern Matching
ISBN Verifier Parsing & Validation Decide whether a string is a valid ISBN-10, with or without dashes. Functions & Lambdas, Pipes, Scalars & Strings, Iteration & Loops, Pattern Matching
Isogram Strings & Text Decide whether a word or phrase repeats no letter, ignoring case; spaces and hyphens may repeat. Pipes, Scalars & Strings, Collections, Iteration & Loops
Killer Sudoku Helper Numbers & Math List every way a killer sudoku cage can be filled: the sets of different digits 1 to 9, of the cage's size, that add up to its sum, leaving out digits already used. Functions & Lambdas, Pipes, Collections, Iteration & Loops
Kindergarten Garden Grids & Matrices Read a diagram of two rows of plant cups and say which four plants each child of the class looks after. Functions & Lambdas, Pipes, Scalars & Strings, Iteration & Loops, Structs, Enums, Distinct Types, Pattern Matching, Interfaces & Dispatch
Knapsack Collections & Algorithms Choose items, each at most once, to carry the greatest total value without going over a weight limit. Bindings & Expressions, Functions & Lambdas, Pipes, Scalars & Strings, Collections, Iteration & Loops, Structs, Enums, Distinct Types
Largest Series Product Numbers & Math Find the largest product of a given number of adjacent digits in a string of digits. Bindings & Expressions, Pipes, Scalars & Strings, Iteration & Loops, Structs, Enums, Distinct Types, Pattern Matching
Leap Dates & Time Decide whether a year is a leap year in the Gregorian calendar.
Ledger Strings & Text Print a ledger of dated entries as a fixed-width table, with dates and amounts in American or Dutch style. Bindings & Expressions, Functions & Lambdas, Pipes, Scalars & Strings, Collections, Iteration & Loops, Structs, Enums, Distinct Types, Pattern Matching
Lens Person Collections & Algorithms Read and change fields deep inside a nested record of a person, their birth and their address, without writing out every level by hand. Collections, Structs, Enums, Distinct Types
Line Up Strings & Text Write the ticket message a deli gives its customers, with the customer's place in line as an English ordinal: 1st, 2nd, 3rd, 4th, 11th, 21st. Scalars & Strings, Pattern Matching
Linked List Collections & Algorithms Build a list that is read and written at both ends, push and pop at the back, unshift and shift at the front, that counts its values and deletes the first one equal to a given value. Pipes, Scalars & Strings, Collections, Iteration & Loops, Structs, Enums, Distinct Types, Pattern Matching, Generics, Interfaces & Dispatch
List Ops Collections & Algorithms Implement append, concatenate, filter, length, map, both folds and reverse without the built-in list functions. Bindings & Expressions, Functions & Lambdas, Pipes, Collections, Pattern Matching, Generics
Luhn Parsing & Validation Decide whether a string of digits and spaces passes the Luhn checksum. Bindings & Expressions, Functions & Lambdas, Pipes, Scalars & Strings, Iteration & Loops, Pattern Matching
Markdown Parsing & Validation Turn a small part of Markdown into HTML: headings, unordered lists, paragraphs, and bold and italic text. Bindings & Expressions, Functions & Lambdas, Pipes, Scalars & Strings, Collections, Iteration & Loops, Structs, Enums, Distinct Types, Pattern Matching
Matching Brackets Parsing & Validation Check that every bracket, brace and parenthesis in a string is closed by its own kind, in order. Scalars & Strings, Collections, Pattern Matching
Matrix Grids & Matrices Read a matrix of numbers from text, one row per line, and answer any row or column. Functions & Lambdas, Pipes, Scalars & Strings, Collections, Iteration & Loops, Structs, Enums, Distinct Types, Pattern Matching
Meetup Dates & Time Find the date of a monthly meetup described as "the first Monday", "the last Thursday" or "the teenth Saturday" of a month. Functions & Lambdas, Pipes, Collections, Iteration & Loops, Structs, Enums, Distinct Types, Pattern Matching
Micro Blog Strings & Text Truncate a post to its first five characters, where a character may be an emoji or any other Unicode. Scalars & Strings
Nth Prime Numbers & Math Find the nth prime number. Bindings & Expressions, Functions & Lambdas, Pipes, Scalars & Strings, Iteration & Loops
Nucleotide Count Strings & Text Count how often each of the four nucleotides occurs in a DNA strand, rejecting any other letter. Functions & Lambdas, Pipes, Collections, Iteration & Loops, Structs, Enums, Distinct Types, Pattern Matching, Interfaces & Dispatch
OCR Numbers Parsing & Validation Read the digits a scanner drew with pipes and underscores, three columns and four rows per digit, and join several lines of them with commas. Bindings & Expressions, Functions & Lambdas, Pipes, Scalars & Strings, Collections, Iteration & Loops, Structs, Enums, Distinct Types, Pattern Matching
PaaS I/O Collections & Algorithms Wrap a stream so that it reports what passed through it: the bytes read or written, and the number of read or write operations. Functions & Lambdas, Pipes, Collections, Structs, Enums, Distinct Types, Pattern Matching
Palindrome Products Numbers & Math Find the smallest and the largest palindrome that is a product of two numbers in a range, with every pair of factors that makes it. Bindings & Expressions, Functions & Lambdas, Pipes, Scalars & Strings, Collections, Iteration & Loops, Structs, Enums, Distinct Types, Pattern Matching
Pangram Strings & Text Decide whether a sentence uses every letter of the English alphabet at least once, ignoring case. Functions & Lambdas, Pipes, Scalars & Strings, Collections, Iteration & Loops
Parallel Letter Frequency Strings & Text Count how often each letter appears in a list of texts, counting the texts in parallel. Bindings & Expressions, Functions & Lambdas, Pipes, Scalars & Strings, Collections, Iteration & Loops
Pascal's Triangle Numbers & Math Build the first rows of Pascal's triangle, where each value is the sum of the two above it. Functions & Lambdas, Pipes, Collections, Iteration & Loops
Perfect Numbers Numbers & Math Classify a positive integer as perfect, abundant or deficient by comparing it with the sum of its other divisors. Bindings & Expressions, Functions & Lambdas, Pipes, Scalars & Strings, Collections, Iteration & Loops, Structs, Enums, Distinct Types, Pattern Matching
Phone Number Parsing & Validation Clean a NANP phone number down to its ten digits, or say why it is not one. Bindings & Expressions, Functions & Lambdas, Pipes, Scalars & Strings, Collections, Iteration & Loops, Structs, Enums, Distinct Types, Pattern Matching
Piecing It Together Numbers & Math Fill in the details of a jigsaw puzzle from some of them (its pieces, border and inside pieces, rows, columns, aspect ratio and format), or say that the details given are too few or contradict each other. Bindings & Expressions, Functions & Lambdas, Pipes, Scalars & Strings, Collections, Iteration & Loops, Structs, Enums, Distinct Types, Pattern Matching, Generics
Pig Latin Strings & Text Translate English words to Pig Latin by moving each word's leading consonants to its end and adding "ay". Bindings & Expressions, Pipes, Scalars & Strings, Collections, Iteration & Loops, Pattern Matching
Poker Games & Simulation Pick the best hand, or the hands that tie for best, from a list of five-card poker hands. Bindings & Expressions, Functions & Lambdas, Pipes, Scalars & Strings, Collections, Iteration & Loops, Structs, Enums, Distinct Types, Pattern Matching, Interfaces & Dispatch
POV Collections & Algorithms Reparent a tree on one of its nodes, so it is seen from that node's point of view, and find the path between two nodes. Bindings & Expressions, Functions & Lambdas, Pipes, Collections, Iteration & Loops, Structs, Enums, Distinct Types
Prime Factors Numbers & Math Break a natural number into its prime factors, smallest first. Scalars & Strings, Collections, Pattern Matching
Prism Games & Simulation Follow a laser beam through an array of prisms, each of which turns the beam by its own angle, and list the prisms it hits in order. Bindings & Expressions, Functions & Lambdas, Pipes, Scalars & Strings, Collections, Iteration & Loops, Structs, Enums, Distinct Types, Pattern Matching
Protein Translation Encoding & Ciphers Translate an RNA strand, three nucleotides at a time, into the amino acids of its protein, stopping at the first STOP codon. Functions & Lambdas, Pipes, Scalars & Strings, Iteration & Loops, Structs, Enums, Distinct Types, Pattern Matching
Proverb Strings & Text Build the "For want of a nail" proverb from any chain of things, one line per link and a closing line for the first. Functions & Lambdas, Pipes, Scalars & Strings, Collections, Iteration & Loops
Pythagorean Triplet Numbers & Math Find every Pythagorean triplet `a < b < c` with `a² + b² = c²` whose sides sum to a given number. Bindings & Expressions, Functions & Lambdas, Pipes, Scalars & Strings, Collections, Iteration & Loops, Pattern Matching
Queen Attack Games & Simulation Place two queens on a chessboard and say whether they can attack each other. Scalars & Strings, Structs, Enums, Distinct Types, Pattern Matching
Rail Fence Cipher Encoding & Ciphers Encode a message by writing it in a zig-zag across a number of rails and reading the rails off in turn, and decode it back. Pipes, Scalars & Strings, Collections, Iteration & Loops
Raindrops Numbers & Math Turn a number into raindrop sounds: "Pling" for a factor of 3, "Plang" for 5, "Plong" for 7, or the number itself when it has none of them. Bindings & Expressions, Functions & Lambdas, Pipes, Scalars & Strings, Iteration & Loops
Rational Numbers Numbers & Math Implement rational numbers: the four arithmetic operations, absolute value, integer powers, a real number raised to a rational power, and reduction to lowest terms. Bindings & Expressions, Functions & Lambdas, Pipes, Scalars & Strings, Collections, Structs, Enums, Distinct Types, Pattern Matching, Interfaces & Dispatch
React Collections & Algorithms Build a small reactive system: input cells hold values that can be set, compute cells hold functions of other cells that stay up to date, and callbacks report when a compute cell's value changes. Bindings & Expressions, Functions & Lambdas, Pipes, Scalars & Strings, Collections, Iteration & Loops, Structs, Enums, Distinct Types
Rectangles Grids & Matrices Count the rectangles in an ASCII diagram: `+` corners joined by `-` sides along the rows and `|` sides down the columns, where a `+` may also stand in a side. Functions & Lambdas, Pipes, Scalars & Strings, Collections, Iteration & Loops, Pattern Matching
Relative Distance Collections & Algorithms Find the degree of separation between two people in a family tree, where a step joins a parent and a child or two siblings. Bindings & Expressions, Functions & Lambdas, Pipes, Collections, Iteration & Loops, Pattern Matching
Resistor Color Encoding & Ciphers Look up the digit a resistor band's color stands for, and list the colors in value order. Structs, Enums, Distinct Types, Pattern Matching, Interfaces & Dispatch
Resistor Color Duo Encoding & Ciphers Read a resistor's first two color bands as a two-digit number, ignoring any band after them. Collections, Structs, Enums, Distinct Types, Pattern Matching
Resistor Color Tolerance Numbers & Math Read the label of a resistor with one, four or five color bands: its resistance in ohms, kiloohms or megaohms, and the tolerance its last band marks. Bindings & Expressions, Functions & Lambdas, Pipes, Scalars & Strings, Iteration & Loops, Structs, Enums, Distinct Types, Pattern Matching, Interfaces & Dispatch
Resistor Color Trio Encoding & Ciphers Read a resistor's first three color bands as a resistance, written in the largest metric unit that keeps the value whole. Bindings & Expressions, Functions & Lambdas, Pipes, Scalars & Strings, Collections, Iteration & Loops, Structs, Enums, Distinct Types, Pattern Matching
REST API Parsing & Validation Track IOUs between roommates behind a small JSON API: list users, add one, and record a loan, keeping each user's debts and balance. Bindings & Expressions, Functions & Lambdas, Pipes, Collections, Iteration & Loops, Structs, Enums, Distinct Types, Pattern Matching, Interfaces & Dispatch
Reverse String Strings & Text Reverse a string by its characters as a reader sees them, so combining marks stay on their letters. Scalars & Strings
RNA Transcription Encoding & Ciphers Turn a DNA strand into its RNA complement: G to C, C to G, T to A and A to U. Pipes, Scalars & Strings, Iteration & Loops, Pattern Matching
Robot Name Games & Simulation Give each robot off the factory floor a random name of two uppercase letters and three digits, give it a new one when it is reset, and never give two robots the same name. Bindings & Expressions, Functions & Lambdas, Pipes, Scalars & Strings, Collections, Iteration & Loops, Structs, Enums, Distinct Types
Robot Simulator Games & Simulation Move a robot around a grid by a string of turn and advance instructions. Collections, Iteration & Loops, Structs, Enums, Distinct Types, Pattern Matching
Roman Numerals Encoding & Ciphers Write a number from 1 to 3999 in Roman numerals. Bindings & Expressions, Functions & Lambdas, Scalars & Strings, Iteration & Loops
Rotational Cipher Encoding & Ciphers Shift every Latin letter of a text a number of places along the alphabet, keeping its case and everything else. Functions & Lambdas, Pipes, Scalars & Strings, Collections, Iteration & Loops, Pattern Matching
Run-Length Encoding Encoding & Ciphers Encode runs of repeated characters as a count and the character, and decode them back. Functions & Lambdas, Pipes, Scalars & Strings, Collections, Iteration & Loops, Pattern Matching
Saddle Points Grids & Matrices Find the cells of a grid that are the largest in their row and the smallest in their column. Functions & Lambdas, Pipes, Scalars & Strings, Collections, Iteration & Loops, Structs, Enums, Distinct Types, Pattern Matching
Satellite Collections & Algorithms Rebuild a binary tree from its pre-order and in-order traversals, rejecting traversals that describe no tree. Functions & Lambdas, Pipes, Scalars & Strings, Collections, Iteration & Loops, Structs, Enums, Distinct Types, Pattern Matching, Generics
Save the Cow Games & Simulation Play a word-guessing game: each guessed letter reveals every place it stands in the secret word, and ten failures lose the game. Bindings & Expressions, Functions & Lambdas, Pipes, Scalars & Strings, Collections, Iteration & Loops, Structs, Enums, Distinct Types, Pattern Matching, Interfaces & Dispatch
Say Numbers & Math Spell out a number from zero to 999,999,999,999 in English words. Bindings & Expressions, Functions & Lambdas, Pipes, Scalars & Strings, Collections, Iteration & Loops, Structs, Enums, Distinct Types, Pattern Matching
Scrabble Score Strings & Text Score a word by summing the Scrabble values of its letters. Pipes, Scalars & Strings, Iteration & Loops, Pattern Matching
Secret Handshake Numbers & Math Turn a number's lowest five bits into the actions of a secret handshake, reversed when the fifth bit is set. Bindings & Expressions, Functions & Lambdas, Pipes, Scalars & Strings, Iteration & Loops, Structs, Enums, Distinct Types, Pattern Matching, Interfaces & Dispatch
Series Strings & Text List every run of adjacent digits of a given length in a string of digits, in order. Pipes, Scalars & Strings, Iteration & Loops, Structs, Enums, Distinct Types, Pattern Matching
SGF Parsing Parsing & Validation Parse a Smart Game Format game tree into nodes of properties and their child trees, with SGF's escaping rules for text values. Bindings & Expressions, Pipes, Scalars & Strings, Collections, Iteration & Loops, Structs, Enums, Distinct Types, Pattern Matching
Sieve Numbers & Math List the primes up to a limit with the Sieve of Eratosthenes. Bindings & Expressions, Functions & Lambdas, Pipes, Collections, Iteration & Loops
Simple Cipher Encoding & Ciphers Encode and decode text with a Vigenère cipher, moving each letter along the alphabet by the matching letter of a repeating key, and make a random key when none is given. Bindings & Expressions, Functions & Lambdas, Pipes, Scalars & Strings, Collections, Iteration & Loops, Structs, Enums, Distinct Types
Simple Linked List Collections & Algorithms Build a singly linked list that is last in, first out: count it, push and pop values, peek at the head, list its values and reverse it. Scalars & Strings, Iteration & Loops, Structs, Enums, Distinct Types, Pattern Matching, Generics, Interfaces & Dispatch
Space Age Numbers & Math Given an age in seconds, say how old someone would be on each planet of the Solar System. Bindings & Expressions, Functions & Lambdas, Pipes, Scalars & Strings, Iteration & Loops, Structs, Enums, Distinct Types, Pattern Matching, Interfaces & Dispatch
Spiral Matrix Grids & Matrices Fill a square grid with 1 to n² in a clockwise spiral from the top left corner. Bindings & Expressions, Pipes, Collections, Iteration & Loops
Split-Second Stopwatch Dates & Time Build a stopwatch that starts, stops, laps and resets, keeping the current lap's time and every finished lap's, and refusing a command its state does not allow. Bindings & Expressions, Scalars & Strings, Collections, Iteration & Loops, Structs, Enums, Distinct Types, Pattern Matching, Interfaces & Dispatch
Square Root Numbers & Math Find the square root of a perfect square of a positive integer without a built-in square root function. Bindings & Expressions, Pipes
State of Tic-Tac-Toe Games & Simulation Decide whether a tic-tac-toe board is a win, a draw or a game still going, or explain why no game played by the rules could have left it. Bindings & Expressions, Functions & Lambdas, Pipes, Scalars & Strings, Collections, Iteration & Loops, Structs, Enums, Distinct Types, Pattern Matching, Interfaces & Dispatch
Strain Collections & Algorithms Implement `keep` and `discard`, which split a collection by a predicate, without the standard library's filter. Functions & Lambdas, Scalars & Strings, Collections, Pattern Matching, Generics
Sublist Collections & Algorithms Say whether one list equals another, sits inside it, contains it, or none of these. Functions & Lambdas, Pipes, Iteration & Loops, Structs, Enums, Distinct Types, Pattern Matching, Generics
Sum of Multiples Numbers & Math Sum the distinct multiples, below a limit, of any of a list of factors. Functions & Lambdas, Pipes, Collections, Iteration & Loops
Swift Scheduling Dates & Time Turn a delivery promise made at a meeting, such as "ASAP", "EOW", "11M" or "Q3", into the date and time the delivery is due. Bindings & Expressions, Functions & Lambdas, Pipes, Scalars & Strings, Collections, Iteration & Loops, Structs, Enums, Distinct Types, Pattern Matching
Tournament Collections & Algorithms Tally the results of a small football competition into a league table, ordered by points and then by name. Functions & Lambdas, Pipes, Scalars & Strings, Collections, Iteration & Loops, Structs, Enums, Distinct Types, Pattern Matching
Transpose Grids & Matrices Transpose lines of text, padding short lines on the left of a column with spaces and never on the right. Functions & Lambdas, Pipes, Scalars & Strings, Iteration & Loops
Tree Building Collections & Algorithms Rebuild a forum's tree of posts from unordered records of an id and a parent id, rejecting records that do not form a tree. Bindings & Expressions, Functions & Lambdas, Pipes, Scalars & Strings, Collections, Iteration & Loops, Structs, Enums, Distinct Types, Pattern Matching, Interfaces & Dispatch
Triangle Numbers & Math Classify a triangle by its three side lengths as equilateral, isosceles or scalene. Bindings & Expressions, Pipes, Scalars & Strings, Collections, Iteration & Loops, Structs, Enums, Distinct Types, Pattern Matching
Twelve Days Strings & Text Recite the verses of "The Twelve Days of Christmas", each adding a gift to the one before. Bindings & Expressions, Pipes, Scalars & Strings, Collections, Iteration & Loops
Two Bucket Games & Simulation Find the fewest actions that measure an exact number of liters with two buckets, starting by filling a given one, and never leaving the starting bucket empty with the other full. Bindings & Expressions, Functions & Lambdas, Pipes, Scalars & Strings, Collections, Iteration & Loops, Structs, Enums, Distinct Types, Pattern Matching
Two-fer Strings & Text Say who gets one of two cookies: "One for Alice, one for me.", or "you" when no name is given. Functions & Lambdas, Scalars & Strings
Variable Length Quantity Encoding & Ciphers Encode numbers as variable-length quantities, seven bits to a byte with the high bit marking that more follow, and decode them back. Bindings & Expressions, Functions & Lambdas, Pipes, Scalars & Strings, Iteration & Loops, Pattern Matching
Word Count Strings & Text Count how many times each word occurs in a sentence, ignoring case and punctuation but keeping apostrophes inside contractions. Pipes, Scalars & Strings, Iteration & Loops
Word Search Grids & Matrices Find where each of a list of words lies in a square of letters, reading in any of the eight directions, by its first and last letter. Bindings & Expressions, Functions & Lambdas, Pipes, Collections, Iteration & Loops, Structs, Enums, Distinct Types
Wordy Parsing & Validation Parse and evaluate simple arithmetic word problems, left to right. Bindings & Expressions, Functions & Lambdas, Pipes, Scalars & Strings, Collections, Structs, Enums, Distinct Types, Pattern Matching
Yacht Games & Simulation Score a throw of five dice in one of the twelve categories of the dice game Yacht. Bindings & Expressions, Functions & Lambdas, Pipes, Collections, Iteration & Loops, Structs, Enums, Distinct Types, Pattern Matching
Zebra Puzzle Games & Simulation Solve the zebra puzzle: from fifteen statements about five houses, find who drinks water and who owns the zebra. Bindings & Expressions, Functions & Lambdas, Pipes, Scalars & Strings, Collections, Iteration & Loops, Structs, Enums, Distinct Types, Pattern Matching
Zipper Collections & Algorithms Navigate a binary tree with a zipper: move the focus left, right and up, read and change the focused node, and get the whole tree back. Collections, Structs, Enums, Distinct Types, Pattern Matching, Generics