Patterns coding challenges

Practise patterns with 24 coding challenges, from easy to hard. Every challenge runs in your browser with instant tests, an AI review of your code and community solutions to compare.

Easy · 14 Medium · 10

Skills you'll practise: Nested loopsPaddingSymmetryConditionsGrid coordinatesParityString patternsBuilding stringsCase analysisCharacter codesCounters across rowsCounting down
  • Python · C++ · C#
  • Automated tests
  • AI code review
  • Community solutions
341
Challenges
245
Solutions shared
9
Languages

All challenges

Search by name or topic, or filter by difficulty.

24 challenges
Easy

Number Triangle

Build a triangle of increasing numbers.

You'll learn Growing rowsCounters across rows
BeginnerLearning-pathNested-loopsPatterns
Easy

Pyramid Rows

Draw a right-aligned pyramid of # blocks.

You'll learn String patternsPadding
BeginnerLearning-pathNested-loopsPatterns
Easy

Hollow Square

Draw the outline of a square with * characters.

You'll learn Edge detectionBuilding strings
BeginnerLearning-pathNested-loopsPatterns
Medium

Number Spiral Lookup

Find a value by row and column in an expanding number spiral.

You'll learn Math patternsCase analysis
Patternsmath
Medium

Decode the Pattern

Work out the rule behind a family of letter squares from its first members, then build the member for any n.

You'll learn Pattern analysisGrid coordinates
CS1High schoolIntermediateLoopsNested-loopsPatterns
No solutions yet
Easy

Checkerboard Pattern

Draw a checkerboard of # and . cells with the given number of rows and columns.

You'll learn Nested loopsParity
BeginnerCS1GridsHigh schoolLoopsMatricesNested-loopsPatterns
No solutions yet
Medium

Diamond Pattern

Print a solid diamond of stars made of a pyramid and its mirror image.

You'll learn Nested loopsSymmetry
CS1High schoolIntermediateLoopsNested-loopsPatterns
No solutions yet
Easy

Binary Triangle

Print a right triangle of alternating 1s and 0s where each row starts with the opposite digit of the row above.

You'll learn Nested loopsParity
BeginnerBit manipulationCS1High schoolLoopsNested-loopsPatterns
No solutions yet
Easy

Inverted Pyramid

Print a centered pyramid of stars upside down, with the widest row on top.

You'll learn Nested loopsPadding
BeginnerCS1High schoolLoopsNested-loopsPatterns
No solutions yet
Medium

Hollow Diamond

Print the outline of a diamond: only the first and last star of each row.

You'll learn Nested loopsEdge cases
CS1High schoolIntermediateLoopsNested-loopsPatterns
No solutions yet
Easy

Right Triangle of Stars

Print the classic right triangle of stars: one star on the first row, n on the last.

You'll learn Nested loopsString patterns
BeginnerCS1High schoolLoopsNested-loopsPatterns
No solutions yet
Medium

Butterfly Pattern

Print a butterfly: two star triangles facing each other that grow until they touch, then shrink again.

You'll learn Nested loopsSymmetry
CS1High schoolIntermediateLoopsNested-loopsPatterns
No solutions yet
Medium

Palindromic Number Pyramid

Print a centered pyramid where each row counts up to its row number and back down.

You'll learn Nested loopsPalindromes
CS1High schoolIntermediateLoopsNested-loopsPalindromesPatterns
No solutions yet
Easy

Centered Star Pyramid

Print a centered pyramid of stars with an odd number of stars on each row.

You'll learn Nested loopsPadding
BeginnerCS1High schoolLoopsNested-loopsPatterns
No solutions yet
Medium

Zigzag Wave Pattern

Draw a zigzag line of stars that bounces between the top and bottom rows of a grid.

You'll learn GridsModular arithmetic
CS1High schoolIntermediateLoopsNested-loopsPatterns
No solutions yet
Easy

Inverted Right Triangle

Print a right triangle upside down: n stars on the first row, one on the last.

You'll learn Nested loopsCounting down
BeginnerCS1High schoolLoopsNested-loopsPatterns
No solutions yet
Easy

X Pattern

Draw both diagonals of an n by n square with stars to form an X.

You'll learn Nested loopsGrid coordinates
BeginnerCS1High schoolLoopsNested-loopsPatterns
No solutions yet
Medium

Number Diamond

Print a diamond whose rows count up from 1 to a peak and back down.

You'll learn Nested loopsSymmetry
CS1High schoolIntermediateLoopsNested-loopsPatterns
No solutions yet