Rosettacode tasks in Perl 6
  • Introduction
  • Programming tasks
    • 1
      • 10001th prime
      • 100 doors
      • 100 prisoners
      • 15 puzzle game
      • 15 puzzle solver
      • 16 puzzle game
    • 2
      • 2048
      • 21 game
      • 24 game
        • Solve
    • 4
      • 4-rings or 4-squares puzzle
    • 9
      • 99 bottles of beer
      • 9 billion names of God the integer
    • A
      • A* search algorithm
      • A B
      • Abbreviations automatic
      • Abbreviations easy
      • Abbreviations simple
      • ABC problem
      • ABC words
      • Abelian sandpile model
        • Identity
      • Abstract type
      • Abundant deficient and perfect number classifications
      • Abundant odd numbers
      • Accumulator factory
      • Achilles numbers
      • Ackermann function
      • Active Directory
        • Connect
        • Search for a user
      • Active object
      • Add a variable to a class instance at runtime
      • Addition-chain exponentiation
      • Addition chains
      • Additive primes
      • Address of a variable
      • ADFGVX cipher
      • Air mass
      • AKS test for primes
      • Algebraic data types
      • Align columns
      • Aliquot sequence classifications
      • Almkvist-Giullera formula for pi
      • Almost prime
      • Alternade words
      • Amb
      • Amicable pairs
      • Anadromes
      • Anagram generator
      • Anagrams
        • Deranged anagrams
      • Anaprimes
      • Angle difference between two bearings
      • Angles geometric normalization and conversion
      • Animate a pendulum
      • Animation
      • Anonymous recursion
      • Anti-primes
      • Apéry's constant
      • Append a record to the end of a text file
      • Append numbers at same position in strings
      • Apply a callback to an array
      • Apply a digital filter direct form II transposed
      • Approximate equality
      • Arbitrary-precision integers included
      • Archimedean spiral
      • Arena storage pool
      • Arithmetic
        • Complex
        • Integer
        • Rational
      • Arithmetic-geometric mean
        • Calculate Pi
      • Arithmetic coding
        • As a generalized change of radix
      • Arithmetic derivative
      • Arithmetic evaluation
      • Arithmetic numbers
      • Array concatenation
      • Array length
      • Arrays
      • Ascending primes
      • ASCII art diagram converter
      • ASCII control characters
      • Aspect oriented programming
      • Assertions
      • Assertions in design by contract
      • Associative array
        • Creation
        • Iteration
        • Merging
      • Atomic updates
      • Attractive numbers
      • Audio alarm
      • Audio frequency generator
      • Autogram checker
      • Average loop length
      • Averages
        • Arithmetic mean
        • Mean angle
        • Mean time of day
        • Median
        • Mode
        • Pythagorean means
        • Root mean square
        • Simple moving average
      • AVL tree
    • B
      • Bézier curves
        • Intersections
      • B-spline
      • Babbage problem
      • Babylonian spiral
      • Bacon cipher
      • Balanced brackets
      • Balanced ternary
      • Banker's algorithm
      • Barnsley fern
      • Base58Check encoding
      • Base64 decode data
      • Base64 encode data
      • Base 16 numbers needing a to f
      • Bell numbers
      • Benford's law
      • Bernoulli numbers
      • Bernstein basis polynomials
      • Best shuffle
      • Bifid cipher
      • Bilinear interpolation
      • Bin given limits
      • Binary coded decimal
      • Binary digits
      • Binary search
      • Binary strings
      • Binomial transform
      • Bioinformatics
        • Base count
        • Global alignment
        • Sequence mutation
        • Subsequence
      • Biorhythms
      • Birthday problem
      • Bitcoin
        • Address validation
        • Public point to address
      • Bitmap
        • Bézier curves
          • Cubic
          • Quadratic
        • Bresenham's line algorithm
        • Flood fill
        • Histogram
        • Midpoint circle algorithm
        • PPM conversion through a pipe
        • Read a PPM file
        • Read an image through a pipe
        • Write a PPM file
      • Bitwise IO
      • Bitwise operations
      • Blum integer
      • Boolean values
      • Boustrophedon transform
      • Box the compass
      • Boyer-Moore string search
      • Brace expansion
      • Brace expansion using ranges
      • Brazilian numbers
      • Break OO privacy
      • Brilliant numbers
      • Brownian tree
      • Bulls and cows
        • Player
      • Burrows Wheeler transform
    • C
      • Caesar cipher
      • Calculating the value of e
      • Calendar
      • Calendar - for REAL programmers
      • Calkin-Wilf sequence
      • Call a foreign-language function
      • Call a function
      • Call a function in a shared library
      • Call an object method
      • Calmo numbers
      • CalmoSoft primes
      • Camel case and snake case
      • Canny edge detector
      • Canonicalize CIDR
      • Cantor set
      • Card shuffles
      • Carmichael 3 strong pseudoprimes
      • Carmichael lambda function
      • Cartesian product of two or more lists
      • Case-sensitivity of identifiers
      • Casting out nines
      • Catalan numbers
        • Pascal's triangle
      • Catamorphism
      • Centre and radius of a circle passing through 3 points in a plane
      • Centroid of a set of N-dimensional points
      • Change e letters to i in words
      • Changeable words
      • Chaocipher
      • Chaos game
      • Character codes
      • Chat server
      • Chebyshev coefficients
      • Check if a polygon overlaps with a rectangle
      • Check if two polygons overlap
      • Check input device is a terminal
      • Check Machin-like formulas
      • Check output device is a terminal
      • Check that file exists
      • Checkpoint synchronization
      • Checksumcolor
      • Chemical calculator
      • Chernick's Carmichael numbers
      • Cheryl's birthday
      • Chinese remainder theorem
      • Chinese zodiac
      • Cholesky decomposition
      • Chowla numbers
      • Church numerals
      • Cipolla's algorithm
      • Circles of given radius through two points
      • Circular primes
      • Cistercian numerals
      • Classes
      • Closest-pair problem
      • Closures
        • Value capture
      • Code Golf Code Golf
      • Code segment unload
      • Collect and sort square numbers in ascending order from three lists
      • Collections
      • Color of a screen pixel
      • Color quantization
      • Color wheel
      • Colorful numbers
      • Colour bars
        • Display
      • Colour pinstripe
        • Display
        • Printer
      • Combinations
      • Combinations and permutations
      • Combinations with repetitions
        • Square digit chain
      • Comma quibbling
      • Command-line arguments
      • Commatizing numbers
      • Comments
      • Common list elements
      • Common sorted list
      • Compare a list of strings
      • Compare length of two strings
      • Compare sorting algorithms' performance
      • Compile-time calculation
      • Compiler
        • Code generator
        • Lexical analyzer
        • Simple file inclusion pre processor
        • Verifying syntax
        • Virtual machine interpreter
      • Composite numbers k with no single digit factors whose factors are all substrings of k
      • Compound data type
      • Concatenate two primes is also prime
      • Concurrent computing
      • Conditional structures
      • Conjugate a Latin verb
      • Conjugate transpose
      • Consecutive primes with ascending or descending differences
      • Consistent overhead byte stuffing
      • Constrained genericity
      • Constrained random points on a circle
      • Continued fraction
        • Arithmetic
          • Construct from rational number
          • Gmatrix ng continued fraction n
          • Gmatrix ng continued fraction n1 continued fraction n2
      • Continued fraction convergents
      • Convert decimal number to rational
      • Convert seconds to compound duration
      • Convex hull
      • Conway's Game of Life
      • Coprime triplets
      • Coprimes
      • Copy a string
      • Copy stdin to stdout
      • CORDIC
      • Count how many vowels and consonants occur in a string
      • Count in factors
      • Count in octal
      • Count occurrences of a substring
      • Count the coins
        • 0-1
      • Countdown
      • Cousin primes
      • Cramer's rule
      • CRC-32
      • Create a file
      • Create a file on magnetic tape
      • Create a two-dimensional array at runtime
      • Create an HTML table
      • Create an object
        • Native demonstration
      • Create an object at a given address
      • Create your own text control codes
      • CSV data manipulation
      • CSV to HTML translation
      • Cuban primes
      • Cubic special primes
      • Cullen and Woodall numbers
      • Cumulative standard deviation
      • Currency
      • Currying
      • Curve that touches three points
      • Curzon numbers
      • CUSIP
      • Cut a rectangle
      • Cycle detection
      • Cycles of a permutation
      • Cyclops numbers
      • Cyclotomic polynomial
    • D
      • Damm algorithm
      • Data Encryption Standard
      • Date format
      • Date manipulation
      • Dating agency
      • Day of the week
      • Day of the week of Christmas and New Year
      • Days between dates
      • De Bruijn sequences
      • De Polignac numbers
      • Deal cards for FreeCell
      • Death Star
      • Deceptive numbers
      • Decimal floating point number to binary
      • Decision tables
      • Deconvolution
        • 1D
        • 2D
      • Decorate-sort-undecorate idiom
      • Deepcopy
      • Define a primitive data type
      • Delegates
      • Delete a file
      • Deming's funnel
      • Department numbers
      • Descending primes
      • Detect division by zero
      • Determinant and permanent
      • Determine if a string has all the same characters
      • Determine if a string has all unique characters
      • Determine if a string is collapsible
      • Determine if a string is numeric
      • Determine if a string is squeezable
      • Determine if only one instance is running
      • Determine if two triangles overlap
      • Determine sentence type
      • Dice game probabilities
      • Digit fifth powers
      • Digital root
        • Multiplicative digital root
      • Dijkstra's algorithm
      • Dinesman's multiple-dwelling problem
      • Dining philosophers
      • Disarium numbers
      • Discordian date
      • Discrete Fourier transform
      • Display a linear combination
      • Display an outline as a nested table
      • Distance and Bearing
      • Distinct palindromes within decimal numbers
      • Distinct power numbers
      • Distributed programming
      • Distribution of 0 digits in factorial series
      • Diversity prediction theorem
      • Divide a rectangle into a number of unequal triangles
      • DNS query
      • Documentation
      • Doomsday rule
      • Dot product
      • Double Twin Primes
      • Doubly-linked list
        • Definition
        • Element definition
        • Element insertion
        • Element removal
        • Traversal
      • Dragon curve
      • Draw a clock
      • Draw a cuboid
      • Draw a pixel
      • Draw a rotating cube
      • Draw a sphere
      • Draw pixel 2
      • Duffinian numbers
      • Dutch national flag problem
      • Dynamic variable names
    • E
      • Earliest difference between prime gaps
      • Eban numbers
      • Echo server
      • Eertree
      • Egyptian division
      • Eisenstein primes
      • EKG sequence convergence
      • Element-wise operations
      • Elementary cellular automaton
        • Infinite length
        • Random number generator
      • Elliptic curve arithmetic
      • Elliptic Curve Digital Signature Algorithm
      • Emirp primes
      • Empty directory
      • Empty program
      • Empty string
      • Enforced immutability
      • Engel expansion
      • English cardinal anagrams
      • Entropy
        • Narcissist
      • Enumerations
      • Environment variables
      • Equal prime and composite sums
      • Equilibrium index
      • Erdös-Selfridge categorization of primes
      • Erdős-Nicolas numbers
      • Erdős-primes
      • Erdős Woods numbers
      • Esthetic numbers
      • Ethiopian multiplication
      • Euclid-Mullin sequence
      • Euclidean rhythm
      • Euler's constant 0 5772
      • Euler's identity
      • Euler's sum of powers conjecture
      • Euler method
      • Evaluate binomial coefficients
      • Even numbers which cannot be expressed as the sum of two twin primes
      • Even or odd
      • Events
      • Evolutionary algorithm
      • Exactly three adjacent 3 in lists
      • Exceptions
        • Catch an exception thrown in a nested call
      • Executable library
      • Execute a Markov algorithm
      • Execute a system command
      • Execute Brain****
      • Execute Computer
        • Zero
      • Execute CopyPasta Language
      • Execute HQ9
      • Execute SNUSP
      • Exponential digital sums
      • Exponentiation operator
      • Exponentiation order
      • Exponentiation with infix operators in or operating on the base
      • Extend your language
      • Extensible prime generator
      • External sort
      • Extra primes
      • Extract file extension
      • Extreme floating point values
      • Extreme primes
    • F
      • Faces from a mesh
      • Factor-perfect numbers
      • Factorial
      • Factorial base numbers indexing permutations of a collection
      • Factorial primes
      • Factorions
      • Factorize string into Lyndon words
      • Factors of a Mersenne number
      • Factors of an integer
      • Fairshare between two and more
      • Farey sequence
      • Fast Fourier transform
      • FASTA format
      • Faulhaber's formula
      • Faulhaber's triangle
      • Feigenbaum constant calculation
      • Fermat numbers
      • Fermat pseudoprimes
      • Fibonacci heap
      • Fibonacci matrix-exponentiation
      • Fibonacci n-step number sequences
      • Fibonacci sequence
      • Fibonacci word
        • Fractal
      • File extension is in extensions list
      • File input
        • Output
      • File modification time
      • File size
      • File size distribution
      • Filter
      • Find adjacent primes which differ by a square integer
      • Find Chess960 starting position identifier
      • Find common directory path
      • Find duplicate files
      • Find first and last set bit of a long integer
      • Find first missing positive
      • Find if a point is within a triangle
      • Find largest left truncatable prime in a given base
      • Find limit of recursion
      • Find minimum number of coins that make a given value
      • Find palindromic numbers in both binary and ternary bases
      • Find prime n such that reversed n is also prime
      • Find prime numbers of the form nnn 2
      • Find square difference
      • Find squares n where n 1 is prime
      • Find the intersection of a line with a plane
      • Find the intersection of two lines
      • Find the last Sunday of each month
      • Find the missing permutation
      • Find URI in text
      • Find words which contain the most consonants
      • Find words which contains all the vowels
      • Find words which contains more than 3 e vowels
      • Find words whose first and last three letters are equal
      • Find words with alternating vowels and consonants
      • Finite state machine
      • First-class functions
        • Use numbers analogously
      • First 9 prime Fibonacci number
      • First class environments
      • First perfect square in base n with n unique digits
      • First power of 2 that has leading decimal digits of 12
      • Five weekends
      • Fivenum
      • Fixed length records
      • FizzBuzz
      • Flatten a list
      • Flipping bits game
      • Flow-control structures
      • Floyd's triangle
      • Floyd-Warshall algorithm
      • Forbidden numbers
      • Forest fire
      • Fork
      • Formal power series
      • Formatted numeric output
      • Fortunate numbers
      • Forward difference
      • Four bit adder
      • Four is magic
      • Four is the number of letters in the
      • Four sides of square
      • Fractal tree
      • Fraction reduction
      • Fractran
      • French Republican calendar
      • Frobenius numbers
      • FTP
      • Function composition
      • Function definition
      • Function frequency
      • Function prototype
      • Functional coverage tree
      • Fusc sequence
    • G
      • Galton box animation
      • Gamma function
      • Gapful numbers
      • Gauss-Jordan matrix inversion
      • Gaussian elimination
      • Gaussian primes
      • General FizzBuzz
      • Generalised floating point addition
      • Generate Chess960 starting position
      • Generate lower case ASCII alphabet
      • Generate random chess position
      • Generate random numbers without repeating a value
      • Generator
        • Exponential
      • Generic swap
      • Geohash
      • Geometric algebra
      • Get system command output
      • Getting the number of decimal places
      • Giuga numbers
      • Globally replace text in several files
      • Go Fish
      • Goldbach's comet
      • Golden ratio
        • Convergence
      • Goodstein Sequence
      • Gotchas
      • Gradient descent
      • Graph colouring
      • Gray code
      • Grayscale image
      • Greatest common divisor
      • Greatest element of a list
      • Greatest prime dividing the n-th cubefree number
      • Greatest subsequential sum
      • Greed
      • Greedy algorithm for Egyptian fractions
      • Greyscale bars
        • Display
      • GSTrans string conversion
      • Guess the number
        • With feedback
        • With feedback player
      • GUI
        • Maximum window dimensions
      • GUI component interaction
      • GUI enabling
        • Disabling of controls
    • H
      • Hailstone sequence
      • Halt and catch fire
      • Hamming numbers
      • Handle a signal
      • Happy numbers
      • Harmonic series
      • Harshad or Niven series
      • Hash from two arrays
      • Hash join
      • Hashtron inference
      • Haversine formula
      • Hello world
        • Graphical
        • Line printer
        • Newbie
        • Newline omission
        • Standard error
        • Text
        • Web server
      • Here document
      • Heronian triangles
      • Hex dump
      • Hex words
      • Hickerson series of almost integers
      • Higher-order functions
      • Hilbert curve
      • History variables
      • Hofstadter-Conway 10 000 sequence
      • Hofstadter Figure-Figure sequences
      • Hofstadter Q sequence
      • Holidays related to Easter
      • Home primes
      • Honaker primes
      • Horizontal sundial calculations
      • Horner's rule for polynomial evaluation
      • Horse racing
      • Host introspection
      • Hostname
      • Hough transform
      • Hourglass puzzle
      • HTTP
      • HTTPS
        • Authenticated
        • Client-authenticated
      • Huffman coding
      • Humble numbers
      • Hunt the Wumpus
    • I
      • I'm a software engineer get me out of here
      • I before E except after C
      • IBAN
      • Iccanobif primes
      • Identity matrix
      • Idiomatically determine all the characters that can be used for symbols
      • Idiomatically determine all the lowercase and uppercase letters
      • Idoneal numbers
      • Image convolution
      • Image noise
      • Imaginary base numbers
      • Implicit type conversion
      • Include a file
      • Inconsummate numbers in base 10
      • Increasing gaps between consecutive Niven numbers
      • Increment a numerical string
      • Index finite lists of positive integers
      • Infinity
      • Inheritance
        • Multiple
        • Single
      • Inner classes
      • Input
        • Output for lines of text
        • Output for pairs of numbers
      • Input loop
      • Integer comparison
      • Integer long division
      • Integer overflow
      • Integer roots
      • Integer sequence
      • Interactive help
      • Interactive programming repl
      • Intersecting number wheels
      • Introspection
      • Inventory sequence
      • Inverted index
      • Inverted syntax
      • IPC via named pipe
      • ISBN13 check digit
      • Isograms and heterograms
      • Isqrt integer square root of X
      • Iterated digits squaring
      • Iterators
    • J
      • Jaccard index
      • Jacobi symbol
      • Jacobsthal numbers
      • Jaro-Winkler distance
      • Jaro similarity
      • Jensen's Device
      • Jewels and stones
      • Jordan-Pólya numbers
      • JortSort
      • Josephus problem
      • Joystick position
      • JSON
      • Juggler sequence
      • Julia set
      • Jump anywhere
      • Just in time processing on a character stream
    • K
      • K-d tree
      • K-means clustering
      • Kahan summation
      • Kaprekar numbers
      • Kernighans large earthquake problem
      • Keyboard input
        • Flush the keyboard buffer
        • Keypress check
        • Obtain a Y or N response
      • Keyboard macros
      • Klarner-Rado sequence
      • Knapsack problem
        • 0-1
        • Bounded
        • Continuous
        • Unbounded
      • Knight's tour
      • Knuth's algorithm S
      • Knuth's power tree
      • Knuth-Morris-Pratt string search
      • Knuth shuffle
      • Koch curve
      • Kolakoski sequence
      • Kosaraju
      • Kronecker product
      • Kronecker product based fractals
    • L
      • L-system
      • Lagrange Interpolation
      • Lah numbers
      • Langton's ant
      • Largest difference between adjacent primes
      • Largest five adjacent number
      • Largest int from concatenated ints
      • Largest number divisible by its digits
      • Largest palindrome product
      • Largest prime factor
      • Largest product in a grid
      • Largest proper divisor of n
      • Last Friday of each month
      • Last letter-first letter
      • Last list item
      • Latin Squares in reduced form
        • Randomizing using Jacobson and Matthews' technique
      • Launch rocket with countdown and acceleration in stdout
      • Law of cosines - triples
      • Leap year
      • Least common multiple
      • Least m such that n m is prime
      • Left factorials
      • Legendre prime counting function
      • Length of an arc between two angles
      • Leonardo numbers
      • Letter frequency
      • Levenshtein distance
        • Alignment
      • Line circle intersection
      • Linear congruential generator
      • Linux CPU utilization
      • List comprehensions
      • List rooted trees
      • Literals
        • Floating point
        • Integer
        • String
      • Logical operations
      • Logistic curve fitting in epidemiology
      • Long literals with continuations
      • Long multiplication
      • Long primes
      • Long stairs
      • Long year
      • Longest common prefix
      • Longest common subsequence
      • Longest common substring
      • Longest common suffix
      • Longest increasing subsequence
      • Longest palindromic substrings
      • Longest string challenge
      • Longest substrings without repeating characters
      • Look-and-say sequence
      • Loop over multiple arrays simultaneously
      • Loops
        • Break
        • Continue
        • Do-while
        • Downward for
        • For
        • For with a specified step
        • Foreach
        • Increment loop index within loop body
        • Infinite
        • N plus one half
        • Nested
        • While
        • With multiple ranges
        • Wrong ranges
      • LU decomposition
      • Lucas-Carmichael numbers
      • Lucas-Lehmer test
      • Lucky and even lucky numbers
      • Ludic numbers
      • Luhn test of credit card numbers
      • Lychrel numbers
      • Lyndon word
      • LZW compression
    • M
      • Möbius function
      • MAC vendor lookup
      • Machine code
      • Mad Libs
      • Magic 8-ball
      • Magic constant
      • Magic numbers
      • Magic squares of doubly even order
      • Magic squares of odd order
      • Magic squares of singly even order
      • Magnanimous numbers
      • Main step of GOST 28147-89
      • Make a backup file
      • Make directory path
      • Man or boy test
      • Mandelbrot set
      • Map range
      • Marching squares
      • Markov chain text generator
      • Mastermind
      • Matrix-exponentiation operator
      • Matrix chain multiplication
      • Matrix digital rain
      • Matrix multiplication
      • Matrix transposition
      • Matrix with two diagonals
      • Maximum difference between adjacent elements of list
      • Maximum triangle path sum
      • Mayan calendar
      • Mayan numerals
      • Maze generation
      • Maze solving
      • McNuggets problem
      • MD4
      • MD5
        • Implementation
      • Median filter
      • Meissel Mertens constant
      • Memory allocation
      • Memory layout of a data structure
      • Menu
      • Merge and aggregate datasets
      • Mersenne primes
      • Mertens function
      • Metallic ratios
      • Metaprogramming
      • Metered concurrency
      • Metronome
      • Mian-Chowla sequence
      • Middle three digits
      • Miller Rabin primality test
      • Mind boggling card trick
      • Minesweeper game
      • Minimal steps down to 1
      • Minimum multiple of m where digital sum equals m
      • Minimum number of cells after before above and below NxN squares
      • Minimum numbers of three lists
      • Minimum positive multiple in base 10 using only 0 and 1
      • Minimum primes
      • Minkowski question-mark function
      • Modified random distribution
      • Modular arithmetic
      • Modular exponentiation
      • Modular inverse
      • Modulinos
      • Monads
        • List monad
        • Maybe monad
        • Writer monad
      • Monte Carlo methods
      • Montgomery reduction
      • Monty Hall problem
      • Morse code
      • Mosaic matrix
      • Most frequent k chars distance
      • Motzkin numbers
      • Mouse position
      • Move-to-front algorithm
      • Multi-base primes
      • Multi-dimensional array
      • Multidimensional Newton-Raphson method
      • Multifactorial
      • Multiline shebang
      • Multiple distinct objects
      • Multiple regression
      • Multiplication tables
      • Multiplicative order
      • Multiplicatively perfect numbers
      • Multisplit
      • Multiton
      • Munchausen numbers
      • Munching squares
      • Musical scale
      • Mutex
      • Mutual recursion
    • N
      • N'th
      • N-body problem
      • N-grams
      • N-queens minimum and knights and bishops
      • N-queens problem
      • N-smooth numbers
      • Named parameters
      • Names to numbers
      • Naming conventions
      • Narcissist
      • Narcissistic decimal number
      • Native shebang
      • Natural sorting
      • Nautical bell
      • Negative base numbers
      • Neighbour primes
      • Nested function
      • Nested templated data
      • Next highest int from digits
      • Next special primes
      • Nice primes
      • Nim game
      • Nimber arithmetic
      • Non-continuous subsequences
      • Non-decimal radices
        • Convert
        • Input
        • Output
      • Non-transitive dice
      • Nonoblock
      • Nonogram solver
      • Nth root
      • Null object
      • Number names
      • Number reversal game
      • Numbers divisible by their individual digits but not by the product of their digits
      • Numbers in base-16 representation that cannot be written with decimal digits
      • Numbers in base 10 that are palindromic in bases 2 4 and 16
      • Numbers k such that the last letter of k is the same as the first letter of k 1
      • Numbers which are not the sum of distinct squares
      • Numbers which are the cube roots of the product of their proper divisors
      • Numbers whose binary and ternary digit sums are prime
      • Numbers whose count of divisors is prime
      • Numbers with equal rises and falls
      • Numbers with prime digits whose sum is 13
      • Numbers with same digit set in base 10 and base 16
      • Numeric error propagation
      • Numeric separator syntax
      • Numerical and alphabetical suffixes
      • Numerical integration
        • Adaptive Simpson's method
        • Gauss-Legendre Quadrature
      • NYSIIS
    • O
      • O'Halloran numbers
      • Object serialization
      • Odd and square numbers
      • Odd squarefree semiprimes
      • Odd word problem
      • Odd words
      • Old lady swallowed a fly
      • Old Russian measure of length
      • One-dimensional cellular automata
      • One-time pad
      • One-two primes
      • One of n lines in a file
      • OpenGL
        • Utah teapot
      • OpenWebNet password
      • Operator precedence
      • Optional parameters
      • Orbital elements
      • Order by pair comparisons
      • Order disjoint list items
      • Order two numerical lists
      • Ordered partitions
      • Ordered words
      • Ormiston pairs
      • Ormiston triples
      • Overloaded operators
      • Own digits power sum
    • P
      • P-Adic numbers basic
      • P-value correction
      • Padovan n-step number sequences
      • Padovan sequence
      • Pairs with common factors
      • Palindrome dates
      • Palindrome detection
      • Palindromic gapful numbers
      • Palindromic primes
      • Palindromic primes in base 16
      • Pan base non-primes
      • Pancake numbers
      • Pandigital prime
      • Pangram checker
      • Paraffins
      • Parallel brute force
      • Parallel calculations
      • Parameterized SQL statement
      • Parametric polymorphism
      • Parse an IP Address
      • Parse command-line arguments
      • Parse EBNF
      • Parsing
        • RPN calculator algorithm
        • RPN to infix conversion
        • Shunting-yard algorithm
      • Partial function application
      • Particle fountain
      • Particle swarm optimization
      • Partition an integer x into n primes
      • Partition function P
      • Pascal's triangle
        • Puzzle
      • Pascal matrix generation
      • Password generator
      • Pathological floating point problems
      • Peaceful chess queen armies
      • Peano curve
      • Pell's equation
      • Pell numbers
      • Penholodigital squares
      • Penney's game
      • Penrose tiling
      • Penta-power prime seeds
      • Pentagram
      • Pentomino tiling
      • Percentage difference between images
      • Perceptron
      • Percolation
        • Bond percolation
        • Mean cluster density
        • Mean run density
        • Site percolation
      • Perfect numbers
      • Perfect shuffle
      • Perfect totient numbers
      • Periodic table
      • Peripheral drift illusion
      • Perlin noise
      • Permutation test
      • Permutations
        • Derangements
        • Rank of a permutation
      • Permutations by swapping
      • Permutations with repetitions
      • Permutations with some identical elements
      • Permuted multiples
      • Pernicious numbers
      • Phrase reversals
      • Pi
      • Pick random element
      • Pierpont primes
      • Pig the dice game
        • Player
      • Pinstripe
        • Display
        • Printer
      • Piprimes
      • Pisano period
      • Plasma effect
      • Playfair cipher
      • Playing cards
      • Plot coordinate pairs
      • Pointers and references
      • Poker hand analyser
      • Polymorphic copy
      • Polymorphism
      • Polynomial derivative
      • Polynomial long division
      • Polynomial regression
      • Polynomial synthetic division
      • Polyspiral
      • Population count
      • Posit numbers
        • Decoding
        • Encoding
      • Positive decimal integers with the digit 1 occurring exactly twice
      • Power set
      • Powerful numbers
      • Practical numbers
      • Pragmatic directives
      • Price fraction
      • Price list behind API
      • Primality by trial division
      • Primality by Wilson's theorem
      • Prime conspiracy
      • Prime decomposition
      • Prime numbers p for which the sum of primes less than or equal to p is prime
      • Prime numbers which contain 123
      • Prime numbers whose neighboring pairs are tetraprimes
      • Prime reciprocal sum
      • Prime triangle
      • Prime triplets
      • Prime words
      • Primes - allocate descendants to their ancestors
      • Primes n*2 m 1
      • Primes which contain only one odd digit
      • Primes whose first and last number is 3
      • Primes whose sum of digits is 25
      • Primes with digits in nondecreasing order
      • Primorial numbers
      • Print debugging statement
      • Print itself
      • Priority queue
      • Probabilistic choice
      • Problem of Apollonius
      • Process SMIL directives in XML data
      • Product of divisors
      • Product of min and max prime factors
      • Program name
      • Program termination
      • Proof
      • Proper divisors
      • Pseudo-random numbers
        • Combined recursive generator MRG32k3a
        • Middle-square method
        • PCG32
        • Splitmix64
        • Xorshift star
      • Pseudorandom number generator image
      • Pythagoras tree
      • Pythagorean quadruples
      • Pythagorean triples
    • Q
      • QR decomposition
      • Quad-power prime seeds
      • Quadrat special primes
      • Quaternion type
      • Queue
        • Definition
        • Usage
      • Quickselect algorithm
      • Quine
      • Quoting constructs
    • R
      • Radical of an integer
      • Railway circuit
      • Rainbow
      • Ramanujan's constant
      • Ramanujan primes
        • Twins
      • Ramer-Douglas-Peucker line simplification
      • Ramsey's theorem
      • Random Latin squares
      • Random number generator device
      • Random number generator included
      • Random numbers
      • Random sentence from book
      • Range consolidation
      • Range expansion
      • Range extraction
      • Range modifications
      • Ranking methods
      • Rare numbers
      • Raster bars
      • Rate counter
      • Ray-casting algorithm
      • RCRPG
      • Read a configuration file
      • Read a file character by character
        • UTF8
      • Read a file line by line
      • Read a specific line from a file
      • Read entire file
      • Readline interface
      • Real constants and functions
      • Recaman's sequence
      • Record sound
      • Recursive descent parser generator
      • Reduced row echelon form
      • Reflection
        • Get source
        • List methods
        • List properties
      • Regular expressions
      • Remove duplicate elements
      • Remove lines from a file
      • Remove vowels from a string
      • Rename a file
      • Rendezvous
      • Rep-string
      • Repeat
      • Repeat a string
      • Repunit primes
      • Resistance calculator
      • Resistance network calculator
      • Resistor mesh
      • Respond to an unknown method call
      • Retrieve and search chat history
      • Return multiple values
      • Reverse a string
      • Reverse the gender of a string
      • Reverse the order of lines in a text file while preserving the contents of each line
      • Reverse words in a string
      • Rhonda numbers
      • Rice coding
      • Riordan numbers
      • RIPEMD-160
      • Robots
      • Rock-paper-scissors
      • Rodrigues rotation formula
      • Roman numerals
        • Decode
        • Encode
      • Roots of a cubic polynomial
      • Roots of a function
      • Roots of a quadratic function
      • Roots of unity
      • Rosetta Code
        • Count examples
        • Find bare lang tags
        • Find unimplemented tasks
        • Fix code tags
        • List authors of task descriptions
        • Rank languages by number of users
        • Rank languages by popularity
        • Run examples
        • Tasks without examples
      • Rot-13
      • Round-robin tournament schedule
      • RPG attributes generator
      • RSA code
      • Run-length encoding
      • Run as a daemon or service
      • Runge-Kutta method
      • Runtime evaluation
        • In an environment
      • Ruth-Aaron numbers
    • S
      • S-expressions
      • Safe addition
      • Safe and Sophie Germain primes
      • Safe mode
      • Safe primes and unsafe primes
      • Sailors coconuts and a monkey problem
      • Same fringe
      • Sanitize user input
      • Sattolo cycle
      • Scope
        • Function names and labels
      • Scope modifiers
      • Sealed classes and methods
      • Search a list
      • Search a list of records
      • Search in paragraph's text
      • Secure temporary file
      • SEDOLs
      • Segmentation fault protection
      • Selection bias in clinical sciences
      • Selective file copy
      • Selectively replace multiple instances of a character within a string
      • Self-describing numbers
      • Self-hosting compiler
      • Self numbers
      • Semiprime
      • Semordnilap
      • Send an unknown method call
      • Send email
      • SEND MORE MONEY
      • Separate the house number from the street name
      • Sequence nth number with exactly n divisors
      • Sequence of non-squares
      • Sequence of primes by trial division
      • Sequence of primorial primes
      • Sequence smallest number greater than previous term with exactly n divisors
      • Sequence smallest number with exactly n divisors
      • Set
      • Set consolidation
      • Set of real numbers
      • Set puzzle
      • Set right-adjacent bits
      • Set the card game
      • Seven-sided dice from five-sided dice
      • Sexy primes
      • SHA-1
      • SHA-256
      • SHA-256 Merkle tree
      • Shell one-liner
      • Shift list elements to left by 3
      • Shoelace formula for polygonal area
      • Short-circuit evaluation
      • Shortest common supersequence
      • Show ASCII table
      • Show the decimal value of a number of 1s appended with a 3 then squared
      • Show the epoch
      • Sierpinski arrowhead curve
      • Sierpinski carpet
      • Sierpinski curve
      • Sierpinski pentagon
      • Sierpinski square curve
      • Sierpinski triangle
        • Graphical
      • Sieve of Eratosthenes
      • Sieve of Pritchard
      • Simple database
      • Simple windowed application
      • Simulate input
        • Keyboard
        • Mouse
      • Simulated annealing
      • Sine wave
      • Singleton
      • Singly-linked list
        • Element definition
        • Element insertion
        • Element removal
        • Reversal
        • Traversal
      • Singular value decomposition
      • Sisyphus sequence
      • Sleep
      • Sleeping Beauty problem
      • Smallest enclosing circle problem
      • Smallest multiple
      • Smallest number k such that k 2 m is composite for all m less than k
      • Smallest numbers
      • Smallest power of 6 whose decimal expansion contains n
      • Smallest square that begins with n
      • Smarandache-Wellin primes
      • Smarandache prime-digital sequence
      • Smith numbers
      • Snake
      • Snake and ladder
      • SOAP
      • Sockets
      • Sokoban
      • Soloway's recurring rainfall
      • Solve a Hidato puzzle
      • Solve a Holy Knight's tour
      • Solve a Hopido puzzle
      • Solve a Numbrix puzzle
      • Solve a Rubik's cube
      • Solve equations with substitution method
      • Solve hanging lantern problem
      • Solve the no connection puzzle
      • Solve triangle solitaire puzzle
      • Sorensen Dice coefficient
      • Sort a list of object identifiers
      • Sort an array of composite structures
      • Sort an integer array
      • Sort an outline at every level
      • Sort disjoint sublist
      • Sort numbers lexicographically
      • Sort primes from list to a list
      • Sort stability
      • Sort the letters of string in alphabetical order
      • Sort three variables
      • Sort using a custom comparator
      • Sorting algorithms
        • Bead sort
        • Bogosort
        • Bubble sort
        • Circle Sort
        • Cocktail sort
        • Cocktail sort with shifting bounds
        • Comb sort
        • Counting sort
        • Cycle sort
        • Gnome sort
        • Heapsort
        • Insertion sort
        • Merge sort
        • Pancake sort
        • Patience sort
        • Permutation sort
        • Quicksort
        • Radix sort
        • Selection sort
        • Shell sort
        • Sleep sort
        • Stooge sort
        • Strand sort
        • Tree sort on a linked list
      • Soundex
      • Sparkline in unicode
      • Special characters
      • Special divisors
      • Special factorials
      • Special neighbor primes
      • Special pythagorean triplet
      • Special variables
      • Speech synthesis
      • Spelling of ordinal numbers
      • Sphenic numbers
      • Spinning rod animation
        • Text
      • Spiral matrix
      • Split a character string based on change of character
      • Spoof game
      • SQL-based authentication
      • Square-free integers
      • Square but not cube
      • Square form factorization
      • Square root by hand
      • Stable marriage problem
      • Stack
      • Stack traces
      • Stair-climbing puzzle
      • Start from a main routine
      • Starting a web browser
      • State name puzzle
      • Statistics
        • Basic
        • Chi-squared distribution
        • Normal distribution
      • Steady squares
      • Steffensen's method
      • Stem-and-leaf plot
      • Stern-Brocot sequence
      • Stirling numbers of the first kind
      • Stirling numbers of the second kind
      • Straddling checkerboard
      • Strange numbers
      • Strange plus numbers
      • Strange unique prime triplets
      • Strassen's algorithm
      • Stream merge
      • String append
      • String case
      • String comparison
      • String concatenation
      • String interpolation included
      • String length
      • String matching
      • String prepend
      • Strip a set of characters from a string
      • Strip block comments
      • Strip comments from a string
      • Strip control codes and extended characters from a string
      • Strip whitespace from a string
        • Top and tail
      • Strong and weak primes
      • Sturmian word
      • Sub-unit squares
      • Subleq
      • Subset sum problem
      • Substitution cipher
      • Substring
        • Top and tail
      • Substring primes
      • Subtractive generator
      • Successive prime differences
      • Sudan function
      • Sudoku
      • Suffix tree
      • Suffixation of decimal numbers
      • Sum and product of an array
      • Sum and product puzzle
      • Sum data type
      • Sum digits of an integer
      • Sum multiples of 3 and 5
      • Sum of a series
      • Sum of divisors
      • Sum of elements below main diagonal of matrix
      • Sum of first n cubes
      • Sum of primes in odd positions is prime
      • Sum of square and cube digits of an integer are primes
      • Sum of squares
      • Sum of the digits of n is substring of n
      • Sum of two adjacent numbers are primes
      • Sum to 100
      • Summarize and say sequence
      • Summarize primes
      • Summation of primes
      • Sunflower fractal
      • Super-d numbers
      • Super-Poulet numbers
      • Superellipse
      • Superpermutation minimisation
      • Sutherland-Hodgman polygon clipping
      • Sylvester's sequence
      • Symmetric difference
      • Sync subtitles
      • Synchronous concurrency
      • System time
      • Szymański's algorithm
    • T
      • Table creation
        • Postal addresses
      • Take notes on the command line
      • Tarjan
      • Tau function
      • Tau number
      • Taxicab numbers
      • Teacup rim text
      • Temperature conversion
      • Terminal control
        • Clear the screen
        • Coloured text
        • Cursor movement
        • Cursor positioning
        • Dimensions
        • Display an extended character
        • Hiding the cursor
        • Inverse video
        • Positional read
        • Preserve screen
        • Restricted width positional input
          • No wrapping
          • With wrapping
        • Ringing the terminal bell
        • Unicode output
      • Ternary logic
      • Test a function
      • Test integerness
      • Text between
      • Text completion
      • Text processing
        • 1
        • 2
        • Max licenses in use
      • Text to HTML
      • Textonyms
      • The ISAAC cipher
      • The Name Game
      • The sieve of Sundaram
      • The Twelve Days of Christmas
      • Thiele's interpolation formula
      • Three word location
      • Thue-Morse
      • Tic-tac-toe
      • Time-based one-time password algorithm
      • Time a function
      • Tokenize a string
      • Tokenize a string with escaping
      • Tonelli-Shanks algorithm
      • Top rank per group
      • Topic variable
      • Topological sort
        • Extracted top item
      • Topswops
      • Total circles area
      • Totient function
      • Towers of Hanoi
      • Trabb Pardo Knuth algorithm
      • Transliterate English text using the Greek alphabet
      • Transportation problem
      • Tree datastructures
      • Tree from nesting levels
      • Tree traversal
      • Triangular numbers
      • Trigonometric functions
      • Triplet of three numbers
      • Tropical algebra overloading
      • Truncatable primes
      • Truncate a file
      • Truth table
      • Twelve statements
      • Twin primes
      • Two's complement
      • Two bullet roulette
      • Two identical strings
      • Two sum
      • Type detection
    • U
      • Ulam numbers
      • Ulam spiral for primes
      • Ultra useful primes
      • Unbias a random generator
      • Undefined values
      • Undulating numbers
      • Unicode strings
      • Unicode variable names
      • Unique characters
      • Unique characters in each string
      • Unit testing
      • Universal Turing machine
      • Unix
        • Ls
      • Unprimeable numbers
      • Untouchable numbers
      • Untrusted environment
      • UPC
      • Update a configuration file
      • Upside-down numbers
      • URL decoding
      • URL encoding
      • URL parser
      • URL shortener
      • Use another language to call a function
      • Useless instructions
      • User defined pipe and redirection operators
      • User input
        • Graphical
        • Text
      • Using a speech engine to highlight words
      • UTF-8 encode and decode
    • V
      • Validate International Securities Identification Number
      • Vampire number
      • Van der Corput sequence
      • Van Eck sequence
      • Variable-length quantity
      • Variable declaration reset
      • Variable size
        • Get
        • Set
      • Variables
      • Variadic function
      • Vector
      • Vector products
      • Verhoeff algorithm
      • Verify distribution uniformity
        • Chi-squared test
        • Naive
      • Vibrating rectangles
      • Video display modes
      • Vidir
      • Vigenère cipher
        • Cryptanalysis
      • Visitor pattern
      • Visualize a tree
      • VList
      • Vogel's approximation method
      • Voronoi diagram
    • W
      • Wagstaff primes
      • Walk a directory
        • Non-recursively
        • Recursively
      • Walsh matrix
      • War card game
      • Wasteful equidigital and frugal numbers
      • Water collected between towers
      • Wave function collapse
      • Waveform analysis
        • Doh ray me
      • Web scraping
      • Weird numbers
      • Welch's t-test
      • Wieferich primes
      • WiktionaryDumps to words
      • Wilson primes of order n
      • Window creation
        • X11
      • Window management
      • Wireworld
      • Wolstenholme numbers
      • Word break problem
      • Word frequency
      • Word ladder
      • Word search
      • Word wheel
      • Word wrap
      • Wordiff
      • Wordle comparison
      • Words containing the substring
      • Words from neighbour ones
      • World Cup group stage
      • Worthwhile task shaving
      • Write entire file
      • Write float arrays to a text file
      • Write language name in 3D ASCII
      • Write to Windows event log
    • X
      • Xiaolin Wu's line algorithm
      • XML
        • DOM serialization
        • Input
        • Output
        • XPath
      • XML validation
      • XXXX redacted
    • Y
      • Y combinator
      • Yahoo search interface
      • Yellowstone sequence
      • Yin and yang
    • Z
      • Zebra puzzle
      • Zeckendorf arithmetic
      • Zeckendorf number representation
      • Zero to the zero power
      • Zhang-Suen thinning algorithm
      • Zig-zag matrix
      • Zsigmondy numbers
      • Zumkeller numbers
  • The End
Powered by GitBook
On this page

Was this helpful?

  1. Programming tasks
  2. R

Range extraction

sub range-extraction (*@ints) {
    my $prev = NaN;
    my @ranges;

    for @ints -> $int {
        if $int == $prev + 1 {
            @ranges[*-1].push: $int;
        }
        else {
            @ranges.push: [$int];
        }
        $prev = $int;
    }
    join ',', @ranges.map: -> @r { @r > 2 ?? "@r[0]-@r[*-1]" !! @r }
}

say range-extraction
    -6, -3, -2, -1, 0, 1, 3, 4, 5, 7, 8, 9, 10, 11, 14, 15, 17, 18, 19, 20;

say range-extraction
    0,  1,  2,  4,  6,  7,  8, 11, 12, 14,
    15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
    25, 27, 28, 29, 30, 31, 32, 33, 35, 36,
    37, 38, 39;

Output:

-6,-3-1,3-5,7-11,14,15,17-20
0-2,4,6-8,11,12,14-25,27-33,35-39
PreviousRange expansionNextRange modifications

Last updated 1 year ago

Was this helpful?