Cs1 coding challenges

Practise cs1 with 90 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 · 52 Medium · 36 Hard · 2

Skills you'll practise: Nested loopsSymmetryDigit extractionDigit sumEdge casesLookup tablesPaddingRecurrencesSieve of EratosthenesSquare root bound2D arraysBit shifts
  • 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.

90 challenges
Easy

Integer Square Root

Find the largest whole number whose square does not exceed n, without a square root function.

You'll learn Binary searchInteger overflow
BeginnerBinary-searchCS1High schoolLoopsNumbersmath
No solutions yet
Easy

Perfect Square Check

Decide whether an integer is the square of a whole number.

You'll learn Integer square rootEdge cases
BeginnerCS1High schoolLoopsNumbersmath
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

Step Tracker Class

Simulate a step tracker object: record daily steps and answer total, active day, average and best day queries.

You'll learn Object stateRunning statistics
AP Computer ScienceCS1ClassesHomeworkIntermediateIntro programmingOOPStudent-beginner
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
Easy

Driving Costs

Work out the fuel cost of several trips from a car's miles per gallon and the gas price.

You'll learn Arithmetic expressionsLoops over a list
BeginnerCS1FinanceHomeworkIntro programmingStudent-beginner
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
Medium

Plurality Election

Count one vote per voter and return every candidate with the most votes.

You'll learn Counting with mapsFinding all maxima
CS1CS50 styleHomeworkIntermediateIntro programmingSortingStudent-beginnerVoting
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

Vowel Counter by Position

List the positions of every a, e, i, o and u in a piece of text.

You'll learn String indexingCase-insensitive comparison
BeginnerCS1HomeworkIntro programmingStudent-beginner
No solutions yet
Easy

Base Converter

Convert a number written in one base (2 to 36) to another base.

You'll learn Positional notationRepeated division
BeginnerCS1High schoolLoopsNumbersmath
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

Runoff Election

Run an instant runoff election on ranked ballots, eliminating the weakest candidates round by round.

You'll learn Simulation in rounds2D arrays
CS1CS50 styleHomeworkIntermediateIntro programmingSortingStudent-beginnerVoting
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

Word Scramble

Scramble words by swapping each vowel with the consonant right after it, scanning left to right.

You'll learn Character scanningSwapping
AP Computer ScienceBeginnerCS1ClassesGamesHomeworkIntro programmingOOPStudent-beginner
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
Hard

Edge Detection (Sobel Filter)

Run the Sobel filter over a grayscale pixel grid and return the edge strength of every pixel.

You'll learn 2D grid traversalConvolution kernels
AdvancedCS1CS50 styleGridsHomeworkImage processingIntro programmingMatricesStudent-beginner
No solutions yet
Medium

DNA Short Tandem Repeats

For each short tandem repeat, find the longest run of back-to-back copies in a DNA sequence.

You'll learn Substring matchingLongest run counting
CS1CS50 styleHomeworkIntermediateIntro programmingStudent-beginner
No solutions yet