text:
Calculate average characters of string
Task
Your task is to produce string that contains average characters of string.
First character of result would be average character of first character (which is first character) and second character average of two first characters and so on.
What is average character?
Strings are arrays of bytes. Average character of string can be found by calculating the average of the ASCII values of characters in string and taking corresponding ASCII character.
For example string "Hello!" can be written as byte sequence 72 101 108 108 111 33. Average of ascii values is 533/6 = 88.833... and when it's rounded to nearest integer we get 89 which is ascii code for captial letter Y.
Rules

You can assume that input contains only printable ASCII characters
Input can be read from stdin or as command line arguments or as function arguments
Output must be stdout. If your program is function, you can also return the string you would otherwise print.
It must be whole program or function, not snippet
Standard loopholes apply
Integers are rounded by function floor(x+0.5) or similar function.

How do I win?
This is code-golf, so shortest answer (in bytes) in wins.
Examples

Hello! → HW^adY
test → tmop
42 → 43
StackExchange → Sdccd_ccccddd

Edited question. Now it should be clear: you have to round halves upwards.

"Input can be read from stdin or as command line arguments": or as function arguments (since you allow functions), right?

Of course, edited again.

Sorry to bother you once again, but do functions actually have to print the output to STDOUT or can they return the desired string?

Sorry, forgot to edit that before. Now it should be ok.

StackExchange should be Sdcce`ccddeee

Shouldn't Hello! be HW^bdY?

Sdcce\ccddeeeandHW^bdYbugs are if you use ceil instead of round, whileHV^adY` bugs is if you use banker's rounding (round to even). The original asker has it right for traditional math rounding.

Brainfuck 106 bytes
,[>,<.[->+<]>>++<[>[->+>+<<]>[-<<-[>]>>>[<[>>>-<<<[-]]>>]<<]>>>+<<[-<<+>>]<<<]>[-]>>>>[-<<<<<+>>>>>]<<<<<]

This is my first participation in a code-golf, please be gentle!
It does work but brainfuck can't handle floats (not that i know of) so the rounded value is always the bottom one (might fix my algorithm later).
Also, the algorithm averages the values 2 by 2, meaning it could be innacurate in some spots.
And I need to fix a bug that is printing a number at the end of the output too.

Pyth, 16 bytes
smCs+.5csaYCdlYz

Pretty straightforward. Using s+.5 instead of rounding, because for some reason round(0.5, 0) is 0 in Python.

Python 3 rounds half towards even, which introduces less bias. The question doesn't explicitly specify how halves should be rounded, so I've requested clarification from the OP.

Edited question. 0.5 rounded should be 1.

Q, 15 12 bytes
12 bytes as an expression
"c"$avgs"i"$

q)"c"$avgs"i"$"Hello!"
"HW^adY"
q)"c"$avgs"i"$"test"
"tmop"
q)"c"$avgs"i"$"42"
"43"
q)"c"$avgs"i"$"StackExchange"
"Sdccd_ccccddd"

or 15 bytes as a function
{"c"$avgs"i"$x}

q){"c"$avgs"i"$x} "Hello!"
"HW^adY"
q){"c"$avgs"i"$x} "test"
"tmop"
q){"c"$avgs"i"$x} "42"
"43"
q){"c"$avgs"i"$x} "StackExchange"
"Sdccd_ccccddd"

takes advantage of

the "i"$ cast to convert a string (list of characters) to a list of integers
the avgs function, which computes the running average of a list as a list of floats
the "c"$ cast to convert a list of floats to a list of characters, and which  automatically rounds each float to the nearest integer before doing so [i.e. ("c"$99.5) = ("c"$100) and ("c"$99.4) = ("c"$99) ]

Does Q require the function wrapper here or can you get away with just the tacit expression "c"$avgs"i"$ ? I don't think a solution could get much more straightforward than that. :)

you're correct --  no need for the function wrapper, as
"c"$avgs"i"$ "Hello!"
works fine

I think you can save 2 bytes by changing "c" to `c and "i" to `i.

unfortunately, i don't think that works. To use the symbol type representation for casting I'd have to use `char and `int as per http://code.kx.com/wiki/JB:QforMortals2/casting_and_enumerations#Cast_.28.24.29   I considered using 10h and 6h instead of "c" and "i" but that wouldn't save any bytes -- 10h is the same length as "c" and substituting 6h for "i" requires a trailing space, making them the same length also.

CJam, 19 bytes
Uq{i+_U):Ud/moco}/;

Try it online in the CJam interpreter.

Perl: 31 30 characters
(29 characters code + 1 character command line option.)
s!.!chr.5+($s+=ord$&)/++$c!ge

Sample run:
bash-4.3$ perl -pe 's!.!chr.5+($s+=ord$&)/++$c!ge' <<< 'StackExchange'
Sdccd_ccccddd

Python 3, 65 bytes
n=t=0
for c in input():n+=1;t+=ord(c);print(end=chr(int(.5+t/n)))

Try it online!
If I use round() instead of int(.5+ etc., it saves one character but is technically not in compliance with the challenge: Python's round() rounds halves to the nearest even integer, not upwards. However, it works correctly on all sample inputs.

If you increment n before printing, you can avoid adjusting it by 1.

@xnor: Face, palm. Palm, face. Thanks for pointing that out.

do print(end=chr(int(...)) to save some bytes

@Flp.Tkc: Thanks! Answer updated.

C# 189 135 134 106 Bytes
var x=s.Select((t,i)=>Math.Round(s.Select(a=>(int)a).Take(i+1).Average())).Aggregate("",(m,c)=>m+(char)c);

Can be seen here
First time golfer

Ruby, 46
s=0.0
$<.bytes{|b|s+=b;$><<'%c'%(0.5+s/$.+=1)}

ideone.
With apologies to w0lf, my answer ended up different enough that it seemed worth posting.
$<.bytes iterates over each byte in stdin, so we print the rolling average in each loop. '%c' converts a float to a character by rounding down and taking the ASCII, so all we have to do is add 0.5 to make it round properly. $. is a magic variable that starts off initialized to 0--it's supposed to store the line count, but since here we want byte count we just increment it manually.

JavaScript (ES6), 75 bytes

let f =
s=>s.replace(/./g,x=>String.fromCharCode((t+=x.charCodeAt())/++i+.5),i=t=0)
<input oninput="O.value=f(this.value)" value="Hello!"><br>
<input id=O value="HW^adY" disabled>

I can't believe there's no JS answer with this technique yet...

Python 2, 65 bytes
f=lambda s:s and f(s[:-1])+chr(int(sum(map(ord,s))*1./len(s)+.5))

Try it online!

Ruby, 27 bytes
putc gets.sum.quo(~/$/)+0.5

Solution produced through some collaborative golfing at work.
How this works

Kernel#putc prints a single character (e.g. putc "Hello" outputs H). Passing an object to it prints the character whose code is the least-significant byte of the object. So putc 72 outputs H.
Kernel#gets reads stdin and returns a string.
String#sum returns a checksum. The result is the sum of the binary value of each byte in the string modulo 2**16 - 1. Since ASCII bytes comfortably fit in this space, this just returns the byte total.
Because the byte total is an integer, we can’t do floating point calculations (in Ruby 10 / 3  is 3 whereas 10.to_f / 3 is 3.33…). Here’s where Numeric#quo comes in – 10.quo(3) returns the Rational  (10/3).
Regexp#~ matches a regular expression against the contents of $_ (the last string read by gets). It returns index of the match.
The Regexp /$/ matches the end of the string, so ~/$/ means “print the index of the end of the string” – in other words, the string length. This gives us the final  is a short-hand for the length of the string read by gets.
This gives us the Rational (byte total/string length). Now we need to round it into an integer. +0.5 casts the Rational to a float. putc floors the float into an integer.

Julia, 85 81 bytes
s->(i=[int(c)for c=s];print(join([char(iround(mean(i[1:j])))for j=1:length(i)])))

This creates an unnamed function that accepts a string and creates a vector of its ASCII code points. Means are taken for each sequential group, rounded to integers, converted to characters, joined into a string, and printed to STDOUT.

K, 36 bytes
`0:_ci_.5+{(+/x)%#x}'.0+1_|(-1_)\_ic

Usage:
  `0:_ci_.5+{(+/x)%#x}'.0+1_|(-1_)\_ic"Hello!"
HW^adY
  `0:_ci_.5+{(+/x)%#x}'.0+1_|(-1_)\_ic"test"
tmop
  `0:_ci_.5+{(+/x)%#x}'.0+1_|(-1_)\_ic"42"
43
  `0:_ci_.5+{(+/x)%#x}'.0+1_|(-1_)\_ic"StackExchange"
Sdccd_ccccddd

_ci and _ic convert ascii to chars and vice versa, respectively. {(+/x)%#x} is a classic K idiom for calculating a mean. Pretty straightforward overall.
Edit: oh, misread the spec. `0: is needed to print the result to stdout. Waiting for clarification on input re. Dennis' question.

If you use K5, this can be shortened to 35 bytes: {[s]`0:`c${_.5+(+/u)%#u:x#s}'1+!#s}.

Or 30: \0:`c$.5+{(+/x)%#x}'1|(-1_)\ `

\c$_.5+{(+\x)%+~^x}`i$ for 24. It could be shorter (`c$`i${(+\x)%+~^x}`i$) but your REPL (http://johnearnest.github.io/ok/index.html) isn't rounding correctly when casting from float to int. I'd hesitate to call this a k solution since _ciand_icare nowhere in the K5 spec as far as I can tell, while0:` doesn't print to stdout but instead reads a txt file from disk.

@tmartin: correct- _ci and _ic are entirely replaced in K5 with the forms like \c$`. The original solution I posted is compatible with Kona, which is based on K2/K3. I generally try not to post solutions with oK specifically because the semantics are still shifting around and partially inaccurate.

Ah i see, makes sense to me. I figured this was another K5 solution. Here's a 28 char kona solution \0:_ci_0.5+{(+\x)%1.+!#x}_ic`

@tmartin: Nice! I think I'll start specifying K dialects to avoid confusion.

Python 2, 71
i=s=0
r=''
for c in input():s+=ord(c);i+=1.;r+=chr(int(s/i+.5))
print r

With each new character, updates the character sum s and the number of characters i to compute and append the average character.

Almost exactly the same approach as mine, only Python 2 instead of 3, and posted hours earlier: +1. (Also, I found I saved a few bytes printing each character as it came rather than storing them for one final print. Will that work with Python 2? I forget just now how to suppress newlines in the print statement... comma makes it a space instead, right?)

Python 2 can do print _, to leave a space rather than newline, but no good way to omit the space. Good call with Python 3's end argument, I'd forgotten about that.

@TimPederick Maybe the backspace control could be justified for a terminal that uses it, as a hack to delete the space: print'\b'+_,

Matlab, 43 31 bytes
Thanks to @beaker for 9 bytes off!
Using an anonymous function:
@(s)[cumsum(+s)./find(s)+.5 '']

Examples:
>> @(s)[cumsum(+s)./find(s)+.5 '']
ans =
  function_handle with value:
    @(s)[cumsum(+s)./(find(s))+.5 '']
>> f=ans;
>> f('Hello!')
ans =
    'HW^adY'
>> f('test')
ans =
    'tmop'
>> f('42')
ans =
    '43'
>> f('StackExchange')
ans =
    'Sdccd_ccccddd'

Since all printable ASCII codes are non-zero, find(s) is 5 bytes shorter than (1:numel(s)). In Octave, char seems to do automatic rounding of non-integer values, saving another 7 bytes.

@beaker Thanks! How unexperienced I was back then. I didn't even remove f= from the count :-D Matab seems to round down rather than to nearest, so I had to include +.5

Mathematica, 75 bytes
FromCharacterCode@Floor[.5+Accumulate@#/Range@Length@#]&@ToCharacterCode@#&

Mathcad, 60 "bytes"

Mathcad is mathematical application based on 2D worksheets comprised of "regions" each of which can be text, a mathematical expression, program, plot or scripted component.
A mathematical or programming instruction is picked from a palette toolbar or entered using a keyboard shortcut. For golfing purposes, an operation ("byte") is taken to be the number of keyboard operations necessary to create a name or expression (for example, to set the variable a to 3, we would write a:=3. The definition operator := is a single keypress ":", as are a and 3 giving a total of 3 "bytes". The programming for operator requires typing ctl-shft-# (or a single click on the programming toolbar) so again is equivalent to 1 byte.
In Mathcad the user enters programming language commands using keyboard shortcuts (or picking them from the Programming Toolbar) rather than writing them in text. For example, typing ctl-] creates a while-loop operator that has two "placeholders" for entering the condition and a single line of the body, respectively. Typing = at the end of a Mathcad expressions causes Mathcad to evaluate the expression.
(Count bytes) By looking at it from a user input perspective and equating one Mathcad input operation (keyboard usually, mouse-click on toolbar if no kbd shortcut) to a character and interpreting this as a byte. csort = 5 bytes as it's typed char-by-char as are other variable/function names. The for operator is a special construct that occupies 11 characters (including 3 blank "placeholders" and 3 spaces) but is entered by ctl-shft-#, hence = 1 byte (similar to tokens in some languages). Typing ' (quote) creates balanced parentheses (usually) so counts as 1 byte. Indexing v = 3 bytes (type v[k).

05AB1E, 15 bytes
.pvyDSÇOsg/îç}J

Try it online!

-2 bytes by removing D and }, and replacing s with y.

@KevinCruijssen for how old this answer is there's a lot more than that :P. .p is a 1byter now too

Ah lol, forgot about η xD

Japt, 13 bytes
£T±Xc)/°Y r d

Test it online!
How it works
£   T± Xc)/° Y r d
mXY{T+=Xc)/++Y r d}
                     // Implicit: U = input string, T = 0
mXY{              }  // Replace each char X and index Y in the string by this function:
    T+=Xc            //   Add X.charCodeAt() to T.
         )/++Y       //   Take T / (Y + 1).
               r d   //   Round, and convert to a character.
                     // Implicit: output result of last expression

Ah, nuts; I thought the "non-competing" filter had been removed from the leaderboard, so I didn't see this before posting this.

Japt, 11 bytes
c@V±X /°T r

Try it

PHP, 176 byte
<?=(implode('',array_reduce(str_split($argv[1]),function($c,$k){array_push($c[1],chr(floor(((ord($k)+$c[0])/(count($c[1])+1))+0.5)));return[ord($k)+$c[0],$c[1]];},[0,[]])[1]));

Example:
>php cg.php Hello!
HW^adY
>php cg.php test
tmop
>php cg.php 42
43

The biggest solution so far, but based on php it can't get much shorter I think. 2 bytes could be saved by removing the newlines.

Hmm, good point. I thought I might leave them in the post for better readability. But yeah, this is code golf. I'll remove them ;)

You can always include an additional version with padding for readability along side your short one.  I often do this when my code is too long to be entirely visible on most monitors.

Zig 0.6.0, 84 bytes
fn a(b:[]u8)void{var t:u64=0;for(b)|c,i|{t+=c;b[i]=@intCast(u8,(t+(i+1)/2)/(i+1));}}

Try it Online
Formatted:
fn a(b: []u8) void {
    var t: u64 = 0;
    for (b) |c, i| {
        t += c;
        b[i] = @intCast(u8, (t + (i+1)/2) / (i+1));
    }
}

PHP 7, 79 bytes
As I don't have enough reputation to comment on cb0's answer to provide him hints to improve his answer (mainly using the char index method in a string and while to loop through a string).
But I still bothered to post it due to the large reduction in byte count.
<?php $i=$b=0;while($a=ord($argv[1][$i++]??'')){$b+=$a;echo chr(round($b/$i));}

I didn't find a way though to use the <?= shortcut and avoid undefined errors without using command line flags (this is why i used $i=$b=0;). This answer does not work in PHP 5 due to the ?? syntax.

Vyxal s, 7 bytes
CKvṁ.+C

Try it Online!
.+ should be ṙ, but there's a bug.

Has the bug been fixed?

No, lyxal closed it and claimed it wasn't a bug. https://github.com/Vyxal/Vyxal/issues/1376

J, 22 bytes
(0.5<.@++/%#)\&.(3&u:)

Try it online!
Explanation
(0.5<.@++/%#)\&.(3&u:)
              &.(    )  do this, the left verb then the inverse of this:
                 3&u:     characters -> ordinates
(           )\          over the prefixes of the input:
        +/%#            take the average (sum divide length)
 0.5   +                add one-half
    <.@                 then floor

Jelly, 7 bytes
OÆmƤ+.Ọ

Try it online!
OÆmƤ+.Ọ
O       - Get a list of character codes from the input string
   Ƥ    - Over prefixes:
 Æm     -  Get the mean
    +.  - To each, add 0.5
      Ọ - Convert from character codes to charcters. Decimals are rounded down.

brev, 146 bytes
(as-list reverse(c pair-fold-right(fn(cons(integer->char(inexact->exact(floor(+(/(apply + x)(length x))0.5))))y))'())reverse(c map char->integer))

124 with banker's rounding:
(as-list reverse(c pair-fold-right(fn(cons(integer->char(round(/(apply + x)(length x))))y))'())reverse(c map char->integer))

Which is still a lot. It's clear that a huge painpoint in brev is the type converting (chars to integers, strings to lists etc).

Dart, 76 bytes
t(a,[c=1,s=0])=>String.fromCharCodes([...a.runes.map((i)=>(s+=i+.5)~/c++)]);

Try it online!

Knight, 62 bytes
;;=sP=i 0W<=i+1i+1Ls;=aGs=t 0i;Wa;=t+tAa=aGa 1LaO+A/+t/i 2i"\"

Try it online!

C, 62 bytes
c;t;main(n){for(;(c=getchar())>0;n++)putchar(((t+=c)+n/2)/n);}

(ideone link)
The results are slightly different from the OP's examples, but only because this code rounds 0.5 down instead of up. Not any more!

R, 135 127 Bytes
This got long real quick and I really got it wrong the first time:)  Need to read the questions properly.
cat(sapply(substring(a<-scan(,''),1,1:nchar(a)),function(x)rawToChar(as.raw(round(mean(as.integer(charToRaw(x)))+.5)))),sep='')

Test Run
cat(sapply(substring(a<-scan(,''),1,1:nchar(a)),function(x)rawToChar(as.raw(round(mean(as.integer(charToRaw(x)))+.5)))),sep='')
1: Hello!
2:
Read 1 item
HW^adY

somebody posted a dupe challenge in the sandbox so I found this...This was a looong time ago, but utf8ToInt will help! I have a 68 byte golf of this if you want to update to it.

@Giuseppe Go ahead and post it yourself if you would like.  I suspect that it is significantly different to what I did here.

Ruby 59 61
->w{s=c=0.0;w.chars.map{|l|s+=l.ord;(s/c+=1).round.chr}*''}

Test: http://ideone.com/dT7orT

c+=1;(s/c) → (s/c+=1) http://ideone.com/H2tB9W

@manatwork Well spotted! Thanks! I applied the change.

Java, 100
Much like many other answers here, I'm summing and averaging in a loop. Just here to represent Java :)
void f(char[]z){float s=0;for(int i=0;i<z.length;System.out.print((char)Math.round(s/++i)))s+=z[i];}

My original code is a 97, but it only returns the modified char[] rather than printing it:
char[]g(char[]z){float s=0;for(int i=0;i<z.length;z[i]=(char)Math.round(s/++i))s+=z[i];return z;}

Now, it's just long enough for scrollbars to appear for me, so here's a version with some line breaks, just because:
void f(char[]z){
    float s=0;
    for(int i=0;
            i<z.length;
            System.out.print((char)Math.round(s/++i)))
        s+=z[i];
}

Interesting. Can you show us a call sample too? My Java is very rusty.

As in how to call it? Assuming test is a char array, just use f(test);. If it's a String object, then you'd use f(test.toCharArray());. String literals are fine like that, too: f("Hello!".toCharArray());

Oh. Sure. toCharArray() Me stupid, I tried to violate it with some casting. Thank you.

It'd be way too easy to just cast it. The Java gods would be furious :P

Perl 5, 41 bytes
say map{$s+=ord;chr($s/++$c+.5)}pop=~/./g

run as
$ perl -E 'say map{$s+=ord;chr($s/++$c+.5)}pop=~/./g' StackExchange
Sdccd_ccccddd

><>, 30 bytes
i:0(?v
v &l~<
\+l2(?
\&,12,+o;

The first line reads from stdin and puts the characters on the stack
The second will remove the EOL char, take the size of the stack and put it in the & register
The third line will add numbers on the stack while there are two or more of them
The fourth line will divide the resulting number by the register's value, then add 1/2, output the value as a character and stop. When faced with a float value when displaying a char, ><> will floor it, which is why we added 1/2

You can try it on the online interpreter but then you need to use the following version, because the online interpreter pads the code box to a rectangle and applies ? to spaces.
i:0(?v
v &l~<
\+l2(   ?
\&,12,+o;

TSQL, 118 bytes
DECLARE @ varchar(400) = 'StackExchange'

SELECT
top(len(@))char(avg(ascii(stuff(@,1,number,''))+.5)over(order by number))FROM
master..spt_values
WHERE'P'=type

Returning characters vertical
S
d
c
c
d
_
c
c
c
c
d
d
d

Jelly, 16 bytes
S÷L+.Ḟ
OµḣLR$Ç€Ọ

Try it online!
Only if there were Average and Round built-ins...

SmileBASIC, 65 bytes
LINPUT S$FOR I=1TO LEN(S$)A=A-A/I+ASC(S$[I-1])/I?CHR$(A+.5);
NEXT

Clojure, 69 bytes
#(for[c(map /(reductions +(map int %))(rest(range)))](char(+ c 0.5)))

Returns a sequence of characters, arguably a string-like construct. Would need an #(apply str(for[...]...)) to convert it into a string.

81 bytes with the string conversion.

Jelly, 8 bytes
OÆmƤ+.ḞỌ

Try it online!

Husk, 10 bytes
zȯci/Nt∫mc

Try it online!
                                                    | "tuna"
         mc  -- map each character to ASCII value   | [116,117,110,97]
       t∫    -- prefix sums & drop leading 0        | [116,233,343,440]
z(   )N      -- zip the list with [1..] using       |
    /        --   divide                            | [116/1,233/2,343/3,440/4] == [116.0,116.5,114.̅3,110.0]
   i         --   round                             | [116,117,114,110]
  c          --   convert to character              | "turn"

J, 23 bytes
(0.5<.@++/%#)&.(a.&i.)\

Try it online!
How it works
                      \  on prefixes
               (   i.)   index of the first occurence
               (  &  )   in
               (a.   )   the character set
            x&.y         apply y, then x, then the inverse of y,
(0.5        )              that is the element of a. with a given index
(       +/  )            sum
(          #)            number of elements
(         % )            division
(   <.@+    )            add, then floor

Zsh, 52 bytes
for c (${(s::)1})printf ${(#)$((.5+(n+=0.+#c)/++i))}

Try it online!
In arithmetic mode, #c gets the code of the first character of $c. The parameter expansion ${(#)    } prints the character associated with the code.

PowerShell, 59 bytes
-join($args|%{[char][int][Math]::Floor(($s+=+$_)/++$i+.5)})

Try it online!

Dyalog APL, 25 bytes
{⎕UCS⌊.5+(+\C)÷⍳⍴C←⎕UCS⍵}

Burlesque, 21 bytes
)?^qavpa0.5?+)avqL[\m

Try it online!
)?^   # To codepoint
qavpa # Average on prefixes
0.5?+ # Add 0.5 to each
)av   # Floor each
qL[\m # Back to char

Should be 17 chars, but R_ (round) rounds 0.5 down, not up.

PARI/GP, 45 bytes
s->t=i=0;Strchr([(t+=c)\/i++|c<-Vecsmall(s)])
Attempt This Online!

PARI/GP, 52 bytes
s->Strchr(Vec(intformal(Ser(Vecsmall(s))/(1-x)))\/1)
Attempt This Online!
This one is longer, but I can't resist to do this:

Vecsmall(s): Converts the string to a vector of ASCII codes.
Ser(...): Converts the vector to a formal power series.
.../(1-x): Divides the result by \$1-x\$. This is equivalent to taking the cumsum.
intformal(...): Takes the integral with respect to \$x\$. This is equivalent to dividing the n-th term with n.
Vec(...): Converts the result back to a vector.
...\/1: Rounds the result.
Strchr(...) Converts the result back to a string.

C (clang), 55 bytes
n;t;main(c){for(;read(0,&c,1);putchar(t/++n))t+=c+n%2;}

Try it online!
How it works
n;t;           // t and n are initialized to 0
read(0,&c,1)   // Reads a character from stdin into c,
               // returns the number of characters read, 0 if EOF.
t+=c+n%2       // t is the accumulator, n%2 is used to round up.
putchar(t/++n) // increment n and use the new value to calculate the average.

C (clang), 45 bytes
Same idea, but as a function which modifies the string in-place.
n;t;f(*s){for(n=t=0;*s;*s++=t/++n)t+=*s+n%2;}

Try it online!

Prolog (SWI), 59 bytes
N+X+[A|R]:-L=X+A,T is round(L/N),put(T),N+1+L+R.
+A:-1+0+A.

Try it online!
Takes a list of codepoints and outputs to STDOUT.
A little longer, but using only one predicate:
Prolog (SWI), 63 bytes
+A:-scanl(plus,A,0,Z),nth0(N,Z,E),N>0,T is round(E/N),\+put(T).

Try it online!

Thunno 2 B, 5 bytes
ƒ€m.+

Attempt This Online!
Explanation
ƒ€m.+  # Implicit input
       # Convert to ordinals
ƒ      # Prefixes of ordinals
 €m    # Mean of each
   .+  # Add 0.5 to each
       # Convert to string
       # Implicit output

Scala, 106 bytes
Port of @alephalpha's PARI/GP answer in Scala.

Golfed version. Attempt This Online!
s=>{var(t,i)=(0.0,1);s.map(c=>{t+=c;val a=math.round(t/i).toInt.max(32).min(126);i+=1;a.toChar}).mkString}

Ungolfed version. Attempt This Online!
object Main {
  def f(s: String): String = {
    val vecsmall: Array[Int] = s.map(_.toInt).toArray
    var t = 0.0
    var i = 1
    var res = new StringBuilder

    for (c <- vecsmall) {
      t += c
      val ascii = Math.round(t / i).toInt.max(32).min(126) // ensure within printable ASCII range
      res += ascii.toChar
      i += 1
    }

    res.toString()
  }

  def main(args: Array[String]): Unit = {
    val strings = List("Hello!", "test", "42", "StackExchange")
    strings.foreach(s => println(s"$s -> ${f(s)}"))
  }
}

JavaScript ES7, 122 bytes
s=>String.fromCharCode(...[for(i of s)i.charCodeAt()].map((l,i,a)=>Math.round(eval((t=a.slice(0,++i)).join`+`)/t.length)))

Mostly everything is happening in this bit
eval((t=a.slice(0,++i)).join`+`)/t.length)

The rest is looping / character code conversion
Split up:
s=>
 String.fromCharCode(...                        ) // Converts average character code array to string, ... allows it to take an array
   [for(i of s)i.charCodeAt()]                    // Converts string to char code array
   .map((l,i,a)=>                             )   // Loops through each character
     Math.round(                    /t.length)    // Rounds sum of previous char codes, divides by position + 1
       eval(                       )              // evals string of char codes seperated with +
            (                ).join`+`            // joins previous char codes with +
             t=a.slice(0,++i)                     // creates an array with all the char codes

If functions aren't allowed:
alert(String.fromCharCode(...[for(i of prompt())i.charCodeAt()].map((l,i,a)=>Math.round(eval((t=a.slice(0,++i)).join`+`)/t.length))))

133 bytes

ES5 Snippet:

function _toConsumableArray(r){if(Array.isArray(r)){for(var e=0,t=Array(r.length);e<r.length;e++)t[e]=r[e];return t}return Array.from(r)}function _taggedTemplateLiteral(r,e){return Object.freeze(Object.defineProperties(r,{raw:{value:Object.freeze(e)}}))}var _templateObject=_taggedTemplateLiteral(["+"],["+"]),f,t=function t(s){return String.fromCharCode.apply(String,_toConsumableArray(function(){var r=[],e=!0,t=!1,a=void 0;try{for(var n,i=s[Symbol.iterator]();!(e=(n=i.next()).done);e=!0){var o=n.value;r.push(o.charCodeAt())}}catch(l){t=!0,a=l}finally{try{!e&&i["return"]&&i["return"]()}finally{if(t)throw a}}return r}().map(function(l,i,a){return Math.round(eval((f=a.slice(0,++i)).join(_templateObject))/f.length)})))};

// Demo
document.getElementById('go').onclick=function(){
  document.getElementById('output').innerHTML = t(document.getElementById('input').value)
};
<div style="padding-left:5px;padding-right:5px;"><h2 style="font-family:sans-serif">Average of Words Snippet</h2><div><div  style="background-color:#EFEFEF;border-radius:4px;padding:10px;"><input placeholder="Text here..." style="resize:none;border:1px solid #DDD;" id="input"><button id='go'>Run!</button></div><br><div style="background-color:#EFEFEF;border-radius:4px;padding:10px;"><span style="font-family:sans-serif;">Output:</span><br><pre id="output" style="background-color:#DEDEDE;padding:1em;border-radius:2px;overflow-x:auto;"></pre></div></div></div>

Python 2, 106 bytes
It's not short enough. Since it's python it's way too verbose, you can even read what it does by looking code. But it's working.
a=[.0]+[ord(i)for i in raw_input()]
print"".join([chr(int(.5+(sum(a[:i+1])/i)))for i in range(1,len(a))])

"Since it's python it's way too verbose"... not compared to Java. And I disagree. Any less verbose and it wouldn't be as great as it is. Use Pyth if you want less verbose.

JavaScript ES6, 111 bytes
w=>w.replace(/./g,(_,i)=>String.fromCharCode([for(f of w.slice(0,++i))f.charCodeAt()].reduce((a,b)=>a+b)/i+.5))

This is annoyingly long thanks in part to JavaScript's long String.fromCharCode and charCodeAt functions. The stack snippet contains ungolfed, commented, testable code.

f=function(w){
  return w.replace(/./g,function(e,i){
    return String.fromCharCode(w.slice(0,++i).split('').map(function(f){
      return f.charCodeAt()
    }).reduce(function(a,b){
      // Adds all numbers in the array
      return a+b
      // String.fromCharCode automatically floors numbers, so we add .5 to round up
    })/i+.5)
  })
}

run=function(){document.getElementById('output').innerHTML=f(document.getElementById('input').value)};document.getElementById('run').onclick=run;run()
<input type="text" id="input" value="Hello!" /><button id="run">Run</button><br />
<pre id="output"></pre>

Factor, 80 bytes
[ cum-sum [ dup zero? 1 0 ? + / ] map-index [ .5 + floor >fixnum ] map >string ]

Jelly, 7 bytes
OÄ÷T+.Ọ
OÄ÷T+.Ọ  ~Main link
O        ~Cast to number
 Ä       ~Cumulative sum; add the values
  ÷T     ~Divide by indices
    +.   ~Add .5
      Ọ  ~Cast to characters

Attempt This Online!

Python, 50 bytes
f=lambda s:s and f(s[:-1])+[int(.5+sum(s)/len(s))]

Attempt This Online!
Takes in an list of UTF-8 codepoints, return a list of UTF-8 codepoints.

C#, 210 bytes
Saved so many bytes thanks to the comment of @ceilingcat

Golfed version. Try it online!
static string F(string s){int j=s.Length,i=j;var v=new int[j];var t=.0;var r="";for(;i-->0;)v[i]=Convert.ToInt32(s[i]);for(;++i<j;)r+=((char)Math.Min(Math.Max((int)Math.Round((t+=v[i])/-~i),32),126));return r;}

Ungolfed version. Run it on dotnetfiddle!
using System;
using System.Text;

public class Program
{
    public static string ConvertString(string s)
    {
        int[] vecsmall = new int[s.Length];
        for(int j = 0; j < s.Length; j++)
        {
            vecsmall[j] = Convert.ToInt32(s[j]);
        }

        double t = 0.0;
        int i = 1;
        StringBuilder res = new StringBuilder();

        foreach(int c in vecsmall)
        {
            t += c;
            int ascii = (int)Math.Round(t / i);
            ascii = Math.Max(ascii, 32); // ensure within printable ASCII range
            ascii = Math.Min(ascii, 126); // ensure within printable ASCII range

            res.Append((char)ascii);
            i += 1;
        }

        return res.ToString();
    }

    public static void Main(string[] args)
    {
        string[] strings = new string[] {"Hello!", "test", "42", "StackExchange"};

        foreach(string s in strings)
        {
            Console.WriteLine($"{s} -> {ConvertString(s)}");
        }
    }
}

209 bytes


text:
A Kingdom Hearts VGM challenge
I'm a huge video game music fan. One of my favorite OSTs is that from Kingdom Hearts, by Yoko Shimomura.
The challenge
Create a program or function that takes two arguments in any format: an abbreviated Kingdom Hearts game and a boss in that game. It must return the name of the song that plays for that boss. The program should handle any input case, but you can decide what case the output will be. You may assume the input is always valid. Here is a list of all the valid inputs:
Game   Boss                       Song

1      Ansem                      Guardando nel Buio
1      Riku                       Forze de Male
1      Sephiroth                  One Winged Angel
1      Kurt Zisa                  The Deep End
1      Unknown                    Disappeared
2      Organization XIII          The 13th Struggle, Dilemma, Reflection
2      Xemnas I                   A Fight to the Death
2      Xemnas II                  Darkness of the Unknown
2      Sephiroth                  One Winged Angel
2      Lingering Sentiment        Rage Awakened
CoM    Organization XIII          The 13th Struggle
CoM    Marluxia 1                 Graceful Assasin
CoM    Marluxia 2                 Scythe of Petals
CoM    Marluxia 3                 Lord of the Castle
CoM    Riku Replica               The Force in You
CoM    Ansem                      Revenge of Chaos
BBS    Master Xehanort            Black Powder
BBS    Terra vs Master Xehanort   Rage Awakened
BBS    Vanitas                    Enter the Darkness
BBS    Ventus vs Vanitas          The Key
BBS    Vanitas Remnant            Enter the Void
BBS    Terranort                  Dismiss
BBS    Mysterious Figure          Dark Impetus
Coded  Riku                       Riku
Coded  Pete                       Rowdy Rumble
Coded  Maleficent                 Vim and Vigor
Coded  Sora's Heartless           Guardando nel Buio
Coded  Roxas                      The Other Promise
Days   Xion                       Vector to the Heavens
Days   Riku                       Another Side
DDD    Anti Black Coat Nightmare  Dread of Night
DDD    Ansem I                    L'Eminenza Oscura I
DDD    Ansem II                   L'Eminenza Oscura II
DDD    Xemnas                     L'Oscurita dell'Ignoto
DDD    Young Xehanort             L'Impeto Oscuro
DDD    Armored Ventus Nightmare   Eye of Darkness
DDD    Julius                     The Encounter

Scoring
Your score is not your byte count. You do not need to implement the entire list, but you must implement at least 10 items. Your score is byte count / # of items implemented. For instance, say you write a 90-byte program that implements 25 items of the above table. Your score would be 90/25=3.6. Lowest score wins.
Bonus

-1 off your score of you implement an additional item, from Final Fantasy:
Game    Boss        Song

XV      Behemoth    Omnis Lacrima

AND make it so that any other requested bosses from XV return TBD.
-0.5 if your code also takes in the games 1.5 and 2.5, which take the same bosses as 1 and 2 but return the song name followed by (Orchestrated).
Another -0.5 if your program accepts bosses from CoM and Days when given 1.5 and accepts bosses from Coded and BBS when given 2.5. It must return the songs followed by (Orchestrated).

If you know of any other significant bosses I left out, let me know in the comments.
Also, I'm hoping I'm not the only person here who has memorized all of these songs...

So if I use a language that writes text to stdout (HTML perhaps) the program Riku would give me a score of 4/1=1. I wonder if there's a language where the empty program would echo the second argument to STDOUT. Then for the input Coded,Riku I could have the score 0/1=0. Hmm...

You may want to require that at least 1 item needs to be implemented. Otherwise somebody could submit a 0 length program that implements 0 items. Well, then the next question would be about the value of 0/0...

@steveverrill I was just about to submit a solution that prints "Riku". I guess the idea was obvious enough...

@steveverill I updated the question so that at least 10 items must be implemented.

@RetoKoradi Fixed.

When you say that the input can be in any case, do you mean that the input can be in any case of my choice?

@orlp The user's choice. I updated the challenge.

@kirbyfan64sos Do you have to implement 10 items from the list, or 10 songs? Similarly, is your score divided by the number of items you recognize, or the number of songs? Some songs are duplicates, but boss names are unique.

@orlp Songs. I'll update it again.

@orlp Haha, I meant items. Brain fart.

@MarchHo I don't think the standard loopholes have to be explicitly mentioned - they're standard after all. I think in general they have to explicitly dismissed if a challenge wants to use them.

@MarchHo Actually, it seems the standard loopholes have been renamed to loopholes that are forbidden by default. So it's not necessary to mention them explicitly.

AAAAAAAAAAAAGH! I was writing a solution on repl.it, and I hit backspace once but it went back in my browser. I have to start over... :'(

@mbomb007 Which is why I copy and paste everything I write on a mobile device every 30 seconds...

I'm actually a little glad that it happened. In the process I realized that I was building my program for only nine rather than ten songs. Also, I saw more optimizations as I am typing it all again from memory. I'm now using my Ideone.com account, though. :)

The program needing to handle any input case is super ugly... I wish it could just be the same as shown above.

@mbomb007 What language are you using? I would think that you could just convert the input string to lowercase first...

I meant ugly as in taking like 8 more chars. lol nvm

Ruby 134 131/10=13.1
->g,b{"Rowdy Rumble|Dread of Night|Riku|One Winged Angel|Rage Awakened|Vim and Vigor|The Key|The 13th Struggle".split(?|)[b.ord%8]}

This is a lambda function, which takes arguments for the game and the boss. The argument for the game is actually ignored by the code, but the OP has clarified that the argument cannot be eliminated.
In fact it only uses the first letter of the boss's name. the ASCII code is taken modulo 8 (this gives the same answer for a given letter, regardless of case) and one of 8 song titles is returned. As two song titles appear twice, this covers a total of 10 elements:
Game   Boss                      Array  Song
                                 index
Coded  Pete                         0   Rowdy Rumble
DDD    Anti Black Coat Nightmare    1   Dread of Night
Coded  Riku                         2   Riku
1      Sephiroth                    3   One Winged Angel
2      Sephiroth                    3   One Winged Angel
2      Lingering Sentiment          4   Rage Awakened
BBS    Terra vs Master Xehanort     4   Rage Awakened
Coded  Maleficent                   5   Vim and Vigor
BBS    Ventus vs Vanitas            6   The Key
CoM    Organization XIII            7   The 13th Struggle

It was a lucky coincidence that the Ascii codes for L and T give the same result modulo 8, so both incidences of Rage Awakened could be covered.
Call the function as in this test program:
f=->g,b{"Rowdy Rumble|Dread of Night|Riku|One Winged Angel|Rage Awakened|Vim and Vigor|The Key|The 13th Struggle".split(?|)[b.ord%8]}
B=gets                  #get boss name from stdin
puts f.call("dummy",B)  #call function, and output return value to stdout

Wow! I've never seen Ruby beat Pyth before!

@kirbyfan64sos That's kind of why I entered the challenge, I saw an opportunity for Ruby to beat a golfing language. It really is more about picking the items to implement than anything else. My code is 105 data (including quote marks but excluding .split) + 29 program. @Orlp 's is 124 data + 20 program.  BTW, do I have to include the g,? It doesn't do anything. The question says "two arguments" but in "any format" (which might mean one argument could be not taken at all, so I'm not sure.)

@steveverill What do you mean by g,?

@kirbyfan64sos I mean my code takes two arguments for the game and boss: ->g,b{...} but the game argument is in fact ignored by the code. So I wondered if I had to count those two characters g, or if I could eliminate them and just have one argument:  ->b{...}

@steveverill It's needed. I doubt that's an issue for your answer, though... :)

Pyth, 144/10 = 14.4
@c"|L'Impeto Oscuro|Riku|Eye of Darkness|Disappeared||Another Side|Forze de Male|Dread of Night|Rowdy Rumble|One Winged Angel"\|%.hrzZ11

Incredibly simple hash table, with the 'coincidence' of re-using the song 'One Winged Angel' twice. The above program recognizes the following items correctly:
ddd young xehanort            | L'Impeto Oscuro
coded riku                    | Riku
ddd armored ventus nightmare  | Eye of Darkness
1 mysterious figure           | Disappeared
days riku                     | Another Side
1 riku                        | Forze de Male
ddd anti black coat nightmare | Dread of Night
coded pete                    | Rowdy Rumble
1 sephiroth                   | One Winged Angel
2 sephiroth                   | One Winged Angel

Does it accept the uppercase variants of the games too?

The challenge says it should handle any input case...

When I said "the user", I meant the user of the program, not the developer. :)

@kirbyfan64sos Now it accepts any case.

I know I'm torturing you, but I changed the scoring a bit to make it more even. :O

I edited the answer for you.

@kirbyfan64sos The new scoring makes no sense, provides no incentive to implement anything more than 10 items, and is contradictory in the question (you still say 90/25=3.6). Plus, changing the scoring after answers have been posted is bad manner, unless you're patching up a very obvious loophole.

Save a byte by separating by linebreaks, then c by b.

@orlp So should I change it back?

@kirbyfan64sos In my opinion, yes.

@orlp I'm sorry for the mess I was last night. I had gotten upbsuper early, and it was late, so when you started asking questions, my brain wasn't functioning correctly.

source: Stack Exchange

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

sort: votes


text:
Through the bases
Through the bases
In this challenge, you will be taking a number through all the bases of the rainbow
Given an input, n, you will output n in every base from 9 to 2, and back up to 9. That's 9 8 7 6 5 4 3 2 3 4 5 6 7 8 9.
Example:

>>> 16
17
20
22
24
31
100
121
10000
121
100
31
24
22
20
17

Rules:

You input can be a string or a number.
Your output may be separated by new lines, spaces, commas, or tabs.
You may use built in functions.
Shortest code wins!

Can the output be comma-separated?

@vihan1086 yes.

I'm really late on this but can each line be surrounded by quotes? e.g. "17"\n"20"

CJam, 14 bytes
riF,f{7-z2+bN}

Try it online in the CJam interpreter.
How it works
ri             e# Read an integer I from STDIN.
  F,           e# Push [0 ... 14].
    f{       } e# For each B in that range, push I and B; then:
      7-z2+    e#   Compute abs(B - 7) + 2.
               e#   This maps [0 ... 14] to [9 ... 2 ... 9].
           b   e#   Perform base conversion.
            N  e#   Push a linefeed.

Just when I thought I had a chance at winning with Pyth. :P

@AlexA. I'm here to save your hope!

Pyth, 14 bytes
V+_Jr2TtJjkjQN

Needs more work, most code is spent generating 9..2..9.

Pyth, 18 15 14 bytes
Saved 3 bytes thanks to Dennis and 1 thanks to Jakube!
V+r9 1r3TjkjQN

Explanation:
V                     For N in
 +r9 1r3T             the list [9,8,...3,2,3,...,8,9],
           jQN        convert the input to base N (returns a list),
         jk           join the list into a string, implicitly printed.

Try it online.

"" is just k, p already appends a linefeed and printing is implicit anyway, so FN+r9 1r3TjkjQN is 3 bytes shorter and looks a bit better.

@Dennis You're the man.

Haskell, 59
0%_=0
k%b=div k b%b*10+mod k b
g n=map(n%)$[9,8..3]++[2..9]

First, recursively defines a binary operator % to do base conversion, representing the output as a decimal number rather than a string. The function g converts the input n to each base from 9 to 2 and back up.
There's probably a shorter approach, advice is welcome. Saved 2 chars on parens thanks to nimi.

Out of curiosity, why does [9,8...3] work but [9..3] doesn't? (the latter seems to return an empty list)

@Sp3000 It defaults to a step size of +1, so [9..3] is empty because 9>3. Putting the second terms fixes the step size. It general, you can do range(a,b,s) as [a,a+s..b].

Bash + dc, 27
echo {{9..2},{3..9}}o$1p|dc

Slightly shorter: echo {{9..2},{3..9}}o$1p|dc

@Dennis very good - I didn't know brace expansions could be nested like that!

Julia, 43 bytes
n->for i=[9:-1:2,3:9] println(base(i,n))end

This creates an unnamed function that accepts and integer and prints to STDOUT on separate lines. The base function takes two integers: a base (i) and a number (n) and returns the string representation of the number in the given base. Here we just loop through the required bases and print.

JavaScript (ES6), 57 bytes
f=n=>[...`987654323456789`].map(v=>n.toString(v)).join` `

CoffeeScript, 57 bytes
Different approach:
f=(n)->[-7..7].map((v)->n.toString 2+Math.abs v).join ' '

JavaScript (ES5), 97 bytes
function f(n){return'987654323456789'.split('').map(function(v){return n.toString(v)}).join(' ')}

Demo

function f(n) {
  return '987654323456789'.split('').map(function(v) {
    return n.toString(v)
  }).join(' ')
}

document.body.innerHTML = f(16)

Python 2, 79
g=lambda b,k=input():k and g(b,k/b)*10+k%b
c=7;exec"print g(abs(c)+2);c-=1;"*15

The function g converts a number k to a base b. We can take k as the program input because Python initializes default arguments when the function is defined, not each time it's called. We get the desired sequence of bases by taking the range [-7, -6, ..., 6, 7], taking the absolute value, and adding 2.

JavaScript SpiderMonkey 31 (1.8), 47 bytes
n=>[for(i of`987654323456789`)n.toString(i)]+''

It doesn't get simpler than this.

Nice, but array comprehensions have been dropped from ES7.

@Chiru Hm, I'll update it

Pip, 14 = 13 + 1 bytes
Uses the -n flag.
aTB2+AB(-7,8)

GitHub repository for Pip
Takes the number as a command-line argument.
        -7,8   Range containing integers from -7 through 7
     AB(    )  Absolute value of each
   2+          Add 2 to each
aTB            Convert command-line arg to each base
               Print resulting list, newline-separated (-n flag)

It's amazing how all the golfing languages are getting the same score here.

Those list formatting switches look really useful.

@Dennis Yes, the main reason I thought of them was so I wouldn't have to wrap the whole program in (...)Jn (4 bytes vs. 1 with -n) when the program consisted of a map expression (parentheses needed since Map is lower precedence than Join).

JavaScript (ES5), 69 66 65 bytes
function f(o){for(i=15;i--;)console.log(o.toString(i>7?i-5:9-i))}

Ruby, 44 bytes
a=->n{(0..14).map{|j|p n.to_s((j-7).abs+2)}}

Call the lambda with a.call(number). This prints out with quotes around each line because p is shorter than puts. I'm assuming this is allowed.

but n=ARGV[0].to_i;(0..14).map{|j|puts n.to_s((j-7).abs+2)} is 56 bytes and is complete (could be 54 if used p instead of puts

Oh, gotcha, thanks, I'll fix that. Edit: Fixed. Also, defining a function is slightly shorter than getting the parameters passed to the code @rdnewman

But not sure that requiring a.call(number) in IRB would be considered a complete program by others.  If it is, then I'd agree with you.   Actually, might be able to just do (0..14)map{|j|p ARGV[0]((j-7).abs+2)} and remove the n altogether (didn't test).

@rdnewman I saw a lambda solution like this on an answer with 6 upvotes here so I assumed it was ok. In fact, they didn't even assign it to a variable and just put ->s..

Ah, ok.  Here's the corrected version of the last one I tried: (0..14).map{|j|p ARGV[0].to_i.to_s((j-7).abs+2)}; will run, but 48 bytes to your 44, so if they'll accept it, yours is better.

APL, 52 bytes
I'll admit, this could use more golfing.
{n←⍵⋄⊃{⍺,' ',⍵}/{⊃,/⍕¨(~∧\0=e)/e←(10⍴⍵)⊤n}¨2+|8-⍨⍳15}

it is limited to at most 10 digits output
suggestions for improvement welcome
output for 16 looks like
17 20 22 24 31 100 121 10000 121 100 31 24 22 20 17

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


text:
Probability to clear the board or win
In the game Hearthstone there is a playing board containing friendly and enemy minions, and two heroes - yours and the enemy's.
To generalize and simplify, we will assume it's your turn, the opponent has 0-7 minions with given health values on the board, and is at H life points. We will ignore our side of the board entirely.
Now we will cast a supercharged version of Arcane Missiles. This ability shoots a random enemy (uniformly selected from all alive minions and the hero) for 1 damage, repeated A times. Note that if a target dies (reduced to 0 health), it can not be hit again.
Given H, A and a list L containing the health values of the minions, output the probability as a percentage accurate to 2 digits after the decimal point that either or both the hero dies, or every minion dies (clearing the board).
Some examples logically derived:
H: 30, A: 2, L: [1, 1]

We have no chance of killing our opponent here. To clear the board, both shots
must hit a minion. The first shot has a 2/3 chance of hitting a minion, then
that minion dies. The second shot has a 1/2 chance. The probability of clearing
the board or killing our opponent is thus 2/6 = 33.33%.

H: 2, A: 3, L: [9, 3, 4, 1, 9]

We have no chance of clearing the board here. 2/3 shots must hit the hero. However,
if any of the shots hit the 1 health minion, it dies, increasing the odds for
future shots.

4/6 the first shot hits a health minion. The next two shots must hit the hero,
for a total probability of 4/6 * 1/6 * 1/6.

1/6 the first shot hits the 1 health minion and it dies. The next two shots must
hit the hero, for a total probability of 1/6 * 1/5 * 1/5.

1/6 the first shot hits the hero. Then there are three options again:

    1/6 the second shot hits the hero.
    4/6 the second shot hits a healthy minion. The last shot must hit 1/6.
    1/6 the second shot hits the 1 health minion. The last shot must hit 1/5.

This last option gives a probability of 1/6 * (1/6 + 4/6 * 1/6 + 1/(5*6)). The
total probability is the chance of any of these scenarios happening, or:

    4/6 * 1/6 * 1/6 + 1/(6*5*5) + 1/6 * (1/6 + 4/6 * 1/6 + 1/(5*6)) = 7.70%

As you can see, it gets complicated quickly... Good luck!

Your score is the number of bytes of code of your answer. If your code computes a probability exactly rather than simulating boards, halve your score. Lowest score wins.

If the calculations use floating-point, does that count as computing "exactly"?

@feersum If the method would be exact with an infinitely precise data type, then yes. Note however that the precision requirement is not forgiven - no matter the data type used, you must be precise to at least 2 digits after the decimal point.

Also, is OK to use intermediate floating point values if we're not going for the bonus?

@isaacg Maybe I made myself unclear. You're free to use floating point either way, whether you go for the bonus or not. The only thing you have to do to qualify for the bonus is to make sure your answer would be exact, if hypothetically you'd replace the floating point numbers with infinitely precise reals. Note however that the precision requirement is not forgiven - no matter the data type used, you must be precise to at least 2 digits after the decimal point.

@orlp OK, but intermediate floating point values means that on sufficiently complicated board states there will be some inaccuracy. So I'm sticking to arbitrary precision.

Pyth, (67 bytes) / 2 = 33.5
L_,*lbJ*FeCbsm*hd/JedbM?&hHstH?GymgtG-XdKH_1_!dlH,01,TT*100cFghQstQ

This qualifies for the bonus even though I had to manually implement arbitrary precision rationals.
(I wish Pyth5 was already a thing).
Input from STDIN in the format A, H, L
Demonstration.
Corrected to output percentage. Percentage is as acurate as possible, due to use of integer math until the last step.
At the high level, the first segment, L_,*lbJ*FeCbsm*hd/Jedb, is a helper function which takes a list of rationals in the form of 2 element lists, and outputs their average as an (unreduced) rational.
The second segment, M?&hHstH?GymgtG-XdKH_1_!dlH,01,TT, recusively calculates the probability of victory.
The third segment, cFghQstQ formats the input to fit the function and performs the final division.
On the second example case, the final unreduced 2-tuple is too long to fit on the screen:
[83158592487544376524800000000000000000000, 1079462498636393349120000000000000000000000]

Fortunately, Pyth does have arbitrary precision integers.

You must give the answer as a percentage accurate to 2 digits after the decimal point .

@orlp Oh, I thought you meant at least, not exactly. Will change.

Oh no, the program is fine, I just got thrown off by your explanation. I thought you were outputting a fraction. You can revert to the old version, except that you still have to multiply by 100 so you output a percentage.

Ruby, Score: 328/2 = 164
Here is a ruby solution that calculates the answer exactly (and then truncates the answer as specified), using the power of recursion. You run it in irb with the g function:
require 'rational'
def c(h, a, l)
  l=l.reject { |m| m == 0 }
  return 1.to_r if l.empty? ||h==0
  return 0.to_r if a==0
  a-=1
  n=[c(h-1, a, l), *((0..l.length-1).map { |i| nl = l.dup;nl[i]-=1;c(h, a, nl)})]
  n.inject(:+)/n.length
end
def g(h, a, l)
  puts "%.2f%%" % (c(h.to_r, a.to_r, l.map(&:to_r)) * 100)
end

Example output:
> g 30, 2, [1,1]
33.33%
> g 2, 3, [9,3,4,1,9]
7.70%

@orlp: done. No worries about the mistake, these things happen :)


text:
Deep thought: Levenshtein distance
So, blatantly plagiarizing from inspired by this challenge and its sequel, I thought I'd add another.
The text to match:

What do you get when you multiply six by nine

The result your function/program/etc. should print or return:

42

An online calculator for Levenshtein distance can be found here: http://planetcalc.com/1721/
Comments are disallowed.

Personally, I don't find these challenges very interesting. Most of the time it's near-impossible to have any meaningful overlap with the text, leading to submissions which just leave the excess floating around.

Fair enough. I haven't seen all that many of these myself, though - do they have a tag associated with them, or are they just that bad?

Voting to close as a duplicate of the linked challenge because, while not an exact duplicate, it isn't appreciably different.

This is much too similar, and in much too close succession. If you're going to steal a challenge, at least wait until it's long dead before posting it ;)

GolfScript, 2
What 42 you get when you multiply six by nine

All words except do are undefined tokens, so they do nothing.
Try it online in Web GolfScript.

TI-BASIC, 3
Replaces the first character with length(, which is a single TI-BASIC token.
length("t do you get when you multiply six by nine

So you're allowed to count the length of your program after tokenisation?

There is no "after tokenization" in TI-83 BASIC; the only way to enrer characters is as tokens.

Ruby, 10
p"What do you get when you multiply six by nine".sum/99

In the spirit of the challenge. Following the letter I think the best you can do is
p 42||"What do you get when you multiply six by nine"

but that program would still work if you changed the string.

Pyth, 4
42 "What do you get when you multiply six by nine

That's not a comment, it's a string that doesn't get printed.

CJam, 3
"hat do you get when you multiply six by ni",

, pushes the string's length.
Try it online in the CJam interpreter.

CMD, 9
echo 42||What do you get when you multiply six by nine

Code after || inline will only run if the previous command generates an error.


text:
Make the Stretchy Snakes Kiss
A stretchy snake looks something like this:
<||=|||:)~

Each separate sequence of vertical bars (|) in a stretchy snake, known as a stretchy portion, is individually extendable to twice its width, and is drawn with alternating slashes (/,\) once extended.
The particular snake above has two such stretchy portions, giving it four possible poses:
<||=|||:)~

</\/\=|||:)~

<||=/\/\/\:)~

</\/\=/\/\/\:)~

The general form of a stretchy snake in its least stretched pose is defined by this regex:
<(\|+=)*\|+:\)~

Which can be stated in words as:

<, followed by any number of sequences of |'s joined with = signs, followed by :)~.

So <|:)~ and <||:)~ and <|=|:)~ and <|=|=||=|||||=||:)~ are stretchy snakes, but <=:)~ and <=|:)~ and <||=:)~ and <|==||:)~ are not.
Stretchy snakes can also face left instead of right, e.g. ~(:|||=||>. The forms are the same, just mirrored.
Challenge
Write a program that takes in a single line string of two stretchy snakes facing each other, with some number of spaces in between. Both snakes will be in their least stretched pose (all vertical bars, no slashes). The string will start with the tail of the right-facing snake and end with the tail of the left-facing snake (you may optionally assume there's also a trailing newline).
For example, here's a possible input with five spaces between the snakes:
<|=||:)~.....~(:||||>

I'm using periods (.) instead of actual space characters for clarity.
Zero spaces between snakes is also valid input:
<|=||:)~~(:||||>

We say the snakes are kissing when their tongues are touching like this.
Your program needs to extend some combination of the stretchy portions of both of the snakes such that the snakes have the fewest number of spaces possible between them (without overlapping), i.e. such that the snakes are as close to kissing as possible.
Both the snakes' tails are fixed but their heads and bodies can move - right for the right-facing snake, left for the left-facing snake - according to what stretchy portions have been extended.
The output of your program is the single line string (plus optional trailing newline) that shows the snakes as close to kissing as possible, with alternating slashes drawn in place of vertical bars for stretchy portions that have been extended.

For example, the output for <|=||:)~.....~(:||||> (from above) would be:
</\=||:)~~(:/\/\/\/\>

This is the only solution here because with any other combination of the stretchy portions extended, the snakes would either overlap or be farther away from kissing.

If there are multiple solutions possible, the output may be any one of them.
For example, if the input were
<|=||:)~.....~(:|||=|>

the output could be
<|=/\/\:)~~(:/\/\/\=|>

or
</\=||:)~~(:/\/\/\=/\>

Remember that it won't always be possible to make the snakes kiss, but you still need to get them as close as possible.
For example, if the input were
<||=||||:)~...~(:||>

the output could be
</\/\=||||:)~.~(:||>

or
<||=||||:)~.~(:/\/\>

If the snakes are already kissing, the output will be the same as the input. e.g.
<|=||:)~~(:||||>

In general, the output will be the same as the input if the extension of any stretchy portion would make the snakes overlap. e.g.
<|||=|||:)~..~(:||||=|||||=||||||>

Notes

Takes input from stdin or the command line as usual, or write a function that takes a string. Print or return the output.
You can use periods (.) in the input and output in place of spaces ( ) if you prefer.
It's only important that slashes alternate within the sequence of vertical bars they replaced. Their ordering in the snake at large or whether a forward or backward slash comes first doesn't matter.
Stretchy portions cannot extend partway - it's exactly double or no extension at all.

Scoring
This is code-golf. The shortest submission in bytes wins. Tiebreaker is earlier answer.

Snex Education 101 - How to kiss properly

"We say the snakes are kissing when their tongues are touching like this." What am I reading...

So Snakes only do French ?

You say "The forms are the same, just mirrored", but the examples show that only the head and tail are mirrored, not the extended stretchy sections.

@PeterTaylor Well, "mirrored", not "reversed" (otherwise > wouldn't become < either, same for for ( and )), but he also says "It's only important that slashes alternate within the sequence of vertical bars they replaced. Their ordering in the snake at large or whether a forward or backward slash comes first doesn't matter."

This reminds me of Thumb Wars (parody of Star Wars). "Touch your tongue to mine."

How do you think up these challenges?

@qwr Imagination.

CJam, 87 71 70 68 bytes
l:L"|"f&Qa%_,Y\m*\f{.{_,"/\\"*?}L'|%.\s" /"1$fe=:-\a+}${0a>}=~S%\S**

Try it online in the CJam interpreter.
How it works
l:L        e# Read a line from STDIN and save it in L.
"|"f&      e# Intersect each character with the string "|".
           e# This pushes either "|" or "".
Qa%        e# Split the resulting array at runs of "".
_,         e# Compute the length of the resulting array (A).
           e# This yield K, the number of stretchy parts.
Y\m*       e# Push the array of all vectores in {0,1}^K.
\f{        e# For each vector V in {0,1}^K, push V and A; then:
  .{       e#   For each C in V and the corresponding P in A:
    _,     e#     Compute the length of the stretchy part P.
    "/\\"* e#     Repeat "/\" that many times.
    ?      e#     If C, select P; else, select "/\"*length(P).
  }        e#   This modifies A.
  L'|%     e#   Split L at runs of vertical lines.
  .\s      e#   Interleave the chunks of L and the modified A. Sringify.
           e#   In each iteration, this constructs a different modification of L,
           e#   with some stretched out stretchy parts.
  " /"1$   e#   Push " /" and a copy of the modified L.
  fe=      e#   Calculate the number of spaces and slashes in the modifed L.
  :-       e#   Subtract the number of occurrences.
  \a+      e#   Construct the array [difference modified-L].
}          e#
$          e# Sort the array (by final number of spaces).
{0a>}=     e# Find the first element greater than [0].
           e# This skips over too far stretched snakes, where the number of
           e# slashes is less than the number of spaces.
~          e# Dump the difference (D) and modified L on the stack.
S%         e# Split L at runs of spaces.
\S*        e# Construct a string of D spaces.
*          e# Join the split L, delimiting by D spaces.

Retina, 209 107 99 97 92 bytes
.(?=(.+)(?<=(?=<((\|+|(?<-5>\|(?=\1())?)+)[^|]+)+$(?(5)!)).+( )+\S+))\4
/ \
+` (.*~|~.*)
$1

For counting purposes, each line goes in a separate file, but you can run the code from a single file with the -s flag.
Bringing the best features of .NET regex and Retina together: balancing groups, arbitrary length lookbehinds and repeated regex substitution.
Essentially, the long regex encodes a valid solution and the regex engine's backtracker finds one of the optimal ones for me.
Explanation
First, let's consider how we can find a valid solution (not necessarily producing the correct output) with a regex. We can use .NET's balancing groups to help us count the stretchy parts. Consider the following simpler regex:
\S+( )+.+(?<=(?(1)!)^([^|]+(\|+|(?<-1>\|)*))+>)

We can disect that.
\S+( )+.+

This matches the entire string, pushing one capture onto the group 1 stack for each space in the input. We will use that stack to ensure that the stretchy parts exactly fill the space captured into those groups.
Next is a lookbehind. The catch is that lookbehinds are matched from right to left in .NET (so that's how you should read them). This gives us the opportunity to traverse the string a second time, figuring out whether there's a subset of stretchy part that sums to the number of matched spaces. Going through the lookbehind from right-to-left:
>

This is just ensure that we're actually starting from the end of the string (the snake's tail).
(
  [^|]+
  (
    \|+
  |
    (?<-1>\|)+
  )
)+

For each stretchy part, this either just matches the entire part without doing anything (\|+), or it matches the entire part while popping captures off stack 1 ((?<-1>\|)*). Having this alternation ensures that we can only fully extend a stretchy part or leave it unchanged, and not get stuff like |/\|. Then we move on to the next stretchy part with [^|]+.
(?(1)!)^

Finally, we ensure that we've traverse the entire string (both snakes), and that stack 1 is completely empty. I.e. that we've found a subset of stretchy part that exactly sums to the number of spaces we've captured earlier.
The backtracker will go back and forth through the string trying all combinations of unchanged and extended parts until the subset sum problem is solved. If such a subset doesn't exist, the lookbehind will fail. This will cause the backtracker to go back to the \S+( )+.+ part and try capturing one space less with ( )+ (which will just be cover by .+ instead). Due to the greediness of + we therefore try filling as many spaces as possible.
You can check the validity of this approach with this slightly modified substitution:
\S+(( )+).+(?<=(?(2)!)^([^|]+(\|+|(?<-2>\|)*))+>)
=$1=

Which will give you a string =spaces= with exactly the number of spaces that can be filled with the given snakes.
I've had to add some more trickery to actually expand the correct |s. Basically, I want to replace all |s which were matched using the (?<-1>\|)+ branch. The idea is to match an individual character, put the solver in a lookaround and set a flag if the match happens to be inside that branch. If that flag wasn't set we invalidate the match at the end to avoid replacement of other characters.
To do this, we use a bunch of nested lookarounds. Again, .NET's variable-length lookbehinds are matched from right to left, so if we nest lookaheads and lookbehinds, we can let the regex engine traverse the string several times. For golfing reasons, the solver is reversed in my actual solution (starting at the end, picking up the spaces from right to left, and then solving the subset sum from left to right), but otherwise the structure of the solver is exactly the same. Let's dissect the full regex:
.(?=(.+)...)

We match a single character, then capture the remainder of the string and move the cursor to the end of the string. We will use this group 1 later to check in the solver whether we're at the position of the match.
(?<=....+( )+\S+)

This is like the first part of the simple solver above, except that we pick up the spaces from right to left. The backtracking of the number of spaces works exactly the same as before, except that we're using group 5 now.
(?=<((\|+|(?<-5>\|(?=\1())?)+)[^|]+)+$(?(5)!))

This is the same as before, except we're going from left to right, and whenever we match a | in the expanding branch, we check if it's the one being matched right with
(?=\1())?

This is an optional lookahead. It tries to match group 1 again (which, here, is only possible if we're right after the character being matched), and if we do, we capture an empty string into group 4, which indicates that we did find the current character in one of the expanded bits. If \1 doesn't match, 4 won't capture anything, and the ? ensures that the failing lookahead won't affect the solver at all.
Finally, after all the solving is done, we just check with \4 whether this lookahead was used. If so, we want to replace the current character with /\.
One difficulty remains: removing the right amount of spaces. The shortest way to do this I've found so far is to insert a space along with the /\ and then get rid of one space between the tongues for each of those marker spaces in a separate step:
+` (.*~|~.*)
$1

Ruby 191 187 186 170 162
->t{s=r=t.size
i=m=t[o=/ +/].size
(0...2**t.scan(y=/\|+/).size).map{|n|q=-1
x=t.gsub(y){|r|n[q+=1]<1?r:'\/'*r.size}
d=i+s-x.size
d<0||d<m&&r=x.gsub(o,' '*m=d)}
r}

This is a function that takes a string as a parameter and returns a string.
Online tests: http://ideone.com/uhdfXt
Here's the readable version:
# enumerates the possible states for any string containing snakes
COMBINATIONS =-> snake {
  expandable_fragments = snake.scan /(\|+)/

  (0...2**(expandable_fragments.size)).map{ |i|
    x=-1
    snake.gsub(/\|+/){|r| i[x+=1]>0 ? '\/'*r.size : r}
  }
}

# finds the configuration in which snakes are closest to each other
KISS=
-> input {
  result = input
  s = input.size
  initial_distance = min_distance = input[/ +/].size

  COMBINATIONS[input].map{|c|
    distance = initial_distance + s - c.size
    if distance > -1 && distance < min_distance
      min_distance = distance
      result = c.gsub(/ +/,' '*distance)
    end
  }

  result
}

In the golfed version, the main function is the equivalent of the KISS function above, and the COMBINATIONS function has been inlined.

Fails on input <|=||:)~~(:||||>, which the spec mentions is valid input.

Python, 205 bytes
from itertools import*
f=lambda s:min([c.replace(".","",c.count("X"))for c in map("".join,product(*map({"|":"|X"}.get,s,s)))if{c.count("X")>c.count("."),"|X"in c,"X|"in c}=={0}],key=len).replace("X","/\\")

Having a single lambda looks neat and all, but I'm almost certain this is not the best way to go. But I'm posting this because it's all I've got so far that looks half decent.
This is a simple brute force over all possible replacements of | with /\, filtering out the invalid configurations. The only neat bit I guess is that we don't actually replace any | with /\ directly - we first replace | with X and drop a . from the middle for every replacement, take the minimum length string over all valid strings, then replace the Xs with /\.
I tried a few other approaches, including recursive ones, but they ended up pretty messy. I also learnt that re.split currently doesn't split on empty strings, which was unfortunate, because one of my ideas involved splitting on \b word boundaries.

Mathematica, 381 bytes
StringReplace[MapAt[StringReplace[#,"|"->"/\\"]&,StringSplit[#<>"="<>#2,"="],#3]~StringRiffle~"=",")="->")~"<>If[#4>0,"."~StringRepeat~#4,""]<>"~"]&[#1,#3,Sequence@@Function[{l,s},{#,#2-Total@Extract[l,#]}&[Flatten[l~Position~#~Take~#2&@@@Tally@#&@@Select[Subsets@l,Total@#<=s&]~MaximalBy~Total,1],s]][StringLength/@StringCases[#1<>#3,"|"..],StringLength@#2]]&@@#~StringSplit~"~"&

Pure function taking the string as its argument. Expects . rather than   between the snakes.
I didn't think it would be this bad...Here's what I had before I smashed it together and infixed everything.
f[lhs_, rhs_,
  spaces_] := {StringLength /@ StringCases[lhs <> rhs, "|" ..],
  StringLength@spaces}

g[barLens_,
   spaceLen_] := {#, #2 - Total@Extract[barLens, #]} & @@ {Flatten[
     Take[Position[barLens, #], #2] & @@@
      Tally[First[
        MaximalBy[Select[Subsets[barLens], Total@# <= spaceLen &],
         Total]]], 1], spaceLen};

h[lhs_, rhs_, partspec_, newSpaceLen_] :=
 StringReplace[
  StringRiffle[
   MapAt[StringReplace[#, "|" -> "/\\"] &,
    StringSplit[lhs <> "=" <> rhs, "="], partspec], "="],
  ")=" -> ")~" <>
    If[newSpaceLen > 0, StringRepeat[".", newSpaceLen], ""] <> "~"]

 h[#1, #3, Sequence @@ g @@ f[#1, #3, #2]] & @@
     StringSplit[#, "~"] &

Here is an example run-through with explanation:
Input: "<|=||:)~.....~(:||||>"
@Call StringSplit[#, "~"] &, yielding  {"<|=||:)", ".....", "(:||||>"}
@@Apply h[#1, #3, Sequence @@ g @@ f[#1, #3, #2]] &, but first
Set arguments: h["<|=||:)", "(:||||>", Sequence @@ g @@ f["<|=||:)", "(:||||>", "....."]]
@Call f, yielding {{1, 2, 4}, 5} = {# of bars in each segment, # of spaces}
@@Apply g, let's trace from the interior:
Subsets[barLens] = all subsets of {1, 2, 4}
Select those subsets whose sum is less than # of spaces {{},{1},{2},{4},{1,2},{1,4}}
MaximalBy Total, yielding a list of all subsets whose sum is maximal {{1, 4}}
First of these subsets, can be any of them {1, 4}
Tally the subset, yielding frequencies of each {{1, 1}, {4, 1}}
@@@Apply Take[Position[barLens, #], #2] & at the first level, yielding
    {Take[Position[{1, 2, 4}, 1], 1], Take[Position[{1, 2, 4}, 4, 1]]}
    which takes the first 1 positions of 1 and the first 1 positions of 4, yielding
    {{{1}},{{3}}}
Flatten at the first level, yielding {{1}, {3}}
Create a list {{{1}, {3}}, 5}
@@Apply {#, #2 - Total@Extract[barLens, #]} &, inserting arguments:
    {{{1}, {3}}, 5 - Total@Extract[{1, 2, 4}, {{1}, {3}}]} = {{{1}, {3}}, 0}
    where the second element becomes the # of spaces left over.
Done with g, it returned {{{1}, {3}}, 0}
@@Apply Sequence, splicing the return of g into h, yielding the
@Call, h["<|=||:)", "(:||||>", {{1}, {3}}, 0]; let's start from the interior
StringSplit the concatenated "<|=||:)=(:||||>" with delimiter "=", {"<|","||:)","(:||||>"}
MapAt the part specification {{1}, {3}} and StringReplace at those indices any | with /\
    yielding {"</\","||:)","(:/\/\/\/\>"}
StringRiffle together, inserting back the delimiter "=", yielding "</\=||:)=(:/\/\/\/\>"
StringReplace ")=" with ")~", concat the new number of spaces, concat "~"
Yields "</\=||:)~~(:/\/\/\/\>", done.

Easily reduced to 355 by starting with a=StringReplace;b=StringSplit;c=StringLength;d=Total; and then substituting those as needed elsewhere inside: a=StringReplace;b=StringSplit;c=StringLength;d=Total;a[MapAt[a[#,"|"->"/\\"]&,b[#<>"="<>#2,"="],#3]~StringRiffle~"=",")="->")~"<>If[#4>0,"."~StringRepeat~#4,""]<>"~"]&[#1,#3,Sequence@@Function[{l,s},{#,#2-d@Extract[l,#]}&[Flatten[l~Position~#~Take~#2&@@@Tally@#&@@Select[Subsets@l,d@#<=s&]~MaximalBy~d,1],s]][c/@StringCases[#1<>#3,"|"..],c@#2]]&@@#~b~"~"&

Prolog (ECLiPSe), 438 bytes
My other answers were solving the wrong problem (sorry for the noise). Here is another attempt in Prolog which actually respects all rules.
:-lib(fd).
a([],[]).
a([H|T],L):-append(H,X,L),a(T,X).
s(E,Z,X,Y,L):-length(E,L),a([[60],M,[58,41,126],T,[126,40,58],W,[62]],E),checklist(=(32),T),length(T,Z),b(M,X-[]),b(W,Y-[]).
b(I,[K:M|R]-E):-(I:K=[47,92|L]:s;I:K=[124|L]:n),M#=N+1,N#>=0,b(L,[K:N|R]-E).
b([61|L],[_:0|R]-E):-b(L,R-E).
b([],[_:0|E]-E).
d(_:N,Y:N):-Y=s;Y=n.
s(W,P):-string_list(W,E),s(E,_,X,Y,L),minimize((maplist(d,X,U),maplist(d,Y,V),s(K,Q,U,V,L)),Q),string_list(P,K).

Tests
(format: input, output, newline)
<===:)~         ~(:>
<===:)~         ~(:>

<|||:)~         ~(:||||=|>
</\/\/\:)~ ~(:/\/\/\/\=/\>

<=|=:)~         ~(:||||=|>
<=/\=:)~   ~(:/\/\/\/\=/\>

<===|:)~         ~(:||=|>
<===/\:)~     ~(:/\/\=/\>

<|=|=|||=|:)~         ~(:=|>
</\=/\=/\/\/\=/\:)~  ~(:=/\>

<||||||:)~         ~(:=|>
</\/\/\/\/\/\:)~  ~(:=/\>

<||||||:)~         ~(:||>
</\/\/\/\/\/\:)~ ~(:/\/\>

<||=||||:)~ ~(:||>
<||=||||:)~ ~(:||>

<||=||||:)~   ~(:||>
</\/\=||||:)~ ~(:||>

<||=||||:)~    ~(:||>
</\/\=||||:)~~(:/\/\>

<||=||||:)~~(:||>
<||=||||:)~~(:||>

Explanations

The main predicate is s/2, which takes the input as a first argument and unfiy the result with the second argument (both strings). The input is converted to a list of character codes, E.
Then, s(E,Z,X,Y,L) destructures the list into the following elements:

Z number of spaces between snakes
X and Y, abstract representation of the left and right bodies
The format of a body is a list of n:N or s:N expressions, where N is a positive length; n means normal and s means stretched.
L total length of the list

What is interesting about s/5 is that it goes both ways, i.e. we can build a snake if other arguments are instanciated:
    s(E,5,[n:3],[s:2,n:7,s:1],_),string_list(S,E).

... unifies `S` with `"<|||:)~     ~(:/\\/\\=|||||||=/\\>"` (backslashes are quoted). This is due to how `b/2` is written, which can parse the character list or generate it.

We build modified left and right bodies where each part is either normal or stretched, while minimizing the space Q that separates the new snakes. The total length of the computed string is bounded so that the search terminates.

Python 2.7.3 427 421 400 371 Bytes
import re,itertools as K
g,o,k='\|+',len,raw_input()
d=k.count(' ')
if d==0:exit(k)
p,x,y,s=re.sub,0,0,map(o,re.findall(g,k))
for e in [A for w in range(o(s)+1)for A in K.combinations(s,w)]:
 v=sum(e)
 if v==d or x<v<d:x,y=v,list(e)
print p(" +",' '*(d-x),p(g,lambda m:('/\\'*o(m.group(0))if y.remove(o(m.group(0)))or True else 1)if o(m.group(0))in y else m.group(0),k))

Non-golfed code here -
#!/usr/bin/env python
import sys
import re

def find_dist_combo(li, d):
    #Listing all combinations
    from itertools import combinations as c
    max_dist = -1
    max_dist_combo = []
    for p_len in xrange(1,len(li)+1):
        for e in c(li, p_len):
            e_sum = sum(e)
            cond1 = e_sum == d
            cond2 = max_dist < e_sum < d
            if cond1 or cond2:
                max_dist = e_sum
                max_dist_combo = list(e)
                if cond1:
                    return (max_dist, max_dist_combo)
    return (max_dist, max_dist_combo)

def snakes_foreplay(snakes):
    #find distance
    distance = snakes.count(" ")

    #already kissing
    if distance == 0:
        return snakes

    #find num_stretches
    stretch = map(len, re.findall("\|+", snakes))

    #find lowest combination of numbers
    (e_dist, res_stretch) = find_dist_combo(stretch, distance)

    def sub_callback(m):
        s = m.group(0)
        l = len(s)
        if l in res_stretch:
            res_stretch.remove(l)
            return '/\\'*l
        return s

    #Resultant substitution
    res_snakes = re.sub("\s+", " "*(distance - e_dist), re.sub("\|+", sub_callback, snakes))

    return res_snakes

if __name__ == "__main__":
    for s in [ip.strip() for ip in sys.stdin]:
        print snakes_foreplay(s)

Testing the golfed solution -
$ python stretchy_snakes.py
[In]  <=  <|=||:)~     ~(:||||>
[Out] =>  </\=||:)~~(:/\/\/\/\>

$ python stretchy_snakes.py
[In]  <=  <|=||:)~             ~(:||||>
[Out] =>  </\=/\/\:)~      ~(:/\/\/\/\>

$ python stretchy_snakes.py
[In]  <=  <|=||:)~     ~(:|||=|>
[Out] =>  </\=||:)~~(:/\/\/\=/\>

$ python stretchy_snakes.py
[In]  <=  <||=||||:)~   ~(:||>
[Out] =>  </\/\=||||:)~ ~(:||>

$ python stretchy_snakes.py
[In]  <=  <|=||:)~~(:||||>
[Out] =>  <|=||:)~~(:||||>

Surely this can be done better(I can't figure out how :)).Let me know if I've missed anything obvious while golfing (It's my first codegolf, I may be doing something stupid :P)

@Sp3000 Thats a good one. Replaced exit for sys.exit() (forgot exit existed). And you are right, __import__ can be removed, that eliminated like 20 chars :)

btw rule of thumb: for aliasing you need > 6 chars to be worth aliasing if you use it twice, > 3 chars if you use it three times. I'm not sure the f=' ' alias is worth it (I count twice)

@Sp3000 yep you are right. In an earlier version I had used that variable thrice. Saved me another couple of bytes :) :)

05AB1E, 93 bytes
#õKDεγʒ'|å]©ε€gxøDgU`XGâ€˜]`âDε˜ODI„| Ãg>‹*}ZQÏε˜ε®˜NèDgyÊi„/\y∍]н©J'/¢Ið¢αð×ý'|¡õK®.ιJIðå≠iI

Way too long.. >.>
Try it online or verify all test cases or verify all possible results for all test cases.
Explanation:
#õK                   # Split the (implicit) input by one or multiple adjacent spaces
                      # (we now have both snakes as separated items
                      #  - if any spaces were in the input-string)
   D                  # Duplicate this list
    ε                 # Map both snakes to:
     γ                #  Split the snake into chunks of the same character-type
      ʒ'|å]          '#  And only leave the chunks of "|" characters
    ©                 #  Store this list in variable `r` (without popping)
     ε                #  Map the "|" chunks of both snakes again:
      €g              #  Get the length of each chunk of "|"
        xø            #  Pair each length with double itself
          DgU`XGâ€˜   #  Create all possible combinations for the current snake
     ]`â              # After the map: create all possible combinations for both snakes
        ε             # Map over each possible combination
         ˜O           #  Get the flattened sum
            I„| Ãg    #  Count the amount of "|" and spaces in the input
                  >‹  #  Check if it's smaller than or equal to this sum
                      #  (1 if truthy; 0 if falsey)
           D        * #  And multiply it by the sum
        }ZQ           # After the map, get the positions of the largest flattened sum,
                      # still below (or equal to) the amount of "|" and spaces combined
       D   Ï          # And only keep those combinations
ε                     # Then map over the remaining combinations
 ˜ε                   #  Flatten it, and map over each value `y`
   ®˜Nè               #   Get the `N`'th part of the snakes
                      #   (where `N` is the index of the map for the current combination)
       D              #   Duplicate this "|"-part
        gyÊi          #   If the length of this "|"-part is not equal to the map-value:
            „/\       #    Push the string "/\"
               y∍     #    Extended to a size equal to the map-value
                      #   (implicit else:
                      #    use the duplicated value)
]н                    # After the map: only leave the first (since we don't have
                      # to output all possibilities)
 ©                    # Store it in variable `r` (without popping)
  J'/¢               '# Count the amount of "/" in it
      Ið¢             # Count the amount of spaces in the input
         α            # Get the difference between those
          ð×ý         # And join the list of snakes by that many spaces
'|¡õK                '# Then split by one or multiple adjacent "|"
     ®.ι              # Interleave it with the modified parts of variable` r`
        J             # And join everything together to a single string
Iðå≠i                 # If the input didn't contain any spaces:
     I                #  Output the input instead
                      # (implicit else:
                      #  output the top of the stack before this if)

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