High school coding challenges

Practise high school with 50 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 · 28 Medium · 22

Skills you'll practise: Nested loopsSymmetryDigit sumPaddingRecurrencesSieve of EratosthenesSquare root boundBit shiftsConditionsDigit extractionDivisor pairsEdge cases
  • Python · C++ · C#
  • Automated tests
  • AI code review
  • Community solutions
341
Challenges
241
Solutions shared
9
Languages

All challenges

Search by name or topic, or filter by difficulty.

50 challenges
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
Medium

Integer to Roman

Write a whole number from 1 to 3999 as a Roman numeral.

You'll learn Greedy algorithmsLookup tables
CS1High schoolIntermediateLoopsNumbersmath
No solutions yet
Medium

Hourglass Pattern

Print an hourglass of stars: an inverted pyramid on top of an upright one, sharing the single-star waist.

You'll learn Nested loopsSymmetry
CS1High schoolIntermediateLoopsNested-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
Medium

Catalan Numbers

List the Catalan numbers C(0) to C(n).

You'll learn Dynamic programmingRecurrences
CS1Dynamic-programmingHigh schoolIntermediateLoopsNumbersmath
No solutions yet
Easy

Count Primes in a Range

Count how many prime numbers lie between two bounds, both included.

You'll learn Sieve of EratosthenesRange counting
BeginnerCS1High schoolLoopsNumber-theoryNumbersPrimesmath
No solutions yet
Easy

Automorphic Number

Check whether the square of a number ends with the number itself.

You'll learn Digit comparisonPowers of ten
BeginnerCS1High schoolLoopsNumbersmath
No solutions yet
Easy

Binomial Coefficient

Count the ways to choose k items out of n (n choose k).

You'll learn Pascal's triangleOverflow-safe arithmetic
BeginnerCS1High schoolLoopsNumbersmath
No solutions yet
Medium

Double Staircase

Print two staircases of # blocks that face each other across a two-space gap.

You'll learn Nested loopsPadding
CS1CS50 styleHigh schoolIntermediateLoopsNested-loopsPatterns
No solutions yet
Easy

Happy Number

Decide whether repeatedly summing the squares of the digits of a number reaches 1.

You'll learn Digit extractionCycle detection
BeginnerCS1High schoolLoopsNumbersmath
No solutions yet
Medium

Nth Prime

Return the nth prime number, counting 2 as the first.

You'll learn Prime testingSieve of Eratosthenes
CS1High schoolIntermediateLoopsNumber-theoryNumbersPrimesmath
No solutions yet
Medium

Modular Exponentiation

Compute base to the power exponent, modulo a number, with fast exponentiation.

You'll learn Exponentiation by squaringModular arithmetic
CS1High schoolIntermediateLoopsNumber-theoryNumbersPrimesmath
No solutions yet
Medium

Derangements

Count the arrangements of n items where nothing stays in its original place.

You'll learn RecurrencesCombinatorics
CS1Dynamic-programmingHigh schoolIntermediateLoopsNumbersmath
No solutions yet
Easy

Strong Number

Check whether a number equals the sum of the factorials of its digits.

You'll learn Digit extractionFactorials
BeginnerCS1High schoolLoopsNumbersmath
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
Easy

Floyd's Triangle

Build Floyd's triangle: the counting numbers written in rows of length 1, 2, 3 and so on.

You'll learn Nested loopsRunning counters
BeginnerCS1High schoolLoopsNested-loopsPatternsShortest-path
No solutions yet
Easy

Alphabet Triangle

Print a right triangle of letters where row i spells the first i letters of the alphabet.

You'll learn Nested loopsCharacter codes
BeginnerCS1High schoolLoopsNested-loopsPatterns
No solutions yet
Easy

Spy Number

Check whether the sum of a number's digits equals the product of its digits.

You'll learn Digit sumDigit product
BeginnerCS1High schoolLoopsNumbersmath
No solutions yet