text:
Drink your morning coffee
Draw this Ascii coffee cup:
  o
       o
    o
 __________
/          \__
|   J      |  \
|    A     |  |
|     V    |  |
|      A   |__/
\__________/
Brownie points for coffee-script or java :)
Shortest code in bytes, function or program, trailing newline or white space is acceptable, drink up!

I'd be very suspicious of a cup of sparkling coffee. ;)

@Dennis it's my special coffee for Friday mornings ;)

Wouldn't be this more interesting with 2 or more drinks: the hot one would have vapors symbolized with “(” and “)”, the cold one sparkles? And by borrowing from Rod's comment, the code should display one or other based on current time.

Would it be acceptable to have trailing white space on lines?

@Aaron the cup don't have a good pattern, hard-coding/compressing will be shorter in many languages

@Rod my intention was to try to encourage an extremely small huffamn decoder, but I can see it has largely failed... I can also see a good regex coming into play here

I like this pattern. The opportunities for compression are there, but subtle.

@xnor I have created challenges that end up getting solved in 4 or 5 bytes before by the likes of jelly, matl, etc... I didn't want to make it too easy :) Here languages like JavaScript and Perl have a fighting chance (although still at a disadvantage)

@Dennis Yeah, fizzy coffee isn't normal or tasty at all... except if it's a new type of coffee, anti-golfing coffee.

SOGL, 48 bytes
mγmλ⁶…Jcēņ▒&↓¡℮štΥ{ιE‽▼⅛÷εγ╝Ξ∫$■⌡πθ&χF׀▼ΡQ7L↓F¶‘

Explanation:
SOGL has built-in string compression and one of the things it has is a char dictionary compression. Even better, it has a boxstring compression type where the only chars available are " /\|_-\n". So the whole program is a string encased in "‘ (the " is implicit).
The string I gave the compressor are (escaped):
"  o\n       o\n    o\n ",
"__________",
"\n/          \\__\n|   ",
"J",
"      |  \\\n|    ",
"A",
"     |  |\n|     ",
"V",
"    |  |\n|      ",
"A",
"   |__/\n\\",
"__________",
"/"

JavaScript (ES6), 110 104 bytes
Saved 4 bytes thanks to edc65

let f =

_=>`1o
6o
3o
 9
/44\\__
|2J5|1\\
|3A4|1|
|4V3|1|
|5A2|__/
\\9/`.replace(/\d/g,n=>' _'[n>>3].repeat(++n))

console.log(f())

How it works
The compression of the original ASCII art is achieved by replacing all sequences of 2 to 10 consecutive spaces and the two sequences of 10 consecutive underscores with a single digit:

Each sequence of N consecutive spaces is encoded with the digit N-1.
The underscore sequences are encoded with a 9.

We use N-1 rather than N so that we never have to use more than one digit. Hence the need for ++n when decoding.
The expression n>>3 (bitwise shift to the right) equals 0 for n = 1 to n = 7 and equals 1 for n = 8 (not used) and n = 9. Therefore, ' _'[n>>3] gives an underscore for 9, and a space for all other encountered values.
The only special case is the sequence of 10 consecutive spaces just above "JAVA". Encoding it with a 9 would conflict with the underscore sequences. So we need to split it into two sequences of 5 spaces, encoded as 44.

I count 108 bytes (not counting f=). You can save 4 bytes this way: n>>3 instead of +!(n&7), 9 instead of _8 (twice) and 44 instead of 9

@edc65 I've no idea why I counted f= in that one... Thanks for the saved bytes!

Can you explain how the regex works a little bit? It appears like it replaced a digit d, with d spaces ('4' becomes '    '). But not sure exactly how it does that. What does the bit shift do? Why are we incrementing n?

@Cruncher I've added a 'How it works' section.

@Arnauld Very clever :)

Why not change console.log(f()) to alert(f()) to save 6 bytes

Or is that not part of your byte count?

@AlbertRenshaw That's right: let f = and console.log(f()) are not part of the answer. They're not counted at all.

Ah gotcha okay cool! Good answer btw

Jelly, 67 64 bytes
-2 bytes thanks to Dennis (1. remove redundant ”, and 2. replace transpose and run-length decode, ZŒṙ, with reduce by element repetition, x/.)
“Ñṁ{xGgṭḷVỤɲ8ṿfƬT9Ɱ¹=qṀS“$<(ƇỤ08ØÑḌṃṘX6~cuc8HṗḞ2’Dx/ị“ ¶_/\|JAVo

Try it online!
How?
“...“...’ is a list of two base-250 compressed numbers:
[1021021021332411532617161526181616261916162618163425334, 2117114111551155121131612111415121115141211161312111551]

D converts to decimal to yield two lists of digits:
[[1, 0, 2, 1, 0, 2, 1, 0, 2, 1, 3, 3, 2, 4, 1, 1, 5, 3, 2, 6, 1, 7, 1, 6, 1, 5, 2, 6, 1, 8, 1, 6, 1, 6, 2, 6, 1, 9, 1, 6, 1, 6, 2, 6, 1, 8, 1, 6, 3, 4, 2, 5, 3, 3, 4], [2, 1, 1, 7, 1, 1, 4, 1, 1, 1, 5, 5, 1, 1, 5, 5, 1, 2, 1, 1, 3, 1, 6, 1, 2, 1, 1, 1, 4, 1, 5, 1, 2, 1, 1, 1, 5, 1, 4, 1, 2, 1, 1, 1, 6, 1, 3, 1, 2, 1, 1, 1, 5, 5, 1]]

x/ reduces by element repetition to give one list of digits (repeating the number from  the first list by the corresponding value of the other):
[1, 1, 0, 2, 1, 1, 1, 1, 1, 1, 1, 0, 2, 1, 1, 1, 1, 0, 2, 1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 5, 3, 3, 2, 6, 1, 1, 1, 7, 1, 1, 1, 1, 1, 1, 6, 1, 1, 5, 2, 6, 1, 1, 1, 1, 8, 1, 1, 1, 1, 1, 6, 1, 1, 6, 2, 6, 1, 1, 1, 1, 1, 9, 1, 1, 1, 1, 6, 1, 1, 6, 2, 6, 1, 1, 1, 1, 1, 1, 8, 1, 1, 1, 6, 3, 3, 4, 2, 5, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4]

ị instructs to index into the list of the right, one based and modularly (0 indexes into the rightmost item). The list on the right,  ¶_/\|JAVo, is simply the character used in the required order where the pilcrow, ¶, is the same code-point as a linefeed. The closing partner of “ is not required as this is the end of the program:
[' ', ' ', 'o', '\n', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'o', '\n', ' ', ' ', ' ', ' ', 'o', '\n', ' ', '_', '_', '_', '_', '_', '_', '_', '_', '_', '_', '\n', '/', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '\\', '_', '_', '\n', '|', ' ', ' ', ' ', 'J', ' ', ' ', ' ', ' ', ' ', ' ', '|', ' ', ' ', '\\', '\n', '|', ' ', ' ', ' ', ' ', 'A', ' ', ' ', ' ', ' ', ' ', '|', ' ', ' ', '|', '\n', '|', ' ', ' ', ' ', ' ', ' ', 'V', ' ', ' ', ' ', ' ', '|', ' ', ' ', '|', '\n', '|', ' ', ' ', ' ', ' ', ' ', ' ', 'A', ' ', ' ', ' ', '|', '_', '_', '/', '\n', '\\', '_', '_', '_', '_', '_', '_', '_', '_', '_', '_', '/']

Jelly performs an implicit print of this list, which, since it contains characters, prints as if it were a string:
  o
       o
    o
 __________
/          \__
|   J      |  \
|    A     |  |
|     V    |  |
|      A   |__/
\__________/

I swear some of these languages are straight up compression algorithms

@Cruncher that would be Bubblegum

Of course, any language that can output text longer than the code, must necessarily have code longer than the output text for some output texts. I assume if you tried to write something for a completely randomized input the code for it(unless you got lucky) would be longer?

Yep if random. Bubblegum is actually using compression, the goal being Kolmogorov complexity challenges and hence the input should have pattern (or at least repetition like here).

The final ” is implicit and you can replace ZŒṙ with x/. Also, while it doesn't have any bytes, using ¶ instead of a literal newline makes the code more redable imo.

@Dennis ah, nice save with the reduce, and catch on the trailing close quote. I did actually think about using the pilcrow and must have gotten side-tracked.

CoffeeScript ES6, 214 180 bytes
r="replace";" 1o0n0 6o0n0 3o0n0 _9n0/0 9b0_1n0|0 2J0 5|0 1b0n0|0 3A 4|0 1|0n0|0 4V0 3|0 1|0n0|0 5A0 2|0_1/0n0b0_9/0"[r](/\d/g,(a,b,c)->c[b-1].repeat(a))[r](/n/g,"\n")[r](/b/g,"\\")

CoffeeScript, 135 bytes with hardcoding
f=()->"""  o
       o
    o
 __________
/          \__
|   J      |  \\
|    A     |  |
|     V    |  |
|      A   |__/
\__________/"""

No up/down vote; I don't like this answer because generally the point in a kolmogorov-complexity answer is to generate the output without using the entire thing in the code.

@HyperNeutrino, I agree, working on improving it.

PowerShell, 136 124 123 105 bytes
"""2o
7o
4o
 $(($a='_'*10))
/55\__
|3J6|2\
|4A5|2|
|5V4|2|
|6A3|__/
\$a/"""-replace'(\d)','$(" "*$1)'|iex

Try it online!
Thanks to @briantist for finding the shorter -replace method that I knew was there somewhere.
This takes the string with numbers in place of the requisite number of spaces. We then regex -replace the digits with a script expression $(" "*$1). So, for example, the first line of the string will be $(" "*2)o, the second will be $(" "*7)o and so on. Because of the triple-quoting, this is left as a string on the pipeline. We dump that to iex (short for Invoke-Expression and similar to eval), which processes the script expressions and leaves the resulting multi-line string on the pipeline. Output is implicit.

That's strange, hardcoding is shorter. Hm. +1 anyway :)

I was hoping for some answers using innovative (huffman) coding schemas, but my python implementation is still coming up longer as well..

for some reason the short-hand if/else doesn't seem to work ($_,' '*$_)[+$_-in48..57] - no matter what I change it seems to fail for me.

@ConnorLSW That's because both expressions are evaluated and the array built before the indexing happens. As a result, PowerShell doesn't know how to multiply space by o and barfs.

strange that wrapping the ' '*$_ in a scriptblock doesn't stop that behavior, but powershell will do as it will.

@ConnorLSW you can do it like this, but the extra quoting kills its viability (the solution would be 124 bytes again): ("'$_'","' '*$_")[+$_-in48..57]|iex

@AdmBorkBork I believe you ordered a shorter -replace method?

@briantist Thanks for finding that! I knew it was there, just couldn't come up with the right combination of quotes to get it to work.

@AdmBorkBork not related to this question but I thought you might be interested in this

Python 2, 174 172 171 167 bytes
No hard-coding.
No Base-64 encoding.
No Regex.
k=' '
q='_'*10
print'\n'.join([k*i+'o'for i in 2,7,4]+[k+q]+['/'+k*10+'\\__']+['|'+k*s+'JAVA'[s-3]+k*(9-s)+'|'+' _'[s==6]*2+'\\||/'[s-3]for s in 3,4,5,6]+['\\'+q+'/'])

Saved 2 bytes by externalizing '_'*10 and by exploiting Python's conversion of True -> 1 and False -> 0.
Saved 1 byte by removing unnecessary whitespace.
Saved 4 bytes thanks to @TuukkaX!

You seem to have 2 useless whitespaces at ] for and in [.

Actually, you can shorten [2,7,4] and [3,4,5,6] to 2,4,7 and 3,4,5,6.

Python 2, 128 127 bytes
-1 byte thanks to Rod (use multiplication of tuple ('_'*10,) to avoid a declaration).
print''.join('0'<c<':'and' '*int(c)or c for c in'''2o
7o
4o
 %s
/ 9\__
|3J6|2\\
|4A5|2|
|5V4|2|
|6A3|__/
\%s/'''%(('_'*10,)*2))

Try it online!
Note: that double backslash is needed before the line feed.
Everything between the ''' and ''' is a single string, the two %s are formatters which get replaced by the content of the trailing %(...) tuple, which in turn contains two copies of '_'*10 via the tuple multiplication (...)*2. The '_'*10 performs string multiplication to yield '__________'.
The code traverses the characters, c, of that whole string using for c in '''... and creates a new string by joining (join(...))
either the number of spaces identified by c, int(c), if c is a digit
or c itself
- being a digit is identified by '0'<c<':' to save over c.isdigit().

You can replace u,u with ('_'*10,)*2 and drop the u declaration

Oh, nice I did look at that and think there was a way - thanks @Rod!

MATL, 87 86 83 82 78 bytes
[TIH][IAC]111Z?c'(ty!(OWM4J4gW{lm> >bw8ch|.FU2W"@\#2Dj!NQDeIMZ'F'_ /|\JAV'Za7e

This solution breaks the coffee into two pieces: the "bubbles" and the mug. To create the bubbles, we create a sparse matrix with 111 located at three locations and convert it to a character array
[TIH][IAC]111Z?c

For the mug component, we rely upon string compression
'(ty!(OWM4J4gW{lm> >bw8ch|.FU2W"@\#2Dj!NQDeIMZ'F'_ /|\JAV'Za7e

Both components are printed to the output and a newline is automatically placed between the components
Try it at MATL Online

GNU sed, 113 112 bytes
s:$:  o@SS o@S o@ UU@/SSS \\__@|SJSS|  \\@|S AS  |  |@|S  VS |  |@|SSAS|__/@\\UU/:
s:S:   :g
y:@:\n:
s:U:_____:g

Basic encoding, it stores 3 spaces as S, \n as @ and 5 underlines as U. I'll keep trying combinations to find something shorter.
Try it online!
The trivial solution of printing the string directly is given below. It has 136 bytes, resulting in a compression of 18 %, using the encoding scheme above.
c\  o\
       o\
    o\
 __________\
/          \\__\
|   J      |  \\\
|    A     |  |\
|     V    |  |\
|      A   |__/\
\\__________/

Try it online!

Encoding ss as S saves 1 byte.

@Riley Thanks. I also just found a 1 byte less solution, with S storing 3 spaces, no s. I think I'll edit this one instead, because it keeps the same number of transformations.

Java 8, 294 289 248 bytes
Golfed:
()->{String s="";for(char c:"\u026F\n\u076F\n\u046F\n __________\n/\u0A5C__\n|\u034A\u067C\u025C\n|\u0441\u057C\u027C\n|\u0556\u047C\u027C\n|\u0641\u037C__/\n\\__________/".toCharArray()){for(int i=0;i<c>>8;++i)s+=' ';s+=(char)(c&255);}return s;}

In the spirit of kolmogorov-complexity, this does not hard-code the string to output. Instead, it makes use of the fact that there are many cases of multiple spaces followed by a printable character. It encodes the number of spaces that precede a character in the high-order byte of the character, with the actual ASCII character in the low-order byte.
Ungolfed:
import java.util.function.*;

public class DrinkYourMorningCoffee {

  public static void main(String[] args) {
    System.out.println(f(
    () -> {
      String s = "";
      for (char c : "\u026F\n\u076F\n\u046F\n __________\n/\u0A5C__\n|\u034A\u067C\u025C\n|\u0441\u057C\u027C\n|\u0556\u047C\u027C\n|\u0641\u037C__/\n\\__________/".toCharArray()) {
        for (int i = 0; i < c >> 8; ++i) {
          s += ' ';
        }
        s += (char) (c & 255);
      }
      return s;
    }
    ));
  }

  private static String f(Supplier<String> s) {
    return s.get();
  }
}

I think it would be better to encode the number of leading spaces before a character in the high byte. So, an 'A' preceded by six spaces would be encoded as \u0641.

@DavidConrad why not do both? There are no more than ten consecutive repetitions anywhere in the string, and decimal ten fits in hex F. It should be possible to fit both in there.

That's a good point.

@DavidConrad it ended up making the file size bigger due to the second loop I had to add. But I did save a few bytes by converting hex to decimal constants. Losing the 0x prefix helped.

There are two encodings that look useful: number of spaces, and number of repetitions. You were correct: encoding the number of spaces is a net gain. I was also able to golf some of the other code (if is redundant, for example) and shave off around 1/6th of the size.

Common Lisp, 125 123 122 120 114 bytes
(format t"~3@{~vto
~} ~10@{_~}
/~11t\\__
|   J~11t|  \\
~2@{|~5t~a~11t|  |
~}|~7tA   |__/
\\~10{_~}/"2 7 4'A" V"1)

I saved 6 bytes, using idea of just putting enters in string instead of ~&s.
Ideas for improvement welcomed.

Befunge, 158 105 101 bytes
<v"XaXXXNYXNY77777'XXXXX2_TXQXX0XZTXDXX0X^TXXRX0X^TXXDX07]27777#"p29+55
:<_@#:,g2/+55,g2%+55
\JV/|_Ao

Try it online!
The characters in the string are first encoded as indices into a lookup table of the ten possible values. The indices are then grouped into pairs, each pair being combined into a single number (i1 + i2*10) in the range 0 to 99. By carefully choosing the order of the lookup table, we can guarantee that those values will always be valid ASCII characters which can be represented in a string literal.
This is a breakdown of the code itself:

 We start by initialising the last element of the lookup table with a newline character (ASCII 10).
 We then use a string literal to push the encoded content onto the stack.
 Finally we loop over the values of the stack, decoding and outputting two characters at a time.
 The last line hold the lookup table: the 9th element is an implied space, and the 10th (newline) is set manually, as explained earlier.

Retina, 71 bytes
Differently from my other answer, this one was written by hand.

2o¶6o¶3o¶1=¶/55\__¶|3J6|2\¶|4A5|2|¶|5V4|2|¶|6A3|__/¶\=/
=
10$*_
\d
$*

(there's a trailing space at the end)
Try it online!
The principle is still having a "compressed" string from which the cup of coffee can be reconstructed by substitutions. Trying different substitutions it turned out that the only ones worth doing are:

= turns into __________ (10 underscores)
any digit turns into that number of spaces

Python3, 206 bytes
print('  o\n'+7*' '+'o\n'+4*' '+'o\n'+' '+10*'_'+'\n'+'/'+10*' '+'\__\n'+'|'+3*' '+'J'+6*' '+'|  \\\n'+'|'+4*' '+'A'+5*' '+'|  |\n'+'|'+5*' '+'V'+4*' '+'|  |\n'+'|'+6*' '+'A'+3*' '+'|__/\n'+'\\'+10*'_'+'/')

So many space characters… Better declare a s=' ' variable and use it.

Also wouldn't hurt to predefine newline

Hardcoding the output is shorter

@WheatWizard, I don't think so. There is only a single solitary newline. The others are inside strings, so using a variable would also need a concatenation operator. And 'o\n' has the same length as 'o'+n.

@manatwork One could: print(*('  o',7*' '+'o',4*' '+'o',' '+10*'_','/'+10*' '+'\__','|'+3*' '+'J'+6*' '+'|  \\','|'+4*' '+'A'+5*' '+'|  |','|'+5*' '+'V'+4*' '+'|  |','|'+6*' '+'A'+3*' '+'|__/','\\'+10*'_'+'/'),sep='\n') or for x in('  o',7*' '+'o',4*' '+'o',' '+10*'_','/'+10*' '+'\__','|'+3*' '+'J'+6*' '+'|  \\','|'+4*' '+'A'+5*' '+'|  |','|'+5*' '+'V'+4*' '+'|  |','|'+6*' '+'A'+3*' '+'|__/','\\'+10*'_'+'/'):print(x), both are 197. Still longer than a 136 hard code.

Pyth, 80 bytes
r"  o
7 o
4 o
 10_
/10 \__
|3 J6 |  \\
|4 A5 |  |
|5 V4 |  |
|6 A3 |__/
\\10_/"9

Online interpreter available here.
Simple run-length decoding.

C - 179
Solution with extensive use of format string:
void f(){printf("%1$3c\n%1$8c\n%1$5c\n%2$11s\n/%3$13s\n|%4$4c%5$7c%6$3c\n|%7$5c%5$6c%5$3c\n|%8$6c%5$5c%5$3c\n|%7$7c%5$4c__/\n\\%2$s/\n",'o',"__________","\\__",74,'|',92,65,86);}

Here is a more readable version:
void f() {
  printf("%1$3c\n"
         "%1$8c\n"
         "%1$5c\n"
         "%2$11s\n"
         "/%3$13s\n"
         "|%4$4c%5$7c%6$3c\n"
         "|%7$5c%5$6c%5$3c\n"
         "|%8$6c%5$5c%5$3c\n"
         "|%7$7c%5$4c__/\n"
         "\\%2$s/\n"
         'o',"__________","\\__",'J','|','\','A','V');
}

Brute forcing the art inside code give a shorter version and print with puts:
void g(){puts("  o\n       o\n    o\n __________\n/          \\__\n|   J      |  \\\n|    A     |  |\n|     V    |  |\n|      A   |__/\n\__________/\n");}

It's hard-coding, not brute-forcing. Brute-forcing is repeatedly generating random strings until one generated is correct, which is a standard loophole.

Retina, 99 bytes
This solution was generated automatically using this script.

0 0o¶ 1¶/32\__¶4 J24\¶|3A 34|¶| 3V34|¶|2A   |__/¶\1/
4
|
3

2

1
__________
0
  o¶

(there are trailing spaces on many lines)
This works by using numbers 1,2,3,4 in place of some character sequences that are repeated in the target string and then substituting them back.
I know it could be golfed more by tweaking this code or completely changing approach, but since the kolmogorov meta-golf challenge had quite a disappointing outcome I wanted to try using my script on a real challenge.
Try it online!

You can replace all the spaces at the end of the last line to a 3 and then move the substitution up to before the 3. Also you can change 2\n       to 2\n3   and move this substitution to before the 3. Try it online!

You can also change 1\n__________ to 1\n_____ and then change each 1 in the main substitution to 11 Try it online!

@KritixiLithos as I said, I know this can be golfed :) I just wanted to post a solution created directly by my algorithm, maybe I'll post another answer which is optimized manually^^

PowerShell, 96 bytes
"2o
7o
4o
 0
/55\__
|3J6|2\
|4A5|2|
|5V4|2|
|6A3|__/
\0/"-replace'\d',{' '*"$_"+(,'_')["$_"]*10}

Try it online!

Charcoal, 62 bytes
≔\||||α”{“‽!⭆hi¿ü” ×_¹⁰↓× ⁵¦ __↑/||\← __↓α←”|⁻⎚}”↑⁺α/Ｍ⁴¦²↘JAVA

Try it online!
Pure ”~” compression, 62 bytes
”~∨]S⁶Ｇ⌈↖Ｌ⌈ＬＴＦＪＳ‖j∕⍘c⊗l⁶D⍘2Ｓ∧⦃﹪�⎚º}ερＫＭ✳AV³α；≕～FＹ|◧:¶d⮌rt；↶≕Xê

Try it online!

Python 3.6 (non-competing)
Here's my attempt at Huffman encoding. It's definitely golfable further if anyone wants to take up the idea.
from bitarray import bitarray as b
a=b()
a.frombytes(bytes.fromhex('ca7fca7e53b6db6db664ffc6d9ae1fd6335e2fad1af83d68d7e2e9b218db6db6db20'))
print(''.join(a.decode({k:b(v)for k,v in zip(" _|\no/\\AJV","1 011 010 0011 00101 00100 00011 00010 00001 00000".split())})))
The literal could be compressed further still by converting to base64 or other, and the Huffman tree could be optimized to yield a shorter bitarray still.

Non-competing is not an excuse for invalidity.

@Mego I don't have the time rn to fix it, I just wanted to give the framework of a solution for someone else to run with. non-competitive because I was the OP of the challenge

That really doesn't matter. Our policy is clear.

@Mego fixed... just for you

GameMaker Language, 138 bytes
show_message("  o#       o#    o# __________#/          \__#|   J      |  \#|    A     |  |#|     V    |  |#|      A   |__/#\__________/")

C, 141 Bytes
f(){printf("  o\n%7co\n    o\n __________\n/%11c__\n|   J%6c|  \\\n|    A     |  |\n|%6c    |  |\n|%7c   |__/\n\\__________/",0,92,0,86,65);}

Usage
main(){f();}

Easy Solution, 148 Bytes:
w(){puts("  o\n       o\n    o\n __________\n/          \\__\n|   J      |  \\\n|    A     |  |\n|     V    |  |\n|      A   |__/\n\\__________/");}

PHP, 116 bytes
for(;$c="1o
6o
3o
 9
/44\\__
|2J5|1\\
|3A4|1|
|4V3|1|
|5A2|__/
\\9/"[$i++];)echo$c>0?str_repeat(" _"[$c>8],$c+1):$c;

This looks a lot like Arnauld´s answer - and does pretty much the same. Run with -r.

zsh, 86 bytes
printf "^_<8b>^H^@^@^@^@^@^B^CSPÈçR^@^A^P^CJÆÃ^A<97>¾^B^\Ä^@¹5@Ú^KÂ^E2cÀ|^EG^X¿^FÂW^HCæÃTÔÄÇësÅÀ^L^Fq^@<92>}ý^?{^@^@^@"|zcat

Explanation: that string is the gzip-compressed java cup ascii art.  I use printf, because with echo, zcat prints a warning, and echo -e is one character longer.  It doesn't work with bash or sh, because they think it's a binary file.  Since you can't effectively paste that output from the browser, here's a usable file.

Java 9 / JShell, 299 bytes
()->{String s="";BigInteger b=new BigInteger("43ljxwxunmd9l9jcb3w0rylqzbs62sy1zk7gak5836c2lv5t36ej6682n2pyucm7gkm9bkfbn4ttn0gltbscvbttifvtdfetxorj6mmy3mt6r3",36);while(!b.equals(BigInteger.ZERO)){int x=b.intValue()&0x3ff;for(int i=0;i<x>>7;i++)s+=' ';s+=(char)(x&0x7f);b=b.shiftRight(10);}return s;}

Ungolfed:
() -> {
    String s = "";
    BigInteger b = new BigInteger(
        "43ljxwxunmd9l9jcb3w0rylqzbs62sy1zk7gak5836c2lv5t36ej6682n2pyucm7gkm9bkfbn4ttn0gltbscvbttifvtdfetxorj6mmy3mt6r3",
        36);
    while (!b.equals(BigInteger.ZERO)) {
        int x = b.intValue() & 0x3ff;
        for (int i = 0; i < x >> 7; i++) s+=' ';
        s += (char)(x&0x7f);
        b = b.shiftRight(10);
    }
    return s;
}

Usage in JShell:
Supplier<String> golf = <lambda expression>
System.out.println(golf.get())

Encodes each character as ten bits consisting of a count of the number of spaces before the character in the high three bits following by the code point in the low seven bits.
(Since there are only three bits for the count it can't represent more than seven consecutive spaces, and there are ten spaces at one point in the string. These are encoded as a count of six, followed by a space, and then a count of three followed by the next character.)
Sadly, it loses to this trivial 140-byte Java solution:
()->"  o\n       o\n    o\n __________\n/          \\__\n|   J      |  \\\n|    A     |  |\n|     V    |  |\n|      A   |__/\n\\__________/"

05AB1E, 85 bytes
•1d'uì[_ÍpH»Ð]jŠ$ÿ{É˜ß|ªpå±W¾Ö:ÞjÇ&@è$´Öàˆå]Á¢šBg¦ï&-ã¥ønØ7Ñà'?•9B8ÝJ"o _/\|JAV"‡15ô»

Try it online!

05AB1E, 67 65 bytes
'oƵ®Sú»•BÇÉι!т³ÂSˆtTóV”PHAëdÀāåΘý”å.@=Ø₂)øUqrÖ½ñ*•“_ |
\/AVJ“ÅвJ»

Pretty straight-forward approach which most likely has room for improvement.
Try it online.
Explanation:
'o            '# Push an "o"
  Ƶ®           # Push compressed integer 274
    S          # Convert it to a list of digits: [2,7,4]
     ú         # Prepend that many leading spaces to the "o": ["  o","       o","   o"]
      »        # Join them by newlines: "  o\n       o\n   o"
•BÇÉι!т³ÂSˆtTóV”PHAëdÀāåΘý”å.@=Ø₂)øUqrÖ½ñ*•
               # Push compressed integer 21514733101393053622421734761651860518184887728386739717403046550918945532453802933506348033205129
 “_ |\n\/AVJ“  # Push string "_ |\n\/AVJ"
  Åв           # Convert the integer to base-"_ |\n\/AVJ"
               # (builtin for converting to base string-length, and index those into the string)
    J          # Join the characters to a single string
     »         # And join the two strings on the stack by a newline
               # (after which the result is output implicitly as result)

See this 05AB1E tip of mine (section How to compress large integers?) to understand why Ƶ® is 274 and •BÇÉι!т³ÂSˆtTóV”PHAëdÀāåΘý”å.@=Ø₂)øUqrÖ½ñ*• is 21514733101393053622421734761651860518184887728386739717403046550918945532453802933506348033205129.

Vyxal, 108 bytes
`274`ƛI\o꘍,;_ð\_₀*+,\/₀꘍`\__`+,\|3꘍\J6꘍\|ðd\\Wṅ,\|4꘍\A5꘍`| `m++,\|5꘍\V4꘍`| `m++,\|6꘍\A3꘍`|__/`++,\\\_₀*\/++,

Try it Online!

05AB1E, 65 bytes
'oƵ®Sú»•BÇÉι₆₅8á·ŸˆE©/LнDË9Ï0³†₃þC¤ā¸·Í¨z©´Kˆι₃BÄ•"_
/\|JAV"ÅвJ»

Try it online!
Pure Åв compression (compressing the bubbles too), 67 bytes
•5m™ÔćtвÃÔηŒćõ»θpøàÄqŠZ₂rÓ¢γβÞĆ?úËÄÌUöÉн%Cñí₄‡±ÁkÆùi•"o
_/\|JAV"Åв

Try it online! Outputs as a list of characters.
Λ canvas, 109 bytes
'oƵ®Sú»6…/||º4Λ12„\_`5×«º2Λ2„/|0Λ4„|_º2Λ4„/|º0Λ4„\ º6Λ4'|4Λ5'|0Λ4ð2Λ4„ _º6Λ2'\0Λ2ð6ΛT'_6Λ3…_  4Λ4ð2Λ4'îáu3.Λ»

Try it online!

Canvas, 59 bytes
？Eα)⁶^↑^jo↕ｊα◂9Ｓ⁷YNＵ>AｇＸ↷ＵＥ╬ｑ\ｄ7ｆ²ｔ}ＭøＱ＃║Ｍ<Y5２ｄｐc３Ｉ‰０Ｃ5Ｇ９－‟

Try it online!


text:
Alphanumerical order
Task is to output this text:
ABCDEFGHIJKLMNOPQRSTUVWXYZA
A 00000000000000000000000 Z
B                         Y
C  101010101010101010101  X
D                         W
E                         V
F   2101210121012101210   U
G                         T
H                         S
I                         R
J    12321012321012321    Q
K                         P
L                         O
M     234321012343210     N
N     123432101234321     M
O                         L
P                         K
Q    23210123210123210    J
R                         I
S                         H
T                         G
U   1210121012101210121   F
V                         E
W                         D
X  010101010101010101010  C
Y                         B
Z 00000000000000000000000 A
ABCDEFGHIJKLMNOPQRSTUVWXYZA

Rules

shortest code wins, but you are encouraged to post answers even if your language is among more verbose ones
trailing newline allowed,
lowercase letters allowed

Hi there! I've downvoted this challenge as I'm really struggling to see any sort of pattern to the middle digits, leading most answers to be like the Bubblegum answer and do just straight up compression. I recommend you post future challenges to the Sandbox where you can get meaningful feedback before posting them to main.

@AdmBorkBork He posted it to sandbox. Some people said there wasn't much interesting about it though.

@AdmBorkBork Thank you for taking your time to comment. There definitely is pattern in middle numbers. Perhaps it's unusable in miningful way.@LliwTelracs It was one person. Perhaps I should have trusted his judgement :-)

Looks like there is some pattern to me. Let's try to beat the gum!

@AdmBorkBork I think for the inside, it cycles. For example, the outermost ones cycles [0], next cycles [0,1] in 0101 fashion, next cycles [0,1,2] in 0121 fashion, so on so forth until the middle one cycles [0,1,2,3,4] in 0123-4-3210 fashion. Ascending and descending?

SOGL 0.8.2, 121 120 bytes
Z A+p→**1"PļΔķ≠ƨν↕KzøjQ¶°³²y⁹ν⅔E    "§768╗@ū℮^‰Y√ψ⅜εrυd┘mZΣlL⅝6׀KTφυZŗ4M7E¤Δ≠⅓∫⁽mΜ‽κuΘ\λ`ω¬ρDDz⅞":e─░χ′⁷‘’«n{;³ZWO≤oZ±WoI}*

Explanation:
Z                                 push the uppercase alphabet
  A+                              append "A"
    p                             output in a new line
     →*                           define function "*" with the above
       *                          call the function "*"
        1                         push 1 (counter)
         "...‘                    push the middle lines (without the alphabet letters) joined
              ’«n                 convert to an array with each item 25 chars long
                 {            }   for each line
                  ;³              put the counter ontop on stack and triplicate it
                    ZW            get the counterth letter of the alphabet
                      O           output in newline
                       ≤          put the current array item ontop of stack
                        o         append
                         Z±W      get the counterth letter of the reversed alphabet
                            o     append
                             I    increase counter
                               *  call the function "*"

Bubblegum, 186 bytes
00000000: 7592 d70d c330 0c44 ff6f 0a8e e092 05dc  u....0.D.o......
00000010: 2df7 def6 1f24 3263 0429 3e09 2281 7b38  -....$2c.)>.".{8
00000020: 1284 1884 519c a459 6e8a b2aa 9bb6 eb87  ....Q..Yn.......
00000030: 719a 9775 db8f 0081 38f7 470e 84c2 ce8e  q..u....8.G.....
00000040: 48c4 756e aec8 8698 fa56 2494 2d48 6df4  H.un.....V$.-Hm.
00000050: 6c8d 9f67 d519 19f5 4dc8 291b 6128 1b50  l..g....M.).a(.P
00000060: 9cc9 f57c edf3 8ea7 d8a3 a4be 0e15 652d  ...|..........e-
00000070: 6acd 9eff b8ea 6956 ad41 2357 c34f a85a  j.....iV.A#W.O.Z
00000080: 8d96 d6ac d051 56a2 7fb5 fb1e 411b 1618  .....QV.....A...
00000090: a8cf 60a4 2cc7 4459 8659 27f8 fb24 aba6  ..`.,.DY.Y'..$..
000000a0: 58a8 2fc1 4a59 8c4d e46e 95ec 1411 76ea  X./.JY.M.n....v.
000000b0: 0b71 d0dd b57b cd77 fe09                 .q...{.w..

Try It Online!

NO!, 34067 bytes
OP asked for verbose. I give you verbose.
I would say the NO! isn't old enough to compete but the length of the code says that it's not competing
As the code is too long for SE, here is a link to the actual code: actual code. I chose a TIO page because I can't be bothered to find anything else.

NO! Shouting is not the answer :)

@AnthonyPham NO! says YES! SHOUTING IS THE ANSWER! (No rudeness intended)

I think that's the only TIO link I have had to scroll up to see the first line of...

PHP, 294 Bytes
$d=[0=>[0,23],2=>["01",21],5=>[2101,19],9=>[123210,17],12=>[23432101,15],13=>[12343210,15],16=>[232101,17],20=>[1210,19],23=>[10,21],25=>[0,23]];echo$j=join(range(A,Z)),"A\n";for($i=0;$i<26;$i++)echo$j[$i].str_pad($d[$i]?str_pad("",$d[$i][1],$d[$i][0]):"",25," ",2).$j[-$i-1]."\n";echo$j."A\n";

Expanded
$d=[
0=>[0,23],
2=>["01",21],
5=>[2101,19],
9=>[123210,17],
12=>[23432101,15],
13=>[12343210,15],
16=>[232101,17],
20=>[1210,19],
23=>[10,21],
25=>[0,23]];
echo$j=join(range(A,Z)),"A\n";
for($i=0;$i<26;$i++)
echo$j[$i].str_pad($d[$i]?str_pad("",$d[$i][1],$d[$i][0]):"",25," ",2).$j[-$i-1]."\n";
echo$j."A\n";

source: Stack Exchange

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/

sort: votes


text:
Number of string permutations that are palindromes
Your input will be a string consisting of small english letters.
Your task is to determine the number of distinct permutations of the original string that are a palindrome.
The input string has up to 100 letters. In the case of a longer string the result might be very big so the output should be the number of permutations modulo 666013.
For example,
cababaa -> 3

The possible permutations are:
aabcbaa
abacaba
baacaab

This is code-golf, so the shortest answer wins!

"Given that the string has up to 100 digits the result must be %666013." If so, it would be a good idea to include a corresponding test case.

For future reference the sandbox sometimes works wonders

I don't understand the %666013 line. This is a promising challenge, though, and I'd be willing to vote to reopen once that's explained.

Oh, now that's been edited, I see what you're getting at. I don't think that line adds to the challenge; it mostly just punishes languages without arbitrary-precision integers. Normally we do something like "the answer should be correct if run in a hypothetical version of your language with unbounded integers".

This could really use more test-cases.

Suggestions for test-cases (please verify them though): abcdabcddddd -> 120 (no odd character count), abcdabcdddddd -> 120 (one odd character count), abcdabcddddddeee -> 0 (two odd character counts), aabbccddeeffgghhiijj -> 298735 (affected by the modulo).

Brachylog (2), 15 bytes
{p.↔}ᶠdl%₆₆₆₀₁₃

Try it online!
Explanation
{p.↔}ᶠdl%₆₆₆₀₁₃
{   }ᶠdl          Count (l) the number of distinct (d) results (ᶠ) obtainable by:
 p                  permuting {the input}
  .                 to produce an output
   ↔                that, if reversed, is still the output
        %₆₆₆₀₁₃   then take that number modulo 666013

I definitely need to implement that "find unique"...

@Fatalize: Yes! I think even "count unique" happens often enough in challenges to maybe be worth a 1-byte representation. On the other hand, "modulo 666013" almost certainly doesn't ;-)

05AB1E, 17 16 13 bytes
-1 byte from Jonathon Allan
-3 bytes from Emigna and Adnan
œÙvyÂQO•E›j•%

Explanation:
œÙ                # Unique permutations of [implicit] input
  vy              # For each permutation...
    ÂQ            # Check if it is a palindrome
      O           # If so, increment the counter
       •E›j•%     # Modulo 666013 (no clue why this number, or even why this rule is in place)

Try it online!

It seems to work without either of the }s. I'm not entirely sure it'll work for all string that way though.

You can use •E›j• in place of 666013 to save a byte (it's a base compression).

@JonathanAllan mind if you explain how that works? I haven't used that feature in 05AB1E before :)

The content, E›j, represents the digits [14, 116, 45] which are converted from base 214, and becomes 14*214^2 + 116*214 + 45 = 666013. I'm not quite sure where the reference is for the digits, but they seem to be in line (ish?) with their order on the info page. @Adnan may enlighten us.

@JonathanAllan: They are in the order: digits/uppercase_letters/lowercase_letters/other_ascii/non_ascii. If you want the specific order it can be found as a string in the baseconvert functions here

@Emigna thanks so much! I had not dug down - I found the value quite quickly and once asked just evaluated the single •x• values.

@JonathanAllan: Good thinking! Easiest way is just doing it programatically

@Emigna Easy when you know the language :D

You can save 2 bytes removing the if-statement as you only have the needed values on stack anyways: œÙvyÂQ}O•E›j•%

@JonathanAllan: True. Your way was more impressive though :)

@JonathanAllan The full range of digits (and characters) can be found here :).

Building on @Emigna's comment, you can save another byte by removing the closing bracket: œÙvyÂQO•E›j•%.

@Adnan I think you should add a 1-byte alias for vy, I see it being used a lot.

Perl 6, 104 108 88 84 bytes
{my &f={[*] 1..$_ div 2}
.comb.Bag{*}.&{(2>.grep(*%2))*f(.sum)/[*]($_».&f)%666013}}

Try it online!
How it works
I can't easily generate all permutations and filter them, even if astronomical run-times are allowed, because Perl 6's built-in permutations routine straight-out refuses to permute lists of more than 20 elements and the task description requires inputs of up to 100 characters.
So instead I use a direct formula based on the letter frequencies of the input:

my &f={[*] 1..$_ div 2}
A helper function that halves a number and rounds it down to the nearest integer, and then takes the factorial of that.
.comb.Bag{*}.&{    };
Tally up the letter frequencies in the input string, and make them the topic for the rest of the code.
E.g. for input abcdabcdddddd this would be the list (2, 2, 2, 7).
(2>.grep(*%2))*
If there is more than one odd letter frequency, multiply the result by zero, because no palindromes are possible in that case.
f(.sum)/[*]($_».&f)
Calculate the number of possible permutations of the characters that will be on "one side" of each palindrome (which corresponds to a multiset with the multiplicities obtained by halving and flooring the input letter frequencies). The formula used is from this PDF:
(n1+...+ nk)! / (n1!⋅...⋅nk1)
E.g. for input letter frequencies (2,2,2,7), the letters on one side of the palindrome form a multiset with multiplicities (1,1,1,3), and the number of permutations is thus (1+1+1+3)! / (1!⋅1!⋅1!⋅3!) = 120.
%666013
Take the result modulo 666013.

Good to see that my alternative method is valid!

Python3, 81 80 bytes
from itertools import*
lambda s:sum(a==a[::-1]for a in{*permutations(s)})%666013

This is the shortest I could come up with. Not sure if the permutations can be generated more easily...
Explanation
lambda s:                       # Anonymous function taking a parameter <s>.
    sum(                        # Sum the following terms.
        a==a[::-1]              # Check whether the permutation <a> is a palindrome,
        for a in                # for each element <a>,
        {                       # inside a set that can only contain distinct elements.
            *                   # Splat the elements of the following object:
            permutations(s)     # the permutations of the input parameter <s>.
        }                       #
    )%666013                    # Modulo the sum by 666013.

Notes

The check a==a[::-1] returns a boolean value, but the sum(...) function implicitly casts it to an integer (0 or 1) and sums accordingly.
I have to use the 'splat operator' (not the real name), to extract the elements from the object permutations(...). Otherwise the set ({...}) would contain only one element, the object itself.
I use a set ({...}) to keep only distinct permutations inside.

In Floroid, this is (almost) z(T(a==aDKaIW(cb(L)))%666013), but prints the result instead, and takes input through the command line.
Thanks to @Jonathan Allan for saving a byte! --> Changed the import style
Try it online!

Jelly, 13 bytes
Œ!QŒḂ€S%“µɲ€’

Try it online!
How?
A brute forcer.
Œ!QŒḂ€S%“µɲ€’ - Main link: string
Œ!            - all permutations
  Q           - unique
     €        - for each
   ŒḂ         - isPalindromic? (yep a built-in!)
      S       - sum
       %      - mod
        “µɲ€’ - base 250 compressed number 666013

I believe that this will do it more efficiently, but it's 30 bytes (edit: this pdf seems to confirm it, courtesy of smls's answer):
ÑHḞµS!÷!P$ - Link 1, palindrome count: string a    e.g. 'abcabcd'
Ñ          - call the next link (2) as a monad(a)  e.g. [2, 2, 2, 1]
 H         - halve                                 e.g. [1, 1, 1, 0.5]
  Ḟ        - floor (get pair counts)               e.g. [1, 1, 1, 0]
   µ       - start a new monadic chain - call that p
    S      - sum(p)                                e.g. 3
     !     - factorial                             e.g. 6
         $ - last 2 links as a monad:
       !   -     factorial(p) (vectorises)         e.g. [1, 1, 1, 1]
        P  -     product                           e.g. 1
      :    - integer division                      e.g. 6

ĠL€ - Link 2, count characters: string a           e.g. 'abcabcd'
Ġ   - group indexes                                e.g. [[1, 4], [2, 5], [3, 6], 7]
 L€ - length of €ach                               e.g. [2, 2, 2, 1]

ÇḂS⁼LḂ$aÑ%“µɲ€’ - Main link: string a              e.g. 'abcabcd'
                - first check to see if any palindromes will be possible:
Ç               - last link (2) as a monad         e.g. [2, 2, 2, 1]
 Ḃ              - mod 2                            e.g. [0, 0, 0, 1]
  S             - sum                              e.g. 1
      $         - last two links as a monad:
    L           -     length(a string)             e.g. 7
     Ḃ          -     mod 2                        e.g. 1
   ⁼            - equal?                           e.g. 1 (1 when palindromes are possible)
       a        - and
        Ñ       - next link as a monad             e.g. 6
         %“µɲ€’ - mod 666013, as in the brute force version.

Yes it does, the % is mod.

Gah, I was just about to post exactly this answer, but didn't get there in time because I posted the Brachylog answer first. A matter of second in it, I think. Clearly I should remember that Jelly is a more popular language than Brachylog and so I should work on that submission first.

Wow, byte for byte? I have another 13 too, but think it's slightly less efficient :)

Is the number compressed in a different base or what? :P

From my TIO tab, Œ!QŒḂ€S%“µɲ€’. That looks bytewise identical to me.

@TuukkaX yes it's in base 250 (the bytes inside the quotes).

Your alternative method doesn't corrently handle inputs with odd letter counts>1 (my answer didn't either in its first revision). E.g. aadddeee should produce 0, and aaddd should produce 2.

@smls oops, yes; fixed - I was counting the number of 0.5s in the halved counts rather than counting the number of odd counts. (managed to rearrange for a 0 byte cost too).

Mathematica, 46 bytes
Permutations@#~Count~_?PalindromeQ~Mod~666013&

Takes a list of characters as input.
Terribly inefficient, because it actually generates all permutations of the input and then counts the palindromic ones.

I think this incorrectly gives a positive answer, rather than 0, if the string has multiple letters occurring with odd multiplicity (like "abcdabcddddddeee").

@GregMartin Thanks, fixed. This was needlessly complicated anyway.

Mathematica, 68 bytes
If[i=Floor[t=Last/@Tally@#/2];Tr[t-i]<1,Multinomial@@i,0]~Mod~666013

Pure function taking a list of characters as input and returning an integer. Not as short as Martin Ender's Mathematica answer, but it's a cute approach nonetheless, which seems to be the same approach as in smls's Perl 6 answer.
First, t=Last/@Tally@#/2 computes the counts of all the distinct characters in the input, divided by 2; then i=Floor rounds down any fractions occurring in t. Note that palindromic permutations of the input exist exactly when there is at most one odd number among the original counts, that is, when there is at most one fraction in t. We can test for that by simply adding up all the elements of t-i (using Tr): if the answer is less than 1, there are palindromic permutations, otherwise not.
If there are, then i represents the counts of distinct characters in the left half of the permutations, which can be arranged arbitrarily. The number of ways to do that is exactly the Multinomial coefficient (a quotient of certain factorials), which Mathematica has built-in.

k, 23 bytes
{666013!+/{x~|x}'cmb x}

If using oK, or cmb doesn't exist, use prm instead of cmb.

Pyth - 15 bytes
%l{_I#.pQ666013

Try it online here.

Ruby, 67 57 52 59 chars
->s{s.chars.permutation.uniq.count{|t|t.reverse==t}%666013}

Codegolf submissions should be proper programs/functions/lambdas, not snippets. I'm not a Ruby programmer, but I think you can turn this into a lambda by wrapping it in ->s{  }, can't you?

Also, based on the documentation, isn't the (s.size) argument redundant?

I tested it on Ruby 2.4, and it works without the .to_a too.

@smls Doesn't work on ruby 2.3.3 (undefined method uniq' for #<Enumerator`), but right it works on ruby 2.4, thanks :)

Does the result have to be taken mod 666013?

@NonlinearFruit I guess yes, it just doesn't make sense why such a random number

Japt, 20 18 bytes
á f_¥Zw} l %666013

Saved 2 bytes thanks to ETHproductions.
Try it online!

Nice, that's what I would have done. You can save two bytes with f_¥Zw} , as _ is short for Z{Z

á fêS â l %666013 would save you a byte.

C++14, 161 bytes
As unnamed lambda assuming input is like std::string and returning via reference parameter.
#import<algorithm>
[](auto s,int&n){auto a=s.begin(),b=s.end();std::sort(a,b);n=0;do n=(n+std::equal(a,b,s.rbegin()))%666013;while(std::next_permutation(a,b));}

Ungolfed and usage:
#include<iostream>
#include<string>

#import<algorithm>
auto f=
[](auto s,int&n){
 auto a=s.begin(),b=s.end();
 std::sort(a,b);
 n=0;
 do
  n=(n+std::equal(a,b,s.rbegin()))%666013;
 while(std::next_permutation(a,b));
}
;

using namespace std;

int main(){
 string s;
 s = "cababaa";
 s = "abcdabcddddd";
 int n;
 f(s,n);
 cout << n << endl;
}

MATL, 13 bytes
Y@Xu!"@tP=Avs

Try it at MATL Online
Explanation
        % Implicitly grab input as a string
Y@      % Compute all permutations of the inputs (one per row)
Xu      % Determine the unique rows
!       % Take the transpose so each permutation is a column
"       % For each unique permutation
  @     % Take this permutation
  tP=A  % Duplicate it, reverse it, and compare (yields 1 for palindrome and 0 otherwise)
  v     % Vertically concatenate the entire stack
  s     % Compute the sum of all elements
        % Implicitly end for loop and display the result

CJam, 19 bytes
qe!{_W%=}%:+666013%

Try it online!
Explanation:qe!{_W%=}%:+666013% e# Full program.
q                   e# Get all input.
 e!                 e# Get all unique permutations.
   {_W%=}           e# Function to check if a list is a palindrome.
    _               e# Duplicate ToS.
     W%             e# Reverse ToS (Push -1, Modular index of ToS).
       =            e# Check if ToS is equal to SToS.
         %          e# Map.
          :+        e# Sum (Reduce by addition).
            666013  e# Push 666013.
                  % e# Modulo.

Ohm, 17 bytes
I⌐:_₧?¡;;¼,

Explanation:
I⌐:_₧?¡;;¼,  ■Main wire
I⌐:     ;    ■for _ in permutations(input()){
   _₧? ;     ■  if(palindrome(_)){
      ¡      ■    counter++;
       ;     ■  }
        ;    ■}
         ¼,  ■print(counter)

PHP, 182 Bytes
function f($a,$b=1){return$a?f($a-1,bcmul($a,$b)):$b;}$a=count_chars($argv[1],$r=1);foreach($a as$v){$c+=$v%2?:0;$c>1?die("0"):$z+=$f=$v/2^0;$r=bcmul(f($f),$r);}echo bcdiv(f($z),$r);

Online Version
Breakdown
function f($a,$b=1){  #Factorial
    return$a?f($a-1,bcmul($a,$b)):$b;
}
$a=count_chars($argv[1],$r=1); # Array count for every char
foreach($a as$v){
    $c+=$v%2?:0; # counter mod 2 ==1
    $c>1?die("0"):$z+=$f=$v/2^0; # end program if there are 2 chars which cannot divide by 2
    $r=bcmul(f($f),$r);
}
echo bcdiv(f($z),$r);

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/


text:
Fizz Buzz Lightyear
In the wake of the many (two?) FizzBuzz-related challenges posted recently on PPCG, I've been tempted to come up with my own. Behold...
Fizz Buzz Lightyear
Write a program or function that takes an integer n and prints out FizzBuzz for any number divisible by 15, Fizz for any number divisible by 3, and Buzz for any number divisible by 5, up to (and including) n. Output for all i must be followed by a newline. But there's a twist!
For every third time you print Buzz, Buzz Lightyear finally heeds your call and crash lands in your program. He then introduces himself - but since he crash landed, some of what he said gets mixed up with your program's output:
Buzz Lightyear, Space Ranger, Universe Protection Unit.
FizzBuzz Lightyear, Space Ranger, Universe Protection Unit.

(that is, only append  Lightyear, Space Ranger, Universe Protection Unit. to Buzz or FizzBuzz - whatever it is you'd have displayed otherwise. Note the leading space)
However, Buzz Lightyear, being the Space Ranger he is, has very acute hearing, and so printing FizzBuzz will count towards your Buzz count.
Then, Buzz hangs around to defend your computer from all of that evil output, until you hit another number that's divisible by 5 (or 15, since those are divisible by 5, too). What that means is until you have to print Buzz (or FizzBuzz) again, you don't print anything at all.
When you finally reach that condition, Buzz departs:
To infinity and beyond!

Example Output
This is the expected output for n = 25: (notice how it skips 16 through 19)
1
2
Fizz
4
Buzz
Fizz
7
8
Fizz
Buzz
11
Fizz
13
14
FizzBuzz Lightyear, Space Ranger, Universe Protection Unit.
To infinity and beyond!
Fizz
22
23
Fizz
Buzz

Rules
Optional trailing newline is acceptable.
This is code golf; as such, shortest code, in bytes, wins.
Assume given n is valid and greater than or equal to 15 (which is when the challenge first deviates from standard fizzbuzz)
Buzz greets you when the "Buzz counter" (which counts both Buzz and FizzBuzz) hits 3; he departs when the next Buzz (including, again, both Buzz and FizzBuzz) is printed.
The number in which he departs does not count towards the next "Buzz counter"; you should instead start counting the Buzzes again from 0. For instance, a program running with n = 25 (example output) should end with a "Buzz counter" of 1, since that's how many times Buzz was printed since the last time he departed.
In case n falls between one of Buzz's arrivals and one of his departures (i.e., he's still there - you're not printing anything), graceful termination is expected. Therefore, the last line of output would be his introduction
Standard loopholes are forbidden.

Can you clarify the expected behavior when n falls in-between Buzz Lightyear's arrival and his departure?

Simply quit the program. I'll edit the rules in a second

Javascript (ES6), 182 175 bytes

-7 bytes: Moved Buzz Lightyear logic into Buzz ternary expression.

f=(n,s=i=b=_='')=>i++<n?f(n,s+`${(i%3?_:'Fizz')+(i%5?_:`Buzz${++b%3?_:` Lightyear, Space Ranger, Universe Protection Unit.${(i+=5)>n?_:`
To infinity and beyond!`}`}`)||i}
`):s
<!-- snippet demo: -->
<input oninput=o.innerHTML=f(this.value)>
<pre id=o>

Python 2, 185 178 172 bytes
for i in range(input()):
 if-~i%20<16:print i%20/19*"To infinity and beyond!"or i%3/2*"Fizz"+i%5/4*"Buzz"+i%20/14*" Lightyear, Space Ranger, Universe Protection Unit."or-~i

Try it online!
Explanation
Observe: Buzz Lightyear arrives on the third "buzz number" and departs on the fourth. "Buzz numbers" are the multiples of five. Thus, Buzz's movements happen on a cycle of length 20.
We loop over each i from 0 through input-1. (This means that i is always one less than the actual number we're considering.)
Using -~i as a shortcut for i+1, if-~i%20<16: checks if i+1, mod 20, is 15 or under. (If it's 16 to 19, Buzz Lightyear is present and we don't want to output anything.)
Inside the if statement, we want to print To infinity and beyond! on every multiple of 20--that is, every time i%20 is 19. (Remember that i is one less than the actual number.) Since i%20 will never be greater than 19, i%20/19 will be 1 in the desired case, <1 otherwise. Python 2, conveniently, truncates floats when multiplying by strings, so i%20/19*"..." gives the full string if i%20 is 19, otherwise "".
If the above case applies, we don't print anything else. But if the first expression is "" (which is falsy), we use or to keep going. The expressions for Fizz, Buzz, and the introduction are computed similarly to the above and added together.
Finally, if none of these cases applies, we print the number itself with -~i.

05AB1E, 97 93 90 bytes
>GN"FizzBuzz"2äN35SÖÏJ)˜1(è“To infinity€ƒ—°!“)N20%©_è®15Q” Lightyear,‡²ìÓ,ªÜŠí‰¿.”×J®16‹i,

Try it online!
Explanation to come after further golfing.
Alternative 97 byte version
>G"FizzBuzz"2ä” Lightyear,‡²ìÓ,ªÜŠí‰¿.”)˜N•9¨•3äR%15%_ÏJ“To infinity€ƒ—°!“)N20ÖèN)˜é®èN20%15›i\},


text:
Blink the CAPS LOCK
Most computer keyboards feature a small integrated LED light,
indicating the current input mode, as controlled with the CAPS LOCK button.

Your task is to blink it:

Turn it on;
Wait for 0.5 (+/-0.1) seconds;
Turn it off again.

Video footage of the LED blinking is highly appreciated !
Rules

You can blink a different LED (e.g. Scroll Lock, Num Lock, Wi-Fi status etc), if you wish, but it must be physically located on your keyboard;

If your language is missing a subsecond sleep command, your program may use a 1 second delay instead, at a penalty of +2 bytes (that's for 0.);

Your program must blink at least once, what happens afterward is up to you, i.e. it can continue to blink (in which case you must wait for the same delay, before turning it on again), or halt e.t.c.;

If the chosen LED is ON by default, on your system, you can assume that it has been explicitly switched off (e.g. manually), before the program is run;

This is code-golf, the shortest answer in bytes wins.

Leaderboard

var QUESTION_ID=110974,OVERRIDE_USER=61904;function answersUrl(e){return"https://api.stackexchange.com/2.2/questions/"+QUESTION_ID+"/answers?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+ANSWER_FILTER}function commentUrl(e,s){return"https://api.stackexchange.com/2.2/answers/"+s.join(";")+"/comments?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+COMMENT_FILTER}function getAnswers(){jQuery.ajax({url:answersUrl(answer_page++),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){answers.push.apply(answers,e.items),answers_hash=[],answer_ids=[],e.items.forEach(function(e){e.comments=[];var s=+e.share_link.match(/\d+/);answer_ids.push(s),answers_hash[s]=e}),e.has_more||(more_answers=!1),comment_page=1,getComments()}})}function getComments(){jQuery.ajax({url:commentUrl(comment_page++,answer_ids),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){e.items.forEach(function(e){e.owner.user_id===OVERRIDE_USER&&answers_hash[e.post_id].comments.push(e)}),e.has_more?getComments():more_answers?getAnswers():process()}})}function getAuthorName(e){return e.owner.display_name}function process(){var e=[];answers.forEach(function(s){var r=s.body;s.comments.forEach(function(e){OVERRIDE_REG.test(e.body)&&(r="
"+e.body.replace(OVERRIDE_REG,"")+"
")});var a=r.match(SCORE_REG);a&&e.push({user:getAuthorName(s),size:+a[2],language:a[1],link:s.share_link})}),e.sort(function(e,s){var r=e.size,a=s.size;return r-a});var s={},r=1,a=null,n=1;e.forEach(function(e){e.size!=a&&(n=r),a=e.size,++r;var t=jQuery("#answer-template").html();t=t.replace("{{PLACE}}",n+".").replace("{{NAME}}",e.user).replace("{{LANGUAGE}}",e.language).replace("{{SIZE}}",e.size).replace("{{LINK}}",e.link),t=jQuery(t),jQuery("#answers").append(t);var o=e.language;/s.lang?1:e.lang<s.lang?-1:0});for(var c=0;c<t.length;++c){var i=jQuery("#language-template").html(),o=t[c];i=i.replace("{{LANGUAGE}}",o.lang).replace("{{NAME}}",o.user).replace("{{SIZE}}",o.size).replace("{{LINK}}",o.link),i=jQuery(i),jQuery("#languages").append(i)}}var ANSWER_FILTER="!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe",COMMENT_FILTER="!)Q2B_A2kjfAiU78X(md6BoYk",answers=[],answers_hash,answer_ids,answer_page=1,more_answers=!0,comment_page;getAnswers();var SCORE_REG=/<h\d>\s*([^\n,]*[^\s,]),.*?(\d+)(?=[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/,OVERRIDE_REG=/^Override\s*header:\s*/i;
body{text-align:left!important}#answer-list,#language-list{padding:10px;width:290px;float:left}table thead{font-weight:700}table td{padding:5px}
 <link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b">

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

{{PLACE}}	{{NAME}}	{{LANGUAGE}}	{{SIZE}}	Link

{{LANGUAGE}}	{{NAME}}	{{SIZE}}	Link

Cheating answer that doesn't quite work: on a Linux system, intentionally crash the kernel. Linux's equivalent of a BSOD flashes the Caps Lock light, just in case the crash also took down the video hardware and you can't see the BSOD report onscreen. Unfortunately, as far as I can tell it flashes a little too fast to be an eligible answer. This would lead to a (somewhat malicious) 14-byte solution if it were allowed.

Does it need to be an LED, or can it be any type of indicator light on the keyboard?

@12Me21 Well, it's a tricky one, I'm probably ok with a different type of indicator, as long as it is a dedicated hardware thing, which sole purpose is to indicate that something is on or off, e.g. blinking a pixel on a general purpose touch screen does not count.

Now blink it in Morse code: "Help, I'm trapped in a keyboard factory!"

@ais523 my laptop will do that if I shake it (0 bytes). Too fast tho...

The capslock key on a C64 is a mechanical switch.  Blinking that might be a bit tricky...

@Mark, still can be done with a bit of Arduino and some type of actuator, not sure on how to include them in the byte count though.

I want to see an Objective-c or Swift answer toggling the capslock on an iPhone keyboard

Now I'm wondering whether the low-battery LED on my wireless keyboard flashes at the correct rate. If so: zero bytes.

Is it okay if we write a snippet (I'm thinking about Swift, where writing an entire program is literally making a whole app).

@Dopapp, by default, you should either submit a full program or a function,
so you can probably just do the latter.

@mbomb007 I wrote that patch once :)

@mbomb007 Cameras can steal data from computer hard drive LED lights. "The researchers found that once malware is on a computer, it can indirectly control the HDD LED, turning it on and off rapidly (thousands of flickers per second)—a rate that exceeds the human visual perception capabilities. As a result, highly sensitive information can be encoded and leaked over the fast LED signals, which are received and recorded by remote cameras or light sensors."

@KeithMcClary Even more impressive is that data may be exfiltrated from an air-gapped machine (up to 8 bits per hour) using room temperature fluctuations created by changing the amount of heat the machine generates. Other methods

@whrrgarbl - I believe most implementations here will actually be longer without the loop, as this way they don't have to repeat the code to turn the Caps Lock (or whatever indicator they use) off. Otherwise, it is not required (i.e. you can just blink once).

I made a code golf puzzle inspired by this one, called "Blink the webcam light!" Is this okay? I've given the appropriate credit, including linking to both this question and your user profile on [codegolf.se].

@haykam I'm fine with that, it's actually nice to hear that my challenge has inspired you to post your own.

@zeppelin if my language has a way to do a subsecond sleep but it's more than 2 bytes longer than a 1 second sleep, can I choose to take the penalty for the 1 sec sleep?

@briantist This rule was introduced to allow languages which can not do a sub-second delay to still compete, so if your language can do a sub-second delay, I would say that you have to use that. However, I release that there might be some borderline cases (e.g. there is a sub-second delay command, but it is not documented or is only available in some implementations but not the others), in those cases I rely on the community to do its vote.

@RogerLipscombe you would need a program to drain the battery then ;)

By the way, why a two-byte penalty for a one second delay? In many languages (e.g., C) you can just drop the zero and write ".5".

@Ale, in some languages you can shortcut it to .5, but in others it would be 500 or 0.5 instead, I was trying to find a compromise here.

@zeppelin right didn't think that even in C it would have even been a usleep(500000)... as it doesn't take floating point parameters

@mbomb007 lol beat me to it

@DLosc are you there? It really deserves a QBasic answer!

Befunge (BEF32), 390 334 305 bytes
This is really silly, but as long as this site accepts the notion that the interpreter defines the language, I might as well abuse the rule. This code only works in Kevin Vigor's Win32 Befunge-93 Implementation, version 1.01 (I think the only version available). You can download the binary here.
p55p99+5p65*5p")"5p"M"3*"I~q"+\3*3445"|"2*"lm"2v
v"y"*3\*2"e/n"4\5"nnIn"*833*2"mn"4\7"nnIn"*833*<
>2*"yO"4"DJG"3*\2*55*3"T"4"DLG"3*\2*55*3"/~M"+\3*4446"~A"+4v
>+00p9p:v:"l'"*2"^D"4"l3"*2"^D"4"l"*54*2"^D"4"l"*2+94*2"^D"<
^1:g00-4_5"u1"*-:1+:1+"@"\0p"%"5*\0p"P"\0p@
Sleep kernel32.dll keybd_event user32.dll

Now normally you wouldn't expect this sort of challenge to be possible in a Befunge, but BEF32 is a Win32 port of a very old version of the reference implementation, and back then there was no bounds checking on the p (put) command. This effectively allows us to write to any location in memory, which ultimately lets us force the interpreter to execute arbitrary machine code.
Now we can't actually alter any of the existing code, since the .text section of the executable won't have write permissions. However, we can trick the system into executing an address in the .data section, by writing that address into the the runtime library's atexit table (at least I suspect that's what it is). The end result is that our code is automatically executed when the interpreter exits.
This relies on the fact that the executable is loaded at a fixed address, so we know exactly where everything is in memory - it assumedly wouldn't work if you overrode the default ASLR settings. It also relies on the .data section being executable, despite not having the executable attribute set, so again it most likely wouldn't work if you overrode the default DEP settings.
The code itself is essentially a copy of Mego's keybd_event technique translated into machine code:
6823B84000         push "keybd_event"
682FB84000         push "user32.dll"
6810B84000         push "Sleep"
6816B84000         push "kernel32.dll"
BB02000000         mov  ebx,2
               initloop:
89C7               mov  edi,eax
FF1594D14000       call LoadLibraryA
50                 push eax
FF1590D14000       call GetProcAddressA
4B                 dec  ebx
75EE               jnz  initloop
89C6               mov  esi,eax
               flashloop:
6A00               push 0
6A01               push 1
6A45               push 69
6A14               push 20
FFD6               call esi
6A00               push 0
6A03               push 3
6A45               push 69
6A14               push 20
FFD6               call esi
68F4010000         push 500
FFD7               call edi
EBE3               jmp  flashloop

This version of the code continues flashing forever (or at least until you kill the process), since that turned out to be easier to golf than a single flash.
And since everyone is posting animations, this is an approximation of what it looks like on my keyboard.

People usually abuse rules in order to make life easier for them, but those are not Befunge coders :)

Never expected an esolang answer to this challenge +1

This is now my favourite answer on this site

Excellent implementation!

While I very much appreciate all the upvotes, and the bounty (thank you @Pureferret), I feel obliged to point out that for a code golf challenge this is literally the worst answer here!

@JamesHolderness So? This is a great answer, even if it is long.

AutoHotkey, 29 26 bytes
Thanks to @Dane for saving 3 bytes
Loop{
Send,{VK14}
Sleep,500
}

I originally chose NumLock because it's one character shorter than CapsLock. The GIF below reflects that condition. It's the same effect as the altered code above. I could have gone with VK90 above to make the GIF still be accurate but aligning with the original challenge felt better.

In honor of mbomb007's comment, here's a morse code message in 239 bytes:
s:=000090901009011091100110090111109111901090190110901109091000091001101909101191000911190190109100001090191010919111901091011
Loop,123{
StringMid,c,s,A_Index,1
IfEqual,c,9
{
Sleep,2000
Continue
}
Send,{NumLock}
Sleep,%c%500
Send,{NumLock}
Sleep,500
}

Here are the first 30 seconds of that message:

How about send,{vk14} instead to shave off 3 bytes? Bonus: you'd be blinking the CapsLock.

GFA-Basic 3.51 (Atari ST),  61 56 43  35 bytes
This code will make the floppy drive LED blink forever at the required rate (PAUSE 25 = pause for 25 / 50 second).
This would probably be shorter in assembly, but I don't have the appropriate tools at my fingertips. This is the size of the GFA-Basic listing once saved in .LST format and manually edited to remove useless whitespace, rename instructions to shorter strings and replace each CR+LF with a simple CR. Note that a final CR is required.
DO
i=i XOR2
SP &HFF8802,i
PA 25
LO

Will automatically expand to:
DO
  i=i XOR 2
  SPOKE &HFF8802,i
  PAUSE 25
LOOP

SPOKE is a supercharged POKE that first puts the 68000 in supervisor mode, so that it's allowed to access restricted memory areas (here: the register write address of the YM2149 soundchip, which is also responsible for some other I/O).
And yes: the LED is physically located on the keyboard ... I suppose.

I don't have access to a real ST right now, so this is just a mockup.

Floppy drive! Wow!

Hand-drawn red circle missing ...

fish + ckb, 56 54 bytes
while cd;echo rgb (random)|tee /d*/*/*/c*;sleep .5;end

Blinks my entire keyboard in random colors, though since the number isn't 6 hex digits long it's a bit limited.

And yes, that shell glob is potentially dangerous. Works On My Machine™
Bonus script, 8 months later: This will go through all colors. Not golfed.
#!/usr/bin/fish
while true
        echo rgb (printf '%06x' (random 0 16777215)) | tee /dev/input/ckb*/cmd > /dev/null
        sleep 0.5
end

Which keyboard is it? lol

@McKernel bump curious as to what keyboard that is as well

K70 RGB with custom keycaps - https://unascribed.com/f/67209fe8_keyboard_design.svg

Bonus points for going above and beyond by making the entire keyboard blink.

tee /d*/*/*/c*? Bonus points for being liable to brick some poor sod's computer in the future when this inevitably expands to something important. (EFI variables anyone? Maybe there'll be something like /dev/efi/vars/cpu_type)

Bash + amixer, 45 Bytes
a() { amixer set Master toggle
}
a;sleep .5;a

Blinks the mute light on my keyboard.

a()(amixer set Master toggle;sleep .5;a) or amixer set Master toggle;sleep .5;$0 as a full program are a bit shorter.

C (Windows), 79 bytes
#include<windows.h>
k(n){keybd_event(20,69,n,0);}f(){k(1);k(3);Sleep(500);f();}

Explanation
keybd_event is a (deprecated) Windows API function to send a keyboard event (keyup or keydown). 20 is the code for the Caps Lock key, 69 is the hardware scan code (I have no idea what that means), and 1 means keydown and 3 means keyup. A keypress is simulated by sending a keydown event immediately followed by a keyup event. One keypress is sent to turn on Caps Lock, then the program sleeps for 500 milliseconds, and then another keypress is sent to turn Caps Lock back off.
Thanks to Steadybox for a bunch of bytes saved

Given this is C, can you not declare int keybd_event();?

@Neil It would be void keybd_event();, and I also need void Sleep(); from windows.h. Those two declarations together are longer than the include.

D'oh, I totally overlooked Sleep. (But C doesn't really care if something doesn't return int if you don't use the result.)

@Neil There would still be a return type mismatch between the declarations and the definitions.

79 bytes: #include<windows.h> k(n){keybd_event(20,69,n,0);}f(){k(1);k(3);Sleep(500);f();}

Sure, but for primitive types, C doesn't care about the mismatch if you never use the result.

@Neil Regardless, the windows.h header also does a lot of other preprocessing needed to make things work. That's not how C is supposed to be done, but it's Windows...

Scan codes are what your keyboard sends over the wire at the lowest level. Their values are based on positions in a standard layout because doing that let them make the keyboard as dumb as possible and without having to wire each key up (limitations of this design are part of why cheaper keyboards can only return a few simultaneous keystrokes - the baseline USB keyboard interface then baked the limitation into the vast majority of keyboards about 20 years ago by designing to the min std) at the cost of offloading a translation step onto the host computer. https://en.wikipedia.org/wiki/Scancode

I didn't even see this answer and wrote the C# version, nice!

MATLAB, 146 136 70
Thanks to @Poke for removing 66 bytes!
r=java.awt.Robot;while 1
r.keyPress(20)
r.keyRelease(20)
pause(.5);end

This uses Matlab's ability to call Java classes. The Caps Lock light is blinked in a loop by programmatically pressing and releasing Caps Lock.
Video or it didn't happen.

Can you use 144 instead of java.awt.event.KeyEvent.VK_NUM_LOCK? CAPS_LOCK would be 20

@Poke Yes! There go 66 bytes!!

Funny that it's shorter than the java answer

x86 machine code for PC (e.g. MS-DOS COM file), 27 bytes
This machine code (displayed here with a Unicode rendering of the usual CP437 of PC BIOS) will blink the CAPS LOCK indicator forever on a PC:
j@▼î▐j`Z░φεê╪εÇ≤♦╞♦◙Ç<☺t∩δ∙

The code has been made so it contains no NULL bytes, and can thus be typed with the keyboard (using the Alt+XXX trick for extended characters) to create a COM file (e.g., using the COPY CON blink.com command under MS-DOS, in which case the output file will have to contain a spurious 28th byte, the ^Z (EOF) character required to stop the copy operation).
The effect is achieved by directly sending commands to the keyboard controller of the PC (port 60h) to set the LED state (as a side-effect, it might set Num Lock and Scroll Lock LEDs to a random non-blinking state). The timing, to minimize the number of instructions, is achieved by using the countdown timer maintained by the BIOS at address 0040:0040 (it decrements every 54.925 ms, with 9 cycles the blinking cycle is 494.3 ms, which is within the allowed margin) — this counter is normally used by the BIOS to stop the floppy disk motor; as the floppy drive is not used by the program and the code is assumed to run in a single-task environment (e.g. DOS), playing with the floppy motor timer is not an issue.
The code runs fine under MS-DOS (tried with VirtualBox, it should also run fine on real hardware, although I didn't have the time yet to make a bootable MS-DOS USB stick to test). As it doesn't rely on any OS functions, it can even run without the operating system (e.g., by placing it in the boot sector of a disk). It requires at least a 80186 processor to run, because of the "immediate push" instructions used to shorten the code of some bytes.
Assembly source code:
  PUSH 0x40               ; pushes 0x0040 (BIOS data segment) on the stack
  POP DS                  ; pops it into DS segment selector
  MOV SI, DS              ; copies DS to SI (timer counter is nicely placed at 40:40)
  PUSH 0x60               ; pushes 0x0060 (kbd controller port) on the stack
  POP DX                  ; pops it to DX
loop:
  MOV AL, 0xED            ; 8042 keyboard controller 'set mode indicators' command
  OUT DX, AL              ; outputs the command to the keyboard contr oller
  MOV AL, BL              ; copy BL register to AL
  OUT DX, AL              ; outputs LED state to keyboard controller
  XOR BL, 4               ; toggles bit 2 (CAPS LOCK) for next iteration
  MOV BYTE PTR[SI], 0x0A  ; sets floppy motor countdown timer to 10
wait:
  CMP BYTE PTR[SI], 0x01  ; checks if timer reached 1
  JE loop                 ; if yes, time for next iteration
  JMP wait                ; if not, checks again

Hexadecimal dump of the assembled code:
6A 40 1F 8C DE 6A 60 5A B0 ED EE 88 D8 EE 80 F3 04 C6 04 0A 80 3C 01 74 EF EB F9

Here is the result running under MS-DOS in VirtualBox (doesn't work with DosBox, presumably because the keyboard controller is not completely emulated):

(sorry for the shaky video).

An example of actually using copy con program.exe : https://www.youtube.com/watch?v=iefuJ_jZAiQ

SmileBASIC, 36 23 bytes
XON MIC
WAIT 30XOFF MIC

Blinks the microphone status light.
(video coming soon)

Python2 - 108 bytes
Does the capslock key. Interestingly, this actually turns on just the LED itself without affecting the keyboard or pressing the key. You can change the 4 at the end to 2 to do numlock. 6 does both.
import fcntl,os,time;exec"fcntl.ioctl(os.open('/dev/console',os.O_NOCTTY),19250,%d);time.sleep(.5);"*2%(4,0)

Looks like I got an error: Traceback (most recent call last):   File "<stdin>", line 1, in <module>   File "<string>", line 1, in <module> IOError: [Errno 25] Inappropriate ioctl for device

@haykam are you on Windows?

No, I'm on macOS Sierra Version 10.12.1 (16B2555).

shell+numlockx, 40 35 bytes
[Saved 5 bytes thanks to Ryan.]
Continually blinks the NumLock light on unixish systems.
numlockx toggle;sleep .5;exec sh $0

Single blink, 33 bytes
numlockx on;sleep .5;numlockx off

You can use exec sh $0 instead of while to save 5 bytes, or sh $0 if creating processes forever is considered okay.

watch -n0.5 numlockx toggle   for 27 bytes.

For a different flavour of the above, on interactive shells, you could type in: numlockx toggle;sleep .5;!# (27 bytes) for a single blink . !# is the history expansion event replaced by everything typed so far in the command line.

in the single blink command, the on can be omitted. it's the default.

With assignments, no tricks: f=numlockx;$f;sleep .5;$f off (29). And (an inferior) looping version using recursion: g(){ f=numlockx;$f toggle;sleep .5;g;};g (40).

PowerShell, 71 bytes
for(){(New-Object -c WScript.Shell).SendKeys('{NUMLOCK}');sleep -m 500}

Notes

Blinks forever
Uses NUM LOCK to save a byte.

"If your language is missing a subsecond sleep command..." - doesn't sound like it's missing from PowerShell.

@Dane I've asked the poster for clarification. If electing to accept the penalty is not allowed I will revert it.

@Dane rolled back.

How come sleep .5 doesn't work here? I tried it and it seems to go at like 5ms but I thought by default it's (-s) so it would be 0.5 s?

@JakeHarry: The -Seconds parameter is an int, so 0.5 will be converted to int, which results in 0 (round to even is the default rounding mode). So you're not sleeping at all (results in a delay of about 1000 ticks here, so 10 µs). Fairly basic conversion and parameter binding rules in PowerShell.

VBS, 75 bytes
do
wscript.sleep 500
Createobject("wscript.shell").sendkeys"{numlock}"
loop

Repeatedly blinks Num Lock key, as numlock is 1 byte shorter than capslock.

C#, 215 202 198 195 185 bytes
Without realising I have done the "same" code as this answer by @Mego, go check it out!.
[System.Runtime.InteropServices.DllImport("user32")]static extern void keybd_event(int v,int s,int f,int e);n=>{for(n=0;;System.Threading.Thread.Sleep(125))keybd_event(20,69,n++&2,0);};

Saved 13 bytes thanks to @Metoniem
Saved 10 bytes thanks to @VisualMelon
Here's a full formatted version showing it working:
class P
{
    [System.Runtime.InteropServices.DllImport("user32")]
    static extern void keybd_event(int v, int s, int f, int e);

    static void Main()
    {
        System.Action<int> a = n =>
        {
            for (n = 0; ; System.Threading.Thread.Sleep(125))
                keybd_event(20, 69, n++ & 2, 0);
        };

        a(0);
    }
}

For bonus fun change n++ & 2 to n+=2 & 2 and watch the num lock and caps lock keys alternate in flashing on and off. I have no idea why that happens because it shouldn't but it looks "cool".

Wait, you're using System; but as far as I can tell you're not actually using anything directly from the System namespace? I think you can remove that.

@Metoniem Good spot the signature for the keybd_event method is actually void keybd_event(byte bVk, byte bScan, uint dwFlags, UIntPtr dwExtraInfo);. I releasise I could remove the UIntPtr's after posting and have them as int's and just forgot to remove the using.

Ahh, I see haha, stuff like that happens! Nice answer man :)

I think you really should name and type the two 'functions': you refer to k in one, but it is clearly undefined. Not checked, but I think you'd be better off having one call to keybd_event in an unbraced for loop, I should think: for(int i=0;;...Sleep(250))keybd_event(i++&2) or something.

@VisualMelon Thanks, I have updated the code, had to alter the sleep to get the timing right though :)

With ++ you send 0, 0, 2, 2 in a loop. With +=, the parsing is n += (2 & 2) so you send 2, 4, 6, 8... That parameter's only documented as supporting 0, 1 and 2 so maybe the higher numbers are interfering somehow.

Java 7, 121 118 113 bytes
void a()throws Exception{java.awt.Robot r=new java.awt.Robot();r.keyPress(20);r.delay(500);r.keyRelease(20);a();}

A single press and release just triggers the state; it doesn't blink it. Thus we may as well loop it and it looks like recursion is the cheapest manner of doing that.

What a pity I don't have a QBasic interpreter here! Because it is done using a Poke instruction!

Does this get tail-call optimized or will this eventually exceed the call stack limit?

@Cyoce I don't think Java has tail call optimization until Java 9 so this eventually hits the recursion depth limit but that's ok because I only needed to blink the light once :]

What about wrapping the whole thing in a for(;;){...}? Seems to me to be 22-byte saving.

@TamoghnaChowdhury I'm not sure what you mean. Currently the looping mechanism (tail recursion) only costs 4 bytes a();. If I instead use an infinite loop, that will cost 10 bytes for(;;){}

I mean that you can put the entire code into a lambda, which loses the function declaration overhead. Kind of like: ()->for(;;){java.awt.Robot r=new java.awt.Robot();r.keyPress(20);r.delay(500);r.keyRelease(20);}, which is a saving of 18 bytes due to the 4-character lambda declaration overhead.

@TamoghnaChowdhury no lambdas in Java 7 ;)

One more reason I'm not going back! ;) In all seriousness, just change the answer to Java 8 and go into double-digit scores. Install it if you don't have it already for testing.

@TamoghnaChowdhury Wouldn't you have to wrap the for(;;){} in other curled braces, meaning ()->{for(;;){...}}? I can't get your sample compile with Java 8, while it does with the curved braces.

@OlivierGrégoire I think I missed a semicolon at the end of the thing. Let me check.

@OlivierGrégoire You are correct, but that shouldn't be happening. IDK why. A for loop is a valid single line statement.

Linux terminal, 8+11 = 19 bytes

File f = 1B 5B 33 71 1B 5B 30 71
native@shell:~$ pv f -q -L8
WAT?
According to ECMA-48, 1B starts terminal control escape sequence.
Caps on =1B 5B 33 71, then off = 1B 5B 30 71
pv progress view
f file
-q quiet
-L8 8 bytes/s = 0.5 sec delay
Usage
Prepare
#Create file
echo "1B 5B 33 71 1B 5B 30 71"|xxd -r -p > f

#Install progress view utility
sudo apt install pv

Ctrl+Alt+F6 switch to native console
run pv f -q -L8
Ctrl+Alt+F7 switch back

JavaScript, 82 bytes
Credit goes to @FinW actually, I just changed old function to new ES6 arrow function in order to save some bytes. And becuase I don't have enough points to comment I wrote a new reply.
Edit - deleted brackets to save another 2 bytes.
o=new ActiveXObject("WScript.Shell");setInterval(()=>o.SendKeys("{NUMLOCK}"),500);

His code looked like this
o=new ActiveXObject("WScript.Shell");setInterval(function(){o.SendKeys("{NUMLOCK}")},500);

For arrow function you don't need the parentheses in front of it.

Totally forgot about this, thanks.

I had meant the parentheses which were left over from when you removed function()

Oh, but you can't do that, it won't work. But you can remove the brackets as they are not needed in one-line statements (for some reason your comment reminded me of them even though you meant something different)

Save a byte by either replacing the () with another, single character, such as _ or by making o a parameter with a default, like so: (o=new ActiveXObject("WScript.Shell"))=>.

@fəˈnɛtɪk Does ES6 implemented in Microsoft JScript?

Scala, 84 83 78 bytes
Edit: Saved 1 byte thanks to @TheLethalCoder,
He suggested using 1>0 in place of true.
Edit 2: Saved 5 bytes thanks to @Corvus_192,
He suggested using infix notation and dropping the parentheses after the constructor
while(1>0){val r=new java.awt.Robot;r keyPress 20;r keyRelease 20;r delay 500}

Ungolfed:
while(1>0) {
    val r=new java.awt.Robot()
    r.keyPress(20)
    r.keyRelease(20)
    r.delay(500)
}

Standard Scala port of @Poke's Java answer. Type it directly into the Scala interpreter prompt.
A video of it blinking both my Caps Lock LED and my OSD to boot!

Can you do for(;;) or while(1>0) or while(1) in Scala?

The second is possible. A 1-byte saving which hadn't occurred to me before. Thanks!

You can use infix notation: r keyPress 20 is a byte shorter than r.keyPress(20). The same applies to the other method calls, saving 3 bytes in total.

Also, drop the parenthesis from the constructor call to save another 2 bytes.

Bash, 31 bytes
xset led 1;sleep .5;xset -led 1

Works in X, without root access ! (If it does not work for you, see the init function of the code below to make sure xkbcomp is configured correctly)
And a bonus script to send any morse code through caps lock (not golfed) :
unit=0.15
id=1
function init {
        file=/tmp/blink_tmp
        xkbcomp $DISPLAY $file
        sed -i 's/!allowExplicit/allowExplicit/' $file
        xkbcomp $file $DISPLAY &>/dev/null
        rm $file
}
if [[ -z $1 ]]; then
        echo "Usage : blink [message]"
        exit 1
fi
init
function finish {
        off
}

function on {
#su -c 'setleds -L +caps < /dev/console'
xset led $id
}
function off {
#su -c 'setleds -L -caps < /dev/console'
xset -led $id
}
function slp {
        sleep $(echo "$unit*$1" | bc)
}
function dot {
on
slp 1
off
slp 1
}
function dash {
on
slp 3
off
slp 1
}
function gap {
        slp 3
}
function morse {
        msg=$1
        for (( i=0; i<${#msg}; i++ )); do
                char=${msg:$i:1}
                if [[ $char == "-" ]]; then
                dash
                elif [[ $char == "." ]]; then
                dot
                elif [[ $char == "/" ]]; then
                gap
                fi
        done
}
while true; do
        morse $1
done

Exemple : blink "...././.-../.-../---//.--/---/.-./.-../-..///"

Bash + Xdotool, 36 bytes
for((;;)){ xdotool key 66;sleep .5;}

Just execute it in a bash shell.  It needs to be in a graphical environment.  Infinite loop from here.  Changed Num_Lock to 66 to save 6 bytes, and thanks to @Michael Kjörling for 2 bytes.

You can save at least two bytes by removing unnecessary whitespace. You don't need the whitespace before the closing curly bracket, and you don't need whitespace surrounding the semicolons separating the commands. You do need the whitespace after the opening curly bracket, though.

Also, regarding your initial revision: Keep in mind that you can use : as an alias for true on most systems. while :;do sth;done does the same thing as while true;do sth;done but is three bytes shorter. for((;;)){ sth;} is still shorter, though.

@Cyoce Where?  It didn't work for me.

@Cyoce I think that only works for declaring functions.

@Feldspar15523 oops nevermind then

Python using pyautogui: 126 143 115 103 bytes
Thanks to @nedla2004 for saving 12 bytes
from pyautogui import*
import time
while 1:keyDown('capslock');time.sleep(.5);keyUp('capslock')pslock')

You could change the while loop to while 1:keyDown('capslock');time.sleep(.5);keyUp('capslock'), and you can change the first line to from pyautogui import*, and the second to import time.

you can remove the duplicate 'capslock'.   import time;c='capslock' ...

you could also remove time altogether.
from pyautogui import*; while 1:press('capslock',1,.5). ymmv. on my environment pyautogui does affect the case I type, but the light doesn't blink.

xdotool, 20 bytes
key -delay=500 66 66

Presses the key 66 aka Caps Lock twice, with a delay of 500 ms between key presses.
Note that xdotool is a scripting language; it can be run from a file and it even supports shebangs. Since its exec command allow running external programs, it is capable of addition and primality testing, so it satisfies our definition of programming language.
Test run
$ cat blink.xdo; echo
key -delay=500 66 66
$ xdotool blink.xdo

Bash + setleds, 43 bytes
setleds -D +caps;sleep 0.5;setleds -D -caps

Pretty simple. Uses setleds to toggle the light.

Bash, 103 bytes
cd /sys/class/leds/asus\:\:kbd_backlight;while true;do echo 3;sleep .5;echo 0;sleep .5;done>brightness

Must be run as root.
Does flashing the entire keyboard backlight work? (video to come when I get home)

Does flashing the entire keyboard backlight work? Well, if you think of it, the keyboard highlight  is an indicator of the keyboard highlight being on or off, and it is definitely "physically located on the keyboard", so, yes, I think it counts.

JavaScript, 90 bytes
o=new ActiveXObject("WScript.Shell");setInterval(function(){o.SendKeys("{NUMLOCK}")},500);

It requires ActiveX meaning it will only run on IE (Edge doesn't support it, though). It flashes the NUMLOCK key because, as with other answers, it is shorter than CAPSLOCK or SCROLLLOCK.
Ungolfed
shell = new ActiveXObject("WScript.Shell");
setInterval(
    function(){
        shell.SendKeys("{NUMLOCK}")
    }
,500);

Bash, 33 Bytes
This assumes Num-Lock to be on before it is run. Switch off and on otherwise. Requires the numlockx package obviously ;)
numlockx off;sleep .5;numlockx on

Edit:
Saw Alex Howansky has already posted this solution, yet not marked it with Bash and I just searched the site for "Bash".

+1, you don't have to repeatedly blink it (I think).

If you're in an interactive shell, you can type at the command line: numlockx toggle;sleep .5;!#   (27 bytes) . !# is the event that expands to everything in the command line that has been typed so far.

Batch File (With help of vbs), 74+2=76 bytes
echo Createobject("wscript.shell").sendkeys"{numlock}">z.vbs&z&timeout 1&z

Partially based on Trelzevir's answer.
.vbs is automatically included in PATHEXT.

C (msvc) + Win32, 51 bytes
main(i){main(i+keybd_event(20,69,i%4,Sleep(125)));}

Kotlin Script, 72 bytes
While not smallest one, still it's pretty good. I'm loving kotlin's run for some things, and this is one of them ( smaller than val r = java.awt.Robot() because we don't need both r. and val r =. Still, it's longer than MathLab )
java.awt.Robot().run{while(1>0){keyPress(20);keyRelease(20);delay(500)}}

Ungolfed:
java.awt.Robot().run {
    while(1>0) {
        keyPress(20)
        keyRelease(20)
        delay(500)
    }
}

Python3 , 55 49 bytes
Thank you @NoOneIsHere for -4 bytes!
This includes packages: pyautogui and time modules
Code:
while(1):pag.press("capslock");time.sleep(0.5)

Thank you @NoOneIsHere for -4 bytes!
The key in action:

Welcome to the site! :)

You can save quite a few bytes by using while 1, and making it a one-liner with a semicolon. (while 1:pyautogui.press("capslock");time.sleep(.5))

Unfortunately, this is also a snippet but by adding import pyautogui to the start of the program and changing the rest to while 1:pyautogui.press("capslock");time.sleep(.5) you can make this a valid answer.

@cairdcoinheringaahing There's also need to be an import time there.

@cairdcoinheringaahing Exactly, which is why you need an import time...

VBA, 82 Bytes
Anonymous VBE Immediate window function that takes no input and annoys the user indefinitely. Depedant upon the windows kernel32 function sleep that is declared below.
Sleep Declaration (Win-32)
Declare Sub Sleep Lib "kernel32" (ByVal M&)

Sleep Declaration (Win-64, + 8 Bytes)
Declare PtrSafe Sub Sleep Lib "kernel32" (ByVal M&)

Anonymous VBE immediate window function
Do:SendKeys"{CAPSLOCK}":Sleep 500:DoEvents:Loop

Slightly more fun version, 97 Bytes
A set of mutually recursive subroutines that indefinitely annoys the user
Sub A
Application.OnTime Now+5.8E-6,"B"
End Sub

Sub B
DoEvents
SendKeys"{CAPSLOCK}"
A
End Sub

Questionable version, 66 + 2 Bytes
I'm not sure if having to declare a function from a dll counts as having an inbuilt function so, in the case that it does not, then here is a 66+2 byte version that waits 1 second
Do:DoEvents:Application.Wait Now+#0:0:1#:SendKeys"{CAPSLOCK}":Loop

按键精灵, 41 bytes
For 2
KeyPress"Num Lock",1
Delay 500
Next

Clojure, 134 bytes
(repeatedly(fn[](Thread/sleep 500)(.setLockingKeyState(java.awt.Toolkit/getDefaultToolkit)java.awt.event.KeyEvent/VK_CAPS_LOCK true)))

Loops infinitely, constantly resetting the caps lock's key state. For some reason, setting it to true over and over again toggles it, even though that's not supposed to happen.
Those imports are killer. Might try going the route of the Java answer and use Robot instead; see if that helps.
Thanks for posting this challenege. I'm currently sitting in a chair at the dentist waiting to get a tooth pulled. The distraction is appreciated!
The GIF ended up being too big to upload.
(repeatedly ; Implicit infinite loop
  (fn[]
     (Thread/sleep 500)

     (.setLockingKeyState
       (java.awt.Toolkit/getDefaultToolkit)
       java.awt.event.KeyEvent/VK_CAPS_LOCK
       true)))

"I took a video of it, but I can't upload it to a gif converter until I get onto wifi." Please don't upload videos of your teeth being pulled-- it might upset the dentist!

@thedarkwanderer I took a picture of the tooth post op! But obviously I won't post that. I had to sit in the chair for awhile to wait, so I whipped out my computer and did this challenge, then took a video. I feel like crap though, so I'll get to the GIF eventually. It's not high on my list anymore lol.

authors: Евгений Новиков