KITT car ASCII art
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>
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.
Jelly, 28 22 bytes
-6 bytes thanks to the help of @Dennis! (upend first, then concatenate)
”-ẋ6;“#++”ṙ7Ḷ’¤Ḋ€U;$⁸ị
TryItOnline
Or perform four oscillations with a bonus easter egg!!
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) "-#++-----"])