Rotate Matrix 90° Clockwise
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
| A | B | C | D | E | F | G | H | |
|---|---|---|---|---|---|---|---|---|
| 1 | 165 | 77 | 202 | 24 | 37 | 48 | 187 | 29 |
| 2 | 109 | 19 | 44 | 222 | 214 | 35 | 123 | 46 |
| 3 | 217 | 30 | 63 | 114 | 31 | 203 | 25 | 113 |
| 4 | 23 | 68 | 148 | 214 | 73 | 60 | 157 | 92 |
| 5 | 52 | 96 | 190 | 49 | 32 | 30 | 105 | 254 |
| 6 | 218 | 160 | 238 | 232 | 185 | 153 | 127 | 92 |
| 7 | 124 | 41 | 153 | 253 | 175 | 229 | 147 | 37 |
| 8 | 60 | 214 | 84 | 175 | 77 | 250 | 215 | 20 |
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))) )