Approval chain
ShowcaseBuild a release approval process with states and deadlines.
Big integers
ShowcaseCalculate factorials, Fibonacci numbers, and powers larger than 64 bits.
Chudnovsky π
ShowcaseCalculate 100 digits of π with the Chudnovsky formula and big integers.
Digest schedule
ShowcaseSchedule digest jobs from a cadence and a time window.
Escalation policy
ShowcaseRoute support tickets from their severity and response deadline.
Event timestamps
ShowcaseFormat RFC3339 timestamps with whole or fractional seconds.
Hash projection
ShowcaseRemove, select, merge, and fetch fields from a hash.
Late fee
ShowcaseCalculate a late fee from an overdue duration.
Late fee policy
ShowcaseChoose a late fee from the account standing and days overdue.
Log digest
ShowcaseParse log lines, group them by level, and count each group.
Maintenance window
ShowcasePlan a maintenance window with environment rules, freeze notices, and durations.
Matrix report
ShowcaseTurn rows of daily metrics into totals for each metric.
Numeric literals and rounding
ShowcaseRead hex, octal, binary, and scientific numbers, then round them.
On-call handoff
ShowcaseBuild an on-call handoff from the coverage level and shift length.
Payout schedule
ShowcaseSchedule payouts from the amount, cadence, and settlement delay.
Quote approval
ShowcaseSend each quote to the right approval step based on its total.
Refund decision
ShowcaseUse enums, money, and durations to decide whether to refund an order.
Release readiness
ShowcaseReport whether a release is ready from its state, approvals, and schedule.
Reminder schedule
ShowcaseSchedule reminders from a channel and lead time.
Reshape a list
ShowcaseSplit a list into pages and rolling windows, then sample values.
Resilient lookups
ShowcaseRecover from missing hash keys and check float edge cases.
Retry backoff schedule
ShowcaseBuild an exponential retry schedule with enums, durations, and timestamps.
Send an email
EmbeddingBuild a welcome email and send it through a host email capability.
Send an SMS
EmbeddingWrite a delivery update and send it through a host SMS capability.
Session expiry
ShowcaseSet a session expiry time from its risk level.
Shipping quote
ShowcaseCalculate delivery dates and prices for each shipping speed.
Statement grid
ShowcaseTurn rows of money values into totals for each category.
Subscription billing
ShowcasePrice a subscription invoice from the plan and quantity.
Synchronous blocks
ShowcasePass short-lived behavior directly to the function that uses it.
Text toolkit
ShowcaseSplit, align, and inspect text with Ruby-style string helpers.
Trial offer
ShowcaseBuild a trial offer from the account type and trial length.
Trial reminder
ShowcaseRemind free users that their trial is ending, and skip everyone else.
Value boundaries
ShowcaseUpdate arrays and hashes without changing the values held by aliases.
Word and symbol arrays
ShowcaseBuild explicit string and symbol arrays, with interpolation for generated names.
Batch sensor readings
ReferenceSplit readings into batches, smooth them with a moving window, and find the gaps.
Extras
ReferenceUse array helpers to search, sort, combine, and inspect values.
Rank a leaderboard
ReferenceSort scores, break ties by name, and pick out the podium.
Jobs and Events
ReferenceQueue jobs and publish events through APIs from the host app.
Publish milestone events
ReferenceTotal a player's entries and publish an event for each milestone crossed.
Stagger queued jobs
ReferenceSpread follow-up jobs over time so the host's queue never gets a burst.
Functions and Calls
ReferenceDefine functions, call other functions, and return values.
Literals and Operators
ReferenceWork with numbers, strings, arrays, hashes, and common operators.
Namespaces
ReferenceGroup constants and module functions under a namespace.
Blocks Advanced
ReferenceFilter, group, and reduce data with blocks.
Enumerable Reports
ReferenceGroup donations and total the money in each currency.
Blocks Transformations
ReferenceMap, filter, and reduce collections with blocks.
Yield Patterns
ReferenceWrite functions that accept and yield to blocks.
Context Access
ReferenceRead the current user from context provided by the host app.
Database Queries
ReferenceQuery and update data through a database API from the host app.
Capabilities Iteration
ReferenceIterate over records returned by an API from the host app.
Collections Arrays
ReferenceRead, build, and update arrays.
Hashes
ReferenceBuild, update, and read nested hashes.
Symbols
ReferenceUse labels, strings, and symbols in one string-key hash space.
Case When
ReferenceMatch values and ranges with case and when.
Conditionals
ReferenceChoose values with if, elsif, else, and unless.
Loop Control
ReferenceSkip and stop loop iterations with next and break.
Recursion
ReferenceWrite factorial and Fibonacci functions with recursion.
Until Loop
ReferenceRepeat work with an until loop.
While Loop
ReferenceRepeat work with a while loop.
Describe durations for people
ReferenceBreak durations into days, hours, and minutes, and describe them in plain words.
Durations
ReferenceCreate durations and add them together.
Track support SLAs
ReferenceCompare each ticket's wait against its priority's target and report time left.
Move an order through its states
ReferenceUse an enum and an exhaustive case to allow only valid state changes.
Enums Operations
ReferenceDefine enums and inspect their values.
Sort tickets by priority
ReferenceGive enum members a rank and a label, then sort and count tickets by them.
Assertions
ReferenceCheck inputs with assertions.
Collect validation errors
ReferenceValidate each record, rescue the failures by class, and report them all at once.
Retry a flaky step
ReferenceRescue an error, retry a limited number of times, and always record how it ended.
Layer nested settings
ReferenceMerge default, team, and user settings, resolving conflicts key by key.
Hashes Operations
ReferenceMerge, search, and count values in hashes.
Hashes Transformations
ReferenceRename, filter, and transform hash keys and values.
Loops Advanced
ReferenceNest loops and stop early with break.
Fizzbuzz
ReferenceWrite FizzBuzz with a loop and conditionals.
Loops Iteration
ReferenceIterate over ranges and arrays with common loop helpers.
Money Operations
ReferenceAdd, subtract, and compare money values.
Split a bill fairly
ReferenceDivide money into equal shares without losing a cent, then add tip and tax.
Total payments by currency
ReferenceGroup payments by currency and total each group, since money only adds within one currency.
Access Control
ReferenceWrite access rules as small functions.
Check permissions by role
ReferenceCombine the current user's role with record ownership to decide what they may do.
Decide refund requests
ReferenceApprove, escalate, or deny refunds with small rules that each explain themselves.
Sort values into buckets
ReferenceUse ranges in case branches to label values and count how many land in each bucket.
Step through ranges
ReferenceWalk ranges in steps, test membership, and clamp values into bounds.
Usage
ReferenceCreate ascending and descending ranges, then filter their values.
Core Utilities
ReferenceParse JSON and time values, then create IDs.
Format and round numbers
ReferenceRound, floor, and format numbers for reports, and do exact integer math.
Validate JSON input
ReferenceParse webhook JSON against a shape, handle optional fields, and reject bad payloads.
Build URL slugs
ReferenceTurn titles into clean URL slugs, trim them to a length, and make them unique.
Format a text receipt
ReferenceLine up columns with padding, center a heading, and wrap a long note.
Strings Operations
ReferenceNormalize, split, search, and inspect strings.
Count business days
ReferenceSkip weekends and holidays to find a due date and count working days between two dates.
Duration
ReferenceAdd durations to times and use duration arithmetic.
Format and compare times
ReferenceParse timestamps, show them in other time zones and formats, and measure the gaps between them.
ABC Problem
IntermediateDetermine whether a word can be formed from a fixed set of two-letter blocks without reusing a block.
Ackermann Function
IntermediateRun the Ackermann function on small inputs to show deep recursion.
Balanced Brackets
EasyCheck whether bracket pairs are properly nested and closed by scanning the text with a stack.
Binary Search
EasyLocate values in a sorted array by repeatedly halving the remaining search interval.
Caesar Cipher
EasyEncode and decode text by rotating alphabetic characters through a fixed shift.
100 doors
IntroToggle one hundred doors and return the open door numbers.
99 Bottles of Beer
beginnerGenerate the full 99 Bottles of Beer song from 99 down to 0.
Rosetta Code A+B
IntroAdd fixed integer pairs and return the resulting sums.
Rosetta Code A+B
IntroReturn the sum of integer pairs.
Abbreviations, automatic
IntroCompute the shortest unique command prefixes for a fixed command set and resolve sample abbreviations.
Abbreviations, simple
IntroResolve simple command abbreviations by matching unique prefixes from a fixed command list.
Abundant odd numbers
IntroCheck a few well-known odd abundant numbers by comparing them with their proper divisor sums.
Abundant, deficient and perfect number classifications
IntroClassify sample integers by comparing them with the sum of their proper divisors.
Align columns
MediumAlign Rosetta Code's dollar-delimited sample text into left, right, and centered columns.
Aliquot sequence classifications
MediumBuild short aliquot sequences and classify whether they terminate, loop, or are perfect.
Anagrams
IntroGroup a fixed word list into anagram sets using sorted-letter signatures.
Angle difference between two bearings
IntroCompute the smallest signed turn needed to move from one bearing to another.
Angles (geometric), normalization and conversion
IntroNormalize degree angles and convert between degrees and radians for fixed sample values.
Rosetta Code Arrays
IntroCreate, index, append to, and total arrays.
Bacon cipher
MediumEncode and decode short messages with Bacon's five-letter A/B cipher.
Balanced ternary
IntermediateConvert small signed integers into balanced ternary using 1, 0, and T digits.
Best shuffle
MediumProduce a low-fixed-point shuffle by rotating the sorted characters of a word.
Binary digits
IntroConvert fixed non-negative integers into binary strings.
Binary strings
IntroGenerate all binary strings of a fixed length with a simple recursive builder.
Bitwise operations
MediumRun common bitwise operations with a hand-built 8-bit model.
Box the compass
MediumMap degree headings to the correct 32-point compass names for the Rosetta Code sample bearings.
Brazilian numbers
MediumFind the first Brazilian numbers by searching for bases whose representation uses one repeated digit.
Bubble sort
EasySort an array of integers using the bubble sort algorithm.
Call a function
IntroCall functions with positional arguments and combine their results.
Cartesian product of two or more lists
IntroBuild Cartesian products iteratively for a pair of lists and a three-list input.
Catalan numbers
IntroGenerate the opening Catalan numbers with the standard multiplicative recurrence.
Chinese zodiac
IntroMap sample years to their Chinese zodiac animal and element.
Conditional structures
IntroClassify values with if, elsif, and else branches.
Day of the week
IntroCompute weekdays for fixed Gregorian dates with Zeller's congruence.
Determine if a string is numeric
IntroRecognize simple signed integer and decimal strings.
Determine if a string is squeezable
IntroCollapse repeated adjacent characters and compare the squeezed result with a target string.
Digital root
EasyCompute the digital root and additive persistence of a non-negative integer.
Discordian date
MediumConvert Gregorian dates into the Discordian calendar.
Dot product
IntroCompute the dot product of two vectors of equal length.
Ethiopian multiplication
IntroMultiply two integers by repeated halving, doubling, and summing odd rows.
Factorial
IntroCompute factorial values both recursively and iteratively, well past the 64-bit range.
Factors of an integer
IntroCompute all positive factors of a small positive integer with trial division up to its square root.
Farey sequence
MediumGenerate Farey sequences of small orders with the classic iterative recurrence.
Fibonacci n-step number sequences
IntroGenerate Tribonacci and Tetranacci sequences by summing the previous n terms.
Fibonacci sequence
IntroProduce the opening terms of the Fibonacci sequence iteratively.
Fibonacci word
IntroBuild the opening Fibonacci words by concatenating the two previous terms.
Find palindromic numbers in both binary and ternary bases
MediumSearch for numbers whose binary and ternary representations are both palindromes.
Find words which contain the most consonants
IntroCount consonants in a fixed word list and return the words with the highest totals.
FizzBuzz
IntroEmit the classic FizzBuzz sequence up to a chosen limit.
Floyd's triangle
IntroGenerate the opening rows of Floyd's triangle.
Four bit adder
EasyAdd two four-bit binary values and return the carry with the result bits.
Fraction reduction
IntroReduce sample fractions to lowest terms with Euclid's algorithm.
Gray code
MediumGenerate the 4-bit Gray code sequence with the standard reflective construction.
Greatest common divisor
IntroCompute greatest common divisors with the iterative Euclidean algorithm on a fixed sample set.
Greedy algorithm for Egyptian fractions
MediumDecompose sample rational numbers into Egyptian fractions with the standard greedy method, including inputs whose unit-fraction denominators run to 25 digits.
Hailstone sequence
IntroBuild a hailstone sequence and report its length.
Hamming numbers
IntermediateGenerate the opening Hamming numbers with the classic 2-3-5 pointer technique.
Happy numbers
IntroClassify happy numbers by iterating the sum-of-squares process and list the first twelve.
Harshad or Niven series
EasyFind Harshad (Niven) numbers, which are divisible by the sum of their digits.
Heronian triangles
MediumSearch a small side-length range for Heronian triangles with integer area.
Humble numbers
IntermediateGenerate humble numbers with the standard 2-3-5-7 pointer technique.
I before E except after C
IntroCheck sample words against the classic “i before e except after c” spelling rule.
Insertion sort
EasySort an array by repeatedly inserting each element into its correct position.
Isqrt (integer square root) of X
IntroCompute integer square roots with a binary search over fixed sample inputs.
Josephus problem
MediumFind the survivor position in the Josephus problem for n people counting every k-th.
Kaprekar numbers
IntroTest fixed integers for the Kaprekar split-square property.
Kaprekar routine
MediumApply the Kaprekar routine to a 4-digit number and watch it converge to 6174.
Last letter-first letter
IntermediateBuild a word chain where each next word starts with the previous word's last letter.
Leap year
IntroDetermine whether a given year is a leap year using the Gregorian calendar rules.
Letter frequency
IntroCount alphabetic character frequencies in a sample phrase.
Levenshtein distance
MediumCompute edit distance with insert, delete, and substitute operations using a single rolling row.
Long multiplication
IntroBreak a multiplication problem into the partial products used by long multiplication.
Look-and-say sequence
EasyGenerate terms of the look-and-say sequence where each term describes the digits of the previous one.
Luhn test of credit card numbers
EasyValidate account numbers with the Luhn checksum.
Lychrel numbers
IntroCheck sample numbers for palindrome formation under 200 rounds of the reverse-and-add process, where sums grow far past 64 bits.
Magic squares of odd order
MediumBuild a 3x3 magic square with the classic Siamese method.
Matrix multiplication
MediumMultiply two small matrices.
Matrix transposition
EasyTranspose a matrix by swapping its rows and columns with the built-in Array#transpose.
Middle three digits
IntroReturn the middle three digits of integers that have an odd number of digits.
Minimum multiple of m where digital sum equals m
IntroSearch small multiples until the digit sum matches the divisor.
Morse code
EasyEncode text to Morse code using a fixed A-Z and digit lookup table.
Multiplication tables
IntroBuild a small multiplication table as nested arrays.
N-smooth numbers
IntroGenerate the first twenty 5-smooth numbers by stripping allowed small factors.
Narcissistic decimal number
IntroIdentify fixed sample numbers that equal the sum of their digits raised to the digit count.
Natural sorting
MediumSort filenames by comparing embedded digit runs numerically instead of lexicographically.
Number names
IntermediateSpell small whole numbers in English.
Numerical integration
IntroApproximate definite integrals with the trapezoidal rule over fixed functions.
Palindrome detection
IntroDetect palindromes after normalizing letters and digits to lowercase.
Palindromic gapful numbers
MediumFind the first palindromic gapful numbers in a bounded decimal range.
Pangram checker
IntroCheck whether a sentence contains every letter of the alphabet at least once.
Parse an IP Address
EasyParse dotted IPv4 strings into four validated octets.
Pascal's triangle
IntroGenerate the opening rows of Pascal's triangle iteratively.
Permutations
IntroGenerate every permutation of three items with a simple recursive backtracking routine.
Pig Latin
EasyTranslate English words into Pig Latin by moving leading consonants and appending ay.
Playing cards
IntroConstruct a standard 52-card deck from suit and rank combinations.
Prime decomposition
MediumFind the prime factors of composite integers with trial division.
Priority queue
MediumModel a simple highest-priority-first queue with sorted insertion over an array-backed store.
Pythagorean triples
IntroEnumerate small Pythagorean triples with bounded hypotenuse.
Range extraction
MediumCompress an ordered list of integers into Rosetta Code's comma-and-range string format.
Roman numerals/Decode
EasyConvert a Roman numeral string back to its integer value.
Roman numerals/Encode
EasyConvert an integer to its Roman numeral representation.
Rot-13
IntroEncode and decode text by rotating letters by thirteen positions.
Run-length encoding
EasyEncode and decode a short sample string with classic run-length encoding.
Selection sort
EasySort an array by repeatedly selecting the minimum element from the unsorted portion.
Sequence of primorial primes
MediumCheck primorial minus one and plus one values for primality over a short prime prefix.
Set
IntroFind the union, intersection, and difference of array-backed sets.
Show ASCII table
IntroReturn a compact slice of ASCII rows with code, character, and ordinal data.
Sieve of Eratosthenes
IntroGenerate the prime numbers up to fifty with the classic sieve.
Smith numbers
MediumDetect Smith numbers by comparing the digit sum of a composite integer with the digit sum of its prime factors.
Spiral matrix
MediumFill a square matrix in clockwise spiral order.
Square-free integers
IntroList the square-free integers up to thirty.
Stack
EasyModel a small LIFO stack with push, pop, and peek over an array-backed store.
String comparison
IntroCompare sample string pairs lexicographically and report the sign of each comparison.
String matching
IntroFind every starting index of a pattern inside a fixed string with a naive scan.
Substring
IntroExtract substrings from a source string using start offsets and lengths.
Sum multiples of 3 and 5
IntroSum the integers below fixed limits that are divisible by three or five.
Taxicab numbers
MediumSearch a small cube-sum table for numbers that can be written as two sums of two cubes.
Temperature conversion
IntroConvert values between Celsius and Fahrenheit.
Ternary logic
MediumBuild a small truth table for three-valued logic with true, maybe, and false states.
Top rank per group
IntroPick the highest-scoring row from each group with a stable tie-break on name.
Topological sort
MediumTopologically sort a small dependency graph with Kahn's algorithm.
Total circles area
IntroSum the areas of several circles from their radii.
Towers of Hanoi
MediumSolve Towers of Hanoi recursively and return each move in order.
Tree traversal
MediumTraverse a small binary tree in preorder, inorder, postorder, and level order.
Truth table
IntroEnumerate boolean combinations for common logical operators.
UPC
IntroValidate sample UPC codes with the standard checksum rule.
URL parser
IntroParse a fixed URL into scheme, host, path, and query parameters.
UTF-8 encode and decode
MediumEncode fixed code points into UTF-8 byte arrays and decode them back.
Variables
IntroShow variable assignment, reassignment, and derived values.
Vector products
IntroCompute the dot product and cross product of two fixed three-dimensional vectors.
Vigenère cipher
MediumEncode and decode a short uppercase message with a fixed Vigenère key.
Word frequency
IntroCount the frequency of normalized words in a short sample passage.
Word wrap
IntroWrap a paragraph with the standard greedy algorithm at two different column widths.
Zeckendorf number representation
MediumRepresent integers as sums of non-consecutive Fibonacci numbers using Zeckendorf's theorem.
Zig-zag matrix
MediumFill a small square matrix with zig-zag diagonal ordering.