text:
Qeng Ho units of time
In Vernor Vinge's excellent and fascinating book A Deepness in the Sky
(which, by the way, I highly recommend1), the Qeng Ho, a culture
that spans various star systems, has no notion of "days," "months," "years,"
etc., and hence has a unique timekeeping system that measures time entirely in
seconds.  The most commonly used units are the Ksec (kilosecond), Msec
(megasecond), and Gsec (gigasecond). Here's a handy chart from my own copy of
the book (since I can't find it online):

You are currently flying on the Pham Nuwen, and you have just received a
message from a strange, unknown planet called "Earth."2 They use different
time units than you do, and your computers don't recognize theirs. As the
resident Programmer-Archaeologist of the ship, your job is to patch the
time-handling code so that it recognizes Earth units of time.
Naturally, since you're only out of coldsleep for another few Ksecs, you want
to make your code as short as possible so it can be written quickly.
Fortunately, as an interstellar trading culture, the Qeng Ho has access to
every programming language invented.
Input
The input will be a single string containing one or more space-separated
components. A component is defined as an integer number > 0 and ≤ 255, then
a space, and then one of second, minute, hour, day, week, month,
year, decade, or century, possibly plural (with an added s, or
centuries for the last case).
Here are some valid example inputs:
10 days 12 hours
1 year
184 centuries 1 second
9 weeks 6 days 2 hours 1 minute 20 seconds

You may assume the following about the input:

Pluralization of units will always agree with the relevant number.
If there are multiple components in the input, they will always be in
descending order of length.

Here are what the various input units mean, for the purposes of this challenge:
unit     relative    absolute
---------------------------------------
second   1 second    1 second
minute   60 seconds  60 seconds
hour     60 minutes  3600 seconds
day      24 hours    86400 seconds
week     7 days      604800 seconds
month    30 days     2592000 seconds
year     365 days    31536000 seconds
decade   10 years    315360000 seconds
century  10 decades  3153600000 seconds

Output
Here are the Qeng Ho units which your code has to support:
unit    relative      absolute
----------------------------------------
second  1 second      1 second
Ksec    1000 seconds  1000 seconds
Msec    1000 Ksecs    1000000 seconds
Gsec    1000 Msecs    1000000000 seconds

Use the following algorithm to determine your code's output:

First, add up the total amount of time that the input represents.
Find the largest Qeng Ho unit that is shorter or the same amount of time as
the input—essentially, find the largest unit that there is at least one of.
Convert the total amount of time given in the input into this unit, and
output the result, rounded to three decimal places.

You may have your choice of which of the following methods to use: rounding up,
rounding down, rounding away from zero, or rounding towards ∞ or -∞. If the
rounded result ends in 0, you may either remove trailing zeroes or keep as
many as you want (or do both, depending on the input).
If the rounded result is exactly 1.000, you must use the singular form
(second, Ksec, Msec, Gsec); otherwise, use the plural form (seconds,
Ksecs, Msecs, Gsecs).
In certain edge-cases, you might be using the unit of, for example, Ksec, but
obtain a rounded result of 1000.000 Ksecs. In this case, you may simply output
1000.000 Ksecs instead of 1 Msec.
You may always assume that the input is in descending order of units (century,
decade, year, etc.); furthermore, the component that comes after any given unit
will always be shorter (that is, 1 decade 20 years is invalid input).
Test cases
Note: results marked with an asterisk (*) may vary by a negligible amount due
to rounding differences.
input                                         output
-------------------------------------------------------------
1 hour                                        3.600 Ksecs
1 day                                         86.400 Ksecs
2 weeks                                       1.210 Msecs
1 year                                        31.536 Msecs
32 years                                      1.009 Gsecs   *
1 second                                      1.000 second
1 century 6 decades                           5.046 Gsecs   *
255 centuries                                 804.168 Gsecs
2 weeks 6 days 1 hour 19 minutes 4 seconds    1.733 Msecs
1 week 3 days 3 hours 7 minutes               875.220 Ksecs
1 week 4 days 13 hours 46 minutes 40 seconds  1.000 Msec
2 months 2 hours                              5.191 Msecs   *
16 minutes 39 seconds                         999.000 seconds

Rules

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

1: only if you like hard scifi, of course. In which case I recommend
reading A Fire Upon the Deep first, which is (in my opinion) even more
fantastic.
2: well, technically "Old Earth" is mentioned several times in A Deepness in the Sky, but...

Test case 9 seems incorrect (see my answer)

@edc65 Thanks for catching that; not sure what went wrong there.

This ship doesn't know Earth time, but has a full understanding of all Earth programming languages. Very logical.

@ConfusedMr_C Of course they don't know Earth time. Why would they? They barely even knew that Earth existed. :P (okay, so technically in the book Earth was portrayed as very ancient human history, but you get the idea)

The Qeng Ho has access to every programming language invented. How unlikely yet convenient. =D

Is it permissible to give 999.000 seconds for the last case?

Dang, I had a really short Mathematica solution using the built-in unit support, but it interprets 2 months 2 hours as "2 months * 2 hours."

Shouldn't one "simply output" 1000.000 Ksecs instead of Ksec?

@2012rcampion Yes, of course: "you may either remove trailing zeroes or keep as many as you want." (I'll edit the test cases for consistency.)

@choroba Yes, that should be plural. Fixed that in the post.

@ConfusedMr_C: Stranger still is that though they have no notion of Earth time, they still know what a "second" is, and apparently it's exactly equal to an Earth second...

Hmm, I notice that these factors look strangely like the ones in the obsolete time-handling functions that nobody uses in a lot of these languages.

@DarrelHoffman their date system is based on January 1, 1970. Software archeologist is a profession - digging around and debugging centuries old programs.  Second by second, the Qeng Ho counted from the instance that a human had first set foot on Old Earth's moon.  But if you looked at it more closely ... the starting instance was actually about fifteen million seconds later, the 0-second of one of Humankind's first computer operating systems.

@MichaelT: Ah, that makes sense. So it's sort of a "distant post-Earth future of humanity" kind of thing, not a completely alien race encountering Earth for the first time. (I've obviously not read the book...)

@DarrelHoffman correct. There's been a diaspora of humanity, a collapse on many planets (some all the way back to near stone age) and golden age on others. The Qeng Ho are a culture of traders who go between the stars reestablishing society and communication links (to other planets and Qeng Ho fleets). Buying and selling information and technology, getting supplies to go to the next world. The communication link is in part to get the next world up to a sufficient level of technology if it isn't already there.  At the start of the book they haven't discovered any alien cultures... yet.

APL (Dyalog APL), 157 156 154 151 154 141 142 bytes
{∊(3⍕N)' '((B/S⊃' KMG')'sec','ond'/⍨~B←T≥1E3),'s'/⍨1≠N←T÷1E3*S←⌊1E3⍟T←+/×/↑⍎¨'\d+ .a?i?'⎕S'&'⊢⍵⊣c←10×d←10×⊃y m w←365 30 7×da←24×h←×⍨mi←60×s←1}

Thanks to ngn for shaving off 13 bytes.
Must have ⎕IO←0, which is default in many APLs.
Try it online!
{…} "dfn"; argument is ⍵:
 s← let s be 1
 mi←60× let mi be 60 times that (i.e. 60)
 h←×⍨ let h be that squared (lit. that multiplied by itself, i.e. 3600)
 da←24× let da be 24 times that (i.e. 86400)
 y m w←365 30 7× let y, m, and w be 365, 30, and 7 times that, respectively (i.e. 31536000, 2592000, and 604800)
 d←10×⊃ let d be 10 times the first of those (i.e. 315360000)
 c←10× let c be 10 times that (i.e. 3153600000)
 ⍵⊣ discard that in favour of the given argument
 '\d+ .a?i?'⎕S'&'⊢ Search for, and extract all runs of digits followed by a space, any character, optionally an "a", and optionally an "i"
 ⍎¨ execute each as APL code (gives pairs of counts and units in seconds)
 ↑ mix the pairs into a 2-column matrix.
 ×/ multiply along the rows, yielding a list of counts of seconds
 T←+/ let T be the sum of those (the total count of seconds)
 1E3⍟ \$\log_{10}\$ of that
 N←⌊ let N be the floor of that (i.e. the order of magnitude of T)
 1≠ yield 1 if that is different from 1, but 0 otherwise
 's'/⍨ use that to replicate the letters of the string "s" (yielding "s" if we need a plural)
 (3…3), prepend the following three things:
  1. 3⍕N the string consisting of N rounded to 3 decimal places
  2. ' ' a space
  3. B←T≥1E3 let B be 1 if T is at least 1000, but 0 otherwise
     ~ logically negate that (i.e. 0 if T is at least 1000, but 1 otherwise)
     'ond'/⍨ use that to replicate the string "ond" (for the full word if there's no prefix)
     '(…)'sec', prepend the 2-element list consisting of the following and the string "sec":
      S⊃' KMG' use S as an index to select a prefix from the string " KMG"
      B/ replicate the letters of that by B (empty out S if B is 0, but leave as-is if it is 1)
 ∊ enlist (flatten until a simple string)

If you assign 1E3 to a name (like z), in the first instance you have wasted two chars, in the second instance you have already saved one, and from the third instance onward you are saving two chars. Don't you?

@lstefano No, the first will cost 4: ⌊1E3⍟ → ⌊(z←1E3)⍟ and then save 2 on each of the next 1E3 → z.

Yup, absolutely right. And given that there are only 3 of them, no gain. Sorry for the noise.

JavaScript (ES6) 255

f=s=>(s=s.replace(/(\d+) (..)/g,(_,n,u)=>t+={se:1,mi:60,ho:3600,da:86400,we:604800,mo:2592e3,ye:31536e3,de:31536e4,ce:31536e5}[u]*n,t=0),[a,b]=t>=1e9?[t/1e9,' Gsec']:t>=1e6?[t/1e6,' Msec']:t>999?[t/1e3,' Ksec']:[t,' second'],a.toFixed(3)+b+(a-1?'s':''))

// test

console.log=x=>O.innerHTML+=x+'\n'

;[
 ['1 hour','3.600 Ksecs']
,['1 day','86.400 Ksecs']
,['2 weeks','1.210 Msecs']
,['1 year','31.536 Msecs']
,['32 years','1.009 Gsecs']
,['1 second','1.000 second']
,['1 century 6 decades','5.046 Gsecs']
,['255 centuries','804.168 Gsecs']
,['2 weeks 6 days 1 hour 19 minutes 4 seconds','1.733 Msecs']
,['1 week 3 days 3 hours 7 minutes','875.220 Ksecs']
,['1 week 4 days 13 hours 46 minutes 40 seconds', '1.000 Msec']
,['2 months 2 hours', '5.191 Msecs']
,['16 minutes 39 seconds', '999 seconds']
].forEach(t=>console.log(t[0]+' '+f(t[0])+' (Check:'+t[1]+')'))

Python, 366 363 bytes
d={};l=1;q=str.replace;i=q(raw_input(),"ie","y")
for u,t in zip('second minute hour day week month year decade century'.split(),(1,60,60,24,7,30./7,73./6,10,10)):l=t*l;d[u]=d[u+"s"]=l
while" "in i:
 i=q(q(i," ","*",1)," ","+",1)
q=eval(i,d);f={};l=1
for u in('second','Ksec','Msec','Gsec'):
 l*=1e3
 if q<l:q=q*1e3/l;print"%.3f %s%s"%(q,u,("s","")[q<1.001]);break

You have unnecessary indentation in q=eval(i,d);f={};l=1 line, which breaks code. Besides, you can save 2 bytes by using 10. and 73. instead of 10.0 and 73.0. Also, there's no need for space after print.

SpecBAS - 476 471 bytes
Because nothing says "cower before our technological superiority" better than line numbers and GOTO statements :-)
1 INPUT e$: DIM t$(SPLIT e$,NOT " "): DIM m=31536e5,31536e4,31536e3,2592e3,604800,86400,3600,60,1
2 LET q=0,n$=" cedeyemowedahomise"
3 FOR i=1 TO ARSIZE t$() STEP 2: LET t=VAL t$(i),u$=t$(i+1)( TO 2),p=POS(u$,n$)/2: INC q,t*m(p): NEXT i
4 IF q>=1e9 THEN LET r=q/1e9,r$=" G": GO TO 8
5 IF q>=1e6 THEN LET r=q/1e6,r$=" M": GO TO 8
6 IF q>999 THEN LET r=q/1e3,r$=" K": GO TO 8
7 IF q<1e3 THEN LET r=q,r$=" "
8 PRINT USING$("&.*0###",r);r$;"sec"+("ond" AND q<1e3)+("s" AND r>1)

C# (in LinqPad as Function), 460 Bytes
void Main(){var x=Console.ReadLine().Split(' ');long s=0,v,i=0;for(;i<x.Length;){v=long.Parse(x[i++]);var w=x[i++].Substring(0,2);s+=w=="ce"?v*3153600000:w=="de"?v*315360000:w=="ye"?v*31536000:w=="mo"?v*2592000:w=="we"?v*604800:w=="da"?v*86400:w=="ho"?v*3600:w=="mi"?v*60:v;}decimal k=1000,m=k*k,g=m*k,r=0;var o="sec";r=s/g>=1?s/g:s/m>=1?s/m:s/k>=1?s/k:s;o=s/g>=1?"G"+o:s/m>=1?"M"+o:s/k>=1?"K"+o:o+"ond";Console.WriteLine(Math.Round(r,3)+" "+o+(r==1?"":"s"));}

ungolfed:
void Main()
{
    var x=Console.ReadLine().Split(' ');
    long s=0,v,i=0;
    for(;i<x.Length;)
    {
        v=long.Parse(x[i++]);
        var w=x[i++].Substring(0,2);
        s+=w=="ce"?v*3153600000:w=="de"?v*315360000:w=="ye"?v*31536000:w=="mo"?v*2592000:w=="we"?v*604800:w=="da"?v*86400:w=="ho"?v*3600:w=="mi"?v*60:v;
    }
    decimal k=1000,m=k*k,g=m*k,r=0;
    var o="sec";
    r=s/g>=1?s/g:s/m>=1?s/m:s/k>=1?s/k:s;
    o=s/g>=1?"G"+o:s/m>=1?"M"+o:s/k>=1?"K"+o:o+"ond";
    Console.WriteLine(Math.Round(r,3)+" "+o+(r==1?"":"s"));
}

Mathematica 296 281 bytes
h: After breaking up the input string into a list of quantity magnitudes and units, Capitalize and Pluralize convert the input units into Mathematica Quantity's, from which the total number of seconds is derived.
d converts seconds to the appropriate units.  The final s is removed if the time corresponds to 1 unit (of any kind).
With minor adjustments in the code, this approach should work for conversion of natural language input into any measurement system, conventional or not.
h=Tr[UnitConvert[Quantity@@{ToExpression@#,Capitalize@Pluralize@#2},"Seconds"]&@@@Partition[StringSplit@#,2]][[1]]&;
d=ToString[N@#/(c=10^{9,6,3,0})[[p=Position[l=NumberDecompose[#,c],x_/;x>0][[1,1]]]]]<>StringDrop[{" Gsecs"," Msecs"," Ksecs"," seconds"}[[p]],-Boole[Tr[l]==1]]&
z=d@h@#&;

Put into table form:
z1[n_]:={n,z@n}

Grid[z1 /@ {"1 hour", "2 day", "2 weeks", "1 year", "32 years",
   "1 second", "1 century 6 decades", "255 centuries",
   "2 weeks 6 days 1 hour 7 minutes",
   "1 week 3 days 3 hours 46 minutes 40 seconds",
   "1 week 4 days 13 hours 46 minutes 40 seconds", "2 months 2 hours",
    "16 minutes 39 seconds"}, Alignment -> Right]

Haskell, 565 555 bytes
import Data.List
import Numeric
import Data.Bool
i=isPrefixOf
s x=showFFloat(Just 3)x""
r=read
f=fromIntegral
b=bool"s"""
c=b.(=="1.000")
h(c:u:l)
 |i"s"u=(r c)+h l
 |i"mi"u=(r c*60)+h l
 |i"h"u=(r c*3600)+h l
 |i"da"u=(r c*86400)+h l
 |i"w"u=(r c*604800)+h l
 |i"mo"u=(r c*2592000)+h l
 |i"y"u=(r c*31536000)+h l
 |i"de"u=(r c*315360000)+h l
 |True=(r c*3153600000)+h l
h _=0
q i
 |v<-s((f i)/10^9),i>=10^9=v++" Gsec"++c v
 |v<-s((f i)/10^6),i>=10^6=v++" Msec"++c v
 |v<-s((f i)/1000),i>=1000=v++" ksec"++c v
 |True=show i++" second"++b(i==1)
t=q.h.words

I'm reasonably sure I'm missing so many golfing opportunities here…The price of being a golfing beginner I guess.
My answer is a function taking a string containing the Earth time as an input parameter and returning the Qeng Ho time.
P.S. : I stupidly forgot about the 3 digits precision…which does drive the byte count up.
P.P.S. : Better chosen top-level expressions shaved off 10 bytes…and it should now be accurate to boot.

Matlab 315 bytes
K='cedeyemowedahomiseconds';Q=' KMGT';for j=1:9;y(j)=double(~isempty(strfind(S,K(2*j-1:2*j))));end
y(y==1)=sscanf(S,repmat('%d %*s ',1,9));y=86400*sum(datenum([sum(y(1:3)*10.^[2;1;0]),y(4),y(5:6)*[7;1],y(7:9)]));z=floor(log10(y)/3);y=num2str(y/10^(3*z)+1e-4);[y(1:4),' ',Q(z+1),K(17:23-(y(1:4)=='1.00'))]

Test:
S = '2 centuries 1 decade 2 years 3 months 3 weeks 4 days 1 hour 44 minutes 58 seconds';

Output:
ans =
6.69 Gseconds


text:
Reverse and Invert a String
Reverse and Invert a String

Challenge
In this challenge. You'll be writing a program which will output or return the input, reversed and inverted.
First, each character should be converted to its character code. Then, that should be converted to base-2. Following, that string should be reversed. After, the string should be inverted (1 -> 0 and 0 -> 1). Finally, that should be converted back to base 2 and then converted back to a character. If an character results to be an unprintable, you may optionally output it but they do not have to be removed.
H -> 72  -> 1001000 -> 0001001 -> 1110110 -> 118 -> v
e -> 101 -> 1100101 -> 1010011 -> 0101100 -> 44  -> ,
l -> 108 -> 1101100 -> 0011011 -> 1100100 -> 100 -> d
l -> 108 -> 1101100 -> 0011011 -> 1100100 -> 100 -> d
o -> 111 -> 1101111 -> 1111011 -> 0000100 -> 4   -> (unprintable)
, -> 44  -> 101100  -> 001101  -> 110010  -> 50  -> 2
  -> 32  -> 100000  -> 000001  -> 111110  -> 62  -> >
W -> 87  -> 1010111 -> 1110101 -> 0001010 -> 10  -> (newline)
o -> 111 -> 1101111 -> 1111011 -> 0000100 -> 4   -> (unprintable)
r -> 114 -> 1110010 -> 0100111 -> 1011000 -> 88  -> X
l -> 108 -> 1101100 -> 0011011 -> 1100100 -> 100 -> d
d -> 100 -> 1100100 -> 0010011 -> 1101100 -> 108 -> l
! -> 33  -> 100001  -> 100001  -> 011110  -> 30  -> (unprintable)

Scoring
Shortest code in bytes wins.
-15% Bonus: if your program removes un-printables from the output. This must be at least all characters below 32 except newlines (char 10)

I need to get my Simplex interpreter working again XD GBktnkZs

So the characters in the string aren't reversed, but the bits in each character are?

Just to be sure: for 0010000 is the bit reverse 0000100 or 00001?

@DigitalTrauma If the binary code is 0010000, it should be treated as 10000 so the reverse would be 00001

For the bonus, do we need to leave newlines, or can we remove anything below 00010000 == space?

@ETHproductions clarified, you should leave newlines

Can we assume just ASCII (as your examples), or should this work for whatever is a character in my language? (Also, if a language uses a different character code, should I use this instead of ASCII/Unicode)?

32 and below? You want to remove spaces too?

@PaŭloEbermann if your language supports only ASCII then you may support only ASCII otherwise you should support the whole character set of your language

@aditsu nope spaces are fine :p Fixed

You say "or return" but you only say "a program." Is a function allowed?

@steveverrill of course

Also, the title is a bit misleading, because I would have supposed that the whole string is reversed, too, not just each individual character.

So you want ASCII 10 and 32 to 126 printed in the bonus version? Are 9 to 13 allowed?

CJam, 14
q{i2bW%:!2bc}%

Try it online
Explanation:
Pretty straightforward:
q       read input
{…}%    convert each character
  i     convert to number
  2b    convert to base 2 (digit array)
  W%    reverse
  :!    invert each digit
  2b    convert from base 2
  c     convert to character

"Printable" version, 20 - 15% = 17
q{i2bW%:!2bc' ,N--}%

Dangit, you. I was just about to post a CJam answer D:

@anOKsquirrel sorry ^^ was it similar?

It would have been if I had finished it.

How does W% work? W is -1, so...

@anOKsquirrel see the documentation here

Just out of interest, it would be nice to have version which removes unprintables, as separate answer probably(@anOKsquirrel ?).

@hyde Okay, will do. I feel it should just be though because I would probably just copy his and I also want to use a different language for this

Pyth, 14 bytes
smCi!M_jCd2 2z

Try it online.
How it works
 m           z  Map over the input with lambda d:
        Cd        Cast d to character.
       j  2       Convert to base 2.
      _           Reverse the resulting array.
    !M            Mapped logical NOT.
   i        2     Convert back to integer.
  C               Cast to character.
s               Concatenate the resulting characters.

Alternative solutions (all 14 bytes): smCi!MvM_.Bd2z smCi.r_.Bd`T2z smCiqR\0_.Bd2z

How about a version which removes unprintables, just out of interest/for comparison? Probably as a separate answer.

Perl, 57 51 characters
(50 characters code + 1 character command-line option.)
s/./$_=unpack b8,$&;s|0+$||;"chr 0b".y|10|01|r/gee

Sample run:
bash-4.3$ perl -pe 's/./$_=unpack b8,$&;s|0+$||;"chr 0b".y|10|01|r/gee' <<< 'Hello, World!'
v,dd2>
Xdl

bash-4.3$ perl -pe 's/./$_=unpack b8,$&;s|0+$||;"chr 0b".y|10|01|r/gee' <<< 'Hello, World!' | od -tad1
0000000    v    ,    d    d  eot    2    >   nl  eot    X    d    l   rs   nl
         118   44  100  100    4   50   62   10    4   88  100  108   30   10
0000016

51 bytes: -p s/./$_=unpack b8,$&;s|0+$||;"chr 0b".y|10|01|r/gee. unpack b8,$& is shorter than sprintf'%b',ord$&, and additionally decodes in reverse order. Unfortunately it also produces trailing 0s, which need to be removed.

Thank you @primo. unpack is still unexplored terrain for me.

42 bytes: -p s/./"chr 0b".unpack(b8,~$&)=~s|1+$||r/gee. Invert the character, no need to transliterate ;)

JavaScript (ES6 ES7), 119 114 108 bytes
This turned out way longer than expected :(
Thanks to @vihan for 5 bytes saved!
Thanks to @ETHProductions for another 6 bytes saved!
To test:  Run the snippet below, enter input like "Hello, World!", and click Test!

x=>String.fromCharCode(...[for(y of x)+('0b'+[...y.charCodeAt().toString(2)].reverse().map(z=>z^1).join``)])

Code:
<textarea id="textbox" style="margin-top:5px; margin-bottom:5px"></textarea>

Input:
<textarea id="inputbox" style="margin-top:5px; margin-bottom:5px"></textarea>
<button id="testbtn">Test!</button><button id="resetbtn">Reset</button>

Original Code Output:

New Code Output:

I think you could save a 4 bytes replacing the parseInt with +('0b'+) as described here and another one by using w^1 instead of +!+w

I wanted to post this, but decided it was too similar to be a separate answer: An advantage of String.fromCharCode is that you can pass in multiple numbers, and it will automatically convert all of them and join them. So here's 110: x=>String.fromCharCode(...[...x].map(y=>+('0b'+[...y.charCodeAt().toString(2)].reverse().map(z=>z^1).join``)))

Or an ES7 variant, 108 bytes: x=>String.fromCharCode(...[for(y of x)+('0b'+[...y.charCodeAt().toString(2)].reverse().map(z=>z^1).join``)])

@ETHproductions wow, never knew that String.fromCharCode could do that! Thanks!

I never would have thought this possible, but I just golfed off .05 bytes: x=>String.fromCharCode(...[for(y of x)if((c=+('0b'+[...y.charCodeAt().toString(2)].reverse().map(z=>z^1).join``)) >31||c==10)c]) (127 - 15% = 107.95) Maybe this isn't legal, though; it only handles 10 == \n, not 13 == \r. @Vɪʜᴀɴ what is your opinion?

@ETHproductions That's fine :)

@ETHproductions wow, I think that's sufficiently different to warrant its own post! However, couldn't you just call alert in the function instead since it automatically won't show unprintables?

@UndefinedFunction It does on my browser :(

@ETHproductions whoops, my bad! the test case I was using didn't have any unprintables.... Sorry, spoke too quickly :(

I get Unexpected token '>' when I try to run the snippet.

@PaulR Try with an ES6-compliant browser, such as one of the newer versions of Firefox.

@ETHproductions: thanks - I only have Safari and Chrome to hand and I guess neither of these is "ES6-compliant".

@PaulR ES6, or ECMAScript 6, is one of the latest sets of new features for JavaScript. See this site for more info. There's also a compatability table that shows which features are supported by which browsers  (and other programs). This answer in particular requires "arrow functions", the "spread operator", and ES7's "array comprehensions".

Thanks for the explanation - I got curious and downloaded the latest Firefox for Mac and now the above snippet does indeed run correctly.

@ETHproductions you can save .85 bytes using | instead of || in your condition

Just in case you missed it, I posted my answer here. @edc65: Thanks, I always forget that usually works. :)

JavaScript (ES7), 126 bytes - 15% = 107.1
I was playing around with this answer to see if the bonus was worth it. Apparently, it is. The test suite was stolen from the same answer, but I added my own twist: full support of the 15% bonus! :)

x=>String.fromCharCode(...[for(y of x)if((c=+('0b'+[...y.charCodeAt().toString(2)].reverse().map(z=>z^1).join``))>31|c==10)c])

Score:

Code:
<textarea id="textbox" style="margin-top:5px; margin-bottom:5px"></textarea>

Input:
<textarea id="inputbox" style="margin-top:5px; margin-bottom:5px">"Hello, World!"</textarea>
<button id="testbtn">Test!</button><button id="resetbtn">Reset</button>

Original Code Output:

New Code Output:

Awesome modification of the test snippet! It seems the snippet now automatically checks for the bonus, may I ask how you did that? (p.s. if you want the original (not on one line) source, feel free to ask, might be easier to modify that way)

@UndefinedFunction Oh, sorry for not replying right away! I added a getScore() function which checks the test-case Hello, World! for compliance (it conveniently contains both a newline and unprintable chars), and returns the score multiplied by .85 or 1, depending on the result. And yes, access to the un-minified snippet would be great. :)

I've made the original snippet code available here. Have fun!

C function, 63
o;f(o,char *s){for(;*s;*s=o,s++)for(o=0;*s;*s/=2)o+=o+!(*s%2);}

PHP - 187 182 163 bytes
<?php $s=$_GET["s"];$m="array_map";echo join($m("chr",$m("bindec",$m(function($v){return strtr($v,[1,0]);},$m("strrev",$m("decbin",$m("ord",str_split($s))))))));?>

Pass the value as GET["s"].
array_map returns an array with all the elements of the second parameter (an array) after applying the callback function (first parameter) to all of them.
Not sure if I should take the 15% off, since echo doesn't output unprintable characters, but I didn't remove them.
Just glad I finished, since this is the first challenge I take part.

Is shorter if you not declare those functions: $m='array_map';echo join($m("chr",$m("bindec",$m(function($v){return strtr($v,[1,0]);},$m("strrev",$m("decbin",$m("ord",str_split($s))))))));.

@manatwork completely forgot about that. Thanks.

You can't just put the input in a variable. You should create a function or read the input from STDIN. By the way, you don't need to use quotes around string ("chr", "bindec", …) since we don't care about warnings. That should save you 12 bytes.

@Blackhole thanks for the infos, I'll be aware of that next time.

You'd better do the modification on this answer, which is otherwise invalid :) . It will cost you almost no bytes, just replace str_split($s) with str_split(fgets(STDIN)) for instance.

You may want to have a look at some simple golfing tips to take your code down to 132 bytes.  By the way, echo does print the control characters; it´s the browsers that ignore them. Oh and strtr(...,[1,0]) only translates 1 to 0, not vice versa; better use strtr(...,10,"01") (+2 bytes).

Julia, 77 bytes - 15% = 65.45
s->join(filter(isprint,[Char(parse(Int,join(1-digits(Int(c),2)),2))for c=s]))

This creates an unnamed functon that accepts a string and returns a string. Unprintable characters are removed, which qualifies this for the bonus.
Ungolfed:
function f(s::AbstractString)
    # digits() returns the digits in reverse order, so no explicit
    # reverse() is needed
    x = [Char(parse(Int, join(1 - digits(Int(c), 2)), 2)) for c = s]

    # Remove unprintables, join into a string
    return join(filter(isprint, x))
end

While it certainly qualifies it for the bonus, it also costs more than the bonus saves. 16 bytes to filter(isprint,) and only 11.55 bytes saved through the bonus.

And if you give up the filter step, you can avoid the comprehension and join by using map directly on the string. s->map(c->Char(parse(Int,join(1-digits(Int(c),2)),2)),s) (for 56 bytes)

@GlenO Thanks for the suggestions, but that approach leaves in unprintables as hex codes, which the OP said is not allowed. Using filter(isprint,) both qualifies it for the bonus and makes it compliant with the rules.

"If an character results to be an unprintable, you may optionally output it but they do not have to be removed."

And if the concern is on the other side of it (that it displays as \x04 and the like), then print() costs seven, which would bring 56 up to 63.

K5, 28 bytes
`c${b/~|{x@&|\x}@(b:8#2)\x}'

This is a bit inconvenient because K5's decode operator performs a fixed-width base conversion, so to comply with the problem statement I have to trim leading zeroes. The lambda {x@&|\x} accomplishes this step.
Smear:
  |\0 0 1 0 1 1 0 1
0 0 1 1 1 1 1 1

Gather:
  &|\0 0 1 0 1 1 0 1
2 3 4 5 6 7

Select:
  {x@&|\x}0 0 1 0 1 1 0 1
1 0 1 1 0 1

The whole program in action:
  `c${b/~|{x@&|\x}@(b:8#2)\x}'"Hello, World"
"v,dd2>\nXdl"

I believe oK's natural behavior with unprintables makes this eligible for -15%, giving this a score of 28*0.85 = 23.8.

+1 because I tried but couldn't figure out a short way to get rid of the leading zeros!

A few related constructions can be found here.

PowerShell, 199 175 (171 - 15%)=145.35
param([char[]]$a)($a|%{$b=[convert]::ToString(+$_,2);$c=[convert]::ToInt32("$((-join$b[$b.Length..0])-split0-replace1,0-join1)",2);if($c-gt31-or$c-eq10){[char]$c}})-join''

Uses an unfortunate amount of some .NET calls/built-ins, which significantly bloats the code.
Explained:
Takes the input param(..) and casts it as a char[] so we can work through it appropriately.
The next bit (..)-join'' collects and joins our output together.
Inside those parens, we iterate with $a|%{..} as a foreach loop.
Inside the loop:

We create a new string $b, which is our input letter cast as an int +$_ and [convert]ed to base 2
This next bit, setting $c, is tricky, so let's start inside and work our way out
We reverse the string $b with (-join$b[$b.length..0])
We leverage my previous code for inverting a binary string and recast the result as a string with "$(..)"
We feed that string into a different .NET call that [convert]s ToInt32 from base 2, which is finally stored that into $c
If $c is greater than 31, or equal to 10, we cast it as a char and that value is left on the pipeline for output (which is what gets collected and -join''ed together, above), else nothing gets left on this particular iteration

Phew.
Qualifies for the -15% bonus, as well.
Example
PS C:\Tools\Scripts\golfing> .\reverse-and-invert-a-string.ps1 "Hello, World!"
v,dd2>
Xdl

, 39 chars / 73 bytes
ô⟦ï]ć⇝ϚĎ(+“0b`+⟦a.ü⬮ß§2]ù⬮ć⇀$^1)ø`”⸩ø⬯⦆

Try it here (Firefox only).

Vyxal K, 5 bytes
bR†vB

Try it Online!
epic.
-2 bytes from Lyxal.
-1 byte from Lyxal.

7 bytes if it's Keg

Actually make that 6 bytes

5 bytes. That's my best and final

smh inb4 0 bytes

bruh 0 bytes is way too long. -69 bytes should be the next stop

Minkolang 0.11, 26 bytes
od?.(d2%,$r2:d)xrI1-[2*+]O

Try it here.
Explanation
od?.            Takes input as character, halting if empty
(d2%,$r2:d)x    Converts to binary, inverting digits on the way
r               Reverses stack
I1-[2*+]        Converts to decimal
O               Outputs as character (if printable)

MATLAB, 60 bytes
@(y)[arrayfun(@(x)bin2dec([97-fliplr(dec2bin(x)) '']),y) '']

Basically each character in turn is converted into a binary string (with no leading zeros). The array is flipped and is subtracted from 97 ('0'+'1') which inverts the character. This is converted back to decimal. After all characters have been processed, the whole array is then converted back to characters before being returned.

Japt, 25 bytes
Want to create a golfy JavaScript program, but the shortest method involves lots of long function names? That's what Japt was made for. :)
UmX=>Xc s2 w mY=>Y^1 n2 d

Try it in the online interpreter!
How it works
         // Implicit: U = first item in input
UmX=>    // for each character X in U:
Xc s2 w  //  take the char-code of X, convert to binary, and reverse
mY=>     //  for each character Y in this:
Y^1      //   take Y XOR 1 (converts 1 to 0 and 0 to 1)
n2 d     //  convert the result back to decimal, then to a character
         // Implicit: output last expression

Using the current version of Japt (as of v1.4.4), the byte count can be cut to 14:
®c ¤w m^1 n2 d

Test it online!

Python 3, 95 91
Straightforward implementation.
print(''.join(chr(int(''.join('10'[j>'0']for j in bin(ord(i))[:1:-1]),2))for i in input()))

Ungolfed:
inp = input()
ints = (ord(i) for i in inp)
bins = (bin(i) for i in ints)
revs = (i[2:][::-1] for i in bins) #without leading '0b'
invs = (''.join('0' if j == '1' else '1' for j in i) for i in revs)
newInts = (int(i, 2) for i in invs)
newChars = (chr(i) for i in newInts)
newStr = ''.join(newChars)
print(newStr)

Ruby, 62 characters
gets.bytes{|b|$><<<b.to_s(2).reverse.tr("01","10").to_i(2).chr}' <<< 'Hello, World!'
v,dd2>
Xdl

bash-4.3$ ruby -e 'gets.bytes{|b|$><<b.to_s(2).reverse.tr("01","10").to_i(2).chr}' <<< 'Hello, World!' | od -tad1
0000000    v    ,    d    d  eot    2    >   nl  eot    X    d    l   rs   nl
         118   44  100  100    4   50   62   10    4   88  100  108   30   10
0000016

Javascript 123 bytes
s=>[].map.call(s,s=>String.fromCharCode("0b"+s.charCodeAt().toString(2).split('').reverse().map(s=>s^1).join(''))).join('')

C#, 156 bytes - 15% = 132.6
class P{static void Main(string[]a){try{for(int i=0,b,c;;){for(b=a[0][i++],c=0;b>0;b/=2)c=c<<1|1-b%2;if(c==10|c>31)System.Console.Write((char)c);}}catch{}}}

Indentation and new lines for clarity:
class P{
    static void Main(string[]a){
        try{
            for(int i=0,b,c;;){
                for(b=a[0][i++],c=0;b>0;b/=2)
                    c=c<<1|1-b%2;
                if(c==10|c>31)
                    System.Console.Write((char)c);
            }
        }
        catch{}
    }
}

Retina, 1107 629 bytes - 15% = 534.65 (non-competing)
Uses features added after challenge date. (Implicit behavior of $*, ¶, Sorting)
Retina doesn't have a built-in to convert a character to its ASCII ordinal or back... so behold its lustrous length. This handles printable ASCII, and removes unprintables as well as newlines. Byte count assumes ISO 8859-1 encoding.
The code contains unprintable characters.

¶
±
S_`
%(S`±
{2`
$`
}T01`-`_o
)Ms`.
\d+
$*
+`(1+)\1
${1}0
01
1
%O$^`.

T`01`10
1
01
+`10
011
0

m`^1{1,31}$

M%`1
m`^0¶?

126
~
125
}
124
|
123
{
122
z
121
y
120
x
119
w
118
v
117
u
116
t
115
s
114
r
113
q
112
p
111
o
110
n
109
m
108
l
107
k
106
j
105
i
104
h
103
g
102
f
101
e
100
d
99
c
98
b
97
a
96
`
95
_
94
^
93
]
92
\
91
[
90
Z
89
Y
88
X
87
W
86
V
85
U
84
T
83
S
82
R
81
Q
80
P
79
O
78
N
77
M
76
L
75
K
74
J
73
I
72
H
71
G
70
F
69
E
68
D
67
C
66
B
65
A
64
@
63
?
62
>
61
=
60
<
59
;
58
:
57
9
56
8
55
7
54
6
32

33
!
34
"
35
#
36
$
37
%
38
&
39
'
40
(
41
)
42
*
43
+
44
,
45
-
46
.
47
/
48
0
49
1
50
2
51
3
52
4
53
5
¶

Try it online
If you check out the Retina tutorial for unary arithmetic, you'll recognize several different pieces of my code as coming from there.
Thanks to Martin for golfing off hundred of bytes

Jelly, 6 bytes
OBU¬ḄỌ

Try it online!
Explanation:
OBU¬ḄỌ Main link: z
O      Convert z to a list of character codes.
 B     Convert the codes to bit lists.
  U    Reverse the bits (not the lists).
   ¬   Invert the bits.
    Ḅ  Convert back to decimal.
     Ọ Convert back to string.

Java, 205 - 15% = 174.2
interface F{static void main(String[]a){for(int i=0,c,s;i>s)&-1>>>s;if(c==10|c>31)System.out.print((char)c);}}}

Ungolfed:
interface F {
    static void main(String[] a) {
        for (int i = 0, c, s; i > s) & -1 >>> s;
            if (c == 10 | c > 31) System.out.print((char)c);
        }
    }
}

I think this solution is a bit interesting in its use of the Integer methods Integer.reverse and Integer.numberOfLeadingZeros which do what they sound like, and the shift of -1 >>> s where s is the number of leading zeroes, to get the mask to mask off high bits that we don't want. I just regret that the name of the latter method is so damn verbose, but that's what I get for golfing in Java.
Output:
v,dd2>
Xdl

PHP, 80 bytes
while(a&$c=$argn[$i++])echo chr(bindec(strtr(strrev(decbin(ord($c))),10,"01")));

takes input from STDIN; run with -R.
bonus version, 97 110 bytes -> 93.5 score
while(a&$c=$argn[$i++])ctype_print($c=chr(bindec(strtr(strrev(decbin(ord($c))),10,"01"))))||"
"==$c?print$c:0;

prints ASCII 10 and 32 to 126 (newline and printables)

breakdown, TiO and if possible some golfing will follow; I´m tired right now.

Japt, 9 bytes
c_¤Ô®^1ÃÍ

Try it

Husk, 9 bytes
m(cḋm¬↔ḋc

Try it online!

Factor, 50 46 41 bytes
[ [ >bin reverse 97 v-n vneg bin> ] map ]

Try it online!
-4 bytes thanks to @Bubbler! -5 bytes thanks to @Bubbler!
Even though removing control characters is just [ control? ] reject it's not worth the 15% discount.

[ ... ] map Map over the code points in the input string.
>bin Convert a code point to a binary string.
reverse Reverse it.
97 v-n vneg Invert the string (1s become 0s and vice-versa).
bin> Convert from a binary string to decimal.

Suggest 97 - neg for 48 = 49 48 ?

And [ 97 - neg ] map to 97 swap n-v. Surprisingly 97 v-n vneg also works.

Haskell, 167 bytes
import Data.Char
import Numeric
r '0'='1'
r '1'='0'
s=map (chr.fst.head.(readInt 2 (`elem` "01") digitToInt).(map r).reverse.flip (showIntAtBase 2 intToDigit . ord)"")

Unfortunately Haskell gets quite verbose when needing to read/print in another base…

Perl 6,  66 bytes
Going all-out by removing the non-printing control characters gets me to (83+1)-15% = 71.4
perl6 -ne 'print grep /<-:C+[\n]>/,.ords».base(2)».flip.map({chr :2([~] $_.comb.map(+!+*))})'

If I remove the code that strips out the control characters I save quite a bit 65+1 = 66
perl6 -ne 'print .ords».base(2)».flip.map({chr :2([~] $_.comb.map(+!+*))})'

( I used » instead of >> for clarity )

Racket 250 15% bonus = 212 bytes
(λ(s)(list->string(map integer->char(filter(λ(x)(or(> x 31)(= x 10)))(for/list((i(string->list s)))(string->number(string-append
"#b"(list->string(map(λ(i)(if(equal? #\0 i)#\1 #\0))(reverse(string->list(number->string(char->integer i)2))))))))))))

Ungolfed:
(define (f s)
    (list->string
     (map
      integer->char
      (filter
       (λ(x)(or(> x 31)(= x 10)))

       (for/list ((i (string->list s)))
         (string->number
          (string-append
           "#b"
           (list->string
            (map
             (λ(i)(if(equal? #\0 i) #\1 #\0))
             (reverse
              (string->list
               (number->string
                (char->integer i) 2)
               )))))))))))

Testing:
(f "Hello, World!")

Output:
"v,dd2>\nXdl"

Zsh, 114 bytes \$\times\$ 0.85 \$=\$ 96.9
for c (${(s::)1})b=(${(s::)$(([##2]#c))})&&b=${(j::)${(Oa)b}}&&s+=${(#)$((2#$b^(2**$#b-1)))}
<<<${s//[^[:print:]]}

Try it online!
Without filtering for printables, this would scores 98 bytes.
for char (${(s::)1}){
    bits=(${(s::)$(([##2]#char))})     # convert to binary, split into characters
    bits=${(j::)${(Oa)b}}              # reverse order of bits, join on empty string
    string+=${(#)$((2#$b^(2**$#b-1)))} # XOR with the 2**(len(bits) - 1), convert from codepoint
}
<<<${string//[^[:print:]]}             # ${string//find/replace}

Java, 78 bytes
s->s.chars().boxed().map(i->(char)(~i.reverse(i)>>>i.numberOfLeadingZeros(i)))

Try it online!

source: Stack Exchange

license: 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/

sort: votes


text:
Check Lyndon word
A Lyndon word is a string that is strictly lexicographically smaller than any of its cyclic rotations. Given a binary string, determine if it's a Lyndon word in as few bytes as possible.
For example, 001011 is a Lyndon word. Its rotations, listed below, are obtained by repeatedly moving the first symbol to the end.
001011
010110
101100
011001
110010
100101

Of these, the original string comes lexicographically first, or equivalently, represents the smallest binary number.
However, 001001 is not a Lyndon word because one of its rotations is the same as itself, which ties it for lexicographically earliest.
A related problem.
Input: A non-empty binary string or list of digits 0 and 1. You may not use numbers, like 5 to represent 101.
Output: A consistent Truthy or Falsey value that says whether the string is a Lyndon word.
Built-ins specifically for Lyndon words are not allowed.
Test cases:
The Lyndon words with length up to 6 are:
0
1
01
001
011
0001
0011
0111
00001
00011
00101
00111
01011
01111
000001
000011
000101
000111
001011
001101
001111
010111
011111

The non-Lyndon words of length up to 4 are:
00
10
11
000
010
100
101
110
111
0000
0010
0100
0101
0110
1000
1001
1010
1011
1100
1101
1110
1111

Leaderboard:

    var QUESTION_ID=62587,OVERRIDE_USER=20260;function answersUrl(e){return"https://api.stackexchange.com/2.2/questions/63075/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

Python 2, 42
It seems to be good enough to compare with suffixes instead of bothering with a rotation.
f=lambda s,i=1:i/len(s)or s<s[i:]*f(s,i+1)

The setup of the recursion does not seem very nice; maybe it could be done better.
This 44-byte version makes it more obvious what's going on:
lambda s:all(s<=s[i:]for i in range(len(s)))

Haskell, 43 38 bytes
f x=all(x<=)$init$scanl(const.tail)x x

scanl(const.tail)x x builds a list of all suffixes of x, including the empty string "" at the end, which is stripped off with init.
Edit: @feersum spotted a bug in my first version and came up with the idea that comparing to suffixes is enough.

How does it check that there aren't any rotations of x that are equal to x?

@feersum: it doesn't. It's a bug. Fixed it. Thanks for finding out!

Pyth, 9 bytes
!f>z>zTUz

Demonstration
Uses Vihan et. al.'s suffixes approach.

Dang it, I thought I was on to something there :p +1

J, 11 char
Outputs 1 on Lyndon words and 0 otherwise.
0=0({/:)<\.

<\. takes suffixes and then /: tells us how to sort them lexicographically. { takes the entry at the 0-th index and 0= checks if it's zero: if it is, we have a Lyndon word, because the biggest suffix wouldn't change place in a sort; if it's nonzero, it is not a Lyndon word, because some suffix is lexicographically earlier.
   0=0({/:)<\. '001011'
1
   0=0({/:)<\. '001001'
0

ShapeScript, 57 47 bytes
0?1'@"2"@+"20"$""~"21"$""~@2?2?>1<*'3?_1-*!@#@#

I created ShapeScript for this competition. The interpreter on GitHub has a slightly modified syntax.
Try it online!

Trivia: This is my 700th PPCG answer.

CJam, 15 14 bytes
r_,,\fm<(f>1-!

Try this fiddle in the CJam interpreter or verify all test cases at once.
How it works
r              e# Read a token from STDIN.
 _,            e# Push the length of a copy.
   ,           e# Turn length L into [0 ... L-1].
    \fm<       e# Rotate the token 0, ..., and L-1 units to the left.
        (      e# Shift out the first rotation, i.e., the original token.
         f>    e# Compare all other rotations with this one.
           1-  e# Remove 1 from the resulting array of Booleans.
             ! e# Apply logical NOT to turn an empty array into 1, and a
               e# non-empty one into 0.

TeaScript, 10 bytes
xe»x«xS(i©

Very golf, much short. Try it online
Explanation && Ungolfed
xe(#x<=xS(i))

xe(#      // Loop through x
          // Check if all iterations return true
    x <=  // Input is less than or equal to...
    xS(i) // Input chopped at current index
)

Holy cow, you're beating Pyth Dennis! How is this even possible?!

@ETHproductions In a world where Dennis can be out-golfed anything is possible :p

I'll savor this moment while it lasts, then the CJam and Pyth answers will probably be golfed more

Wait, wait... I see that this properly handles cases like 00, but how does it do this without catching on itself being equal to itself (i.e. when i==0)?

@ETHproductions This doesn't actually cycle much like feersum's answer, simply comparing the suffixes is functionally equivalent

Oh hey, you're right :) Let's see, that means I can golf about 10 bytes off my WIP Japt answer...

Haskell, 29
f s=all(s<=)$init$scanr(:)[]s

Checks whether s is at most each of its non-empty suffixes, like nimi's answer.
The expression scanr(:)[] generates the list of suffixes by listing.
>> scanr(:)[] "abcd"
["abcd","bcd","cd","d",""]

The init then gets rid of the empty string at the end. Finally, all(s<=) checks whether every suffix x satisfies s<=x. Since the first suffix is s itself, a <= is needed.

Ruby, 37 bytes
->s{(1...s.size).all?{|i|s[i..-1]>s}}

Testing:
lyndon_words = %w(0 1 01 001 011 0001 0011 0111 00001 00011 00101 00111
                  01011 01111 000001 000011 000101 000111 001011 001101
                  001111 010111 011111)

not_lyndon_words = %w(00 10 11 000 010 100 101 110 111 0000 0010 0100 0101
                      0110 1000 1001 1010 1011 1100 1101 1110 1111)

f=->s{(1...s.size).all?{|i|s[i..-1]>s}}

p lyndon_words.all? &f      # => true
p not_lyndon_words.any? &f  # => false

Burlesque, 15 bytes
JiRJU_j<]x/==&&

Mainly 8 of those 7 bytes are to check if it doesn't tie. Otherwise you can go with simply JiR<]==.
Explanation:
J       -- duplicate word
iR      -- all rotations
J       -- duplicate list of all rotations
U_      -- check if list contains no duplicates
j       -- swap
<]      -- find minimum of the list
x/      -- rotate top
==      -- compare minimum with the original word
&&      -- and results of min == orig and list unique

Vyxal, 5 bytes
ẏvǔg=

Try it Online!
 vǔ   # Rotate by each of...
ẏ     # 0 to len(x)
   g  # Does the (lexicographic) minimum
    = # Equal the input?

From the challenge description: "However, 001001 is not a Lyndon word because one of its rotations is the same as itself, which ties it for lexicographically earliest."

Pyth - 12 bytes
Hope to golf a little bit.
.A<Lzt.<Lzlz

Try online.

Javascript (ES6), 129 bytes
a=Array;s=prompt();console.log(a.from(a(s.length),(x,i)=>i).map(n=>(s.substring(n)+s.substring(0,n--))).sort().pop().contains(s))

Javascript, 91 87 bytes
f=x=>(y=(x+x).slice(1,-1),x[0]==x||!(y.indexOf(x)+1)&&!x.indexOf('0')&&x.slice(-1)==1);

I'm basically concatenating the word with itself and check if it's still there.
To check if it is the smallest number possible, I just check that it start with a 0 and end with a 1.
Tests
[
['0',1],
['1',1],
['01',1],
['001',1],
['011',1],
['0001',1],
['0011',1],
['0111',1],
['00001',1],
['00011',1],
['00101',1],
['00111',1],
['01011',1],
['01111',1],
['000001',1],
['000011',1],
['000101',1],
['000111',1],
['001011',1],
['001101',1],
['001111',1],
['010111',1],
['011111',1],
['00',0],
['10',0],
['11',0],
['000',0],
['010',0],
['100',0],
['101',0],
['110',0],
['111',0],
['0000',0],
['0010',0],
['0100',0],
['0101',0],
['0110',0],
['1000',0],
['1001',0],
['1010',0],
['1011',0],
['1100',0],
['1101',0],
['1110',0],
['1111',0]
].forEach(t =>{
  r=f(t[0])
  x=t[1]
  console.log('Test '+(r==x?'OK':'Fail (Expected: ' + x +')')
  +'\nInput: '+t[0]+'\nResult: ' +r+'\n')
})

Mathematica, 86 bytes
(s=Table[#~StringRotateLeft~i,{i,StringLength@#}];Last@s==First@Sort@s&&s~Count~#==1)&

input

["1111"]

PowerShell Core, 85 bytes
param($k)($w=0..($l=$k.Length-1)|%{-join$k[-$_..($l-$_)]}|sort)[0]-eq$k-and$w[1]-ne$k

Try it online!

Generates all the rotations of the input
Sorts them
Checks that the first one equals the input and the second one does not

05AB1E, 7 (or 8?) bytes
ā._{QJR

Outputs a 05AB1E truthy/falsey result, where truthy is a 1 padded with leading 0s up to the input-length, and falsey anything else. But since the challenge description mentions 'consistent' truthy/falsey value, a trailing Θ (05AB1E-truthify builtin: ==1) can be added for consistent 1/0 outputs.
Try it online or verify some more test cases.
Explanation:
ā        # Push a list in the range [1, (implicit) input-length] (without popping)
 ._      # Rotate the input that many times (vectorized) towards the left
   {     # Sort this list of rotations
    Q    # Check for each rotation whether it's equal to the (implicit) input
     J   # Join the checks together
      R  # Reverse this string
         # (after which the result is output implicitly)

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


text:
Find the largest N digit number in a W by H grid of digits
Write a program or function that takes in a positive integer \$N\$ and a grid of decimal digits (\$0\$ to \$9\$) with width \$W\$ and height \$H\$ (which are also positive integers). You can assume that \$N\$ will be less than or equal to the larger of \$W\$ and \$H\$ (\$N \le \max(W,H)\$).
Print or return the largest contiguous \$N\$-digit number that appears horizontally or vertically in the grid, written in normal reading order or in reverse.

Diagonal lines of digits are not considered.
The grid does not wrap around, i.e. it does not have
periodic boundary conditions.

For example, the \$3\times3\$ grid
928
313
049

would have 9 as the output for \$N = 1\$, 94 as the output for \$N = 2\$, and 940 as the output for \$N = 3\$.
The \$4\times3\$ grid
7423
1531
6810

would have 8 as the output for \$N = 1\$, 86 for \$N = 2\$, 854 for \$N = 3\$, and 7423 for \$N = 4\$.
The \$3\times3\$ grid
000
010
000

would have output 1 for \$N = 1\$, and 10 for N = 2 and N = 3 (010 is also valid for N = 3).
The \$1\times1\$ grid
0

would have output 0 for \$N = 1\$.
You can take the input in any convenient reasonable format. e.g. the grid could be a newline separated string of digits, or a multidimensional array, or a list of lists of digits, etc. Leading zeros are allowed in the output if they were part of the grid.
This is code-golf, so the shortest code in bytes wins, but I'll also award brownie points (i.e. more likely upvotes) for answers that can show that their algorithm is computationally efficient.

Are we allowed to print any leading zeroes?

@Pietu1998 "Leading zeros are allowed in the output if they were part of the grid."

Pyth, 22 19 bytes
3 bytes thanks to Jakube.
seSs.:RQ.n,L_MdCB.z

Try it online.
If we are allowed to print leading zeroes, the code is 18 bytes:
eSs.:RQ.n,L_MdCB.z

Converting a string with leading zeros to an integer can be accomplished with s.

CJam, 39 36 35 34 bytes
qN/)i\[{zW%_}4*]ff{_,@e<ew:i}e_:e>

Just quickly, before @Dennis wakes up :P
Try it online.
Explanation
The basic algorithm is to take all four rotations of the grid and split each row into chunks of length N (or the row length, whichever's smaller). Then convert the chunks to ints and take the largest.
qN/             Split input by newlines, giving an array of lines
)i\             Drop N from the array and put at bottom
[        ]      Wrap in array...
 {    }4*         Perform 4 times...
  zW%_              Rotate grid anticlockwise and push a copy
                Note that this gives an array of 5 grids [CCW1 CCW2 CCW3 CCW4 CCW4]
ff{         }   For each grid row, mapping with N as an extra parameter...
   _,             Push length of row
     @e<          Take min with N
        ew        Split into chunks
          :i      Convert to ints
e_              Flatten that array
:e>             Take cumulative max

Out of curiosity, does few do anything special, or is it three separate commands?

@ETHproductions It's actually the operator ew applied using f, or "map with extra parameter". For example, ["abcd" "efgh"] 2 few results in [["ab" "bc" "cd"] ["ef" "fg" "gh"]].

Gotcha :) That's an interesting coincidence, though.

Only issue is that, when @Dennis wakes up, everybody else loses anyway. ;)

Jelly, 12 bytes
ZU$4Ð¡Ẏṡ€ḌFṀ

Try it online!
This takes the grid as an \$W\times H\$ matrix of single digits.
The TIO Footer simply takes each input list and generates the outputs for each \$N = 1, 2, ...\$ up to either \$W\$ or \$H\$, depending on which is larger
How it works
ZU$4Ð¡Ẏṡ€ḌFṀ - Main link. Takes the matrix M on the left and N on the right
  $          - Group the previous 2 links together as a monad f(M):
Z            -   Transpose
 U           -   Reverse
   4Ð¡       - 4 times, run f(M) on M, updating M each time, and return all 4 results
               This yields M, Mᵀ with rows reversed, Mᵀ and M with rows reversed
      Ẏ      - Tighten into a list of lists
        €    - Over each:
       ṡ     -   Yield all overlapping sublists of length N
         Ḍ   - Convert back to integers
          F  - Flatten
           Ṁ - Maximum

05AB1E, 13 bytes
DÅ|«€ÂJ€Œ˜sùà

Try it online! Explanation:
D                 # duplicate matrix
 Å|               # get column vectors
   «              # join matrix with its column vectors
    €Â            # append reversed elements
      J           # join arrays into numbers
       €Œ˜        # Get all substrings
          sù      # Keep only those of required length
            à     # Get the largest value

Japt -h, 13 12 bytes
Takes the matrix as an array of lines. Includes leading 0s in the output, where applicable.
4Æ=z)mãVÃc ñ

Try it
4Æ=z)mãVÃc ñ    :Implicit input of array U & integer V
4Æ              :Map the range [0,4)
  =             :  Reassign to U
   z            :  Rotate 90° clockwise
    )           :  End reassignment
     m          :  Map
      ãV        :    Substrings of length V
        Ã       :End map
         c      :Flatten
           ñ    :Sort
                :Implicit output of last element

Husk, 13 bytes
▲ṁX⁰Σ↑4¡om↔T²

Try it online!
The arguments are a bit finicky here.

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


text:
What's the weather like?
Pick six cities or villages, one from each of the populated continents, Asia, Africa, North America, South America, Europe and Australia. The forecasts cover 8351174 places, more than 2 million in the US, 150000 in Pakistan, 10000 in Uganda, and 16 places in the Shefa province in Vanuatu, so I think you'll find a place near you.
Make a table where the weather for each of the cities are listed, for the coming ten 6-hour periods. The cities should be listed in the order above (first an Asian city, then an African city ...).
The information that should be listed is:

City: Name, CC (CC is the first two letters of the country name)
Time: yyyy-mm-dd
Period: 1
Weather: Cloudy
Temperature: 24

The output format has the following restrictions:
The order is given as below (Time, Period, Weather, Temperature, Weather Temperature, Weather, Temperature ...). The city name and country code are headers
                Kyoto, JA          Addis Ababa, ET     Minneapolis, US     Rio de Janeiro, BR    Genoa, IT          Perth, AU
2015-11-05, 3,  Cloudy, 15         Clear sky, 18       Heavy rain, 24      Cloudy, 12            Fair, 14           Rain, 26
2015-11-06, 0,  Cloudy, 12         Fair, 14            Rain, 26            Cloudy, 12            Fair, 14           Rain, 26
2015-11-06, 1,  Heavy rain, 14     Clear sky, 17       Rain, 22            Heavy rain, 14        Clear sky, 17      Rain, 22
2015-11-06, 2,  Rain, 15           Clear sky, 12       Rain, 25            Heavy rain, 14        Clear sky, 17      Rain, 22
2015-11-06, 3,  Partly cloudy, 9   Fair, 8             Heavy rain, 30      Clear sky, 8          Fair, 14           Partly cloudy, 25
2015-11-07, 1,  Clear sky, -8      Fair, 14            Partly cloudy, 25   Clear sky, 8          Fair, -14          Partly cloudy, 25
2015-11-07, 2,  Fog, 13            Partly cloudy, 15   Fair, 22            Clear sky, 8          Fair, 14           Partly cloudy, 25

The weather forecast can be found on www.yr.no. The weather data can be found on xml-format on urls such as:
http://www.yr.no/place/Australia/Western_Australia/Perth/forecast.xml
http://www.yr.no/place/Italy/Liguria/Genoa/forecast.xml
http://www.yr.no/place/Turks_and_Caicos_Islands/Other/Cockburn_Town/forecast.xml
http://www.yr.no/place/Bahamas/San_Salvador_and_Rum_Cay/Cockburn_Town/forecast.xml

Yes, there are apparently two places called "Cockburn Town". You can search for places on the main page (yr.no), and simply append /forecast.xml when you've found your place. (You can select language in the top right corner, the website might be shown in Norwegian).
The data has the following format:
<time from="2015-11-05T19:00:00" to="2015-11-06T00:00:00" period="3">
<!--
 Valid from 2015-11-05T19:00:00 to 2015-11-06T00:00:00
-->
<symbol number="4" numberEx="4" name="Cloudy" var="04"/>
<precipitation value="0" minvalue="0" maxvalue="0.4"/>
<!--  Valid at 2015-11-05T19:00:00  -->
<windDirection deg="131.5" code="SE" name="Southeast"/>
<windSpeed mps="3.7" name="Gentle breeze"/>
<temperature unit="celsius" value="12"/>
<pressure unit="hPa" value="1014.2"/>
</time>
<time from="2015-11-06T00:00:00" to="2015-11-06T06:00:00" period="0">...</time>
<time from="2015-11-06T06:00:00" to="2015-11-06T12:00:00" period="1">...</time>

As you can see, each 6 hour period has a period number "0", "1", "2" or "3". The table must have the date followed by the period number, 2015-11-06, 3 (might be separated by a comma, tab or whatever).
You must, for each of the periods list what type of weather it is, and the temperature, in this case: Cloudy, 12 (not 12 Cloudy). The values can be separated by a comma, tab, or whatever.
Each city must be separated from the others in such a way that they form distinct "blocks", as in the example output. The output should be on a table like format.
The details of the output format is optional.
These parts: Italy/Liguria/Genoa/, Brazil/Rio_de_Janeiro/Rio_de_Janeiro/ of the code can be subtracted from the byte count (no need to chose the shortest city names). Url-shorteners are prohibited.
It must be possible to run your code a year from now, so you can't hard code dates etc.
The weather data is free and publicly available, as long as the following attribution is shown, so please include it in the bottom of your answer.
This is code golf, so the shortest answer in bytes win.
Weather forecast from yr.no, delivered by the Norwegian Meteorological Institute and the NRK.

if (I_am_camping()) return "Heavy rain";

if (I_am_at_work()) return "Clear sky";

if(is_in_Ireland()) return "Slightly rainy, 54 degrees Fahrenheit

Mathematica 418 bytes
These are the URL's. We will assume they are contained in variables and thus not count them.
t="http://www.yr.no/place/Japan/Tokyo/Tokyo/forecast.xml";
a="http://www.yr.no/place/Algeria/Alger/Algiers/forecast.xml";
b="http://www.yr.no/place/United_States/Massachusetts/Boston/forecast.xml";
r="http://www.yr.no/place/Brazil/Pernambuco/Recife/forecast.xml";
p="http://www.yr.no/place/France/Île-de-France/Paris/forecast.xml";
    c="http://www.yr.no/place/Australia/Australian_Capital_Territory/Canberra/forecast.xml";
This is the code used.
z@{s_,k_}:=Cases[s~Import~"XML",XMLElement["time",{"from"-> d_,b_,"period"->p_},
{XMLElement[_,{___,"name"->w_,___},{}],___,XMLElement["temperature",{___,"value"->t_},{}],
___}]:>{" "->Row[{d~StringTake~10,p},", "],k->Row[{w, t},", "]},Infinity];
w=Join@@(z/@{{t,"Tokyo, JA"},{a,"Algiers, AL"},{b,"Boston, US"},{r,"Recife, BR"},
{p,"Paris, FR"},{c,"Canberra, AU"}});
Dataset[Association/@(Prepend[Cases[w,{#,r__}:>r],#]&/@w[[All,1]])]

I'm not looking forward to 2015-11-10, 3 at all. That seems to be a crappy time all over the world (almost).


text:
Average of a string
You have been employed by a data analysis company, and have been appointed the task of finding the average character of a string of characters. However, this company has limited funding for code storage, so your code must be as small as possible.
Task
Write a program or function that takes one string of characters as input, and outputs the average character of that string.
Calculation of average
The average character of a string is the sum of the ASCII values of the individual characters divided by the total number of characters, then converted back to an ASCII character.
For example, the string cat consists of the sequence 99 97 116 of ASCII values. These values summed equals 312, which then divided by 3 gives an average of 104. 104 represents the ASCII character h. The average character of the string cat is therefore h.
Rules

You can assume the input string will only contain printable ASCII characters
If the average of the string's ASCII values is floating point, it should be rounded to the nearest integer and then converted to the equivalent ASCII character (eg. an average of 66.4 would output B, and an average of 66.5 would output C)
Input can be from STDIN (or language equivalent), or as a function parameter
Output must be to STDOUT (or language equivalent), or as a return result if your program is a function
Standard loopholes are not allowed
This is code-golf, so shortest code in bytes wins

Examples
Input → average → output
Hello, world! → 89.3076923076923 → Y
Code golf → 92.77777777777777 → ]
8112015 → 50.57142857142857 → 3

Matlab, 23,21 16 bytes
I think this is quite obvious, if you know that matlab handles strings as arrays of characters, which can be treated like integers, aparently rounding occurs automatically when concatenated with a string.
@(s)[mean(s),'']

Julia, 41 bytes
With help from @AlexA.
a->Char(round(Int,mean([Int(i)for i=a])))

(Older version only worked in Julia 0.3.)

JavaScript ES6, 87 82 81 79 bytes
f=s=>String.fromCharCode([...s].reduce((r,c)=>r+c.charCodeAt(),0)/s.length+.5);

Thanks ETHproductions for the time to shorten by 5 bytes.
Thanks  rink.attendant for a byte less.
Thanks Vihan for another 2 bytes.

You can save to byte by removing the function declaration f= at the beginning. You can also save two bytes by using two backticks `, instead of (''). You can save one byte by omitting the 0 in charCode At also

Nice work! To go along with Vɪʜᴀɴ, [...s] works in place of s.split('').

Oh hey, I like the +.5|0 in place of Math.round(). I wonder why I've never thought of that... +1

I believe you can omit the 0 argument from String.prototype.charCodeAt

You also don't need the |0 in +.5|0, String.formCharCode will automatically do that

CJam, 11 bytes
q_1b\,d/moc

Test it here.
Explanation
q    e# Read input.
_1b  e# Duplicate and get the ASCII sum by treating the character codes as base-1 digits.
\,   e# Swap with other copy and get its length.
d/   e# Convert to float and divide.
mo   e# Round to nearest integer.
c    e# Convert to character.

Vitsy, 11 Bytes
This was what this was MADE for.
IVzV1-\+V/O
I           Get the length of the input stack.
 V          Save it as the final global variable, popping it.
  z         Push the input stack to the program stack.
   V1-\     Repeat the next item global variable size - 1.
       +    Add the top two items. This adds up everything.
        V/  Divide by the global variable.
          O Output as a character.

Pyth, 9 bytes
C.R.OCMz0

Try it online.

TeaScript, 14 bytes
ÇU(x¿lÅ)x¡/xn©

Probably can be golfed using a reduce
Ungolfed
C(U(xs``.m(#lc())x()/xn))

C(       // Char from code from...
  U(      // Round
    xs``   // Split input
    .m(#   // Map over input
        lc()  // get char code
    ).x()  // Sum up array
    /xn    // Divided by input length
  )
)

Mathematica, 47 bytes
FromCharacterCode@Round@Mean@ToCharacterCode@#&

or using composition:
FromCharacterCode@*Round@*Mean@*ToCharacterCode

String handling in Mathematica is such a joy...

K5, 16 bytes
{`c$.5+(+/x)%#x}

The phrase {(+/x)%#x} is a classic K idiom for calculating an arithmetic mean, and in K5 characters naturally coerce to numbers with no special work. `c$.5+ handles rounding and converting the result back into a character.
In action:
  {`c$.5+(+/x)%#x}'("Hello, world!";"Code golf";"8112015")
"Y]3"

Ruby, 46 45 characters
->s{'%c'%(s.bytes.reduce(0.0,:+)/s.size+0.5)}

Sample run:
2.1.5 :001 > ->s{'%c'%(s.bytes.reduce(0.0,:+)/s.size+0.5)}['Hello, world!']
 => "Y"

2.1.5 :002 > ->s{'%c'%(s.bytes.reduce(0.0,:+)/s.size+0.5)}['Code golf']
 => "]"

2.1.5 :003 > ->s{'%c'%(s.bytes.reduce(0.0,:+)/s.size+0.5)}['8112015']
 => "3"

Python 3, 48 Bytes
Straightforward solution with an anonymous lambda function.
lambda k:chr(int(round(sum(map(ord,k))/len(k))))

Japt, 31 27 bytes
Ua r(X$,$Y =>Xc +Yc)/Ul)r d

Try it in the Stack Snippet interpreter! (Arrow functions require ES6-compliant browser, e.g. Firefox.)
How it works
            // Implicit: U = input string
Ua          // Split U into chars.
r(X$,$Y =>  // Reduce the result by:
Xc +Yc      //  summing the char codes.
/Ul)        // Divide the result by the original string's length.
r d         // Round the result and turn back into a character.
            // Implicit: output last expression

(Side note: c works as .charCodeAt on strings and Math.ceil on numbers. The first time reduce is run, it will be between two strings, so Xc is necessary, but has no effect on the rest of the reducing.)
This is still much longer than it should be. The summing is 17 bytes when it could be 5 or so. Here's a 14-byte version I'd like to get working in the interpreter:
Uamc)r+ /Ul)rd
Uamc)          // Split input into chars, then replace each with its char code.
     r+        // Reduce the result with operator +. Equivalent to summing the array.
        /Ul)   // Divide the sum by the original string's length.
            rd // Round and turn into a character.

CoffeeScript, 94 bytes
f=(x)->String.fromCharCode Math.round x.split('').reduce(((p,v)->p+v.charCodeAt 0),0)/x.length

Haskell, 74 69 bytes
s x=toEnum$round$(fromIntegral.sum.map fromEnum$x)/(foldr(\_ y->y+1)0x)

Pretty straightforward. A good chunk of the length is due to the fact that we can't apply the floating-point division operator (/) to integral types and that besides we need to round so we can't take advantage of the integral division's truncating behaviour.
P.S. : Shaved off 5 bytes by using a fold to avoid the second fromIntegral. Interestingly, replacing the dividend by a fold gives a longer program, probably because you need the fromIntegral there.

Ruby, 48
->s{t=0.0;s.bytes{|i|t+=i};(t/s.size).round.chr}

PowerShell, 60 Bytes
param([char[]]$a)$a|%{$b+=[int]$_};[char][int]($b/$a.Length)

Nothing esoteric. Takes input string param(..) and casts it as a char[]. Iterates over that array $a|%{..}, and each iteration adds the int value of that character to our accumulator $b. Then takes the average, casts it as int (which does implicit rounding to the nearest integer), then casts as a char for output. Since that's left on the pipeline, output is implicit.


text:
Multiple program Quinecatenate!
Your task is to give three different languages A, B, C, and write two different programs P and Q such that:
P is a quine in language A, but not a quine in B nor C;
Q is a quine in language B, but not a quine in A nor C; and
Q concatenated after P (without any new characters added in between) is a quine in language C, but not in B nor A.
This is codegolf, where your score is the length of the final, concatenated quine. Again, adhere to the rules of proper quines  -- no reading your source code, no empty programs etc.

Rules on comments?

That's something that I didn't think of before. I'm inclined to let them slide because then you have to worry about printing that out AND having to make sure language C has the same comment syntax or something but I'm flexible.

Does "not a quine" mean "do anything" or "at least run"?

When put into a compiler it doesn't output its source code. It can run or throw an error or not compile or output something else or nothing, but as long as it doesn't output its source code.

Quine challenge inspiration, for anyone interested: "Print all those programs in , and those only, which do not print themselves."

@ETHproductions what if we used "Print all those programs in , and those only, which do not exclusively print themselves." That would avoid Russell's paradox. Though I suppose it would still run into problems with the Halting Problem, depending on your choice of language.

The program's don't have to even be valid in the other languages, as long as they're quines in the correct labguage!

Even after reading the meta discussion you linked to, I am unsure what exactly is acceptable as quine. For example, would using SMBF (which starts with its source code in the data array) be acceptable?

@Dennis let's let the community decide with votes.

I'd rather have a final decision before I post my answer. There's no point in writing it up if it'll just get downvoted. (I am sitting on a 29-byte solution using SMBF.)

@Dennis well I'm not really the guy to make a decision like this but I would love to see what you have.

Fission + CJam + GolfScript, 38 36 bytes
Fission, 6 bytes
'!+OR"

This is one of Martin Büttner's Fission quines. Try it online!
CJam, 30 bytes
' {"''"@*" "+YX#<
\"0$~"N}0$~

The last byte is a linefeed. Try it online!
GolfScript, 36 bytes
'!+OR"' {"''"@*" "+YX#<
\"0$~"N}0$~

The last byte is a linefeed. Try it online!
Verification
$ wc -c P Q
 6 P
30 Q
36 total
$ cat P Q > P+Q
$
$ Fission P 2>&- | diff -qs - P
Files - and P are identical
$ cjam P 2>&- | diff -qs - P
Files - and P differ
$ golfscript P 2>&- | diff -qs - P
Files - and P differ
$
$ cjam Q 2>&- | diff -qs - Q
Files - and Q are identical
$ golfscript Q 2>&- | diff -qs - Q
Files - and Q differ
$ Fission Q 2>&- | diff -qs - Q
Files - and Q differ
$
$ golfscript P+Q 2>&- | diff -qs - P+Q
Files - and P+Q are identical
$ Fission P+Q 2>&- | diff -qs - P+Q
Files - and P+Q differ
$ cjam P+Q 2>&- | diff -qs - P+Q
Files - and P+Q differ

How it works
Fission

R spawns an atom that moves right, wrapping around at the edge.
" toggles printing mode. Everything up to the next " is printed.
'! sets the atom's to the code point of '!'.
+ increments the atom's mass, setting it to the code point of ".
O prints the character whose code point is the atom's mass and destroys the atom.

CJam
'       e# Push a space character.
{       e# Push the following code block:
  "''"  e# Push that string.
  @*    e# Separate its characters by spaces.
  " "+  e# Append one more space.
  YX#   e# Raise 2 to the first power. Pushes 2.
  <     e# Discard all but the first two characters of the string, i.e., "' ".
  \     e# Swap the string "' " with the code block in execution.
  "0$~" e# Push that string.
  N     e# Push a linefeed.
}       e#
0$~     e# Push a copy of the code block and execute it.

GolfScript
'!+OR"' # Push that string.
{       # Push the following code block:
  "''"  # Push that string.
  @*    # Join its characters, separating them by the first string.
  " "+  # Append a space.
  YX    # Undefined token. Does nothing.
  #<    # Comment.
  \     # Swap the string with the code block in execution.
  "0$~" # Push that string.
  N     # Undefined token. Does nothing.
}       #
0$~     # Push a copy of the code block and execute it.

Found another Dennis!

Self-modifying Brainfuck + GolfScript + CJam, 29 27 bytes
Self-modifying Brainfuck, 12 bytes
 {<[<]>[.>]}

Note the leading space. Try it online!
GolfScript, 15 bytes
{So"0$~"N]}0$~

The last byte is a linefeed. Try it online!.
CJam, 27 bytes
 {<[<]>[.>]}{So"0$~"N]}0$~

Note the leading space. The last byte is a linefeed. Try it online!
Verification
$ wc -c P Q
12 P
15 Q
27 total
$ cat P Q > P+Q
$
$ timeout 10 smbf P | diff -sq - P
Files - and P are identical
$ golfscript P | diff -sq - P
Files - and P differ
$ cjam P | diff -sq - P
Files - and P differ
$
$ golfscript Q | diff -sq - Q
Files - and Q are identical
$ cjam Q | diff -sq - Q
Files - and Q differ
$ timeout 10 smbf Q | diff -sq - Q
Terminated
$
$ cjam P+Q | diff -sq - P+Q
Files - and P+Q are identical
$ golfscript P+Q | diff -sq - P+Q
Files - and P+Q differ
$ timeout 10 smbf P+Q | diff -sq - P+Q
Terminated

How it works
Self-modifying Brainfuck
SMBF starts with its source code on the left of the data pointer.
<space>        (ignored)
{              (ignored)
<              Move the data pointer left.
[<]            Move the data pointer left to the next null byte.
>              Move the data pointer right.
[.>]           Print and move the data pointer right until null byte.
}              (ignored)

GolfScript
{            # Push the following code block:
  So         # Undefined token. Does nothing.
  "0$~"      # Push that string.
  N          # Undefined token. Does nothing.
  ]          # Wrap the stack in a array. Does not affect output.
}            #
0$~          # Push a copy of the code block and execute it.

### CJam

{<[<]>[.>]} e# Push that code block.
{           e# Push the following code block:
  So        e# Print a space. Since it is printed explicitly,
            e# it will appear at the beginning of the output.
  "0$~"     e# Push that string.
  N         e# Push a linefeed.
  ]         e# Wrap the stack in a array. Does not affect output.
            e# This makes the program an infinite, empty  loop
            e# in SMBF; it would be a quine otherwise.
}           e#
0$~         e# Push a copy of the code block and execute it.

Tcl, CJam, GolfScript, 60 + 26 = 86 112 bytes
Not golfed well.
Tcl, 60 bytes
{puts} [{join} {{} \{ \}\]} {{puts} [{join} {{} \{ \}\]} }]

Based on the quine on this page. It has a trailing newline.
CJam, 26 bytes
{"' '@`+n@0"L~;"0$~"N}0$~

It has a trailing newline.
GolfScript, 86 bytes
{puts} [{join} {{} \{ \}\]} {{puts} [{join} {{} \{ \}\]} }]
{"' '@`+n@0"L~;"0$~"N}0$~

How does this work? I've never heard of tcl

@FarazMasroor Strings in Tcl can be surrounded by braces, and command names are also strings. And things in braces are considered blocks in GolfScript, which can be printed as is. CJam is similar to GolfScript but different enough to make a quine in one language not work in the other.  With these choices of languages these are just normal quines with some extra code to output in the right format, which isn't golfed yet.

ShapeScript + CJam + GolfScript, 96 95 62 bytes
ShapeScript, 16 bytes
'"%r"@%"0?!"'0?!

This is the standard ShapeScript quine. Try it online!
CJam, 46 bytes
];{"'\"%r\"@%\"0?!\"'0?!];"SS#~(>
\"0$~"N}0$~

The last byte is a linefeed. Try it online!
GolfScript, 62 bytes
'"%r"@%"0?!"'0?!];{"'\"%r\"@%\"0?!\"'0?!];"SS#~(>
\"0$~"N}0$~

The last byte is a linefeed. Try it online on Web GolfScript.
Verification
$ wc -c P Q
16 P
46 Q
62 total
$ cat P Q > P+Q
$
$ shapescript P 2>&- | diff -qs - P
Files - and P are identical
$ cjam P 2>&- | diff -qs - P
Files - and P differ
$ golfscript P 2>&- | diff -qs - P
Files - and P differ
$
$ cjam Q 2>&- | diff -qs - Q
Files - and Q are identical
$ golfscript Q 2>&- | diff -qs - Q
Files - and Q differ
$ shapescript Q 2>&- | diff -qs - Q
Files - and Q differ
$
$ golfscript P+Q 2>&- | diff -qs - P+Q
Files - and P+Q are identical
$ shapescript P+Q 2>&- | diff -qs - P+Q
Files - and P+Q differ
$ cjam P+Q 2>&- | diff -qs - P+Q
Files - and P+Q differ

How it works
ShapeScript
'       Push a string that, when evaluated, does the following.
  "%r"  Push this formatting string. %r gets replaced by a string
        representation of the corresponding argument.
  @     Swap the string that is being evaluated on top of the stack.
  %     Apply formatting to the string on top of the stack.
  "0?!" Push that string.
'
0?!     Push a copy of the previous string and evaluate it.

CJam
];      e# Clear the stack. Stack is already clear. Does nothing.
{       e# Push the following code block:

  "'\"%r\"@%\"0?!\"'0?!];"

  SS#   e# Find the index of " " in " ". Pushes 0.
  ~(    e# Apply logical NOT and decrement. Pushes -2.
  >     e# Discard all but the two rightmost characters from the string,
        e# i.e., reduce it to "];".
  \     e# Swap the string "];" with the code block in execution.
  "0$~" e# Push that string.
  N     e# Push a linefeed.
}       e#
0$~     e# Push a copy of the code block and execute it.

GolfScript
'"%r"@%"0?!"'

0?!     # Find the index of the number 0 in the string and apply logical NOT.
];      # Clear the stack.
{       # Push the following code block:

  "'\"%r\"@%\"0?!\"'0?!];"

  SS    # Undefined token. Does nothing.
  #~(>  # Comment.
  \     # Swap the string with the code block in execution.
  "0$~" # Push that string.
  N     # Undefined token. Does nothing.
}       #
0$~     # Push a copy of the code block and execute it.

I found myself a wild Dennis!


text:
Across the alphabet
Across the alphabet
In this challenge, you have trouble remembering the letters of the alphabet. To circumvent this, you go up and down the alphabet, till you get to the letter.
Because you want your code to be portable, you'll be writing it with letter blocks. You have a limited amount of letter blocks because most of them got stolen so you need to make sure your code is as short as possible.
Examples
Input / Output pairs are separated by a blank line:
Ac
ABc

Ad
ABcd

fA
fedCBA

adB
abcdcB

Hello, World!
HGfefghijkllmno, WVUTSrqpopqrqponmlkjihgfed!

Challenge
Your goal is to chain adjacent letters with all the intermediate letters of the alphabet (A-Za-z) between them. If capitalization differs, the capitalization should be transformed in the middle. If capitalization cannot be evenly transformed in the middle, it broken up after the middle. If a character isn't an alphabetical character, no transformation should be done.
Winning
This is code-golf so shortest code in bytes wins!
-10% Bonus: if your code chains digits

What do you mean by letter blocks?

@LegionMammal978 Letter blocks. Not really relevant to the challenge, just a random reason I came up with for short code

Okay, just wondering if you meant [tag:restricted-source].

By your rules, dont you think adB should transform to abcdCB because c is in the middle of d and b.

Pretty similar to my Alphabet Between Encryption, but this already has twice the votes so I'll just flag mine.

@geokavel the rules say that if capitalization cannot be evenly transformed in the middle, it's broken up after the middle. since d is lower case, c should also be lower case.

@vic but dcb has a middle: it's c.

@geokavel yes but I think "exactly in the middle" means even numbers. aD would be abCD; two letters in the middle, one uppercase one lower case. aE would be abcDE. Three letters in the middle, 2 lower case and one uper case so dB would be dcB and not dCB because the first letter is lowe case. :)

@vic my interpretation works for all his examples except dB. I hope the OP can clarify.

@geokavel your interpretation goes against common sense. No need of clarification about this point.

Vihan, please DO NOT change the scoring after 2 days. I have specifically avoided to chain digits - even suggested a modification to @user81655 because he was - accidentally - chaining digits. Now that's a bonus?

@geokavel but he does not. In the first example there is 1 char in between - odd - and the case change is placed after the middle. Really, is crystal clear

@geokavel dB would become bcD because bcd does not have a middle   (3/2 = 1.5) so we'll have to round up to 2, this means it'll be bcD instead.

@Vɪʜᴀɴ thanks for clarifying. everytime i look at the bcD example I still think it should be bCD. Probably all the Java programming I do...

Can we assume that the input contains only ASCII characters?

@Dennis yeah, sure

what should a chain look like between a letter and a digit or vice versa?

Pyth, 40 bytes
+sm?-rdZGhd+hdsrVc2jktr.*rdZm!}kGd.:z2ez

Try it online.

Python 2, 303 291 288 282 276 261 253 bytes
This is a completely different algorithm than Hannes Karppila's, and after lots of golfing, I've managed a substantial improvement in length. I think this algorithm might allow for one of the shortest codes in other languages too, especially languages with do-while loops and built-in signum functions. Suggestions for further improvement welcome. (Something tells me that whole inner loop should be rewritten as a list comprehension.)
l=map(ord,list(raw_input()));f=q=1
while q:
 q=0;m=~-f/2;c=m
 while abs(c)<len(l)-1:
  u=c+f;d=(l[u]-96)%32-(l[c]-96)%32
  if chr(l[c]).isalpha()*chr(l[u]).isalpha()*(d*d>1):l[:u-m]+=[l[c]+d/abs(d)];u+=f;q=1
  c=u
 f=-f
print "".join(map(chr,l))

JavaScript (ES6), 198 197 194 bytes
f=s=>(o="",a=u=0,[...s].map(c=>{j=c.toUpperCase();p=j==c;b=j<"A"|j>"Z"?0:j.charCodeAt();for(i=0,m=a<b?b-a:a-b;a&&b&&++i<m;)o+=String.fromCharCode(i*(am/2?p:u));a=b;u=p;o+=c}),o)

Usage
f("Hello, World!")
=> "HGfefghijkllmno, WVUTSrqpopqrqponmlkjihgfed!"

Explanation
f=s=>(
  o="",                                   // o = output string
  a=                                      // a = previous character code (or 0 if symbol)
    u=0,                                  // u = 1 if previous character was upper-case
  [...s].map(c=>{                         // iterate through each letter of input

    // Get information about the current character
    j=c.toUpperCase();                    // j = current character in upper-case
    p=j==c;                               // p = current character is upper-case
    b=j<"A"|j>"Z"?0:j.charCodeAt();       // b = current character code (or 0 if symbol)

    // Interpolate characters (unless A or B is a symbol)
    for(i=0,m=a<b?b-a:a-b;a&&b&&++i<m;)   // loop for each character between A and B
      o+=String.fromCharCode(             // add interpolated character to output
        i*(am/2?p:u)                 // apply case of the nearest character
      );

    // Set character A values to B for the next character
    a=b;
    u=p;
    o+=c                                  // add B itself to the output

  }),
  o                                       // return the output
)

Using \w will fail with digits. Try '09'

Save 1 char using charCodeAt() with no argument

And save 2 chars avoiding Math.abs a>b?a-b:b-a ... and there are more other 'standard' tricks to shorten javascript. With your interpolation method you could beat my score. Check the hints in this site

http://codegolf.stackexchange.com/questions/2682/tips-for-golfing-in-javascript  http://codegolf.stackexchange.com/questions/37624/tips-for-golfing-in-ecmascript-6

Thanks for the info! I'm still getting the hang of code golf. :)

JavaScript ES6, 168 (186-10%) 176 193
Edit Modified to get the 10% bonus
Test running the snippet below using an EcmaScript 6 compliant browser (I use FireFox)

f=s=>[...s].map(c=>{a=parseInt(c,36),m=(a-q)/(d=a>q?1:-1);for(n=1;m&&(a>9)==(q>9)&&(q+=d)!=a;n+=2)r=q.toString(36),o+=n<m&p<'a'|n>=m&c<'a'?r.toUpperCase():r;p=c,q=a,o+=c},o='',p=q=-f)&&o

// Explained
U=s=>(
  o = '', // initialize output
  p = '', // provious char, initialize to none
  q = NaN, // previous char code, initialize to none
  [...s].map( c => { // for each char
    a = parseInt(c,36), // convert digit/letter to numeric code, case invariant, NaN if invalid
    d = a > q ? 1 : -1, // sign of difference (if not equal)
    m = (a - q) / d; // absolute value of difference or NaN
    if (m && (a>9)==(q>9)) // if current and prev are different and both alpha or both digits
      for( n = 1;
          (q += d) != a; // loop from prev char (not included) to current (not included)
           n += 2)
        r=q.toString(36),
        // add intermediate char to output
        // upcase if: left side & prev is upcase or right side and current is upcase
        o+= n<m&p<'a'|n>=m&c<'a'?r.toUpperCase():r;
    p = c, // copy current to previous
    q = a, // copy current to previous
    o += c // add current char to ouput
  }),
  o
)

// test
console.log=(...x)=>O.innerHTML+=x+'\n'

;['Ac','Ad','fA','adB','04aQ27','Hello World!'].
forEach(x=>console.log(x + ' -> ' + f(x)))

Python 2, 349 bytes
It's way too long, but at least it's first.
f=lambda p:ord(p.lower())
u=lambda p:"".join(p).upper()
s=raw_input()
w=s[0]
r=w
for q in s[1:]:
 o=q+w
 if q==w:o=""
 if o.isalpha():
  m=(f(w)<f(q))*2-1
  e=map(chr,range(f(w)+m,f(q)+m,m))
  if o==u(o):e=u(e)
  elif q==u(q):e[len(e)/2:]=u(e[len(e)/2:])
  elif -o.islower()+1:e[:len(e)/2]=u(e[:len(e)/2])
  r+="".join(e)
 else:
  r+=q
 w=q
print r


text:
Is it raining? I can't tell
These are raindrops:
! | . " :

These are clouds particles:
( ) _ @ $ &

I want you to verify, when given a block of text, whether or not it is raining. It is raining if, for every raindrop, there is a cloud particle somewhere above it. There must be one cloud particle for every raindrop. Output a truthy or falsy value denoting your conclusions.
Valid examples
(@@@@@@)
 ( $ &  )
Q   (  )
..  .  !
 : .
  |"   !
    .

()()()
......

@_$ &
errrr
h_r-5
.:. .
 "

Invalid examples
!
()

$$$$$
(   )
:::::
.....

This is a code-golf so the shortest program in characters wins.

"There must be one cloud particle for every raindrop"

@feersum The second invalid example is the example you are looking for.

@feersum I see ;)

Can we assume the rows are padded with spaces to form a rectangle?

@feersum yeah you can

So, exactly one cloud particle for each raindrop particle :-(

@Zereges, no: at least one

APL (30)
{∧/∊≤/+⍀¨⍵∘∊¨'!|.":' '()_@$&'}

This is a function that takes a character matrix as input, and gives a boolean output.
Test:
      ex1 ex2 ex3 ex4 ex5
┌─────────┬──────┬─────┬──┬─────┐
│(@@@@@@) │()()()│@_$ &│! │$$$$$│
│ ( $ &  )│......│errrr│()│(   )│
│Q   (  ) │      │h_r-5│  │:::::│
│..  .  ! │      │.:. .│  │.....│
│ : .     │      │ "   │  │     │
│  |"   ! │      │     │  │     │
│    .    │      │     │  │     │
└─────────┴──────┴─────┴──┴─────┘
      {∧/∊≤/+⍀¨⍵∘∊¨'!|.":' '()_@$&'}¨ex1 ex2 ex3 ex4 ex5
1 1 1 0 0

Explanation:

⍵∘∊¨'!|.":' '()_@$&': for both sets of characters (rain and clouds), and each character in ⍵, see if the character is a member of the set.
+⍀¨: get a running sum for each column and each set
≤/: for each position in ⍵, check that the amount of raindrops does not exceed the amount of cloud particles in the running sum
∧/∊: return the boolean AND of all the elements in the result

C++11, 186 184 bytes
#include<map>
int i,c;int main(){std::map<int,int>p;while(~(c=getchar())){for(int m:{40,41,95,64,36,38})p[i]+=c==m;for(int m:{33,124,46,34,58})if(c==m&&!p[i]--)return 1;i=c-10?i+1:0;}}

Ungolfed
#include <map>
int i, c;
int main()
{
    std::map<int, int> p;
    while (~(c = getchar()))
    {
//        for (int m : { '(', ')', '_', '@', '$', '&'})
        for (int m : { 40, 41, 95, 64, 36, 38})
            p[i] += c == m;
//        for (int m : { '!', '|', '.', '"', ':'})
        for (int m : { 33, 124, 46, 34, 58})
            if (c == m && !p[i]--)
                return 1;
        i = c - '\n' ? i + 1 : 0;
    }
    return 0;
}

Basic approach, storing positions of cloud particles in a row and if rain particle is encountered, it checks whether the cloud particle is above it and decreases the counter of cloud particles in that column. The program returns 0 if it's valid and 1 otherwise.

Can't you replace c-m?0:p[i]++ with p[i]+=c==m? Or does that no longer work in C++11?

@marinus Probably yes.

Snails, 125
{t.{t(\(|\)|\_|\@|\$|\&)=(u.,~)d!(.,~)t.!(.,~},!{t(\!|\||\.|\"|\:)ud!(.,~}t(\(|\)|\_|\@|\$|\&)!(d.,~)u.,~},!{t(\!|\||\.|\"|\:

The program outputs the area of the grid (or 1 if its area is 0) if it is raining; otherwise 0. If only I had implemented regex-style character classes.
Ungolfed version
This contains fake instructions for clouds or raindrops instead of writing out all the gibberish. \whatever (replaced with . in the real program) means a thing that ought to be a raindrop, but can actually be anything because it doesn't matter if we match a non-raindrop to a cloud.
{
    t \whatever   ,, Pick a drop in a new column
    {
        t \cloud ,, Find a cloud with
        =(u.,~)  ,, nothing above in the same column marked
        !(d.,~)  ,, but not in an empty column
        t \whatever
        !(d.,~)
    },
    !(t \drop ud !(.,~) )  ,,no drops remaining in column
    t \cloud
    !(d.,~)
    u.,~
},             ,, repeated 0 or more times
! (t \drop)   ,, no drops left

interesting comment system.

Python 2, 121 bytes
def f(i):
 for l in zip(*i.split('\n')):
  s=0
  for p in l:
   s+=p in'()_@$&';s-=p in'!|.":'
   if s<0:return
 return 1

Expects the input to be padded to be rectangular.

Julia, 90 characters
s->all(cumsum(map(i->i∈"!|.\":"?-1:i∈"()_@\$&",mapfoldl(collect,hcat,split(s,"
")))').>-1)

Unlike the original solution (below), this uses mathematics to determine the solution. mapfoldl(collect,hcat,split(s,"\n")) (written above with \n replaced with an actual newline to save characters) converts the string into a 2d array of characters. map(i->i∈"!|.\":"?-1:i∈"()_@\$&",...) creates an array of numbers, with 1 if the character is a cloud, -1 if the character is rain, and 0 otherwise.
cumsum(...') calculates the cumulative sums of the rows (would normally be written cumsum(...,2), but since we don't care about orientation from this point on, transposing only costs one character), and then all(... .>-1) checks for a negative number - negatives will only occur if a rain character appears without being preceded by a cloud character.
Julia, 139 136 characters
s->(t=join(mapfoldl(i->split(i,""),.*,split(s,"
")),"
");while t!=(t=replace(t,r"[()_@$&](.*?)[!|.\":]",s"\g<1>"))end;∩("!|.\":",t)==[])

This function first transposes the text so that rows become columns and vice-versa. Note that newlines are present in the code in the form of actual newlines, to save one character per instance.
The function then iteratively replaces cloud/droplet pairs with spaces, and once all such pairs are removed, it returns true if there are any droplets remaining and false otherwise.
r"[()_@$&](.*?)[!|.\":]" - this is a regex that will match cloud/droplet pairs in a lazy manner, with group 1 containing everything between cloud and droplet. Then s"\g<1>" tells it to remove the matched cloud and droplets, but keep the stuff in between (necessary as it may contain clouds) - the \g<1> is whatever was matched in group 1 of the regex. ∩("!|.\":",t)==[] will generate the intersection of the droplet characters with the final string, and if it's empty, then none of the droplet characters are present, and it's raining.

@nimi - you don't actually need it. You can replace the h in the use with the actual anonymous function. Like this: g((s->join(foldl(.*,[split(i,"")for i=split(s,"\n")]),"\n")s->join(foldl(.*,[split(i,"")for i=split(s,"\n")]),"\n"))("()()()\n......")) - calling it h just makes it easier to invoke.

@nimi - as for the "single function to call", that's a slightly more reasonable assertion, but it's not clear what the community standing on that is - I'm going to make a meta post asking about it.

@nimi - that's what I'm going to get clarification on, right now, with a meta post.

It's moot for this question now, as I found a better way to do it, with only one function.

Perl 5, 80
79, plus one for -E instead of -e
@a=();while(<>){@_=split'';(0>($a[$_]+=/[()_@&\$]/-/[!|.":]/)?die:1)for@_}say 1

I can't read Perl, but I'm strong in math: 79+1 = 80

JavaScript ES6, 112
Test running the snippet below in an EcmaScript 6 compliant browser implementing arrow functions, spread operator and template strings (I use Firefox)

f=t=>!t.split`
`.some(r=>[...r].some((c,i)=>(c='!|.":()_@$&'.indexOf(c),n[i]=~c?c<5?~-n[i]:-~n[i]:n[i])<0),n=[])

//TEST
console.log=x=>O.innerHTML+=x+'\n';

test_valid = [
 '(@@@@@@)\n ( $ &  )\nQ   (  )\n..  .  !\n : .\n  |"   !\n    .',
 '()()()\n......',
 '@_$ &\nerrrr\nh_r-5\n.:. .\n "'
]
console.log('Valid');
test_valid.forEach(t=>console.log(t+'\n'+f(t)+'\n'))

test_invalid = ['!\n()','$$$$$\n(   )\n:::::\n.....']
console.log('Invalid');
test_invalid.forEach(t=>console.log(t+'\n'+f(t)+'\n'))