← All challenges

Rotate Matrix 90° Clockwise

Matrix ★☆☆☆

Rotate an 8×8 grayscale image (intensity values 0–255) 90 degrees clockwise.

A1:H8 is an 8×8 grayscale image — each cell holds a pixel intensity from 0 (black) to 255 (white). Output the same image rotated 90° clockwise: the first row of the result is the first column of the input read bottom-to-top, and so on.

Enter your answer as 8 rows on separate lines, with values separated by tabs, commas, or semicolons.

Input

Range A1:H8

ABCDEFGH
1 1657720224374818729
2 10919442222143512346
3 21730631143120325113
4 2368148214736015792
5 5296190493230105254
6 21816023823218515312792
7 1244115325317522914737
8 60214841757725021520
Hint

MAKEARRAY lets you build the result by indexing the source: cell (r, c) of the rotated matrix comes from (cols - c + 1, r) of the source.

Solution
=LET(
  arr, A1:H8,
  ros, ROWS(arr),
  cols, COLUMNS(arr),
  MAKEARRAY(ros, cols, LAMBDA(r,c, INDEX(arr, c*-1+cols+1, r)))
)