Skip to main content
3 of 3
-1 byte (ngn)

Dyalog APL, 41 39 38 bytes

↑{⌽(⌽,⊃,A↑⊢)⍵↑A⍴' vibgyor'}¨-⍳A←⌈⎕×8÷7 

Try it online!

A similar approach to others: A←⌈⎕×8÷7 finds the height of the rainbow (also the width of the longest 'half row' to the left/right of the centre) and assigns it to A for later use, while ¨-⍳ iterates through the values 1..A, negating them to select on the correct side when used with .

A⍴' vibgyor' generates a 'half row' and ⍵↑ selects the correct length substring. (⌽,⊃,A↑⊢) generates the full row in reverse (which takes fewer characters to do), starting with a reversed half row (), then the centre character taken from the beginning of the half row string () and finally a right padded version of the half row (A↑⊢). The final reverses the row into the correct orientation and turns the vector of rows into a 2D array.

Edit: -2 thanks to dzaima

Edit: -1 thanks to ngn