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
Easy

Twin Primes

List all twin prime pairs (p, p + 2) up to a limit.

You'll learn Sieve of EratosthenesPairing neighbours
BeginnerCS1High schoolLoopsNumber-theoryNumbersPrimesmath
No solutions yet
Easy

Harshad Number

Check whether a number is divisible by the sum of its digits (a Harshad or Niven number).

You'll learn Digit sumDivisibility
BeginnerCS1High schoolLoopsNumbersmath
No solutions yet
Easy

Tribonacci

Return the nth tribonacci number, where each term is the sum of the three before it.

You'll learn LoopsRolling variables
BeginnerCS1High schoolLoopsNumbersmath
No solutions yet
Easy

Neon Number

Check whether the digit sum of a number's square equals the number.

You'll learn Digit sumSquaring
BeginnerCS1High schoolLoopsNumbersmath
No solutions yet
Medium

Kaprekar Number

Check whether the square of a d-digit number splits into a left part and a d-digit right part that add up to the number.

You'll learn Splitting numbersPowers of ten
CS1High schoolIntermediateLoopsNumbersmath
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
Easy

Disarium Number

Check whether a number equals the sum of its digits raised to their positions.

You'll learn Digit positionsInteger powers
BeginnerCS1High schoolLoopsNumbersmath
No solutions yet
Medium

Number to Words

Spell a whole number in English words, such as "one hundred twenty-three".

You'll learn Lookup tablesDecomposing numbers
CS1High schoolIntermediateLoopsNumbersmath
No solutions yet
Easy

Abundant, Perfect or Deficient

Classify a number as abundant, perfect or deficient by the sum of its proper divisors.

You'll learn Divisor pairsSquare root bound
BeginnerCS1High schoolLoopsNumber-theoryNumbersPrimesmath
No solutions yet
Easy

Lucas Numbers

Return the nth Lucas number, the Fibonacci-like sequence that starts 2, 1.

You'll learn LoopsRecurrences
BeginnerCS1High schoolLoopsNumbersmath
No solutions yet
Easy

Sum of Proper Divisors

Add up every divisor of n that is smaller than n.

You'll learn Divisor pairsSquare root bound
BeginnerCS1High schoolLoopsNumber-theoryNumbersPrimesmath
No solutions yet
Medium

Euler's Totient

Count the integers from 1 to n that share no common factor with n.

You'll learn Prime factorizationProduct formula
CS1High schoolIntermediateLoopsNumber-theoryNumbersPrimesmath
No solutions yet
Easy

Hollow Pyramid

Print the outline of a centered pyramid: its two slanted sides and a solid base.

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

Hollow Right Triangle

Print only the outline of a right triangle of stars.

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