[Question]
  [
Inspired by [this challenge](https://codegolf.stackexchange.com/q/188556/78849).
## Goal:
Given a pre-configured switchboard and a list of indexes, invert the switches at the given indexes.
A switchboard is made up of some number of switches (`v` or `^`) wrapped in `-`'s and arranged into rows of varying length. Here is an example switchboard:
```
-v-^-v-
-^-v-
-v-^-v-
```
To invert/flip a switch means changing it from `v` to `^`, or from `^` to `v`.
The switches are indexed left-to-right, top-to-bottom. E.g., in the example above, the last `v` in the first row would be in position 3 and the `^` in the middle row would be at 4 (using 1-indexing).
## Input:
* A string (or list of strings) representing the switchboard. It is guaranteed to match the regex `((-[v^])+-)(\n(-[v^])+-)*`.
* A possibly empty list of numbers representing indexes, may be 0 or 1 (or some arbitrary number if you want) indexed. These are the switches that need to be flipped.
## Output:
* A switchboard in the same shape as the input with the specified switches inverted. Any unspecified switches should retain their initial state.
## Rules:
* Input will always be correctly formatted and no given indexes will be out of bounds.
* The list of indexes will be sorted and will have no duplicates.
* State in your answer what indexing you use, be it 0, 1, or some arbitrary one.
* Trailing whitespace is fine as long as the output looks like the input.
* This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'") so shortest code wins.
## Examples:
```
#Using 1-indexing
input: #Empty Case
[],
-v-^-v-
output:
-v-^-v-
input: #Single switch
[1],
-v-
output:
-^-
input: #Skip a line
[3,5],
-^-v-v-
-v-
-^-^-
output:
-^-v-^-
-v-
-v-^-
input: #Flip one in each line + number wrap
[3,4,6],
-^-v-v-
-v-
-^-^-
output:
-^-v-^-
-^-
-^-v-
input: #Flip 'em all
[1,2,3,4,5,6],
-^-v-v-
-v-
-^-^-
output:
-v-^-^-
-^-
-v-v-
```
  
[Answer]
# Vim, ~~60, 46, 38~~, 37 bytes/keystrokes
```
qq/\d
ggDJ@"/[v^]
sv^<esc>l?\V<C-r>"
x@qq4u@q
```
`<esc>` and `<C-r>` are both 1 byte/keystroke. [Byte Counter](https://tio.run/##K/v/v7BQPyaFKz3dxctBST@6LC6Wq7gsTjrHPiZMSImrwqGw0KTUofD/fwA)
[Test Case 1 (Verbose mode)](https://tio.run/##K/v/v7BQPyaFKz3dxctBST@6LC6Wq7gszia1ONkuxz4mzMZZt8hOiavCobDQpNSh8P9/Yy4TLjMu3TjdMiDkAuM4IPyvWwYA)
[Test Case 2 (Verbose mode)](https://tio.run/##K/v/v7BQPyaFKz3dxctBST@6LC6Wq7gszia1ONkuxz4mzMZZt8hOiavCobDQpNSh8P9/3TjdMiDkAuM4IPyvWwYA)
Thanks to Grimy for the ideas that led to a reduction of 22 bytes :)
[Answer]
# JavaScript, ~~63~~ 59 bytes
```
a=>s=>s.replace(/v|\^/g,x=>"^v"[a.includes(n++)^x>"^"],n=0)
```
[Try it online!](https://tio.run/##HYhBDoMgEADvfQanJQI2bXrEj1g3bnA1NgSMtMRD/47EzMxlPpQpuX3dvjrEictsC9kuVc3OmyfH0Ob/G9tFHbYTmEVPZg3O/yZOEJpG4lG3GFSwd1lcDCl6Nj4uMEP/UE/1GiSMGnWu3K6wMkpZTg)
Saved 4 bytes thanks to [Arnauld](https://codegolf.stackexchange.com/users/58563/arnauld).
[Answer]
# [K (oK)](https://github.com/JohnEarnest/ok), ~~31~~ 27 bytes
**Solution:**
```
`0:{@[x;(&x>93)y;"^v"94=]};
```
[Try it online!](https://tio.run/##y9bNz/7/P8HAqtohusJaQ63CztJYs9JaKa5MydLENrY2Wkk3TrcMCGPyIEQcECpZGykYK5jGWv//DwA "K (oK) – Try It Online")
**Explanation:**
Quick answer, will try to golf it. 0-indexed.
```
`0:{@[x;(&x>93)y;"^v"94=]}; / the solution
`0:                       ; / print to stdout
   {                     }  / lambda taking 2 implicit args x & y
    @[ ;        ;       ]   / apply @[var;index;function]
                     94=    / 94 (ASCII "v") equal to? returns 0 or 1
                 "v^"       / index into "v^" (ie flip switch)
               y            / index into
        (     )             / do this together
          x>93              / x greater than 93 (ASCII "]")
         &                  / indices where true
      x                     / apply to x
```
**Notes:**
* -4 bytes thanks to `>93` trick
[Answer]
# [Python 3](https://docs.python.org/3/), ~~140~~ ~~134~~ 103 bytes
**(-30 thanks to DJMcMayhem♦, -1 more thanks to Black Owl Kai)**
```
def f(i,y,x=1):
 for c in y:q=c>'-';p=len(i)and x==i[0]*q;print([c,"v^"[c>'^']][p],end='');x+=q;i=i[p:]
```
[Try it online!](https://tio.run/##JcpBCoMwEEDRfU8xuJmkHaHWdmOYXiRNoKihgTJGEdHTp4Hy4K9@OtbPJG3OwxggqEgH7dzo7gRhWqCHKHB0M/dPrNEk/o6ion7LADtztFd3nk1aoqzK9lRtvrLl9OicTY5GGRhRm/3Cs4llT53LQdmGbtTSnR6OAGtfb8VL/vEF6vwD "Python 3 – Try It Online")
---
Oof, second try at golfing anything at all. This just uses a rather unsophisticated loop over the string, using `x` to keep track of the current switch index. Uses 1-indexing.
Ungolfed:
```
def f(i,y):
     x = 1
     for c in y:
         nextchar = c # nextchar gets golfed out completely within the print
         if c in 'v^': # golfed as c>'-'
             if len(i) and x==i[0]:
                nextchar = 'v' if c=='^' else '^'
                i = i[1:]
             x += 1
         print(nextchar, end='')
```
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 12 [bytes](https://github.com/DennisMitchell/jelly/wiki/Code-page)
```
O^%5T⁴ịƲ¦40Ọ
```
A full program accepting a string and a list of integers which prints the result.
**[Try it online!](https://tio.run/##y0rNyan8/98/TtU05FHjloe7u49tOrTMxODh7p7////rxumWASEXGMcB4X9jHRMdMwA "Jelly – Try It Online")**
### How?
```
O^%5T⁴ịƲ¦40Ọ - Main Link: list of characters, S; inversion indices, I
O            - to ordinals   ('\n':10, '-':45, '^':94, 'v':118)
        ¦    - sparse application...
       Ʋ     - ...to indices: last four links as a monad: f(O(S))
  %5         -   modulo 5   (10:0, 45:0, 94:4, 118:3)
    T        -   truthy indices (giving, X, indices of '^' and 'v' in S)
     ⁴       -   4th command line argument = I
      ị      -   index into X   (giving indices of '^' and 'v' to invert in S)
 ^       40  - ...action: XOR with 40   (94:118, 118:94)
           Ọ - from ordinals
             - implicit print
```
[Answer]
# [Python 3.8 (pre-release)](https://docs.python.org/3.8/), ~~80~~, ~~78~~, ~~77~~, ~~71~~, 70 bytes
```
lambda x,s,i=0:''.join([c,'^v'[c<'v']][c>s and(i:=i+1)in x]for c in s)
```
*-1 byte, thanks to @Shaggy*
[Try it online!](https://tio.run/##fYxRC8IgHMTf/RTii0r/RWsVMVpfxBSWQ2aUG27I@vTminpbHAcH97vrn2PbueLY@2iqS7zXj2tT4wkGsNWmpHR966xjQgNVgQp9ooFKKfR5wLVrmC0ru8q5dXiSpvNY4xQHHntv3cgMExIIIVnIVHJKnCP06Tj6MfkXWgIK2MFBApqp@Shk6G2VtHgKW5h3@//L@AI)
[Answer]
# [Perl 6](http://perl6.org/), 31 bytes
```
->$_,\s{S:nth(s){\^|v}=$/~^'('}
```
[Try it online!](https://tio.run/##K0gtyjH7n1upoJamYPtf104lXiemuDrYKq8kQ6NYszomrqas1lZFvy5OXUO99n9xYqVCmoaSbpxuGRBygXEcECrpKEQb6yiY6CiYxWr@BwA "Perl 6 – Try It Online")
(-2 bytes thanks to Jo King)
Perl 6's substitution operator `S` conveniently takes an `nth` adverb that accepts not only a single index at which to make the replacement, but a list of them, exactly as needed here.
The replacement is `$/ ~^ '('`, where `$/` is the matched text (either `v` or `^`), `~^` is the stringwise exclusive-or operator, and `(` is the character whose bits turn `v` into `^` and vice versa.
[Answer]
# [MATL](https://github.com/lmendo/MATL), 29 bytes
```
c!tt45>o2yfi)(2=XK)t106-E-K(!
```
[Try it online!](https://tio.run/##y00syfn/P1mxpMTE1C7fqDItU1PDyDbCW7PE0MBM11XXW0Px//9qdd043TIgVNdRUIdRcUCoXssVbaxgomAWCwA) Or [verify all text cases](https://tio.run/##y00syfmf8D9ZsaTExNQu36gyLVNTw8g2wluzxNDATNdV11tD8b@6Z15BaUmxlTqXoXuykbuaC5e6f2kJUAgoYqqSxGWQzBXhElUR8r9aXbdMNw6I1Wu5omO5ULiGYD6IB@TrKKjDqDggBMkbK5gomBFQY6hgpABSZwpSCQA).
Input is a cell array of strings and a row vector of numbers, with 1-based indexing. Output is right-padded with spaces.
[Answer]
# [Python 2](https://docs.python.org/2/), ~~105~~ ~~97~~ 91 bytes
```
lambda a,s:reduce(lambda(t,i),c:(t+[c,'^v'[c<'v']][c>'-'and i in a],i+(c>'-')),s,('',0))[0]
```
[Try it online!](https://tio.run/##JchBCsIwEEDRfU@R3czQCVTFTVEvEhOISYsBTUsbAz19Giqfv3nzlt5TPJfx/iwf@315Kyyv/TL4nxvwL5g4ELseU6scg8mg3A0yaK3cAyTY6EUQIQqrObR4GBGvjADcEalOl3kJMYkR1YkvfNXcAIA0MteaY1OrRmUH "Python 2 – Try It Online")
6 bytes saved by ~~stealing~~ using [Rin's Fourier transform](https://codegolf.stackexchange.com/a/188728/69880)'s `c>'-'` instead of `c in'^v'`.
`0`-indexed.
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 14 bytes
```
⁾^vḟ$€>”-T⁹ịƲ¦
```
[Try it online!](https://tio.run/##y0rNyan8//9R4764soc75qs8alpj96hhrm7Io8adD3d3H9t0aNn///9143TLgJALjOOA8H@0sY6CiY6CWSwA "Jelly – Try It Online")
Full program.
This feels *too overlong*...
[Answer]
# [Stax](https://github.com/tomtheisen/stax), 13 [bytes](https://github.com/tomtheisen/stax/blob/master/docs/packed.md#packed-stax)
```
¿╫╦ÜΦ1▌X○!ΩTæ
```
[Run and debug it](https://staxlang.xyz/#p=a8d7cb9ae831dd580921ea5491&i=[]+%22-v-%5E-v-%22%0A[0]+%22-v-%22%0A[2,3,5]+%22-%5E-v-v-%5Cn-v-%5Cn-%5E-%5E-%22%0A[0,1,2,3,4,5]+%22-%5E-v-v-%5Cn-v-%5Cn-%5E-%5E-%22&a=1&m=2)
This uses 0-based indices.
1. Find all indices of the regex `[v^]`.
2. Index into the *index* array using the input.
3. At each result, xor the input's ascii code with `40`. This is `xor('v', '^')`.
[Answer]
# [Clean](https://github.com/Ourous/curated-clean-linux), 93 bytes
```
import StdEnv
$i=foldl(\s c=s++[if(any((==)(sum[1\\k<-s|k>'-']))i&&c>'-')if(c>'^')'^''v'c])[]
```
[Try it online!](https://tio.run/##JYyxCsIwGIR3n@IfSpPQZlBxM046CG4dkxRi2khokoppCwWf3RiR447v4DjtehWSH7vZ9eCVDcn65/iaoJm6S1g2hWVmdJ3DIoJmsaq4NViFFWPGCI6z51shhiON7@GEKJKE2LLUPyR5mKFFJBstSEvCZWomlc8ZFMB3NexrOEjgiLZ0yRLhH20WkumjjVOPmOj1ls5rUN7qXO5f "Clean – Try It Online")
Defines the function `$ :: [Int] -> [Char] -> [Char]` taking a zero-indexed list of indices and returning a function that takes the string and returns the altered string.
[Answer]
# [JavaScript (Node.js)](https://nodejs.org), ~~101~~ ~~98~~ ~~93~~ ~~91~~ ~~77~~ 67 bytes
```
a=>s=>[...s].map(c=>t+=c>s?"^v"[a.includes(i++)^c>"^"]:c,t=i=``)&&t
```
[Try it online!](https://tio.run/##JcRZCsMgEADQu/iRKC50/SmMPYhVIpOkWKyGar2@DZQH7@WbL/gJW5Upz0tfoXvQBbRRShWr3n6jCLpyQF3uxDVivAoJ43deCg2cM4eaOGJvKCoEmCY2DLVjTiXHRcX8pCs1B3EUJ3EWF3G1jI7SybZ7pH9uNzLWfw "JavaScript (Node.js) – Try It Online")
10 bytes, thx to suggestions by [Shaggy](https://codegolf.stackexchange.com/users/58974/shaggy).
Port of my [Python answer](https://codegolf.stackexchange.com/a/188732/69880). Not used to golfing javascript!
[Answer]
# [V](https://github.com/DJMcMayhem/V), 20 bytes
```
ÑñÀ/vüÞ
sv^l?Ö"
xH
```
[Try it online!](https://tio.run/##K/v///DEwxsPN@iXHd5zeB5XcVmcdI794WlCSlwVHv//68bplgEhFxjHAeF/4/8m/80A "V (vim) – Try It Online")
Uses some new features, such as `Ñ` which is **incredibly** useful.
[Answer]
# JavaScript, 111 bytes
### Code
```
x=>y=>{x.map(i=>eval(`y=y.replace(/(((v|\\^)[^^v]*){${i}})(v|\\^)/,(a,b,c,d,e)=>b+(e<"v"?"v":"^"))`));return y}
```
Takes input in format f(x)(y) where x is the indices and y is the switchboard. Indices are 0 indexed
[Try it online!](https://tio.run/##LYjtCoIwFEBfJSTw3rpqn3@qrQdRh1NnGDZl2lDMZzehOJzz4zyllW1myqbzdJ2ruWBzz/jA@Nj7L9lAybiysoJkYINvVFPJTEEAAPYTRQJDIWy8wXE9ltOE/xkQSEopo5wUMp5uQd0c69wXL45wEBPEq1Hd2@jVMM1Zrdu6Un5VP6CAcEd7OtCRTnSOEVxPeHYh0r@IBRdx/gI "JavaScript (Node.js) – Try It Online")
### Explanation
For each index
```
x.map(i=>...
```
construct the regex that finds the index+1 th "^" or "v"
```
`.../(((v|\\^)[^^v]*){${i}})(v|\\^)/...`
```
insert it into a string to replace it with the opposite symbol "v"<->"^"
```
y=y.replace(...,(a,b,c,d,e)=>b+(e<"v"?"v":"^"))
```
then evaluate the string as a function
```
eval(...)
```
After iterating through the indices to switch, return the switchboard
```
return y
```
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 17 bytes
```
⁾^vK;`©⁹e€ky@€⁸¦®
```
[Try it online!](https://tio.run/##y0rNyan8//9R4764Mm/rhEMrHzXuTH3UtCa70gFIPmrccWjZoXX///831DHSMf2vG6dbBoRcYBwHhAA "Jelly – Try It Online")
A full program taking the indices as first and string as second argument. Prints the output with the indicated switches flipped. 
[Answer]
# [Retina 0.8.2](https://github.com/m-ender/retina/wiki/The-Language/a950ad7d925ec9316e3e2fb2cf5d49fd15d23e3d), ~~66~~ 62 bytes
```
\d+
$*
T`v^`^v`.(?<=\b(?(3)$)(?<-3>1)+(,1+)*(-|¶|(v|\^))+)
1A`
```
[Try it online!](https://tio.run/##K0otycxL/P8/JkWbS0WLKyShLC4hrixBT8PexjYmScNew1hTRRPI0TW2M9TU1tAx1NbU0tCtObStRqOsJiZOU1Nbk8vQMeH/f2MdEx0zLt043TIg5ALjOCAEAA "Retina 0.8.2 – Try It Online") Link includes test case. 1-indexed. Explanation:
```
\d+
$*
```
Convert the input numbers to unary.
```
T`v^`^v`.(?<=\b(?(3)$)(?<-3>1)+(,1+)*(-|¶|(v|\^))+)
```
Transliterate between `v` and `^` all characters with the property that the number of `v`s and `^`s so far (inclusive) equals one of the input numbers.
```
1A`
```
Delete the input numbers.
[Answer]
# [Charcoal](https://github.com/somebody1234/Charcoal), 23 bytes
```
⭆η⎇№θ⌕ΦＬη№v^§ηλκ§v^⁼vιι
```
[Try it online!](https://tio.run/##NYtNCwIhEIb/inhSGC9Fp04RLQQFQd22FWRXVllxW3Olfr2NSLzwzMcz0xsV@lm5nG/B@sjuEct4VS9mgDx08Cp82XFeUS1AGusH1lgXdWAX7cdomOFAqqdJUiCHePaD/pR3xznKqeC/rTenZVXujQP2tmgE3@fcthvYwq4DKqRImKevkBjaZZHcDw "Charcoal – Try It Online") Link is to verbose version of code. 0-indexed. Explanation:
```
 η                      Input string
⭆                       Map over characters and join
  ⎇                     If
   №                    Count of (i.e. exists)
     ⌕                  Index of
               κ        Current index in
       Ｌ                Length of
        η               Input string
      Φ                 Implicit range filtered by
         №              Count of (i.e. exists)
             η          Input string
            §           Indexed by
              λ         Current value
          v^            In literal string `v^`
    θ                   In input list
                 v^     Then literal `v^`
                §       Indexed by
                     ι  Current character
                   ⁼    Equal to
                    v   Literal `v`
                      ι Else current character
```
[Answer]
# [Ruby](https://www.ruby-lang.org/), 56 bytes
1-indexed.
```
->s,i{j=0;s.gsub(/[v^]/){i==i-[j+=1]?$&:"v^".tr($&,'')}}
```
[Try it online!](https://tio.run/##bYpbDoIwFET/u4orIQpaWt8fanUhlSY8itYQJLSQGGHt2Bo/zc0kd86Zpk1fY8HG6Kyxej/Y8qjJTbdpQHknYhq@FWMq4o8FW8UXf3rwOuER0wT@FM9m4TCM/ok0MsmJrktlAp/O1yGRSXaH/Am9kdr0CEABA9klZeAA0aXK5ASoIPNrRUPr69ZoKLizGFT8I0hW@chjFHWRsEGIr77FPhu8xXtbHLfgG2HPbfAaO737O/gA "Ruby – Try It Online")
[Answer]
# [C# (Visual C# Interactive Compiler)](http://www.mono-project.com/docs/about-mono/releases/5.0.0/#csc), 73 bytes
```
a=>b=>{int i=0;return a.Select(x=>x>45&&b.Contains(++i)?(char)(x^40):x);}
```
[Try it online!](https://tio.run/##jY6xasMwEIZ3P4XIEHREDm7rLJWlFkoLhWwdOoQYJFVpDhIFJNk1mDy7KztDClnKzy3/fXx3JuQm4PDWOFO9v7rmaL3SB1uZvfKSXeo1hlihi5LdEFLuxKCE1EL2iSAoCu5tbLwjavlhD9ZE2gnZyXI1n@vly8lFhS7QxQLhiY4KoF1dFvDYAT8PPGtP@EWiDZFezypGQvTovomG/tNjtGt0ll660WlUpDuqgSoA4FciKbPJ5ezPZtvfswe2OrPnWV7nbUo2TZ0yA/4XLNgdG@HyHzhJH26K7Yi1E5iWwy8 "C# (Visual C# Interactive Compiler) – Try It Online")
[Answer]
# [Japt](https://github.com/ETHproductions/japt), 15 bytes
```
®c^(Z>V©øT° *#(
```
[Try it](https://petershaggynoble.github.io/Japt-Interpreter/?v=1.4.6&code=rmNeKFo%2bVqn4VLAgKiMo&input=Ii1eLXYtdi0KLXYtCi1eLV4tIgpbMiwzLDVd)
```
®c^(Z>V©ø°T *#(    U = Input String, V = Array of Indices
®                  Map each Z in U
 c^                   XOR Z's charcode by
   (Z>V                 Z is 'v' or '^'
      ©                 Short-circuiting Logical and
       øT°              The current Z's index is in V
             *#(        Multiply the boolean with 40 (false = 0, true = 1)
```
[Answer]
# [Japt](https://github.com/ETHproductions/japt), ~~16~~ 14 bytes
```
Ëc^#(*(D>V©øT°
```
[Try it](https://petershaggynoble.github.io/Japt-Interpreter/?v=1.4.6&code=y2NeIygqKEQ%2bVqn4VLA&input=Ii1eLXYtdi0KLXYtCi1eLV4tIgpbMiwzLDVd)
```
Ë>V©øT° ?Dc^#(:D     :Implicit input of multi-line string U & integer array V
Ë                    :Map each D in U
 >V                  :  Greater than V? (Coerces V to a string and, conveniently, all digits are > "\n" & "-" and < "^" & "v")
   ©                 :  Logical AND with
    ø                :  Does V contain
     T°              :    T (initially 0) postfix incremented
        ?            :  If true
         Dc          :  Charcode of D
           ^#(       :  XOR with 40
              :D     :  Else D
```
]