[Question]
  [
# Challenge
Consider the rainbow as seven colours, represented by strings as `Red Orange Yellow Green Blue Indigo Violet`.  
Your task is to create a program that receives one of these colours as input and outputs next in order rainbow colour. This includes overlapping `Violet -> Red`
# Input
A string containing one of rainbow colours.
# Output
The next in order colour of the rainbow.
# Rules
* Colour names are case sensitive. They must match the case included in this post.
* The input will always be valid. Any behavior is allowed for invalid input.
* This is code golf, so the shortest amount of bytes wins!
# Example Input and Output
```
Input -> Output
Red -> Orange
Orange -> Yellow
Yellow -> Green
Green -> Blue
Blue -> Indigo
Indigo -> Violet
Violet -> Red
```
  
[Answer]
# JavaScript, 68 bytes
```
s=>'RedOrangeYellowGreenBlueIndigoVioletRed'.match(s+'(.[a-z]*)')[1]
```
For input `"Red"`, this function first construct an RegExp `/Red(.[a-z]*)/` to match the string `'RedOrangeYellowGreenBlueIndigoVioletRed'` and then return the first capture result.
```
f=
s=>'RedOrangeYellowGreenBlueIndigoVioletRed'.match(s+'(.[a-z]*)')[1]
document.write('<table><tr><th>Input<th>Output')
for(i='Red';;){
document.write(`<tr><td>${i}<td>${i=f(i)}`);
if(i=='Red')break;
}
```
[Answer]
# [Perl 5](https://www.perl.org/) `-p`, ~~58~~ 57 bytes
```
#!/usr/bin/perl -p
$_={(Red,Orange,Yellow,Green,Blue,Indigo,Violet)x2}->{$_}
```
[Try it online!](https://tio.run/##K0gtyjH9/18l3rZaIyg1Rce/KDEvPVUnMjUnJ79cx70oNTVPxymnNFXHMy8lMz1fJywzPye1RLPCqFbXrlolvvb/f4jIv/yCksz8vOL/ugX/dX1N9QwN9AwA "Perl 5 ‚Äì Try It Online")
Now that the challenge has been changed to be cyclic the regex solution
```
say RedOrangeYellowGreenBlueIndigoVioletRed=~/$_(.[a-z]+)/
```
isn't optimal anymore (due to the double `Red`)
Also 57 bytes:
```
#!/usr/bin/perl -p
$_=(Indigo,Blue,Violet,Yellow,Orange,Red,Green)[ord>>2&7]
```
[Try it online!](https://tio.run/##K0gtyjH9/18l3lbDMy8lMz1fxymnNFUnLDM/J7VEJzI1Jye/XMe/KDEvPVUnKDVFx70oNTVPMzq/KMXOzkjNPPb/f6Dov/yCksz8vOL/ugX/dX1N9QwN9AwA "Perl 5 ‚Äì Try It Online")
[Answer]
# [Python](https://docs.python.org/2/), 79 bytes
```
z="Red Orange Yellow Green Blue Indigo Violet".split()*2
dict(zip(z,z[1:])).get
```
[Try it online!](https://tio.run/##ncyxCsIwEADQvV9xdGkisWDHQh1cxElwEEQcxFziQbiEeGLMz8d/8H3AS195Rp5aq0t/QgvHfGePcMEQ4gf2GZFhF94IB7bkI5wpBpR@fKVAovRq6txi6SGqUlLV1Otmvmk9epTmYoYCxPBPPHeQMrFAMcN6Oxinim4/ "Python 2 ‚Äì Try It Online")
Handles `Violet -> Red`. The desired function is given anonymously in the second line.
---
**80 bytes**
```
lambda x:"Red Orange Yellow Green Blue Indigo Violet Red".split(x)[1].split()[0]
```
[Try it online!](https://tio.run/##K6gsycjPM/qfZhvzPycxNyklUaHCSikoNUXBvygxLz1VITI1Jye/XMG9KDU1T8EppzRVwTMvJTM9XyEsMz8ntUQBqFRJr7ggJ7NEo0Iz2jAWytaMNoj9n5ZfpFChkJmnQIKBMMM0rbgUCooy80oUKnTUde3UddKA5v8HAA "Python 2 ‚Äì Try It Online")
[Answer]
# [Perl 6](https://github.com/nxadm/rakudo-pkg), 56 bytes
```
{<Indigo Blue Violet Yellow Orange Red Green>[.ord/4%8]}
```
[Try it online!](https://tio.run/##K0gtyjH7n1upoJamYPu/2sYzLyUzPV/BKac0VSEsMz8ntUQhMjUnJ79cwb8oMS89VSEoNUXBvSg1Nc8uWi@/KEXfRNUitvZ/cWKlgpJKvIKtnUJ1moZKvGatkkJafpGCDUg5VCfUHLBmiAVQyyD22P0HAA "Perl 6 ‚Äì Try It Online")
Exploits the fact that bits 2-4 of the ASCII codes of each color's first letter happen to map to 0-6.
```
say map (*.ord +> 2) % 8, <R O Y G B I V>
# (4 3 6 1 0 2 5)
```
Here's a nice non-competing solution that uses "purple" instead of "indigo" and "violet" (38 chars, 59 bytes):
```
{'üçéüß°üíõüíöüíôüíúüçé'.uninames~~m/$^a.\S+.<(\S+/}
```
[Try it online!](https://tio.run/##K0gtyjH7n1upoJamYPu/Wv3D/N6@D/OXL/wwf9JsIJ4FxDOBeA5IXF2vNC8zLzE3tbiuLldfJS5RLyZYW89GA0jq1/4vTqxUUFKJV7C1U6hO01CJ16xVUkjLL1KwCXJ1UfAPcvRzd1WIdPXx8Q9XcA9ydfVTcPIJdVUICA0K8HG1@w8A "Perl 6 ‚Äì Try It Online")
[Answer]
# [Ruby](https://www.ruby-lang.org/) `-n`, ~~62~~ 60 bytes
-2 by Asone Tuhid.
```
p"RedVioletIndigoBlueGreenYellowOrangeRed"[/.[a-z]+(?=#$_)/]
```
[Try it online!](https://tio.run/##KypNqvz/v0ApKDUlLDM/J7XEMy8lMz3fKac01b0oNTUvMjUnJ7/cvygxLz0VqEYpWl8vOlG3KlZbw95WWSVeUz/2/3@g@L/8gpLM/Lzi/7p5AA "Ruby ‚Äì Try It Online")
Regex approach looks promising for Ruby too. However, I arrived at a shorter solution using a lookahead and directly printing the match, rather than playing with capturing groups. The list of colors is in reverse direction since lookahead is 1 byte cheaper than lookbehind.
[Answer]
# [Red](http://www.red-lang.org), 87 bytes
```
func[c][print first find/tail[Red Orange Yellow Green Blue Indigo Violet Red]to-word c]
```
[Try it online!](https://tio.run/##JcwxCsMwDEDRPacQ3kP3jl1Kp0CHQjEegi0Hg5CK6pDjO468SB8hnmJqb0w@TPne8s7Rx@B/WrhCLvq/JqdbXQv5/gaLrrwhfJFIDngqIsODdoQXp7IJfIoQVuivocp8iCaIoWVw/eKmvgdgORBLg6wuzGKAlgN17QQ "Red ‚Äì Try It Online")
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E), 30 bytes
```
‚Äú‚Ä†¬æ‚Ä∫√à≈†√õÀÜ¬®‚Ä°‚Äî√´√üigo¬∞√çolet‚Äú#‚Ñ¢DIk>√®
```
[Try it online!](https://tio.run/##MzBNTDJM/f//UcOcRw0LDu171LDrcMfRBYdnn247tOJRw8JHDVMOrz48PzM9/9CGw735OaklQJXKj1oWuXhm2x1e8f9/WCZIEAA "05AB1E ‚Äì Try It Online")
**Explanation**
```
‚Äú‚Ä†¬æ‚Ä∫√à≈†√õÀÜ¬®‚Ä°‚Äî√´√üigo¬∞√çolet‚Äú          # push a string of colours
                       #         # split on spaces
                        ‚Ñ¢        # title-case each
                         D       # duplicate
                          Ik     # get the index of the input
                            >    # increment
                             √®   # get the element at that index
```
[Answer]
# Excel, 85 bytes
```
=CHOOSE(MOD(CODE(A1),12),"green","indigo","yellow",,,"orange","blue",,"violet","red")
```
Uses lowercase names.
Same approach, with Uppercase letters 86 bytes:
```
=CHOOSE(MOD(CODE(A1),12),"Violet","Red",,,"Green","Indigo","Yellow",,,"Orange","Blue")
```
[Answer]
# [Haskell](https://www.haskell.org/), ~~80 71~~ 75 bytes
Thanks to Laikoni for shortening 9 bytes!
```
g x=snd(span(/=x)$words"Red Orange Yellow Green Blue Indigo Violet Red")!!1
```
[Try it online!](https://tio.run/##VZDBasMwEETv/orR0oN9KvkAXXIJISGGBgq9xaCNbaJIwZKJ@/WuHLki0m00b5eZ7Rp3Y63nucUknVGlezSm/JRT9fG0g3L0xQr10JiW8RNA@8RuYDbY6pGxN6pvLb57q9kjoFQJsZknXFxnR622fMEvJB6jP/vhaFD2V0yQMvz6Lmyh@kBg7Rh0sh71QQhBVVHcm96EOWULhNdiiUHvWylmon9/lRkS8yZklRny6pKIqDJgqZn8l8jseIAErDJD4nESssoMWcoV8x8 "Haskell ‚Äì Try It Online")
---
Another solution, slightly more idiomatic, but I could not get it shorter:
```
data R=Red|Orange|Yellow|Green|Blue|Indigo|Violet deriving(Enum,Read,Eq)
succ.read
```
It needs to derive `Read` because of the requirement that the input is a string and at least `Eq` or `Show` in order to either test for equality or show the result.
[Answer]
## [Retina](https://github.com/m-ender/retina/wiki/The-Language), ~~65~~ 58 bytes
```
$
(.[a-z]+)
L$:`RedOrangeYellowGreenBlueIndigoVioletRed
$1
```
[Try it online!](https://tio.run/##K0otycxLNPyvquGe8F@FS0MvOlG3KlZbk8tHxSohKDXFvygxLz01MjUnJ7/cvSg1Nc8ppzTVMy8lMz0/LDM/J7UEqIZLxfD/fxANUcwFUc0FVs4FUs8F0cAF0QEA "Retina ‚Äì Try It Online")
### Explanation
```
$
(.[a-z]+)
```
We start by appending `(.[a-z]+)` to the input, thereby turning it into a regex which matches the input colour, immediately followed by exactly one more colour (capturing the latter).
```
L$:`RedOrangeYellowGreenBlueIndigoVioletRed
$1
```
Now the `:` swaps the stage's input with its own regex. So the previous result becomes the regex and it's matched against the list of colours. The (single) match gets replaced with its first capturing group (i.e. the next colour in the cycle) and returned. Output at the end of the program happens automatically.
[Answer]
# Vim, 59 56 53 52 Bytes
-1 byte thanks to tsh
```
2IYellow Green Blue Indigo Violet Red Orange *<Esc>**wywVp
```
[Answer]
# [Java (JDK 10)](http://jdk.java.net/), 77 bytes
```
s->"Red Orange Yellow Green Blue Indigo Violet Red".split(s)[1].split(" ")[1]
```
[Try it online!](https://tio.run/##Nc/BaoQwEAbgu0/xExC0aKDXpvXQQ0sPpVChUJY9pBptbEzEjFuWss9u1biHMBlmMt@kkyeZd/XPrPvBjYRuyflE2vBmshVpZ/mNiCojvcer1BZ/ETBMX0ZX8CRpCSena/RLLSlp1LY9HCHH1qdbK/C0z7kP1SyEAg0eZp8X7F3VeBulbRU@lTHuF8@jUhaPZlJ4sbVuHT60M4qwtDLuB6Mp8enh9rjfGdiazWLzGjfui4CUJ9xhJUQgRCDERoiVEIEQgRCl6xV9L4@vEBMsvX4FKM@eVM/dRHxYCGoSFnvkBWIfW5ZtYoaGy2Ew52TN0jSsdYnWc5n/AQ "Java (JDK 10) ‚Äì Try It Online")
## Credits
* -10 bytes thanks to [Kevin Cruijssen](https://codegolf.stackexchange.com/users/52210/kevin-cruijssen)
* -1 byte thanks to [Okx](https://codegolf.stackexchange.com/users/26600/okx)
[Answer]
# [SOGL V0.12](https://github.com/dzaima/SOGL), 23 [bytes](https://github.com/dzaima/SOGL/blob/master/chartable.md)
```
k‚Ä∞¬≥d‚àÜ|ŒùŒºH≈ç‚Üë‚â•‚ñëŒ¥√∑f‚ÄòŒ∏‚ÅΩ,WIw
```
[Try it Here!](https://dzaima.github.io/SOGLOnline/?code=ayV1MjAzMCVCM2QldTIyMDYlN0MldTAzOUQldTAzQkNIJXUwMTREJXUyMTkxJXUyMjY1JXUyNTkxJXUwM0I0JUY3ZiV1MjAxOCV1MDNCOCV1MjA3RCUyQ1dJdw__,inputs=Qmx1ZQ__)
Explanation:
```
...‚ÄòŒ∏‚ÅΩ,WIw  
...‚Äò        push "red orange yellow green blue indigo violet"
    Œ∏       split on spaces
     ‚ÅΩ      uppercase the 1st letter of every item (SOGLs dictionary only has lowercase words)
      ,W    get the inputs index in the array
        I   increment
         w  and get that item in the array, wrapping if necessary
```
[Answer]
# [Coconut](http://coconut-lang.org/), 79 bytes
```
s->"# Violet Red # # Green Indigo Yellow # # Orange Blue".split()[ord(s[0])%12]
```
[Try it online!](https://tio.run/##S85Pzs8rLfmfZhvzv1jXTklZISwzPye1RCEoNUVBGQjdi1JT8xQ881Iy0/MVIlNzcvLLweL@RYl56akKTjmlqUp6xQU5mSUamtH5RSkaxdEGsZqqhkax/9PyixQqFDLzFJRAhkE1QI2AGAvSDTMbYi/cLCsuhYKizLwSjQoddV07dZ00jQpNzf8A "Coconut ‚Äì Try It Online")
[Answer]
# [Husk](https://github.com/barbuz/Husk), 28 bytes
```
S!o‚Üí‚Ç¨‚Å∞w¬®·πô}ŒòŒûƒ†¬´·∫á‚ÇáG¬≤‚Ç¨·∏ÉŒªB≈º·∏ÉI√ø√∂‚åâ
```
[Try it online!](https://tio.run/##AUkAtv9odXNr//9TIW/ihpLigqzigbB3wqjhuZl9zpjOnsSgwqvhuofigodHwrLigqzhuIPOu0LFvOG4g0nDv8O24oyJ////VmlvbGV0 "Husk ‚Äì Try It Online")
Maybe there are better options for managing the arguments, but this is the best I could find
### Explanation
```
S!o‚Üí‚Ç¨‚Å∞w¬®·πô}ŒòŒûƒ†¬´·∫á‚ÇáG¬≤‚Ç¨·∏ÉŒªB≈º·∏ÉI√ø√∂‚åâ
       ¬®·πô}ŒòŒûƒ†¬´·∫á‚ÇáG¬≤‚Ç¨·∏ÉŒªB≈º·∏ÉI√ø√∂‚åâ    Compressed string with all the colors
                                "Red Orange Yellow Green Blue Indigo Violet"
      w                         Split on spaces
S                               Pass the list to both the following functions:
    ‚Ç¨‚Å∞                          1) Find the index of the input in the list
  o‚Üí                                  and increase it by one
 !                              2) Get the element of the list at the
                                   resulting position (indexing is cyclical)
```
[Answer]
# [Stax](https://github.com/tomtheisen/stax), ~~31~~ ~~30~~ 29 [bytes](https://github.com/tomtheisen/stax/blob/master/docs/packed.md#packed-stax)
```
√á√¥F‚îò‚â°‚ñì∆í‚óÑ‚ïô>‚îò‚òº‚ñë‚åÇ‚ï™B<U[√áQ‚ïíe√∂Œ£Q‚ïî√∑n
```
[Run and debug it](https://staxlang.xyz/#p=809346d9f0b29f11d33ed90fb07fd8423c555b8051d56594e451c9f66e&i=Red%0AOrange%0AYellow%0AViolet&a=1&m=2)
This uses the ring translation instruction. It replaces each element in an array with the following one from the "decoder ring". Usually, it's used to do character replacement in a string, but it can be used on an entire string too, if it's wrapped in a singleton array.
Here's the unpacked, ungolfed, commented ascii representation of the same program.
```
]   wrap input in singleton array
`5^bZ_9G*h]h%oM~X9e-0ZQJkb2`    compressed string literal with color names
:.j title case and split on spaces
:t  do ring translation
```
[Run this one](https://staxlang.xyz/#c=]%09wrap+input+in+singleton+array%0A%605%5EbZ_9G*h]h%25oM%7EX9e-0ZQJkb2%60%09compressed+string+literal+with+color+names%0A%3A.j%09title+case+and+split+on+spaces%0A%3At%09do+ring+translation&i=Red%0AOrange%0AYellow%0AViolet&a=1&m=2)
[Answer]
# [J](http://jsoftware.com/), 67 64 62 bytes
-2 bytes thank to FrownyFrog
```
>:&.((cut'Red Orange Yellow Green Blue Indigo Violet Red')i.<)
```
[Try it online!](https://tio.run/##y/qvpKeepmBrpaCuoKNgoGAFxLp6Cs5BPm7/7azU9DQ0kktL1INSUxT8ixLz0lMVIlNzcvLLFdyLUlPzFJxySlMVPPNSMtPzFcIy83NSSxSAStU1M/VsNP9rcilwpSZn5CukKYAMUIdzwHoRXIhGda7/AA "J ‚Äì Try It Online")
[Answer]
# [R](https://www.r-project.org/), ~~109~~ 93 bytes
```
function(x){y=c("Red","Orange","Yellow","Green","Blue","Indigo","Violet");y[match(x,y)%%7+1]}
```
[Try it online!](https://tio.run/##K/qfpmCjq/A/rTQvuSQzP0@jQrO60jZZQykoNUVJR8m/KDEvPRXIiEzNyckvBzLci1JT84C0U04pSNwzLyUzPR/ICMvMz0ktUdK0rozOTSxJztCo0KnUVFU11zaMrf2fBjFPkwvIgBoJZkNNBbMhBoOZYLPBLKjxYDbMhv8A "R ‚Äì Try It Online")
-16 thanks to [Giuseppe](https://codegolf.stackexchange.com/users/67312/giuseppe) for the use of `match` advice
[Answer]
## Batch, 97 bytes
```
@set s=Red Orange Yellow Green Blue Indigo Violet Red
@call set s=%%s:*%1 =%%
@echo %s: =&rem %
```
Explanation: The `call` on the second line has the effect of substituting the parameter into the command and evaluating it, turning it into e.g. `set s=%s:Red =%`, which deletes the prefix of the string that includes the parameter. The substitution on the third line then replaces all the spaces with statement separators and comments. This works because string substitution happens before parsing.
[Answer]
# [Ruby](https://www.ruby-lang.org/) `-n`, ~~75~~ 69 bytes
```
a=%w{Red Orange Yellow Green Blue Indigo Violet};p a[-~(a.index$_)%7]
```
[Try it online!](https://tio.run/##KypNqvz/P9FWtbw6KDVFwb8oMS89VSEyNScnv1zBvSg1NU/BKac0VcEzLyUzPV8hLDM/J7Wk1rpAITFat04jUS8zLyW1QiVeU9U89v9/iOy//IKSzPy84v@6eQA "Ruby ‚Äì Try It Online")
[Answer]
# [Julia 0.6](http://julialang.org/), 76 bytes
```
f(s)=match(Regex("$s(.[a-z]*)"),"RedOrangeYellowGreenBlueIndigoViolet"^2)[1]
```
[Try it online!](https://tio.run/##yyrNyUw0@/8/TaNY0zY3sSQ5QyMoNT21QkNJpVhDLzpRtypWS1NJU0cpKDXFvygxLz01MjUnJ7/cvSg1Nc8ppzTVMy8lMz0/LDM/J7VEKc5IM9ow9v9/AA "Julia 0.6 ‚Äì Try It Online")
This handles the Violet->Red by recycling the string with the power `^` operator.
Here's a slightly longer solution without regexes:
```
g(s,l=split("Red Orange Yellow Green Blue Indigo Violet"," "))=l[(findin(l,[s])[1])%7+1]
```
[Answer]
# [PowerShell](https://github.com/TryItOnline/TioSetup/wiki/Powershell), 74 bytes
```
(-split("Red Orange Yellow Green Blue Indigo Violet "*2-split$args)[1])[0]
```
[Try it online!](https://tio.run/##K8gvTy0qzkjNyfn/X0O3uCAns0RDKSg1RcG/KDEvPVUhEiiTX67gXpSamqfglFOaquCZl5KZnq8Qlpmfk1qioKRlBNGlkliUXqwZbRirGW0Q@///f3WIAnUA "PowerShell ‚Äì Try It Online")
Takes the string `"Red ... Violet "` and string-multiplies it out by two to properly handle the `Violet -> Red` test case. We then `-split` that string on input `$args` to give us an array of two strings. We take the second string thereof `[1]`, then `-split` that on whitespace to give us an array of strings and take the first `[0]`.
For example, for input `"Yellow"`, the first step will result in `@("Red Orange ", " Green Blue Indigo ... Indigo Violet ")`. We take the second one of that, split it on whitespace (which removes the whitespace), resulting in `@("Green", "Blue", ... "Violet")`, so taking the `[0]` one thereof results in the proper next string.
[Answer]
# IBM/Lotus Notes Formula Language, ~~79~~ 74 bytes
```
@Left(@Right("Red Orange Yellow Green Blue Indigo Violet Red ";a+" ");" ")
```
Previous version for 79:
```
R:=@Explode("Red,Orange,Yellow,Green,Blue,Indigo,Violet,Red");R[@Member(a;R)+1]
```
Takes input from an editable text field called `a`.
There is no TIO for formula language so here's a couple of screenshots.
[![enter image description here](https://i.stack.imgur.com/znDjS.png)](https://i.stack.imgur.com/znDjS.png)
[![enter image description here](https://i.stack.imgur.com/wylU4.png)](https://i.stack.imgur.com/wylU4.png)
[![enter image description here](https://i.stack.imgur.com/qqlZZ.png)](https://i.stack.imgur.com/qqlZZ.png)
[Answer]
# PHP, 92 bytes
```
$a=" Red   OrangeYellowGreen Blue  IndigoVioletRed";echo substr($a,strpos($a,$argv[1])+6,6)
```
[Try it online!](https://tio.run/##JYyxCsIwEEB/5SgZLNahSxetBRdxKjgIIlKiOZJAuAtJqn/vWXF6b3i86KLIblC6r@CMBgDGpMniFUPg9zEhEhzCjAAnMt7yxXPAspTVFp@OIc@PXNJK6WZB5PwzpZN93dp7ve6arh72IvLffTgWz5RlYyA7TmXiiDQVbXumLw "PHP ‚Äì Try It Online")
[Answer]
# [Kotlin](https://kotlinlang.org), 73 bytes
```
x->"RedOrangeYellow Green  BlueIndigoVioletRed".substringAfter(x).take(6)
```
[Try it online!](https://tio.run/##Lc7BCsIwDAbg@54iFA8tdDt6GDhQEPEkKAgeq6azWFvpMh2MPfvsVn8I5PAnfE9P1rhRtw5eyjj@UUGFGuI0JZwoGFcL6DOIYUe8y0NQrkZ5QWv9V@4CopMb26Lcu7upvTwbb5FY0bytIc4kE4X2Yatuj/@XKe/4lqzjbGEI8goWveaGxMDEXBmyIcs@yoIueVf@EXmVllU/dnk1WRIlSWCWAEyUJEmQWIuW9trMt2tNGHgnClJP5EsxDuMP "Kotlin ‚Äì Try It Online")
Taking advantage of the fact that many colors are 6 characters, the ones that are not are prefixed with spaces to make them 6 characters long. Hopefully it's acceptable that some of the colors are outputted with spaces before them.  
e.g. Red is `" Red"`, Blue is `" Blue"`
[Answer]
# SmileBASIC, ~~94~~ 84 bytes
```
C$="Red   OrangeYellowGreen Blue  IndigoViolet
INPUT I$?MID$(C$*2,INSTR(C$,I$)+6,6)
```
[Answer]
# [Gema](http://gema.sourceforge.net/), 67 characters
```
*=@subst{*\?<J>=\?\$2\;\?=;RedOrangeYellowGreenBlueIndigoVioletRed}
```
Sample run:
```
bash-4.4$ echo -n Yellow | gema '*=@subst{*\?<J>=\?\$2\;\?=;RedOrangeYellowGreenBlueIndigoVioletRed}'
Green
bash-4.4$ echo -n Violet | gema '*=@subst{*\?<J>=\?\$2\;\?=;RedOrangeYellowGreenBlueIndigoVioletRed}'
Red
```
# [Gema](http://gema.sourceforge.net/), 59 characters
```
R=Orange
O=Yellow
Y=Green
G=Blue
B=Indigo
I=Violet
V=Red
*=
```
Boring one. Dumbest approach ever, but quite short.
Sample run:
```
bash-4.4$ gema 'R=Orange;O=Yellow;Y=Green;G=Blue;B=Indigo;I=Violet;V=Red;*=' <<< 'Yellow'
Green
bash-4.4$ gema 'R=Orange;O=Yellow;Y=Green;G=Blue;B=Indigo;I=Violet;V=Red;*=' <<< 'Violet'
Red
```
[Answer]
# [q/kdb+](http://kx.com/download/), ~~59~~ 55 bytes
**Solution:**
```
.[!;2 8#($)`Red`Violet`Indigo`Blue`Green`Yellow`Orange]
```
**Examples:**
```
q).[!;2 8#($)`Red`Violet`Indigo`Blue`Green`Yellow`Orange]"Red"
"Violet"
q).[!;2 8#($)`Red`Violet`Indigo`Blue`Green`Yellow`Orange]"Orange"
"Red"
q).[!;2 8#($)`Red`Violet`Indigo`Blue`Green`Yellow`Orange]"Blue"
"Green"
```
**Explanation:**
Create a dictionary of colour => next colour, the input is the key to the dictionary:
```
.[!;2 8#($)`Red`Violet`Indigo`Blue`Green`Yellow`Orange] / the solution
.[ ;                                                  ] / apply multiple args to function
           `Red`Violet`Indigo`Blue`Green`Yellow`Orange  / list of colours
         ($)                                            / convert to strings
    2 8#                                                / reshape into 2x8 grid
  !                                                     / create dictionary
```
**Bonus:**
It's **53 bytes** in K4:
```
.[!;2 8#$`Red`Violet`Indigo`Blue`Green`Yellow`Orange]
```
[Answer]
# [Japt](https://github.com/ETHproductions/japt), ~~45~~ 43 bytes
*-2 bytes thanks to Shaggy*
```
`R‚sO√é√ÅƒY√ÅMwsG√é9sBluƒI˜igosVio¬§t`qs
g1+UbNg
```
[Try it online!](https://tio.run/##y0osKPn/PyHoUFOx/@G@w42HmiMPN/qWF7sf7rMsdsopPdTseWhGZnp@cVhm/qElJQmFxVzphtqhSX7p//8rAcVyUkuUAA "Japt ‚Äì Try It Online")
[Answer]
# sed, 72 bytes
```
s/$/%RedOrangeYellowGreenBlueIndigoVioletRed/;s/(.+)%.*\1(.[a-z]+).*/\2/
```
[Try it Online](https://tio.run/##K05N@f@/WF9FXzUoNcW/KDEvPTUyNScnv9y9KDU1zymnNNUzLyUzPT8sMz8ntQSoRt@6WF9DT1tTVU8rxlBDLzpRtypWW1NPSz/GSP//f6ACLogpXBBjuMDmcIEM4oKYxAUx6l9@QUlmfl7xf90iAA)
**Example 1:**
Input:
```
Red
Orange
Yellow
Green
Blue
Indigo
Violet
```
Output:
```
Orange
Yellow
Green
Blue
Indigo
Violet
Red
```
**Example 2:**
Input:
```
Indigo
Yellow
Red
Red
Blue
Green
Orange
Violet
Green
Green
Green
Blue
Blue
Violet
```
Output:
```
Violet
Green
Orange
Orange
Indigo
Blue
Yellow
Red
Blue
Blue
Blue
Indigo
Indigo
Red
```
]