Matrices coding challenges

Practise matrices with 8 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 · 2 Medium · 5 Hard · 1

Skills you'll practise: 2D grid traversal2D arrays2D boolean gridsBit shiftingBounds checkingConvolution kernelsDirection vectorsInteger roundingMap keysNeighbor offsetsNeighborhood loopsNested loops
  • 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.

8 challenges
Medium

Largest Product in a Grid

Find the largest product of k numbers in a straight line in a grid.

You'll learn 2D grid traversalDirection vectors
Competitive-programmingDynamic-programmingGridsIntermediateMatricesNumber-theoryProject Euler stylemath
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
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
Easy

Mirror an Image

Flip a pixel grid left to right, like the mirror button in a photo app.

You'll learn 2D arraysReversing a list
BeginnerCS1CS50 styleGridsHomeworkImage processingIntro programmingMatricesStudent-beginner
No solutions yet
Medium

Sparse Grid

Keep a mostly empty grid as a list of its non-zero cells and answer get, count, row sum and column removal operations.

You'll learn Sparse storageMap keys
AP Computer ScienceCS1ClassesGridsHomeworkIntermediateIntro programmingMatricesOOPStudent-beginner
No solutions yet
Medium

Grayscale Filter

Turn a grid of packed RGB pixels into grayscale using weighted channel brightness.

You'll learn Bit shiftingInteger rounding
Bit manipulationCS1CS50 styleGridsHomeworkImage processingIntermediateIntro programmingMatricesStudent-beginner
No solutions yet
Medium

Box Blur

Blur a grayscale image by replacing each pixel with the rounded average of its 3 by 3 neighborhood.

You'll learn Neighborhood loopsBounds checking
CS1CS50 styleGridsHomeworkImage processingIntermediateIntro programmingMatricesStudent-beginner
No solutions yet
Medium

Light Board

Simulate a board of lights where pressing one flips it and its neighbors, and answer count queries.

You'll learn 2D boolean gridsNeighbor offsets
AP Computer ScienceCS1ClassesGridsHomeworkIntermediateIntro programmingMatricesOOPStudent-beginner
No solutions yet