[Question]
  [
The 80's TV series [*Knight Rider*](https://en.wikipedia.org/wiki/Knight_Rider_(1982_TV_series)) featured an intelligent, self-aware car called KITT. One distinctive aspect of the car was a front-mounted scanner bar that allowed KITT to "see" (and that looked [suspiciously](https://en.wikipedia.org/wiki/KITT#Features) familiar to fans of another, earlier [TV series](https://en.wikipedia.org/wiki/Battlestar_Galactica_(1978_TV_series))).
The scanner had eight lights as seen in this picture:
[![enter image description here](https://i.stack.imgur.com/kJAA1.png)](https://i.stack.imgur.com/kJAA1.png)
The lights "moved" as shown in [this animated image](https://thumbs.gfycat.com/AdorableSlightBarnswallow-mobile.mp4).
Your task, as you have guessed by now, it to recreate the scanner bar with the moving lights in ASCII art.
# The challenge
Given an integer `t`, output the state of the scanner bar at that instant, defined as follows:
* The scanner consists of eight lights.
* At any instant one of the lights is *active*, and is shown as `#`. The lights that were active at times `t-1` and `t-2` are now *dimmed*, and are shown as `+`; unless they coincide with the current active one. The rest of the lights are *off*, and are shown as `-`.
* The active light moves left to right, then right to left.
The exact output for each `t` is detailed below.
```
0  -->  #++-----   % The leftmost light is active, and it just came from the right.
                   % The two neighbouring lights are dimmed
1  -->  +#------   % The active light has bounced to the right, and it is covering
                   % one of the two lights that should be dimmed. So there is only
                   % one dimmed light
2  -->  ++#-----   % The active light has moved one more step to the right, and the
                   % two trailing dimmed lights are visible
3  -->  -++#----
7  -->  -----++#
8  -->  ------#+   % The active light has bounced to the left
9  -->  -----#++
10 -->  ----#++-
13 -->  -#++----
14 -->  #++-----   % Same as 0
15 -->  +#------   % Same as 1
```
For negative values of `t` the cycle is simply extended:
```
-1 -->  -#++----   % Same as 13
-2 -->  --#++---   % Same as 12
```
#Additional rules
You can write a program or function.
Output can contain trailing whitespace and a leading newline.
Shortest code in bytes wins.
  
[Answer]
## JavaScript (ES6), ~~65~~ 67 bytes
**EDIT** - Fixed for negative values. Now supporting `N >= -8,000,000,000`, which should provide a fairly good extended operating time in AUTO CRUISE mode. :-)
```
let f =
n=>[..."------#++-----".substr((n+=8e9)%7,8)].sort(_=>n/7&1).join``
// testing 28 frames
for(var i = -14; i < 14; i++) {
  console.log(f(i));
}
```
### Animated version
```
let f =
n=>[..."------#++-----".substr((n+=8e9)%7,8)].sort(_=>n/7&1).join``
let n = 0;
setInterval(function() { document.getElementById("o").innerHTML = f(n++) }, 90);
```
```
<pre id="o"></pre>
```
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), ~~28~~ 22 [bytes](https://github.com/DennisMitchell/jelly/wiki/Code-page)
-6 bytes thanks to the help of @Dennis! (upend first, then concatenate)
```
”-ẋ6;“#++”ṙ7Ḷ’¤Ḋ€U;$⁸ị
```
[TryItOnline](http://jelly.tryitonline.net/#code=4oCdLeG6izY74oCcIysr4oCd4bmZN-G4tuKAmcKk4biK4oKsVTsk4oG44buL&input=&args=MA)  
Or perform four oscillations with a bonus **[easter egg!!](http://jelly.tryitonline.net/#code=4oCdLeG6izY74oCcIysr4oCd4bmZN-G4tuKAmcKk4biK4oKsVTsk4oG44buLCjU24bi2w4figqzFvOKAnEcn4bq44bmaS-G4g-KBveG6ueG4peG6klDGpcOwcOG6oeKBt8aRRcOeRjpYxoHCv1U2wqXhuZnigbzhua3CpjLhuKPhuo7hupNOyK4xyZPhuIvhuqBL4bma4bukPzLEscat4bukwrDCocOH4bukUeG4jF3hu41U4bmg4bmAyqDDnuG5gzQqyaDCszMp4oG-xJbDt8i34bif4oG04oG-yZfhuZfCpsak4bqh4bqHa-G5h-G5m04zRMW8aOG6hmY84bu0cEkjwrPDplg54oG4xKHigbfhuo45ZcOHxorCqeKBuX7Jl8qCyLdExp3Dl8K_4buLxJZFw4bIrsmyxp1j4bmGxodva2FEITh4bMK74biywqRH&input=)**
### How?
```
”-ẋ6;“#++”ṙ7Ḷ’¤Ḋ€U;$⁸ị - Main link: n
”-   “#++”             - strings "-" and "#++"
  ẋ6                   - repeat six times: "------"
    ;                  - concatenate: "------#++"
              ¤        - nilad followed by atoms as a nilad (ie make a constant)
           7Ḷ’         -     range(7) decremented: [-1,0,1,2,3,4,5]
          ṙ            - rotate left by (makes)-----------> ["+------#+",
               Ḋ€      - Dequeue each                        "------#++",
                   $   - last two atoms as a monad           "-----#++-",
                 U     -     reverse (vectorises)            "----#++--",
                  ;    -     concatenate                     "---#++---",
                    ⁸  - left argument (n)                   "--#++----",
                     ị - index into (1 based and modular)    "-#++-----"])
```
[Answer]
## JavaScript (ES6), ~~90~~ 87 bytes
```
n=>"01234567".replace(/./g,i=>"-+##"[g=n=>!((+i+n)%14&&(n-i)%14),g(n)*2|g(n-1)|g(n-2)])
```
"-+##" is indexed by a bitmask, where bit 1 signifies an active light and bit 0 signifies a dimmed light. Active/dimmedness is now calculated by adding and subtracting the current position from the desired position and seeing if either result is divisible by 14.
[Answer]
## Python, 53 bytes
```
lambda n:('-'*5+'++#'+'-'*6)[-n%7:][:8][::-n/7%2*2-1]
```
Creates the string `-----++#------`, takes a length-8 window depending on the input modulo 7, reverses for inputs modulo 14 that lie between 1 and 7 .
[Answer]
# [><>](https://esolangs.org/wiki/Fish), 51+3 = 54 bytes
```
<v{"------#++"%7&(7%*27:-1
}>:?!\1-$
{~&?r\~
l?!;o>
```
Input is expected on the stack at program start, so +3 bytes for the `-v` flag.
[Try it online!](http://fish.tryitonline.net/#code=PHZ7Ii0tLS0tLSMrKyIlNyYoNyUqMjc6LTEKfT46PyFcMS0kCnt-Jj9yXH4KbD8hO28-&input=&args=LXYgNQ)
[Answer]
# MATL, ~~34~~ ~~30~~ 27 bytes
```
'++#-'I:7XyY+4LZ)t2&P&viY))
```
*7 bytes saved thanks to @Luis*
[**Try it Online!**](http://matl.tryitonline.net/#code=JysrIy0nSTo3WHlZKzRMWil0MiZQJnZpWSkp&input=MA)
[Another example with the first 25 steps](http://matl.tryitonline.net/#code=OnEiJysrIy0nSTo3WHlZKzRMWil0MiZQJnZAWSkp&input=MjU)
**Explanation**
```
'++#-'      % Push the string literal to the stack
I:          % Create the array [1 2 3]
7Xy         % Create a 7 x 7 identity matrix
Y+          % Perform 2D convolution between the vector and this matrix
4LZ)        % Grab all but the first column. Yields the following matrix
            %
            %    2 3 0 0 0 0 0 0
            %    1 2 3 0 0 0 0 0
            %    0 1 2 3 0 0 0 0
            %    0 0 1 2 3 0 0 0
            %    0 0 0 1 2 3 0 0
            %    0 0 0 0 1 2 3 0
            %    0 0 0 0 0 1 2 3
            %
t2&P&v      % Copy this matrix, flip it horizontally and vertically concatenate
            % it with itself. 
i           % Explicitly grab the input (n)
Y)          % Get the n-th row of the above matrix (and use modular indexing)
)           % Index into the initial string literal to replace 2 with #, 1 and 3 with + 
            % and all 0's with -
            % Implicitly display the result
```
[Answer]
# Pyth, ~~33~~ 28 bytes
Saved 5 bytes by calculating all the lights the same way.
```
X:*8\-@LJ+U7_S7,-Q2tQ\+@JQ\#
```
Starts with the lights all off and turns them on one at a time.
[Try it out online!](http://pyth.herokuapp.com/?code=X%3A%2a8%5C-%40LJ%2BU7_S7%2C-Q2tQ%5C%2B%40JQ%5C%23&input=0&test_suite=1&test_suite_input=0%0A1%0A2%0A3%0A4%0A5%0A6%0A7%0A8%0A9%0A10%0A11%0A12%0A13%0A14%0A-1%0A-2%0A-3%0A-4%0A-5&debug=0)
[Answer]
## JavaScript, 204 bytes
```
function g(i){var a=(i%16+16)%16
if(!a)return g(2)
if(1==a%14)return(g(2)+'-').substr(1)
if((1<a)&&(a<8))return Array(a-1).join('-')+'++#'+Array(8-a).join('-')
return g(a-7).split("").reverse().join("")}
```
**Test**
```
function g(i){var a=(i%16+16)%16
if(!a)return g(2)
if(1==a%14)return(g(2)+'-').substr(1)
if((1<a)&&(a<8))return Array(a-1).join('-')+'++#'+Array(8-a).join('-')
return g(a-7).split("").reverse().join("")}
for (var i = 0; i < 16; ++i) {
    console.log(i + '-->' + g(i));
}
```
[Answer]
# JavaScript (ES6), 72
```
t=>`------${(t=(13+t%14)%14)>6?'#++':'++#'}------`.substr(t>6?t%7:7-t,8)
```
*Less golfed*
```
t=>(
  pad = '------',
  t = (13+(t%14))%14,
  u = t % 7,
  t > 6 ? (pad + '#++' + pad).substr(u, 8)
        : (pad + '++#' + pad).substr(7 - u, 8)
)
```
**Test**
```
f=
t=>`------${(t=(13+t%14)%14)>6?'#++':'++#'}------`.substr(t>6?t%7:7-t,8)
T=_=>(
  O.textContent=f(++N.textContent),
  setTimeout(T, 150)
)
T()
```
```
<input id=I type=number value=0 oninput='N.textContent=this.value'>
<pre id=N>-100</pre>
<pre id=O></pre>
```
[Answer]
# [Vim](https://www.vim.org), 95 bytes
```
D7i-<esc>7a_<esc>@=(<C-r>"%14+13)%14+1
|r#8|i
<esc>:v/#/d
:s/.#/+#
f#i+<esc>:s/\v^(_*)(\+*)#(_*)$/\3#\2\1
:s/_/-/g
```
[Try it online!](https://tio.run/##K/v/38U8U9cmtTjZzjwxHkw72GrYOOsW2SmpGppoGxprgimumiJli5pMLrAKqzJ9Zf0ULqtifT1lfW1lrjTlTG2IRLF@TFmcRryWpkaMtpamMoiloh9jrBxjFGMIUh@vr6ufzvX/v67Rf90yAA "V (vim) – Try It Online")
## Explanation
There might be a better way to do this...
```
D
```
Delete the input number into the `"` register.
```
7i-<esc>7a_<esc>
```
Insert the string `-------_______`.
```
@=...
|
```
Go to the character with the 1-based index given by this expression...
```
<C-r>"%14
```
The previously deleted number, mod 14. Unfortunately, Vim's mod operator gives negative results if the left-hand side was negative, so we have to correct for that...
```
(...+13)%14+1
```
... by adding 14 and taking the result mod 14. But at the same time, we can subtract 1, mod 14, and add 1 to give the 1-based mod (same as the regular mod, except it gives 14 instead of 0).
```
r#
```
Replace the character at that index (`-` or `_`) with `#`.
```
8|i
<esc>
```
Go to index 8 and insert a newline, putting the `-`s and the `_`s each on their own line.
```
:v/#/d
```
Whichever line doesn't contain the `#`, delete it.
```
:s/.#/+#
```
If there's a character before the `#`, replace it with `+`.
```
f#i+<esc>
```
Go to the `#` and insert another `+` before it.
```
:s/\v^(_*)(\+*)#(_*)$/\3#\2\1
```
If the line has `_` instead of `-`, reverse it.
```
:s/_/-/g
```
Replace `_` with `-`.
[Answer]
# Perl, 65 bytes
Includes +1 for `-n`
Run with the number on STDIN:
```
for i in 0 `seq 14`; do perl -M5.010 kitt.pl <<< $i; done
```
`kitt.pl`:
```
#!/usr/bin/perl -n
$_="311e".--$_%14+4e16|0;s/.(.{8})/$&|reverse/e;y/013/-+#/;say//
```
Not very competitive but deserves a post for the strange method
[Answer]
# Perl, ~~56~~ 55 bytes
Includes +3 for `-p`
Run with the number on STDIN:
```
for i in 0 `seq 14`; do kitt.pl <<< $i; echo; done
```
`kitt.pl`:
```
#!/usr/bin/perl -p
$_=eval'1x8
|1x(7-abs$_--%14-7).++$^F#'x3;y;1537;-+#
```
Put this in a file ***without*** the final newline (add a final `;` to the program if you don't want to bother with that). Unfortunately using a literal `^F` doesn't work
This program contains 2 comment characters (ignore the `#!` line). One of them really is a comment and actually ***gains*** a byte....
Implements the actual afterglow algorithm
[Answer]
# [Canvas](https://github.com/dzaima/Canvas), 23 [bytes](https://github.com/dzaima/Canvas/blob/master/files/chartable.md)
```
±７％╵-８×#++１╋８ｍ⁸╷³╵％７＜？↔
```
[Try it here!](https://dzaima.github.io/Canvas/?u=JUIxJXVGRjE3JXVGRjA1JXUyNTc1LSV1RkYxOCVENyUyMysrJXVGRjExJXUyNTRCJXVGRjE4JXVGRjREJXUyMDc4JXUyNTc3JUIzJXUyNTc1JXVGRjA1JXVGRjE3JXVGRjFDJXVGRjFGJXUyMTk0,i=LTI_,v=6)
]