text:
Reverse the truth
Write a program or function that:

takes in a string from stdio or arguments
replaces all occurrences of true with false and false with true
reverses it, but does not reverse true and false
returns or prints result

Examples (left side is input):
"true"                     "false"
"2false"                   "true2"
"true is false"            "true si false"
"false,true,undefined"     "denifednu,false,true"
"stressed-false"           "true-desserts"
"falstrue"                 "falseslaf"
"true false true x"        "x false true false"

Standard loopholes apply.
This is code-golf, so shortest code in bytes wins.
Leaderboard

var QUESTION_ID=63256,OVERRIDE_USER=20569;function answersUrl(e){return"http://api.stackexchange.com/2.2/questions/"+QUESTION_ID+"/answers?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+ANSWER_FILTER}function commentUrl(e,s){return"http://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

In Step 3, only one replacement is required, or all occurrences should be replaced? e.g.true true false false becomes true true false false or true eslaf false eurt?

Should eurt became false or true?

@Zereges It is not false or true before it's reversed, so: eurt->true

@HannesKarppila So, the rules are applied in order: 1 3 2 4 5

Yes, isn't that obvious? (Fixed that, too)

Will the input string contain tabs?

Does this also mean that trufalse -> trueurt?

yes, it does (e.g. "falstrue" -> "falseslaf")

I have a general proposition. We have the cases trufalse and falstrue. This means that if we do the string replacement in one order (e.g. true first, then false, or the opposite) we will make errors (most of the programs down there do one or the other). Most languages cannot do two replacement in one run (all regexps, for example)
One workaround can be introducing escaping characters (like % in my code), but that will also create invalid translations. i cannot imagine any other solution but 2 replacement at once, or escape chars. Is escaping acceptable in the solutions?

C# 6, 144 bytes
string R(string t)=>string.Concat(new System.Text.RegularExpressions.Regex("true|false").Replace(t,m=>m.Value[0]<'g'?"eurt":"eslaf").Reverse());

It uses a regular expression to match true|false, and if it matches true it will be replaced by eslaf, otherwise by eurt. m.Value[0]<'g' is a shorter way to say m.Value[0]=="false", because the only possible values for m.Value are "true" or "false", so if the char code of the first char is smaller than the char code of 'g', it's "false".
Old version, 95 bytes
This one had a bug, it didn't return correct output for falstrue.
string R(string t)=>string.Concat(t.Reverse()).Replace("eurt","false").Replace("eslaf","true");

A C# solution under 100 bytes? Surely the end of days is upon us.

@AlexA. Haha, all thanks to version 6 ;P

@LegionMammal978, maybe you're confusing C# with .NET Framework?

@ArturoTorresSánchez facepalm C# 4 then

This does not work correctly for the input falstrue.

@AlexA. Well, with the incorrect output for falstrue fixed, it's no longer <100 bytes... :(

While that is sad indeed, it means we no longer have to worry about the apocalypse. Software bugs have saved us all.

Bash+GNU, 45 38 73 bytes
Edit: works with both trufalse and falstrue
sed s/false/%eurt%/g\;s/true/%eslaf%/g|rev|sed "s/%\(true\|false\)%/\1/g"

Old version, 38 bytes (shortened, thanks to Digital Trauma):
rev|sed s/eurt/false/g\;s/eslaf/true/g

Combine the sed expressions into one, and remove the "-e" and quotes: rev|sed s/eurt/false/g\;s/eslaf/true/g

This does not work correctly for the input falstrue.

@feersum Good point, fixed. Also checked for trufalse.

TeaScript, 36 25 24 bytes
xv¡g("eurt|eslaf",#ln>4)

TeaScript is JavaScript for golfing.
Edits: Saved 11 bytes thanks to @Vɪʜᴀɴ. Fixed for input falstrue and saved a byte.
Old version (Invalid):
xv¡g("eurt",f)g(f.T¡v¡,t)

Explanation:
x    // Input
 v¡    // Reverse
   g("eurt",    // Global replace "eurt" with "false".
            f)    // f is predefined to false.
              g(f.T¡v¡, // Convert false to string, then reverse.
                       t) // t is predefined to true.

If you use l and i instead of t and f, you can ommit the .s. f is also predefined to false so you can get: xv¡g(l="eurt",i=f+¢)g(iv¡,lv¡)

Actually even better: xv¡g("eurt",f)g(f.T¡v¡,t)

@Vɪʜᴀɴ Thanks for the help. didn't see that in the docs. Would it be possible to auto insert ( after methods? Like replace(/(\.[BcCdeE...])/g,"$1(") or similar after inserting periods.

This does not work correctly for the input falstrue.

@feersum Fixed. Thanks for pointing that out. That was tricky.

JavaScript ES6, 59
As an anonymous function.
Note, replace is used just as a shorthand for match().map(). The replaced string is discarded, and the output string is made piece by piece backwards (so no need to reverse).
s=>s.replace(/false|true|./g,x=>s=(x[1]?x<'t':x)+s,s='')&&s

Test running the snippet below in an EcmaScript 6 compliant browser.

f=s=>s.replace(/false|true|./g,x=>s=(x[1]?x<'t':x)+s,s='')&&s

//test

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

;[
 ["true","false"]
,["falstrue","falseslaf"]
,["1false","true1"]
,["true is false","true si false"]
,["false,true,undefined","denifednu,false,true"]
,["stressed-false","true-desserts"]
,["true false true x","x false true false"]
].forEach(t=>console.log(t[0]+' -> '+f(t[0])))

Came on here to post amazing 62-byte solution...found incredible 59-byte solution. +1

Windows Batch, 184 213 bytes
Fixed the bug, falstrue -> falseslaf and trufalse -> trueurt
Probably one of the less popular languages:
setlocal enabledelayedexpansion
set /p Q=
set N=0
:L
call set T=%%Q:~%N%,1%%%
set /a N+=1
if not "%T%" equ "" (
set R=%T%%R%
goto L
)
set R=%R:eurt=false%
set R=%R:eslaf=true%
set R=%R:falstrue=falseslaf%
echo %R%

This does not work correctly for the input falstrue.

@feersum, fixed it :)

Haskell, 94 bytes
Performs pattern matching on the input string, looking for "false" or "true" and appends the opposite to the result of applying the function on the remainder of the string. If true or false isn't found, it uses recursion to reverse the string in the same fashion.
f[]=[]
f('t':'r':'u':'e':s)=f s++"false"
f('f':'a':'l':'s':'e':s)=f s++"true"
f(x:s)=f s++[x]

Added now, sorry about that

Never mind. It seems I made some mistake when trying to test it. Maybe I simply printed out the string without managing to apply the function to it.

I believe you can take the top f[]=[] line and instead put f x=x at the bottom to save a byte.

JavaScript ES6, 95 93 bytes
Unnamed function. Add f= to the beginning to use it. Thanks Ismael! Also assumes that the input does not contain tabs.
x=>[...x[r="replace"](/false/g,"\teslaf")[r](/(\t)*true/g,"eurt")[r](/\t/g,"")].reverse().join``

You can use .replace(/eurt/g,false).replace(/eslaf/g,true), since they will be converted to string. Try true + '' (should return 'true')

WAIT!!! Change false with !1 and true with !0. There, a few bytes shorter

@IsmaelMiguel whoa thanks!!!!

You're welcome. And my name is Ismael, not Ishmael.

@IsmaelMiguel sorry, mobile autocorrect

I think you should also be able to use [...x] instead of x.split''

67: x=>[...x].reverse().join\`r='replace'r`. I also changed the join param to an empty template string to make strip out array commas.

This does not work correctly for the input falstrue.

@feersum Thanks, working on it.

@ThomasKwa the latter is only valid in the case that true and false do not appear next to each other

Julia, 59 55 46 bytes
s->replace(reverse(s),r"eurt|eslaf",i->i<"et")

This creates an unnamed function that accepts a string and returns a string. To call it, give it a name, e.g. f=s->....
The input is reversed using reverse. We match on the regular expression eurt|eslaf which matches true or false backwards. To the match we apply a function that returns true if the match is lexicographically smaller than et (i.e. eslaf) and false otherwise. The boolean literals are converted to string in the output.
Saved 9 bytes and fixed an issue thanks to Glen O!

I don't believe this works correctly for the input falstrue.

It's using the same basic reasoning, so I'll offer it to you: s->replace(reverse(s),r"eurt|eslaf",i->i<"et") - uses a regex rather than doing it twice, and a function for the replace that evaluates to true if it was "elsaf" and to false if it was "eurt". 46 bytes.

Oh, and it also fixes the falstrue issue.

@GlenO That's great, thanks

@feersum Fixed now

Pyth, 30 bytes
::_z"eurt""false""eslaf""true"

This reverses the input (_z), substitutes "eurt" for "false" and "eslaf" for "true". Replacement is done using :.
Try it online

You can declare "true" and "false" as a variable: =d"true"=k"false"::_z_dk_kd, and use the reverse of it. It will save 3 bytes.

::_zJ"eurt"K"false"_K_J is 23 bytes.

This does not work correctly for the input falstrue.

rs, 56 bytes
\t
+(.*\t)(.)(.*)/\2\1\3
\t/
eurt/fals\t
eslaf/true
\t/e

Live demo and test cases.

This does not work correctly for the input falstrue.

@feersum Ugh...neither does the Pyth answer, FYI...

At least 7 answers have this problem that I have tested

@feersum Ok; I fixed it now.

Javascript, 135 Bytes
function(s){return s.split("").reverse().join("").replace(/eslaf/i,'☺').replace(/eurt/i,'☻').replace(/☻/g,!1).replace(/☺/g,!1)}

Test:
=>"false is the opposite of true"
<="true fo etisoppo eht si false"
Thanks ProgramFOX and edc65 for pointing out a bug!

Welcome to Programming Puzzles & Code Golf! The question requests a full program or a function, so not just a code snippet that assumes that a variable s exists. Also, your code does not work for falstrue: it should output falseslaf, not trueslaf. Do you want to fix these issues? Thanks! :)

@ProgramFOX Thank you! I'll get right on that!

You can save a few bytes if you use ES6, it has this arrow-function syntax: f=s=>s.split(""). ....

This is both overly complex and wrong. Test with 'false1' or 'true0' or 'true1'

@edc65 Why thank you, kind sir!

After the last clarification by OP, this is invalid as does not change all occurrencies (testcase 7). Easily solved changing the flags of regexp from i to g.

Java, 162 98 92 bytes
Thanks (and sorry!~) to @DanielM. for telling me about StringBuffer and the fact that we can use functions!
Because, you know, Java.
s->(""+new StringBuffer(s.replaceAll("false","eurt")).reverse()).replaceAll("eurt","false");
Returns the correct, reversed string.
Ungolfed Version:
s->new StringBuilder(
    s.replaceAll("false","eurt"))
    .reverse().toString().replaceAll("eurt","false");
Basically, I replace all instances of "false" with a backwards "true", then reverse the entire string, and then replace the now backwards versions of "true" (not the ones I just replaced) with "false". Easy peasy.

StringBuffer is a byte shorter. Also, functions are allowed.

I'm preparing another answer in a different language, so you can keep this

The return is implicit when dealing with one-line lambdas

I didn't count it in the byte count, but I'll remove it. :D

Java beat Python? Now surely the end is upon us

Instead of x.toString() you can use (""+x) which is 6 bytes shorter. You could have omitted the parentheses, if it was a parameter to a function or was the RHS, saving you 2 extra bytes, but unfortunately that's not the case.

@GaborSch Nifty. :P Thanks!

Python 3, 68 100 bytes
I'm still golfing it, but it's fixed to the bug, so falstrue -> falselsaf and trufalse -> trueurt
Pretty straightforward:
print(input()[::-1].replace("eurt","false").replace("eslaf","true").replace("falstrue","falseslaf"))

This does not work correctly for the input falstrue.

This can be easily remedied by switching the replace statements (print(input()[::-1].replace("eslaf","true").replace("eurt","false")))

@BetaDecay, that will not work, because trufalse becomes trufalse, while it needs to be trueurt

@Adriandmen However, that's not one of the example I/Os so it will suffice for now :)

@BetaDecay Haha, they won't notice :)

Mathematica, 64 bytes
StringReverse@#~StringReplace~{"eurt"->"false","eslaf"->"true"}&

, 40 chars / 65 bytes
ô[…ïċ/false|true/g,⇏[…⬯+!שúa]ù⬮ø⬯)]ù⬮ø⬯)

Try it here (Firefox only).
Thanks to @feersum for pointing out a bug!
21 chars / 43 bytes, non-competitive
ôᴙ(ïċ/⊭|⊨⌿,↪ᴙ(⬯+!ë$⸩⸩

Try it here (Firefox only).

This does not work correctly for the input falstrue.

Haskell, 102 bytes
h('t':'r':'u':'e':s)="eslaf"++h s
h('f':'a':'l':'s':'e':s)="eurt"++h s
h(x:s)=x:h s
h[]=""
r=reverse.h

The replacement of "true" by "false" and vice-versa is quite lengthy with the pattern-matching, but at least it deals correctly with "falstrue" and the like. And besides, I suspect that a correct regex-based version would be a bit longer.

Pyth, 28 22
Amr`!dZ2jHjLGcR_Hc_z_G

6 bytes thanks to Jakube
Works correctly for falstrue, as shown in the suite below.
Test suite

No, I think I made a mistake. You 22 byte solution is correct.

Python 3 - 108 92 bytes
import re
print(re.sub("eslaf|eurt",lambda m:repr(len(m.group(0))>4).lower(),input()[::-1]))

Uses a regex to match on "true" or "false" and uses a lambda to process matches and choose what to use as a replacement string. Using repr gets the string representation of (len(match)>4) which gives "True" when "false" is matched and vice versa (and use .lower() because repr(bool) gives a capitalized string) to get the inverse of the match and finish up by reversing the replacement and then the processed input using [::-1]
Managed to get the length down 16 bytes from TFelds suggestions.
Edit: Python is back in front of java, no need for alarm.

We require here that programs work for all inputs, not just for the given test cases.

You can save 6 bytes by reversing the string first, and then replacing (saving one [::-1])
print(re.compile("eslaf|eurt").sub(lambda m:repr(m.group(0)!="eurt").lower(),input()[::-1]))

You can also get away with not using re.compile
print(re.sub("eslaf|eurt",lambda m:repr(m.group(0)!="eurt").lower(),input()[::-1]))
Change m.group(0)!="eurt" to len(m.group(0))>4 (for 1 more)

Japt, 26 bytes
Note: This may be invalid, as it requires bug fixes made after this challenge was posted.
Uw r"eurt|eslaf",X=>X<"et"

Try it in the online interpreter! (Arrow function requires ES6-compliant browser, such as Firefox.)
How it works
             // Implicit: U = input string
Uw r         // reverse U, then replace:
"eurt|eslaf" // occurrences of either "eurt" or "eslaf"
X=>X<"et"    // with "false" or "true", respectively
             // Implicit: output last expression

Here's a version that worked before the bug fixes: (38 bytes)
Uw $.replace(/eurt|eslaf/g,X=>X<"et")$

Gema, 43
*=@a{@reverse{*}};a:eurt=false;a:eslaf=true

(Gema is an obscure macro language.)

Prolog, 225 bytes
p(X):-string_to_list(X,L),reverse(L,B),q(B,C),string_to_list(Z,C),write(Z),!.
q([],[]).
q([101,117,114,116|T],[102,97,108,115,101|L]):-q(T,L).
q([101,115,108,97,102|T],[116,114,117,101|L]):-q(T,L).
q([H|T],[H|L]):-q(T,L).

Try it out online here

Run by querying in the following way:
p("falstrue").

Japt, 15 bytes
Ôr`laf|e¨t`Èøf

Try it

Ruby, 55 bytes
->s{s.gsub(/true|false/){$&[?t]?:eslaf: :eurt}.reverse}

Test:
->s{s.gsub(/true|false/){$&[?t]?:eslaf: :eurt}.reverse}["false,true,undefined"]
=> "denifednu,false,true"

53 bytes

Perl 5, 68 bytes
67 plus 1 for -E instead of -e
%a=(false,eurt,true,eslaf);say~~reverse<>=~s/false|true/$a{$&}/gr

OpenSCAD, 178 bytes
(Note that this uses the String Theory library, as OpenSCAD doesn't exactly have a standard library. Additionally, this is a function because the only allowed input is to hard-code it.
use <Strings.scad>;function f(a)=contains(g(a),"eurt")?replace(g(a),"eurt","false"):g(a);function g(a)=contains(reverse(a),"eslaf")?replace(reverse(a),"eslaf","true"):reverse(a);

C#, 260 bytes
using System;class P{static void Main(){var y=Console.ReadLine();char[] n=y.ToCharArray();Array.Reverse(n);var s=new string(n);if(s.Contains("eslaf")){s=s.Replace("eslaf","true");}if(s.Contains("eurt")){s=s.Replace("eurt","false");}Console.WriteLine(s);}}

This is my first (real) post - I've seen someone using c# above didn't include: using system;  class P{ }, static void main(), Console.WriteLine(); or Console.ReadLine();. These obviously take on a lot of bytes for me - if there is a way of golfing that or if it is excluded from code-golf - let me know :)

PHP, 60 bytes
Simple, reverses the string first, then replaces the reversed versions with their respective swaps.
"falstrue" becomes "eurtslaf" becomes "falseslaf".
<?=strtr(strrev($argv[1]),{'eurt'=>'false','eslaf'=>'true'})

Perl 5.10, 54 bytes
$_=reverse<>;s/(eurt)|(eslaf)/$1?"false":"true"/eg;say

Reverse, then replace. A different way of doing it besides the hash table used for the other Perl answer, which ends up being shorter!
Try it online.

Pyth - 18 bytes
Can be golfed a lot more.
Amr`!dZ2::_z_GH_HG

Test Suite.

This does not work correctly for the input falstrue.


text:
Let's Make Music!
Lots of people like to play music for fun and entertainment. Unfortunately, music is pretty difficult sometimes. That is why you're here!
Task
It's your job to make reading music much easier for those struggling with it. You need to write a program or function that takes as input a musical staff, and outputs the names of the notes written on that staff.
Staff, clef, and notes
A musical staff , or stave, is five horizontal lines, inbetween which are four spaces. Each line or space represents a different note (pitch), depending on the clef.
There are a fair few different musical clefs to choose from, but we'll only be dealing with one for now: the treble clef. On the treble clef, the notes are represented on the staff as follows:
Lines
F  ----------
D  ----------
B  ----------
G  ----------
E  ----------

Spaces
   ----------
E
   ----------
C
   ----------
A
   ----------
F
   ----------

Formatting of the input
Input will be given as a single string, as follows:

---------------

---------------

---------------

---------------

---------------

The five lines and four spaces of the staff are constructed out of nine rows of characters. Lines of the staff are constructed with - (hyphen) characters, and spaces with   (space). Each row is separated from the next by a single newline character, eg:
-----\n     \n-----\n     \n-----\n      \n-----\n     \n-----\n
The rows are of arbitrary length (to a reasonable amount that can be handled by your programming language), and each row is exactly the same length in characters as the others. Also note that the rows will always be of a length that is divisible by three (to fit the pattern of one note followed by two columns without a note).
Notes are placed on this staff by replacing the appropriate - or   character with o. Notes can also be raised (sharp) or lowered (flat) in pitch by a semitone (about half the frequency difference between a note and its adjacent notes). This will be represented by the characters # and b, respectively, in place of the o. Each note will be separated from the next by exactly two - characters, and the first note will always occur on the first "column" of - and   (space) characters.
When outputting note names, your program should always use the capitalised letters (A B C D E F G) corresponding to the note given on the staff. For sharp (#) and flat (b) notes, your program needs to append # and b, respectively, to the letter corresponding to the note. For a natural note that is not sharp or flat, a   (space) should be appended instead.
Example
Input:

---------------------o--
                  o
---------------o--------
            o
---------b--------------
      o
---o--------------------
o
------------------------

*note all "empty space" in this example is actually   (space character).
In this case (a simple F major scale), your program should output this:

F  G  A  Bb C  D  E  F

Note the spacing between the characters of the output should be exactly as shown above, to fit correctly with the notes on the staff. Between all the note names there are two   (space) characters, except between the Bb and C. The b here replaces one of the   (space) characters.
Another example
Input:

------------------------
                     o
------------------#-----
               #
------------o-----------
         o
------#-----------------
   #
o-----------------------

Output:
E  F# G# A  B  C# D# E
One more example for good luck
Input:

---------------------
o  o  o     o
---------------------
         o
---------------------

---------------o--o--

---------------------

Output:
E  E  E  C  E  G  G
Rules

Notes will only ever be given in the five line staff range of E flat up to F sharp (except for the challenges, see below)
Any note could be sharp or flat, not just those seen commonly in music (eg. despite B# actually just being played as C in reality, B# can still occur in the input)
You can assume there will be exactly one note per 3 columns (so there will be no chords or anything like that, and no rests either)
You can assume the last note will be followed by two columns with no notes
You can assume even the last line of the staff will be followed by a single newline character
Input should be taken from STDIN (or language equivalent) or as function parameter
Output should be to STDOUT (or language equivalent) or as a return result if your program is a function
Standard loopholes and built-ins are allowed! Music is about experimenting and playing around. Go ahead and have fun with your language (although recognise that exploiting a loophole may not produce the most interesting program)
This is code-golf, so shortest program in bytes wins

Bonus challenges

-10% if your program can also successfully process the space above the top line of the staff (G, G#, Gb).
-10% if your program can also successfully process the space below the bottom line of the staff (D, D#, Db)
In these cases your program would take as input an additional row at the start and end; these rows should be treated exactly the same as the other nine rows

Yes, I realise that one is quite similar to my question. However, that one only got one answer. I was hoping to make something simpler to get more languages involved. And actually, I believe that challenge involves the opposite, converting notes into a staff.

CJam (40 37 * 0.8 = 29.6 points)
qN/z3%{_{iD%6>}#_~'H,65>=@@=+'oSerS}%

Online demo
Thanks to indeed for pointing out some pre-defined variables which I'd forgotten about.

Very neat! You can shave off a few bytes by using S for space characters. Additionally, you replace 13 with D.

Ruby, 106 bytes *0.8 = 84.8
->s{a=' '*l=s.index('
')+1
s.size.times{|i|s[i].ord&34>33&&(a[i%l,2]='GFEDCBA'[i/l%7]+s[i].tr(?o,' '))}
a}

Ungolfed in test program
f=->s{a=' '*l=s.index('
')+1                                 #l = length of first row, initialize string a to l spaces
  s.size.times{|i|                   #for each character in s
  s[i].ord&34>33&&                   #if ASCII code for ob#
   (a[i%l,2]=                        #change 2 bytes in a to the following string
   'GFEDCBA'[i/l%7]+s[i].tr(?o,' '))}#note letter, and copy of symbol ob# (transcribe to space if o)
a}                                   #return a

t='
---------------------o--
                  o
---------------o--------
            o
---------b--------------
      o
---o--------------------
o
------------------------

'

u='
------------------------
                     o
------------------#-----
               #
------------o-----------
         o
------#-----------------
   #
o-----------------------

'

v='
---------------------
o  o  o     o
---------------------
         o
---------------------

---------------o--o--

---------------------

'

puts f[t]
puts f[u]
puts f[v]

JavaScript (ES6), 144 bytes - 20% = 115.2
f=s=>(n=[],l=s.indexOf(`
`)+1,[...s].map((v,i)=>(x=i%l,h=v.match(/[ob#]/),n[x]=h?"GFEDCBAGFED"[i/l|0]:n[x]||" ",h&&v!="o"?n[x+1]=v:0)),n.join``)

Explanation
f=s=>(
  n=[],                      // n = array of note letters
  l=s.indexOf(`
`)+1,                        // l = line length
  [...s].map((v,i)=>(        // iterate through each character
    x=i%l,                   // x = position within current line
    h=v.match(/[ob#]/),      // h = character is note
    n[x]=                    // set current note letter to:
      h?"GFEDCBAGFED"[i/l|0] //     if it is a note, the letter
      :n[x]||" ",            //     if not, the current value or space if null
    h&&v!="o"?n[x+1]=v:0     // put the sharp/flat symbol at the next position
  )),
  n.join``                   // return the note letters as a string
)

Test
Remember to add a line above the staff that is the exact length of the other lines because this solution includes parsing the lines above and below the staff.

f=s=>(n=[],l=s.indexOf(`
`)+1,[...s].map((v,i)=>(x=i%l,h=v.match(/[ob#]/),n[x]=h?"GFEDCBAGFED"[i/l|0]:n[x]||" ",h&&v!="o"?n[x+1]=v:0)),n.join``)
<textarea id="input" style="float:left;width:200px;height:175px">
---------------------o--
                  o
---------------o--------
            o
---------b--------------
      o
---o--------------------
o
------------------------
                        </textarea>

  <button onclick="results.innerHTML=f(input.value)">Test</button>

source: Stack Exchange

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

sort: votes


text:
Letters between two letters
Write a program that accepts a single lowercase word as input and outputs the number of pairs of letters that have the same number of letters between them in the word as in the alphabet.
For example, in the word 'nature', we have 4 pairs:

nr: since there are three letters between them inside the word (a, t, u) and three letters between them in the alphabet (o, p, q)
ae: since there are three letters between them inside the word (t, u, r) and three letters between them in the alphabet (b, c, d)
tu:  since there are no letters between them inside the word and no letters between them in the alphabet
tr:  since there is one letter between them inside the word (u) and one letter between them in the alphabet (s)

Since there are four pairs, the output in this case should be 4.

The wording can be clarified a bit more.

I don't get the question. How are the letters a,t,u going to be inside nr? And all the following examples... (cc @flodel)

If you spell out n.a.t.u.r.e, the n and r are at the 1st and 5th position. So there are three letters between them. They are a, t, and u, at the 2nd, 3rd and 4th position. That's what the text means by there are three letters between n and r inside the word.

@flodel You're right in the edit; I missed the 4th pair.

What if the word were rjjjnfffr?  Would that be one pair (nr) or two pairs (nr and rn)?  And what about abzab?  Is that two pairs of ab or one?

@ghosts_in_the_code So it only counts if the order is the same?

@NotthatCharles Sorry, I missed that. I meant to say 2 pairs in both cases.

Pyth, 19 bytes
lfqF-MSMCT.cCUBCMz2

Try it online: Demonstration
Explanation:
lfqF-MSMCT.cCUBCMz2
                 z   read a string from input
               CM    convert into list of ascii-values
            CUB      create a list of pairs (ascii-value, index in string)
          .c      2  all combinations of length 2
 f                   filter for combinations T, which satisfy:
        CT              transpose T ((ascii1, ascii2), (index1, index2)
      SM                sort each list
    -M                  create the the difference for each
  qF                    check if they are equal
l                    print the number of remaining combinations

R, 110 bytes
function(s){w=strsplit(s,"")[[1]]
O=outer
n=nchar(s)
sum(abs(O(r<-match(w,letters),r,"-"))==O(1:n,1:n,"-"))-n}

Degolfed:
F = function(s){
   chars = strsplit(s,"")[[1]]
   num_chars = nchar(s)
   letter_rank = match(chars, letters)
   rank_dist = abs(outer(letter_rank, letter_rank, "-"))
   position_dist = outer(1:num_chars, 1:num_chars, "-")
   return(sum(rank_dist == position_dist) - num_chars)
}

F("nature")
# [1] 4
F("supercalifragilisticexpialidocious")
# [1] 25

Octave, 41 bytes
@(s)nnz(abs(s-s')==(t=1:(u=nnz(s)))-t')-u

CJam, 36 bytes
r:A,{)Aew}%1>{{:B,B0=BW=-z)=}%}%e_:+

Try it Online.

Husk, 8 bytes
#S≡Γ·…→Q

Try it online!
Explanation
#S≡Γ·…→Q
       Q all continuous sublists
#        number of sublists which satisfy:
 S≡      has the same shape and distribution of truthy/falsy values as:
   Γ·…→  the range between its first and last character?

Awarded bounty for picking the right tool for the job haha.

wow, didn't expect that. Thanks for the bounty!

J, 27 bytes
#-:@-~#\+/@,@:=&(|@-/~)3&u:

Usage:
   (#-:@-~#\+/@,@:=&(|@-/~)3&u:) 'nature'
4

Explanation:
#-:@-~#\+/@,@:=&(|@-/~)3&u:
      #\                    lengths of input prefixes (1,2,...,length)
                       3&u: codepoints of input
               &(     )     with the last two do parallel:
                 |@-/~      create difference table with itself and take absolute values
              =             compare the elements of the two difference tables
        +/@,@:              sum the table
#   -~                      subtract the length of the input (self-similar letters)
 -:@                        half the result (each pair was accounted twice)

Try it online here.

CJam, 25 bytes
l:T,_2m*{_:-\Tf=:-z=},,\-

Try it online
Explanation:
l     Get input.
:T    Store in variable T for later use.
,     Calculate length.
_     Copy for use at the very end.
2m*   Use Cartesian power to calculate all possible position pairs.
{     Start filter.
  _     Create copy of index pair.
  :-    Calculate difference between indices.
  \     Swap copy of index pair to top.
  T     Get input string stored in variable T.
  f=    Extract the letters for the index pair.
  :-    Calculate difference of the two letters.
  z     Take the absolute value.
  =     Compare index difference and letter difference.
},    End filter.
,\
-     Pairs of identical indices passed the filter. Eliminate them from the
      count by subtracting the length of the input.

JavaScript (ES6), 98 bytes
f=w=>(p=0,q="charCodeAt",[...w].map((c,a)=>{for(b=a;w[++b];)p+=Math.abs(w[q](a)-w[q](b))==b-a}),p)

Usage
f("nature")
=> 4

Explanation
f=w=>(
  p=0,                                 // p = number of pairs
  q="charCodeAt",
  [...w].map((c,a)=>{                  // iterate through each character of input
                                       // a = character A index
    for(b=a;w[++b];)                   // iterate through the remaining input characters
                                       // b = character B index
      p+=                              // add 1 to p if true or 0 if false
        Math.abs(w[q](a)-w[q](b))==b-a // compare absolute difference of character codes
                                       //     to difference of indices
  }),
  p                                    // return p
)

Jelly, 32 16 bytes
ḢØaṣU1¦=
ṫJÇ€Fċ1

Try it online!
–16 when I learned how to reverse just the first element of a list.
How?
ḢØaṣU1¦=  - helper monadic link, e.g. nature
Ḣ         - pop first character       n
 Øa       - lowercase alphabet        abcdefghijklmnopqrstuvwxyz
   ṣ      - split list                abcdefghijklm opqrstuvwxyz
    U1¦   - reverse first element     mlkjihgfedcba opqrstuvwxyz
       =  - equate with string        mlkjihgfedcba opqrstuvwxyz
                                    = ature         ature
                                   -> 00000hgfedcba 00010tuvwxyz

ṫJÇ€Fċ1   - main monadic link, e.g. nature
 J        - range                   1 2 3 4 5 6
ṫ         - tail; remove n-1 chars  nature ature ture ure re e
  Ç€      - map previous link       00000hgfedcba 00010tuvwxyz ...
    F     - flatten                 00000hgfedcba 00010tuvwxyz ...
     ċ1   - count 1s                4

Python 2, 91 chars
lambda i:sum(y-x==abs(ord(i[y])-ord(i[x]))for x in range(len(i))for y in range(x+1,len(i)))

MATLAB, 84 bytes
s=input('');disp(sum(diff(nchoosek(find(s),2),[],2)==abs(diff(nchoosek(s,2),[],2))))

This line asks for a string as input. It then creates all possible pairs of letters and does the same for their corresponding indices. Then we determine whether the (absolute) difference of the values matches to finally sum all cases where it does. The result is displayed in the command window.

PowerShell, 114 100 Bytes
param($a)$b=$a.length;0..($b-1)|%{$i=$_;($_+1)..$b|%{$o+=[math]::Abs(+$a[$_]-$a[$i])-eq($_-$i)}};+$o

Pretty straight-forward, but uses a couple tricks.

param(..) takes our input, saves it to $a.
We set a temp variable $b to be the .length of our input. This saves a byte later.
0..($b-1)|%{..} is the equivalent of a for($i=0;$i-le($b-1);$i++){..} loop, but quite a lot shorter.
However, we need to set variable $i in order to keep that going into ...
($_+1)..$b|%{..} the next for loop, since $_ is only positional to the inner loop.
We then use a lengthy .NET call to check if the absolute value between our two characters (here we use implicit casting with prepending + to save a bunch of bytes) is -equal to the positional difference in the array. Since we're explicitly given lowercase input, we don't need to do case conversion. This statement will return either True or False.
We blatantly abuse implicit casting again to accumulate that result into $o, so True will add 1, while False will add 0.
Once the loops are finished, we output $o. Note we need to do the same tricksy-cast-to-int with + to avoid printing False if there were no matches.

JavaScript ES7, 93
Using array comprehension. ES6 with .map.map.map is 2 bytes longer.
Test running the snippet below with Firefox

f=s=>[for(x of s)x.charCodeAt()].map((a,i,s)=>s.map((b,j)=>t+=j>i&(b>a?b-a:a-b)==j-i),t=0)&&t

document.write('nature'+'\n'+f('nature'))

Matlab(94)(80)

Edit: I didnt take in case inversed alphabetic order,as (t,r) in 'nature', so more bytes to upweight :(

@(a)sum(arrayfun(@(x)sum(1:nnz(find(a==fix(x/2)+(-1)^x*(1:1:nnz(a))))-1),2:244))

binomial function throws a stupid exception when k is bigger than n and I cant catch exceptions inside arraycell function, otherwise I could golf it more. Who needs a built in function ??
Now I could just do it by hand, simplifying
binomial(n,2)=n/(2(n-2)!)=n(n-1)/2. remark that this last value
reprensents sum of integers from 1 to n-1, this doesnt throw any
exception in matlab, God bless maths.
Ps: this method is diferent than slvrbld's

Execution
  >> ans('abef')

  ans =

       2

  >> ans('abcd')

  ans =

       6

  >> ans('nature')

  ans =

       4

I think it's safe to remove ,'s' from input()'s arguments. Saves you 4 bytes. Furthermore, it seems to fail on longer strings (e.g. 'supercalifragilisticexpialidocious' that flodel used as test case) due to the hardcoded for-loop range... you may want to fix that.

@slvrbld i doont think i need that,see the newest edit

Ruby, 74
 ->s{[*0...s.size].permutation(2).count{|i,j|(s[i].ord-s[j].ord).abs==j-i}}

Nothing super interesting here.  I would have loved to use eval("s[i].#{["succ"]*(j-i)*?.}") but... seemed too long.

Jelly, 12 bytes
ONƬ_JLƙ€c2SS

Try it online!
Got too caught up in figuring out the best way to do this with Ẇ and forgot to post an answer at all, but now that I've remembered I think I might leave that as an exercise to @cjquines ;)

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

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


text:
Typesetting multidimensional labels
In a steam-punk multidimensional world, our boss wants to affix printed index labels to each drawer in our conglomerate's multidimensional file cabinet.
The boss wants to typeset the entire label sheet as a single form, using a font bought only for this purpose, so we have to order the sorts (metal symbol pieces). Since sorts are very expensive, our order must be for the exact count of each digit-symbol.
For a given (by any means) set of lengths of dimensions ≥ 0, return (by any means) our order, which is the frequency table of digits required to typeset all the Cartesian coordinates. It must be arranged by keyboard order of appearance (i.e. 0 after 9), and may not include orders of 0 sorts, so if no sorts are to be ordered at all (because a dimension has length 0); print nothing.

Bonus of -3 sorts if your code can handle (i.e. print nothing) 0 dimensions too.
Final newline chars are acceptable.
Prohibition on standard loopholes apply.
As mentioned, sorts are expensive, this is therefore codecolf.

A kind soul may edit this challenge to include automated scoring, so include a header like:# LanguageName, 123 sorts
Test cases
Given 11, print:
1 4
2 1
3 1
4 1
5 1
6 1
7 1
8 1
9 1
0 1

because the needed labels are 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, and 11.

Given 2 3, print:
1 5
2 5
3 2

because the needed labels are 1 1,  1 2,  1 3,  2 1,  2 2,  and 2 3.

Given 2 0, print an empty line:

or nothing.

Given 1 2 3, print:
1 11
2  5
3  2

because the needed labels are 1 1 1, 1 1 2, 1 1 3, 1 2 1, 1 2 2, and 1 2 3

Given 5 5 5 5, print:
1 500
2 500
3 500
4 500
5 500

And no, I'm not going to list all 625 labels.

I'm a little unclear about the output requirements. In the text, it says "return (by any means)", but the rest suggests that a very specific output format is required, and that it needs to be printed. Which one is it? E.g. talking about trailing newlines seems completely redundant if the output format can be anything.

@RetoKoradi the format has to look more or less as shown, but it may be in an interactive session, a file, a pop-up, STDOUT, etc. Do you have a suggestion as to how I could phrase this to make it clearer?

Dyalog APL, 10 7
The code is 10 bytes long and qualifies for the bonus.
Thanks to user46915 for 3 bytes!
,∘≢⌸∊⍕¨∊⍳⎕

Note that ⎕ (input) doesn't work on TryAPL; you can try the function form here.
            ⎕      Get input
           ⍳       Index vector
       ∊⍕¨∊        Flatten, stringify, flatten again
      ⌸            From the key, display the
{⍺,  }             elements concatenated with the
   ≢⍵              number of times they occur

I don't completely understand the ⌸ operator, but {⍺}⌸ lists the unique values taken on, and {⍵}⌸ lists their places in the argument.
This has the correct ordering because it is the order in which digits appear in the multidimensional array of labels.

Yup, that's the solution I had in mind. This may help understanding the ⌸ Key operator.

Doesn't APL always win at codegolf?

@vy32 No. APL may be the most concise general purpose language, But there will always be domain-specific languages that are better at a certain limited domain than any general purpose language. Within the specific domain of code-golfing, golfing languages like Pyth and CJam usually win. However, it is remarkable that APL, being a commercial  language used in production by very large companies, comes even close. Also, for the price of being slightly more verbose, it is probably easier for humans to learn to read APL than golfing languages.

Wait, so you mean I can make whole histogram simply with ,∘≢⌸ without any outer products with unique and such?! Dyalog sure is awesome. Also ,∘≢⌸ is shorter than {⍺,≢⍵}⌸.

@NBZ, I miss APL. Back in 1982 I wrote a graphics package in APL that drove a daisy wheel printer. It was a work of art, even though I didn't understand what I had written a month later.

Mathematica, 48 bytes - 3 = 45
Grid@Tally@Flatten@IntegerDigits@Tuples@Range@#&

That's beautiful.

R, 110 bytes
Saved 4 thanks to Alex A. (thanks!)
U=unlist
X=table(U(strsplit(as.character(U(expand.grid(Map(seq_len,scan())))),"")))
z=Map(cat,names(X),X,"\n")

You only use x once so you should just be able to replace the one occurrence of x with scan(). Also why assign z?

Thanks. Agree about not using x. I assigned the output of Map to a z variable otherwise Map would print its output to stdout. A better practice would be to wrap Map inside invisible() but that's a lot of characters...

Mathematica, 111 85 bytes
Grid[Thread@{Range@10~Mod~10,DigitCount@Tuples@Range@#~Total~2}~DeleteCases~{_,0}]&

Most of the work here is done by DigitCount.

Grid[Thread@{Range@10~Mod~10,DigitCount@Tuples@Range@#~Total~2}~DeleteCases~{_,0}]&

Ruby, 92 bytes
f,*r=$*.map{|n|[*1..n.to_i]}
a=f.product(*r)*''
puts a.chars.uniq.map{|c|[c,a.count(c)]*" "}

Takes the lengths as command line arguments:
$ ruby foo.rb 1 2 3
1 11
2 5
3 2

CJam, 31 bytes
Laq~{,m*}/e_:)s{_'0=A*+}$e`{(S\N}%

Try it online
Code is 34 bytes, and takes 3 byte bonus for working with empty input list. The input is a list in CJam format, e.g.:
[1 2 3]

Explanation:
La    Push list containing empty list to seed Cartesian products.
q~    Get and interpret input.
{     Loop over values in input list.
  ,     Built range from 0 to value-1.
  m*    Form Cartesian product with the list we already have.
}/    End loop over values in input list.
e_    Resulting list has extra nesting. Flatten it.
:)    Increment all values in list, since it is 0-based, and we need 1-based.
s     Convert it to string, so we can operate on digits.
{     Block to calculate source key, needed to get 0 to the end.
  _     Copy the digit.
  '0=   Compare with '0.
  A*    Multiply comparison result by 10...
  +     ... and add it to digit.
}$    End of sort key block.
e`    RLE.
{     Start of loop over RLE entries, for generating output in specified format.
  (     Pop off the first value, which is the count.
  S     Push a space...
  \     ... and swap it with the count.
  N     Push a newline.
}%    End of loop over RLE entries.

Pyth, 15 bytes
rjko%N_Ts*FSMQ8

Haskell, 125 bytes
import Data.List
l=mapM_(putStrLn.(\(h:r)->h:' ':show(length r+1))).group.sort.concatMap show.concat.sequence.map(\n->[1..n])


text:
Make a Virtual Pet
Anyone remember these things?

Your challenge today is to make the shortest program that involves your pet growing into 1 of at least 7 different creatures.
Your creature will grow into different forms depending on a random percentage from an RNG and the name you give it (from STDIN or equivalent for your language) at each stage the two possible creatures it could develop in must differ. To determine how the name affects growth use the ascii codes for each character and math operations (as you please) that converts the name to a percentage. For example:
sum(ASCII value for chars in name) % 101 / 100
E.g. "Joe": (74 + 111 + 101) % 101 / 100 = 286 % 100 / 100 = 84 / 100 = 84%

This can then affect the growth like so: Rarity (as %) * Name (as %)
E.g. 40% * 84%* = 33.6% - This means there is a 33.6% chance it will advance into the rarer
of the two possible creatures and a 66.4% it will advance to the other creature.

Your pets life has 4 stages Birth -> Teenager -> Adult -> Death"= Each stage must be printed to STDOUT.
Your can create random creature names for your pets but they must be at least 5 characters long (bonus points for creativity), you can also choose the rarity yourself.
This is code golf - usual rules apply - shortest program in bytes wins!
Example:
                             +-> Adult1 (75%) - 45% (Most Common)
             +-> Teen1 (60%) +
             |               +-> Adult2 (25%) - 15%
Child (100%) +
             |               +-> Adult3 (90%) - 36%
             +-> Teen2 (40%) +
                             +-> Adult4 (10%) - 4% (Super rare)

Input:
Joe

Output:
Joe was born.
Joe grew into Teen2.
Joe grew into Adult3.
Joe died.

This is some deep predestination stuff we're getting into.

Welcome to PPCG. This spec isn't tight enough for codegolf. For example "math operations (as you please)" is open to abuse. I might chose to ignore the name totally (as I pleased) to make the code shorter, and just use the same probability for all names. YOU need to specify the way the name should be used. Species at least 5 characters long is fine, but note that (for example) a Ruby coldgolfer's idea of "creative" is "aaaaa" "aaaaaa" etc as these can be expressed as for example ?a*n· If you don't like that, say that each species must be a string and these are excluded from character count.

Writing a good challenge is hard. Please stick around, answer a few questions, and consider posting your next challenge to the sandbox http://meta.codegolf.stackexchange.com/q/2140/15599 for feedback.


text:
Write a Blade Templating Engine
Blade is a PHP templating engine. For this challenge, you only need to implement a modified version one feature -- text replacement.
Challenge Description
Given an input file and a map of keys to their replacements, write an interpreter that reads through the file to find double open braces ({{) followed by a key, followed by double closing braces (}}). Whitespace inside the braces should be ignored, unless it is inside of the key.
Requirements
If a key is not found in the map, your program should exit without outputting anything
Keys must be nestable. See the examples for a valid nesting example.
Keys may contain any character, but cannot start or end with a space. Whitespace should be trimmed from the start and end of the key.
Example input/output
Input blade file:
Hello, {{user_{{username }}}}! It is { NICE } to meet you!
My name is {{     my n@m3}}!

Input map:
{
'user_Joe': 'Joseph, user #1234',
'username': 'Joe',
'my n@m3': 'Henry'
}

Expected output:
Hello, Joseph, user#1234! It is { NICE } to meet you!
My name is Henry!

Marking:
Feel free to hard code input/output and exclude it from your byte count. However, if you implement the following features, take the corresponding value away from your byte count.
Read filename of blade template from stdin or arguments: 15 bytes
Read variable mapping as JSON from stdin or arguments: 20 bytes
Read variable mapping in any other format from stdin or arguments: 12 bytes
Bonus
Allow calculations (+, -, *, /, %, etc) in your blade script. Example input file:
{{a + b}}

Input map:
{ 'a': 1, 'b': 4 }

Expected output:
5

Keys may contain any character including { and }?

True. in fact, the following key should be valid: '<?>#{dfd    }E}{}3'

Then how are you supposed to decide if {{ or }} is part of a set of braces or part of the name of a key?

If there are two of the same brace in a row, it is safe to assume that it is part of a set. If there is only 1 in a row, it may be part of a key or part of the text left alone

Perl: 105 - 15 - 20 = 70
perl -MJSON -pE'sub f{$_[0]=~s#{{\s*((.*?(?R)?.*?)+)\s*}}#$h->{f($1)}#reg};BEGIN{$h=from_json shift};$_=f$_' 'JSON' <input

Usage: the JSON is given as a command line argument. The template source is passed in STDIN. Example:
$ perl ... '{"user_Joe":"Joseph, user #1234","username":"Joe","my n@m3":"Henry"}'
>Hello, {{user_{{username }}}}! It is { NICE } to meet you!
>My name is {{     my n@m3}}!

(where lines beginning with > are pasted/typed/piped in)
Restrictions:

can't do arithmetic.
keys cannot span multiple lines.
requires the JSON Perl module to be installed (non-standard).
requires a new-ish perl (tested on Perl5 v20, but should work on at least v16 or v14).

I am not sure about the scoring rules, so I excluded perl·, the quotes for the code, and included an extra space and two quotes needed to pass the JSON on the command line.
Explanation:
Perl regexes can be recursive, but substitutions can't. To overcome this, we first define a regex that matches keys that might contain keys again: {{\s* ((.*? (?R)? .*?)+) \s*}}. Here, (?R) recurses into the whole pattern. The key does not have to contain a template tag, so the recursion is optional. In that case, the pattern is a non-greedy “match anything”: .*?.*?. This will terminate given a double closing braces. Usually braces are metacharacters in regexes, e.g. a{10,20} (match 10 to 20 "a"s). Fortunately, the regex compiler recognizes that these braces are not used as quantifiers.
Once we have matched the (possibly recursive) tag contents, we pass it to the function f which again applies the substitution to this content. The result is then used as a key in a hash reference $h, which replaces the tag contents. This is done non-destructively /r and globally /g.
The $h hash reference is defined in the BEGIN phase to the json-decoded value of the first command line argument. Since the sub f definition and the BEGIN block are done before the main execution, the actual script is perl -pE'$_=f$_', which applies our substitution function f to each line.
Voilà, a template engine is born :)

It's beautiful. Thanks for your submission!


text:
Stack Exchange Vote Simulator
Write a program or function that takes in a string only containing the characters ^ and v (you can assume there will be no other characters). Read from left to right this string represents the sequence of mouse clicks a single user made while viewing a Stack Exchange question or answer for the first time.
Every ^ represents a click of the upvote button and every v represents a click of the downvote button. (For working examples look slightly left.)
Assume that no voting limitations are in effect so all the clicks are registered correctly.
Print or return:

1 or +1 if the post ends up being upvoted.
0 if the post ends up not being voted on. (-0 and +0 are not valid)
-1 if the post ends up being downvoted.

Posts start with zero net votes from the user and the buttons change the net votes as follows:
Net Votes Before    Button Pressed    Net Votes After
1                   ^                 0
1                   v                 -1
0                   ^                 1
0                   v                 -1
-1                  ^                 1
-1                  v                 0

The shortest code in bytes wins.
Test cases:
[empty string] -> 0
^^ -> 0
^v -> -1
^ -> 1
v -> -1
v^ -> 1
vv -> 0
^^^ -> 1
vvv -> -1
^^^^ -> 0
vvvv -> 0
^^^^^ -> 1
vvvvv -> -1
^^^^^^ -> 0
vvvvvv -> 0
^^v -> -1
^v^ -> 1
^vv -> 0
vv^ -> 1
v^v -> -1
v^^ -> 0
^vvv^^vv^vv^v^ -> 1
^vvv^^vv^vv^v^^ -> 0
^vvv^^vv^vv^v^^^ -> 1
^vvv^^vv^vv^v^^v -> -1
^vvv^^vv^vv^v^^vv -> 0
^vvv^^vv^vv^v^^vvv -> -1
^vvvvvvvvvvvv -> 0
^^vvvvvvvvvvvv -> 0
^^^vvvvvvvvvvvv -> 0
vvv^^^^^^^^^^^^ -> 0
vv^^^^^^^^^^^^ -> 0
v^^^^^^^^^^^^ -> 0

What? no side voting? Geoborts and Seadrus are sad

Dear Secret SE Developer: Congratulations on successfully duping your own community into making site improvements for you... ;)

I've been starring at the example table for a while now and I still don't get the test cases. a post with a score of 1 gets up-voted and it then has a score of 0. And a post with a score of 0 gets up-voted to have a score of 1. And  post with a score of -1 gets up-voted to have a score of 1. So the ^ character can cause a -1, +1 or +2 score change? Am I dense where? What's going on?

@Brad I suggest you try the actions with some actual post (e.g. this question itself). Upvoting a post you already upvoted undoes the upvote. Same with downvoting.

@Calvin'sHobbies oooooh I am dense :) It was the No voting limitations line that was throwing me for a loop. It all makes sense now!

I wonder what the real-time votes on this question was. I'm willing to bet a lot of people used this question as a test case.

Gol><> 0.3.11, 13 12 11 bytes
iEh`^=:@)+M

Try it online. Even though this will work fine in the next update, I've listed it as 0.3.11 just in case.
Explanation
i               Read char
 Eh             If EOF, halt and output top of stack as num
   `^=          Push 1 if char is ^, else 0
      :@        Dup and rotate, giving [is^ is^ votecount]
        )       Compare greater than, pushing 1 or 0 as appropriate
         +M     Add and subtract 1

Note that the first use of @ pulls a 0 from the bottom of the stack to initialise the vote count for the first iteration
To illustrate with a full table:
Votes before    Button    Is ^?    Compare <    Add     Subtract 1
     1            ^         1         0          1          0
     1            v         0         0          0         -1
     0            ^         1         1          2          1
     0            v         0         0          0         -1
    -1            ^         1         1          2          1
    -1            v         0         1          1          0

....dang! Nice one!

JavaScript (ES7), 47 46 44 43 37 36 bytes
Crossed out 44 is still regular 44 :(
s=>[for(x of s)s=x<"v"?s!=1:!~s-1]|s

Keeps a running total in s. Uses for of loop to iterate over each character in the string and updates s based on current character and previous value.
Edits: Golfed ~s&&-1 to !~s-1. This expression has to equal 0 if s equals -1 and -1 otherwise. Saved 6 bytes thanks to @nderscore.
How the expression works:
 ~s    // Bitwise inverse. ~s==0 only if s==-1
!      // Logical negate. Casts to boolean. Equivalent to s==-1
   -1  // Subtract. Casts to number so true-1 is 1-1 and false-1 is 0-1

I got it down to 37 bytes: v=>[for(x of v)v=x<"v"?~~v<1:!~v-1]|v

@nderscore Hey, that's great. I thought the extra variable was clumsy, but didn't think I could eliminate it.

Crossed out 44 is still regular 44...

Weren't array comprehensions removed from the spec?

x86 machine code, 24 bytes
31 C0 8A 11 84 D2 75 07 C0 E0 02 C0 F8 06 C3 41 38 C2 74 EC 88 D0 EB EA

This is a function using the fastcall calling convention, which takes a string and returns an 8-bit integer.
I tested it with the following C program, which must be compiled for 32-bit mode.
#include <stdio.h>
#include <inttypes.h>

 __attribute__ ((aligned (16))) const unsigned char fun[] = {

    0x31,  //xor eax,eax
        0xC0,
    0x8A, //mov [ecx],dl
        1 | 2<<3,
    0x84, //test dl, dl
        0xC0 | 2<<3 | 2,
    0x75, // jnz
        7,
    0xC0, //shl al 2
        0xC0 | 4<<3,
        2,
    0xC0, //sar al 6
        0xC0 | 7<<3,
        6,
    0xC3, //ret
    0x41, //inc ecx
    0x38, //cmp al,dl
        0xC0 | 2,
    0x74, //je
        -20,
    0x88, //mov dl,al
        0xC0 | 2<<3,
    0xEB, //jmp
        -22,
};

int main()
{
    __fastcall int8_t (*votesimulator)(char*) = fun;
    char* s[] = {
        "",
        "^^",
        "^v",
        "^",
        "v",
        "v^",
        "vv",
        "^^^",
        "vvv",
        "^^^^",
        "vvvv",
        "^^^^^",
        "vvvvv",
        "^^^^^^",
        "vvvvvv",
        "^^v",
        "^v^",
        "^vv",
        "vv^",
        "v^v",
        "v^^",
        "^vvv^^vv^vv^v^",
        "^vvv^^vv^vv^v^^",
        "^vvv^^vv^vv^v^^^",
        "^vvv^^vv^vv^v^^v",
        "^vvv^^vv^vv^v^^vv",
        "^vvv^^vv^vv^v^^vvv",
        "^vvvvvvvvvvvv",
        "^^vvvvvvvvvvvv",
        "^^^vvvvvvvvvvvv",
        "vvv^^^^^^^^^^^^",
        "vv^^^^^^^^^^^^",
        "v^^^^^^^^^^^^",
    };

    for(int i = 0; i < sizeof(s)/sizeof(*s); i++)
        printf("%d\n", votesimulator(s[i]));

    printf("\n%d\n", sizeof(fun));
    for(int i = 0; i < sizeof(fun); i++)
        printf("%02X ", fun[i]);
    return 0;
}

Is this allowed? I mean I could also write the whole thing in C and just say the C code requires an empty file for performing the task while saying my code is the framework making my code becoming 0bytes. Why is that diferent from your solution?

@Zaibis Because my solution contains the code that solves the challenge? See http://meta.codegolf.stackexchange.com/a/1071/30688.

CJam, 18 14 bytes
Updated version with significant improvements contributed by Dennis:
0'jqf{-g_@=!*}

Try it online
Explanation:
0     Start value for running total.
'j    Push character between '^ and 'v for use in loop.
q     Get input.
f{    Apply block with argument to all input characters.
  -     Subtract character from 'j. This will give -12 for '^, 12 for 'v.
  g     Signum, to get 1 for '^, -1 for 'v, which is our increment value.
  _     Copy increment value.
  @     Bring running total to top.
  =     Compare. This will give 1 for the -1/-1 and 1/1 combinations where the new
        running total is 0. Otherwise, the new running total is the increment value.
  !     Negate to get 0 for the -1/-1 and 1/1 cases.
  *     Multiply result with increment value, to get new running total.
}     End block applied to input characters.

Befunge 93 - 55 bytes
vj#p01:>#<:1+|
>~:10g-|v:g25<
^p01"j"<1^   <
./*34-g0<@

52 characters and 3 new lines.
Tested on this interpreter.
The j is equidistant from ^ and v in ascii so it's used to make arithmetic conversions in the end, rather than space consuming conditionals.

Python 2, 49
lambda s:reduce(lambda x,c:cmp(cmp('u',c),x),s,0)

Iterates through with the update function
lambda x,c:cmp(cmp('u',c),x)

that takes the current vote count x and the new character c and outputs the new vote count.
The idea is to use Python 2's cmp function, which compares its two args and gives -1, 0, 1 for <, ==, > respectively. The inner one cmp('u',c) gives -1 for v and 1 for ^; any character between them suffices for 'u'. The outer one then compares that to x, which gives cmp(1,x) for ^ and cmp(-1,x) for v, which have the right values.
Direct iteration was 3 chars longer (52), though would be one char short (48) if taking an input() with quotes was allowed.
x=0
for c in raw_input():x=cmp(cmp('u',c),x)
print x

The best recursive function I found was one char longer (50)
f=lambda s:len(s)and cmp(cmp('u',s[-1]),f(s[:-1]))

brainfuck, 146 bytes
,[[>->+<<-]>[[-]>[<+>-]]>[-]<<[<],]----[>-----<--]--[>>+<<++++++]+>[<-]<[->>++.<++++[<------>-]]>[<+<<]----[>+++++<--]>[,+<]>>[<<]-[>+<-----]>---.

This program takes each byte of input and compares it against the last. If they're the same, it throws the input away and stores "0" as the "previous input", otherwise it saves it normally.
If the final result is v, it prints -. If the final result was non-zero, 1 is added to an empty cell. Finally, 48 is added to that cell and it is printed.

Javascript ES6, 91 48 chars
s=>~~{'^':1,v:-1}[s.replace(/(.)\1/g).slice(-1)]

Explanation: undefined ends by d.
Test:
` -> 0
^^ -> 0
^v -> -1
^ -> 1
v -> -1
v^ -> 1
vv -> 0
^^^ -> 1
vvv -> -1
^^^^ -> 0
vvvv -> 0
^^^^^ -> 1
vvvvv -> -1
^^^^^^ -> 0
vvvvvv -> 0
^^v -> -1
^v^ -> 1
^vv -> 0
vv^ -> 1
v^v -> -1
v^^ -> 0
^vvv^^vv^vv^v^ -> 1
^vvv^^vv^vv^v^^ -> 0
^vvv^^vv^vv^v^^^ -> 1
^vvv^^vv^vv^v^^v -> -1
^vvv^^vv^vv^v^^vv -> 0
^vvv^^vv^vv^v^^vvv -> -1
^vvvvvvvvvvvv -> 0
^^vvvvvvvvvvvv -> 0
^^^vvvvvvvvvvvv -> 0
vvv^^^^^^^^^^^^ -> 0
vv^^^^^^^^^^^^ -> 0
v^^^^^^^^^^^^ -> 0`
.split("\n").map(s => s.split(" -> "))
.every(([s,key]) => (s=>~~{'^':1,v:-1}[s.replace(/(.)\1/g).slice(-1)])(s)==key)

Answer history:
s=>({'':0,'^':1,v:-1}[s.replace(/^(.)\1(\1\1)*(?=.?$)|.*(.)(((?!\3).)\5)+/,"").substr(-1)])
s=>~~{'^':1,v:-1}[s.replace(/^(.)\1(\1\1)*(?=.?$)|.*(.)(((?!\3).)\5)+/,"").substr(-1)]
s=>~~{'^':1,v:-1}[s.replace(/^.*(.)(((?!\1).)\3)+|(.)\4(\4\4)*/,"").substr(-1)]
s=>~~{'^':1,v:-1}[s.replace(/^.*(.)(((?!\1).)\3)+|(.)\4(\4\4)*/,"").slice(-1)]
s=>~~{'^':1,v:-1}[s.replace(/.*(.)(((?!\1).)\3)+|(.)\4(\4\4)*/,"").slice(-1)]
s=>~~{'^':1,v:-1}[s.replace(/.*(.)(((?!\1).)\3)+|((.)\5)*/,"").slice(-1)]
s=>~~{'^':1,v:-1}[s.replace(/((.)\2)+/g,"!").slice(-1)]
s=>~~{'^':1,v:-1}[s.replace(/(.)\1/g,"!").slice(-1)]
s=>~~{'^':1,v:-1}[s.replace(/(.)\1/g,0).slice(-1)]
s=>~~{'^':1,v:-1}[s.replace(/(.)\1/g).slice(-1)]

Prolog, 159 152 bytes
Code:
v(1,^,0).
v(1,v,-1).
v(0,^,1).
v(0,v,-1).
v(-1,^,1).
v(-1,v,0).
r(X,[H|T]):-T=[],v(X,H,Z),write(Z);v(X,H,Z),r(Z,T).
p(S):-atom_chars(S,L),r(0,L).

Test it yourself:
Online Interpreter here

Example
>p("^vvv^^vv^vv^v^^vvv").
-1

>p("^vvv^^vv^vv^v^")
1

Edit: Saved 7 bytes by unifying r-clauses with OR.

Hmm. It seems like you could save quite a few bytes by redefining operators instead of defining functions (if that counts as a function under PPCG's rules?)

@ASCII-only: Yeah. Hadn't learned that trick when I wrote this :)

CJam, 16 bytes
0re`W=(2%*c'a--g

This will crash after printing 0, if applicable. The error can be suppressed with the Java interpreter. If you try this online, ignore everything but the last line of output.
How it works
0                e# Push a 0 on the stack.
 r               e# Read a whitespace-separated token from STDIN.
  e`             e# Perform run-length encoding.
    W=           e# Select the last [repetitions character] pair.
                 e# This will fail for the empty string, so the
                 e# interpreter will print the stack's only element (0).
      (          e# Shift out the number of repetitions.
       2%        e# Compute its parity.
         *       e# Create a string, repeating the character 1 or 0 times.
          c      e# Cast to character.
                 e# This will fail for a zero-length string, so the
                 e# interpreter will print the stack's only element (0).
           'a-   e# Subtract the character 'a' from '^' or 'v'.
              -  e# Subtract the difference (integer) from 0.
               g e# Apply the sign function.

JavaScript (ES6), 64 59 58 52 bytes
f=v=>(t=/\^*$|v*$/.exec(v)[0]).length*(t<'v'?1:-1)%2

This is based on the observation that only the last stretch of the repetition (of either ^ or v) affects the result.
Thanks to Neil for golfing off 6 bytes.

Why do you need the captures? Seems to me f=v=>(t=/\^*$|v*$/.exec(v)[0]).length*(t<'v'?1:-1)%2 suffices.

@Neil: I'm not aware of array being coerced to the first element in > or < operator. Thanks for the tips

No type coercion involved, I merely moved the [0] which may have confused you.

@Neil: Oh, I indeed am confused. I didn't realized that you have moved it inside, I thought it was f=v=>(t=/\^*$|v*$/.exec(v))[0].length*(t<'v'?1:-1)%2, which works due to type coercion with array.

Haskell, 40 bytes
1%'^'=0
_%'^'=1
1%_=-1
_%_=0
v=foldl(%)0

You can cut all the spaces by defining f as an infix function %. Also, I think the v can be a _.

Actually, doesn't this give -1 for vv instead of 0?

Oh, I always forget about infixes. Thanks for the spot, missed the inner inversion.

Save 3 characters by replacing the third line (15 characters) with 1%_=-1 _%_=0, 12 characters.

Okay right, now that's become shorter.

Python 2, 177 159 72 bytes
Still kinda new to this code golf thing.
def v(s):
 c=0
 for i in s:c=((0,1)[c<1],(0,-1)[c>-1])[i=="^"]
 return c

EDIT: Fixed the incorrect behavior.
EDIT 2: Thanks @MorganThrapp for shaving off lots of bytes.

You can shorten it to def v(s):  c=0  for i in s:c=((0,1)[c<1],(0,-1)[c>-1])[i=="^"]  return c. That's 72.

@MorganThrapp Thanks, I didn't know about the (,)[] thing.

Yeah, it's super helpful. If you haven't yet, read the tips for golfing in Python thread.

That indentation isn't quite right, I just suggested an edit with the right indentation. You can't format code in comments, so it was wrong in mine.

I believe this should be either i!="^" or i=="v". You can also use the fact that True/False corresponds to 1/0 for 60 bytes

Scala, 75 bytes
def d(s:String)=s./:(0){case(1,94)|(-1,'v')=>0;case(_,94)=> 1;case _=> -1}

Test for implemented function.
  object Util {
        def d(s: String) = s./:(0) {
    case (1, '^') | (-1, 'v') => 0
    case (_, '^') => 1
    case (_, _) => -1
  }
      def main(s: Array[String]): Unit = {
        println("1 == " + d("^vvv^^vv^vv^v^^^"))
        println("1 == " + d("^vvv^^vv^vv^v^"))
        println("-1 == " + d("^vvv^^vv^vv^v^^vvv"))
        println("0 == " + d("^^^vvvvvvvvvvvv"))
        println("0 == " + d("vvv^^^^^^^^^^^^"))
      }
    }

Welcome to PPCG! Could you please add an explanation and/or an ungolfed version?

APL, 17
(⊣×≠)/⌽0,2-'^ '⍳⍞

For interpreters without fork notation (like GNU APL), it would be {⍺×⍺≠⍵}/⌽0,2-'^ '⍳⍞ (19).
This is probably the most boring of possible solutions because it works directly from the definition of the problem.

Ruby, 41 35 bytes
Regex. Only the last button pressed is interesting, so check the run-length of that. Then compare it to "a" (or any letter between ^ and v) to get 1 or -1.
->s{s[/(.?)\1*$/].size%2*(?a<=>$1)}

C# 6, 18 + 80 = 98 bytes
Requires:
using System.Linq;

Actual function:
int S(string v)=>v.Split(new[]{"^^","vv"},0).Last().Length<1?0:v.Last()<95?1:-1;

How it works: the code first removes everything before the last ^^ or vv. That content is not relevant because clicking the same button twice will always cancel your vote. It does this by splitting on ^^ and vv and taking the last item. If this item is an empty string (.Length<1), then the function returns 0 because all voting has been cancelled. If the string it not empty, then it just looks at the last char of the original string: it will override all previous votes. If the char code is smaller than 95, then it will be 94, ^, so it returns 1, otherwise -1.

Python 2.7, 79 75 88
s=input()
print (0,(1,-1)[s[-1]=='v'])[len(s[s.rfind(('v^','^v')[s[-1]=='v'])+1:])%2!=0]

This doesn't actually print anything.

Running it in my interpreter, it shows the output of the last line

That's because you're running it in the REPL. You need to provide a full program that will work outside the REPL.

Also, you can shorten that ternary to (-1,(1,0)[n==0])[n>0] to save 10 bytes. Also, don't use a=str.count. It actually costs  you 4 bytes.

That produces -1 for n=0, but cool syntax

I get 1 for '^^', '^v' is wrong too. If you want the test suite I have from my own try, it's here. https://bpaste.net/show/8971c60607b9

Where can I find documentation on that syntax?

Let us continue this discussion in chat.

You can use print cmp(n,0) as your last line (since you're using Python 2), which means you could use print cmp(s.count('^')-s.count('v'),0). cmp documentation

This doesn't actually work, so it should really be deleted while you fix it.

Go, 179 bytes
An extremely naive solution.
package main
import(."fmt"."strings")
func main(){a:=""
i:=0
Scanln(&a)
b:=Split(a,"")
for _,e:=range b{switch i{case 1:i--
case 0:if e=="^"{i++}else{i--}
case-1:i++}}
Println(i)}
Ungolfed:
package main

import (
    ."fmt"
    ."strings"
)

func main() {
    a := ""
    i := 0
    Scanln(&a)
    b := Split(a, "")
    for _, e := range b {
        switch i {
        case 1:
            i--
        case 0:
            if e == "^" {
                i++
            } else {
                i--
            }
        case -1:
            i++
        }
    }
    Println(i)
}

05AB1E, 8 bytes
γ¤®öÓÆ.±

Try it online!
Alternative solutions with the same length: uγ¤®öÓÆ(, γ¤®ögÓÆ(.

This doesn't work. Neither your posted code nor the code in the TIO link (which is different) take into account votes like ^^ -> 0

@Emigna thanks for pointing it out! I fixed the code, it’s still 8 bytes.

Minkolang 0.11, 28 22 bytes
0$I2&N."j"o-34*:dr=,*!

Try it here.
Explanation
0                         Push a 0 (running total)
 $I                       Push length of input
   2&N.                   Output as integer and stop if this is 0
       "j"                Push 106
          o               Take character from input (94 for ^, 118 for v)
                          <<so ^ becomes +12 and v becomes -12>>
           -              Subtract
            34*:          Divide by 12
                d         Duplicate top of stack
                 r        Reverse stack
                  =,      Push 0 if equal, 1 otherwise
                    *     Multiply
                          <<this handles two of the same vote in a row>>
                     !    Unconditional trampoline (jumps the 0 at the beginning)

Note that there is no N. at the end. That's because I let it wrap around to the beginning. When the input is empty, the final tally is output as integer and the program stops.

Pyth, 13 bytes
ut+Jq\^H>JGzZ

Mathematica, 60 bytes
Mod[#,2]Sign@#&@Tr@Last@Split@StringCases[#,{"^"->1,_->-1}]&

@#&? That's useless (unless Sequences are involved, but Sequences are not involved.

Shape Script, 26 bytes
"^"$"0>1@-"~"v"$"0<1-"~0@!

How it woks:
"^"$     split input on '^'
"
  0>         Check if the number is more than 0 (1 if true, 0 if false).
  1@-        subtract the answer from one.
"~       Join it back together, with this string in place of '^'
"v"$     Split on 'v'
"
  0<         Check if 0 is more than the number (1 if true, 0 if false).
  1-         subtract one from the results
"~       Join it back together, with this string in place of 'v'
0@       add a zero to the stack and place it under the string just built.
!        run the string as code

Perl 5, 41 bytes
40 bytes, plus 1 for -p
/(.)\1*$/;$_=((length$&)%2)*($1=~v?-1:1)

/(.)\1*$/; compares the input string to the regex /(.)\1*$/, i.e. sees whether it ends with a single character repeated some number ≥1 of times.
If so, $& is the whole repetition string and $1 is the character; otherwise (i.e. the input string is empty), those two variables are the empty string.
$1=~v?-1:1 compares $1 to the regex v and returns −1 if it matches and 1 otherwise.
And multiply that ±1 by (length$&)%2, the length of $& modulo 2.

C# 6, 18 + 97 95 = 115 113 bytes, no string methods, excessive LINQ
int v(string s)=>(int)s.Reverse().TakeWhile((c,i)=>i<1||c==s[s.Length-i])?.Sum(x=>x<95?1:-1)%2;

Truly deserves to be preceded by
using System.Linq;

Got the idea of using x<95?1:-1 instead of x=='^'?1:-1 from ProgramFOX's answer
Coincidences:

The tweak I stole makes use of comparing to 95 – the byte count excluding the using statement, using said tweak
The sum of the digits of the total byte count equals the number of digits of the total byte count written as roman numeral

C: 67 66 Bytes
golfed:
void f(char *v){int i=0,c,s=0;for(;v[i]!=0;i++){v[i]>94?s--:s++;}}

ungolfed:
void f (char *v)
{
    int i = 0, c, s = 0;

    for (;v[i]!=0;i++)
    {
        v[i] > 94 ? s-- : s++;
    }
}

This does not return a result. It does not pass all tests.

05AB1E, 14 12 11 bytes
Îvy'^QDŠ‹+<

Port of @Sp3000's Gol><> answer.
NOTE: @Grimy already posted a shorter 8 bytes alternative for 05AB1E, so make sure to upvote him!
Try it online or verify all test cases.
Explanation:
Î            # Push 0 (later mentioned as `r`) and the input-string
 v           # Loop over the characters of the input:
  y'^Q      '#  Does the current character equal "^"?
             #  (results in 1 for truthy; 0 for falsey - later mentioned as `b`)
      D      #  Duplicate this result `b`
       Š     #  Triple swap (`r`,`b`,`b`) to (`b`,`r`,`b`)
        ‹    #  Check if the boolean `b` is smaller than the result-integer `r`
             #  (again results in 1 for truthy; 0 for falsey)
         +   #  Add them together
          <  #  Decrease this by 1
             # (Implicitly output the result-integer `r` after the loop)

CJam, 27 24 bytes
'^_]r+e`W=(2%\(i99-g@*W*

Try it Online.
All I took from Dennis' answer is g (sign function) .

Ruby, 43
->s{a=0
s.bytes{|i|b=9-i/11;a=a!=b ?b:0}
a}

9-i/11 evaluates to 1 or -1 when given the ascii codes of ^ (94) or v (118)
In test program:
f=->s{a=0
s.bytes{|i|b=9-i/11;a=a!=b ?b:0}
a}

g=gets.chomp
puts f[g]

C (107 bytes)
#include<stdio.h>
int c,t;main(){while((c=getchar())-'\n')(c=='^')?++t:((c=='v')?--t:0);printf("%d\n",t);}

C++, 90 87 bytes
int f(char* c){int r=1,T[2][3]={{2,2,1},{1,0,0}};while(*c)r=T[*c++==94][r];return r-1;}

Ungolfed:
int f( char* c )
{
     // Lookup table created from Golfing description. Need to shift values up by 1
     // because will be using them to index table later
     int lookup_table[ 2 ][ 3 ] = {{2, 2, 1}, {1, 0, 0}};
     int result = 1;                 // empty string result: 1
     while ( *c )                    // check if end of string
     {
          int  row    = *c - '^' ? 1 : 0; // if char is '^' search in second row else in first
          auto column = result;           // column to look for is current result
          result      = lookup_table[ row ][ column ];
          c++;
      }
      return result - 1;                  // make expected result
 }

hehe finally got to write c++ in C++ ;-)
Edit:

Exchanged tenary row calculation to simple boolean expression.

Suggest (char*c) and return~-r instead of return r-1

@ceilingcat Great! Thanks.

Braingolf, 17 bytes
VR{.#veM|}lvlMR-s

Try it online!
Thought I could get it shorter by subtracting 9 from the charcodes of each character, then using J to change vowels to 1 and non-vowels to 0, but it turned out to be the same length

Turing Machine Code, 115 bytes
init:r
accept:e
r,^
^,_,>
r,v
v,_,>
r,_
e,0,-
^,^
r,_,>
^,v
r,v,-
^,_
e,1,-
v,^
r,^,-
v,v
r,_,>
v,_
w,-,>
w,_
e,1,-

Try it here
Ungolfed:
//-------CONFIGURATION
init: startread
accept: end

//startread
startread,^
read^,_,>

startread,v
readv,_,>

startread,_
end,0,-

//read^
read^,^
startread,_,>

read^,v
startread,v,-

read^,_
end,1,-

//readv
readv,^
startread,^,-

readv,v
startread,_,>

readv,_
write-,-,>

write-,_
end,1,-

The approach I used was to compare every two adjacent characters and either remove them if they canceled, or to remove just the first if the second one were to overwrite the first. An extra state is needed so that -1 can be written, because this simulator does not support multi-symbol cells.

Japt, 17 bytes
¬®c nL gÃrÈ-Y©Y}0

Try it online!
Unpacked & How it works
Uq mZ{Zc nL g} rXY{X-Y&&Y}0

Uq     Convert the input string into list of chars
mZ{    Map...
Zc       Get charcode
nL       100 - charcode
g        sign(100 - charcode)
}
rXY{   Reduce...
X-Y&&Y   If X == Y, return 0; Otherwise, return Y
}0     ... default being 0

Having an array of -1s and 1s at hand yields a nice reducing function.

PHP 5, 47 bytes
Run on the command line, using php -nR 'code here'. The option -R counts as one byte.
echo(strrpos($s=x.$argn,"^")-strrpos($s,v))%2;

Julia 0.6, 38 bytes
s->foldl((x,c)->cmp(cmp('u',c),x),0,s)

Try it online!
Julia version of xnor's answer. (Uses foldl instead of reduce to save a byte.)

Jelly, 9 bytes
ŒgṪO³_^/Ṡ

Try it online!
Assumes the program this function is in doesn't take command-line arguments.
For a 10-byte version that doesn't assume so:
ŒgṪOȷ2_^/Ṡ

Try it online!

Perl 5 -pF, 32 bytes
$\=int(/v/?-($\>=0):$\<1)for@F}{

Try it online!

authors: n̴̖̋h̷͉̃a̷̭̿h̸̡̅ẗ̵̨́d̷̰̀ĥ̷̳


text:
What am I even saying?
You're playing TF2, and you want to make a bot that will just put voice commands into the chat box. Typically, to "call" a voice command, one would press a key (Z, X, or C) and a number (1-8) to create an audio dialogue. Here are the text equivalents of the audios displayed when pressing these keys:
Voice Menu 1
Default key: Z
==============
1. MEDIC!
2. Thanks!
3. Go Go Go!
4. Move Up!
5. Go Left
6. Go Right
7. Yes
8. No

Voice Menu 2
Default key: X
==============
1. Incoming
2. Spy!
3. Sentry Ahead!
4. Teleporter Here
5. Dispenser Here
6. Sentry Here
7. Activate ÜberCharge!
8. MEDIC: ÜberCharge Ready   ; ignore the MEDIC: bit

Voice Menu 3
Default key: C
==============
1. Help!
2. Battle Cry    ; see bonus
3. Cheers
4. Jeers
5. Positive
6. Negative
7. Nice Shot
8. Good Job

Objective Given an input string (or input character + character, character + number, etc.; whatever is most relevant/convenient to your language), take the respective message from the chart above and output it. If the input is invalid, do not output anything. This is a code-golf, so the shortest program in bytes wins.
Example IOs
> Z3
Go Go Go!

> Z1
MEDIC!

> Z5
Go Left

> X8
ÜberCharge Ready

> X7
Activate ÜberCharge!

> C1
Help!

> C8
Good Job

Bonuses/penalties
These bonuses are applied in the order of appearance in this list.

-1 byte for every byte used in the physical text of C2 (i.e., Battle Cry); I will not add points for errors on C2, so be creative if you wish! (By physical text, I mean every byte used for constructing (not outputting) the string. For example, for STDOUT "AHHHHHHHH!", "AHHHHHHHH!" is free, but nothing else is. In console.log(`${v="Tha"}t's too you, you idiot!`), the free characters are `"Tha" t's too you, you idiot!`. These characters are the only ones that make up part of the string and their respective quotes.)
-15% if your program takes input and outputs the respective entry until an invalid input is given, at which point your program should terminate.
+5 bytes for every capitalization, punctuation, or spacing error
+10 bytes for every wrong/missing letter
-20 bytes if you can take a string like "X5C3Z6..." and output each respective message, separated by newlines.
-30 bytes if you take a class input (either Scout, Soldier, Pyro, Demoman, Heavy, Engineer, Sniper, Medic, or Spy) and verify if the class can say the given expression. The only expression that applies is X8, i.e., MEDIC: ÜberCharge Ready; only the Medic can say this. If any other class besides the medic attempts to say this, do not output anything. (The names are case insensitive.)

Leaderboard

var QUESTION_ID=63370,OVERRIDE_USER=8478;function answersUrl(e){return"http://api.stackexchange.com/2.2/questions/"+QUESTION_ID+"/answers?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+ANSWER_FILTER}function commentUrl(e,s){return"http://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

I'm guessing the Ü is mandatory?

Are we allowed to exit with an error when we're done taking input (i.e. if it's invalid or there is none left)?

If I choose MEDIC!Thanks!Go Go Go!Move Up!... as battle cry, I should be able to get a fairly low score...

In the examples, shouldn't there be a ! after Activate ÜberCharge?

@LegionMammal978 Indeed.

@Dennis If you were to do this challenge, you'd outgolf everybody anyhow. :P

You should change the code snippet... now a 320.45 byte answer lists as 45 bytes.

@ev3commander Fixed.

Please consider changing the accepted answer.

Sorry @primo; I forgot

Perl, 280 - 15% - 20 = 218 bytes
#!perl -l
@Z=<0 {MEDIC,Thanks,Go_Go_Go,Move_Up}! Go_{Left,Right} Yes No>;
@X=<0 Incoming Spy! Sentry_Ahead! {Teleporter,Dispenser,Sentry}_Here Activate_ÜberCharge! ÜberCharge_Ready>;
@C=<0 Help! You_Fight_Like_A_Dairy_Farmer! {Ch,J}eers {Posi,Nega}tive Nice_Shot Good_Job>;
y/_/ /,print while$_=${getc=~s/
//r||getc}[getc]

Counting the shebang as one, input is taken from stdin. The newlines after semicolons are not necessary, and have been left for readability.

Sample Usage
$ echo Z3 | perl tf2.pl
Go Go Go!

$ echo X7 | perl tf2.pl
Activate ÜberCharge!

$ echo C2 | perl tf2.pl
You Fight Like A Dairy Farmer!

$ echo X5C3Z6 | perl tf2.pl
Dispenser Here
Cheers
Go Right

Interactive Mode
The code may also be run in interactive mode, in which case it will continue accepting input until an invalid input is given.
$ perl tf2.pl
Z2
Thanks!
X3
Sentry Ahead!
C4
Positive
V5

Perl, 331 - 354 (C2) - 20 - 30 = -73 bytes
#!/usr/bin/env perl -l
@Z=<0 {MEDIC,Thanks,Go_Go_Go,Move_Up}! Go_{Left,Right} Yes No>;
@X=(<0 Incoming Spy! Sentry_Ahead! {Teleporter,Dispenser,Sentry}_Here Activate_ÜberCharge!>,{Medic.$/,'ÜberCharge Ready'});
@C=(0,'Help!',(join!open(0),<0>),<{Ch,J}eers>,<{Posi,Nega}tive>,Nice_Shot,Good_Job);
print%{$_=@{$`}[<>=~/.\K(.)/]}?$_->{$c}:y/_/ /rwhile$c=<>

Supports multiple entries, and filtering by class. The battle cry I've chosen is the entire source code. It can be seen that every byte of the source is necessary for the construction of this particular battle cry - were any byte missing, the battle cry would be different. This includes the entire shebang, which by convention is counted as one.

Sample Usage
$ more in.dat
Medic
X8
Spy
X8
Heavy
C8
Pyro
Z2

$ perl tf2.pl < in.dat
ÜberCharge Ready

Good Job
Thanks!

I said These bonuses are applied in the order of appearance in this list.

CJam, -48 bytes
"\"MEDIC!
Thanks!
Go Go Go!
Move Up!
Go Left
Go Right
Yes
No
Incoming
Spy!
Sentry Ahead!
Teleporter Here
Dispenser Here
Sentry Here
Activate ÜberCharge!

Help!

Cheers
Jeers
Positive
Negative
Nice Shot
Good Job
\"N/Fleu\"MEDIC\"=\"ÜberCharge Ready\"*tq2/\"ZXC\"9,1>sm*f{\a#-2$=_S=W$@?N}\?"_~

The source code is 292 bytes long, can handle multiple inputs (-20 bytes) and checks for the class name (-30 bytes). Furthermore, I have chosen
"MEDIC!
Thanks!
Go Go Go!
Move Up!
Go Left
Go Right
Yes
No
Incoming
Spy!
Sentry Ahead!
Teleporter Here
Dispenser Here
Sentry Here
Activate ÜberCharge!

Help!

Cheers
Jeers
Positive
Negative
Nice Shot
Good Job
"N/Fleu"MEDIC"="ÜberCharge Ready"*tq2/"ZXC"9,1>sm*f{\a#-2$=_S=W$@?N}\?

as battle cry, so the first 290 bytes that are used to push this string are free.
Try it online in the CJam interpreter.

I have notified the OP about this loophole 23 hours before posting this answer, but he decided not to close it. This answer might not be terribly interesting, but it's the one the scoring algorithm calls for.

D, 692 bytes
731 - 39(for "B"~"a"~"t"~"t"~"l"~"e"~" "~"C"~"r"~"y")

import std.stdio;import std.conv;import std.utf;void main(char[][] a){char t=a[1][0];int n=to!int(a[1][1])-48;string G="Go ";char z='Z';char x='X';char c='C';string H=" Here";string U=to!string('\u00DC');string[int][char]o;o[z][1]="MEDIC!";o[z][2]="Thanks!";o[z][3]=G~G~"Go!";o[z][4]="Move Up!";o[z][5]=G~"Left";o[z][6]=G~"Right";o[z][7]="Yes";o[z][8]="No";o[x][1]="Incoming";o[x][2]="Spy!";o[x][3]="Sentry Ahead!";o[x][4]="Teleporter"~H;o[x][5]="Dispenser"~H;o[x][6]="Sentry"~H;o[x][7]="Activate "~U~"berCharge!";o[x][8]=U~"berCharge Ready";o[c][1]="Help!";o[c][2]="B"~"a"~"t"~"t"~"l"~"e"~" "~"C"~"r"~"y";o[c][3]="Cheers";o[c][4]="Jeers";o[c][5]="Positive";o[c][6]="Negative";o[c][7]="Nice Job";o[c][8]="Good Job";write(o[t][n]);}

I like D a lot.
D, 724 bytes w/ Classes
793 - 39(same as above) - 30(for class option)

import std.stdio;import std.conv;import std.utf;void main(char[][] a){char t=a[1][0];int n=to!int(a[1][1])-48;string G="Go ";char z='Z';char x='X';char c='C';string H=" Here";string U=to!string('\u00DC');string[int][char]o;o[z][1]="MEDIC!";o[z][2]="Thanks!";o[z][3]=G~G~"Go!";o[z][4]="Move Up!";o[z][5]=G~"Left";o[z][6]=G~"Right";o[z][7]="Yes";o[z][8]="No";o[x][1]="Incoming";o[x][2]="Spy!";o[x][3]="Sentry Ahead!";o[x][4]="Teleporter"~H;o[x][5]="Dispenser"~H;o[x][6]="Sentry"~H;o[x][7]="Activate "~U~"berCharge!";o[x][8]=U~"berCharge Ready";o[c][1]="Help!";o[c][2]="B"~"a"~"t"~"t"~"l"~"e"~" "~"C"~"r"~"y";o[c][3]="Cheers";o[c][4]="Jeers";o[c][5]="Positive";o[c][6]="Negative";o[c][7]="Nice Job";o[c][8]="Good Job";if(a.length>2){if(!(a[2]!="Medic"&&t==x&&n==8))goto P;}else P:write(o[t][n]);}

This version lets you input a class for X8. Use it like tf2 X8 Medic. It will print the correct message if you use the correct class. Yes, this does use a goto. Kill it now.

Prolog, 371 362 - 11 = 351 bytes
My first attempt at code golf.
I chose a language which seem to be underrepresented here.
I'm far from an expert at prolog, so this can most likely be improved a lot.
I did not go for any optional bonuses. I tried for the 15% one but it cost me more than I gained.
    a(z,['MEDIC!','Thanks!','Go Go Go!','Move Up!','Go Left','Go Right','Yes','No']).
    a(x,['Incoming','Spy!','Sentry Ahead!','Teleporter Here','Dispenser Here','Sentry Here','Activate ÜberCharge!','ÜberCharge Ready']).
    a(c,['Help!','For Pony!','Cheers','Jeers','Positive','Negative','Nice Shot','Good Job']).
    r:-read(X),read(Y),a(X,Z),nth1(Y,Z,A),write(A),1=2.

Try it out
You can try it out online here.

Create new program
Paste code
As query, just use 'r' without quotes.

Input is first a letter then a number.
Example:
Input: z
Press Send
Input 3
Press Send
Outputs: Go Go Go!

Edit:
Saved 9 bytes with input from @Fatalize

I don't think you need to use writeln according to the specs of the challenge. write seems sufficient. Also 1=2 is a one-byte shorter way to fail than to use fail ;)

I also don't see why you would need the repeat [...] fail construct here, according to the challenge (unless I didn't read it correctly) you only need to take the two inputs once and output the answer, and them the program can terminate.

@Fatalize some very good points, thank you. Your input saves me 9 bytes. I meant the repeat/fail to be used for the 15% bonus, but it ended up costing more than it gained me so I have no use for it as the program is now.

TeaScript, 225 - 6 = 219 bytes
b=xS(1)-1
x0¦'Z'?æMEDIC!,Tnks!,Go Go Go!,Move Up!,Go Left,Go Right,Y,No`.s`,`[b]:x0¦'X'?æîa,Spy!,SÀ^y AÊ%!,Tà({Zr He,DáÀ He,SÀ^y He,Acve Ã¼rCrge!`.s`,`[b]:x0¦'C'?æHelp!,PÇës!,CÊ8s,JÁÄ,PoÐÓve,Negive,Ni St,Good Job`.s`,`[b]:''

As short as I can get it. None of the bonuses save any bytes.
Try it online. If the outputs show up weird for you, tell me and I'll add a hex dump too deal with all the special characters.

This doesn't work for multiple inputs: X8 => undefined, C7 => Nice S["t"]...

Mathematica, 368 - 24 = 344 bytes
Check[StringExtract["MEDIC!,Thanks!,Go Go Go!,Move Up!,Go Left,Go Right,Yes,No;Incoming,Spy!,Sentry Ahead!,Teleporter Here,Dispenser Here,Sentry Here,Activate ÜberCharge!,ÜberCharge Ready;Help!,Why am I saying this...,Cheers,Jeers,Positive,Negative,Nice Shot,Good Job",";"-><|"Z"->1,"X"->2,"C"->3|>[#~StringTake~1],","->FromDigits[#~StringDrop~1]]/._Missing->"",""]&

Haskell, 397 -15% - 20 = 317.45 bytes
v=[('Z',["MEDIC!","Thanks!","Go Go Go!","Move Up!","Go Left","Go Right","Yes","No"]),('X',["Incoming","Spy!","Sentry Ahead!","Teleporter Here","Dispenser Here","Sentry Here","Activate ÜberCharge!","ÜberCharge Ready"]),('C',["Help!","Battle Cry","Cheers","Jeers","Positive","Negative","Nice Shot"])]
h(Just k)=k
m(x:y:s)=((h$lookup x v)!!((fromEnum y)-49))++('\n':m s)
m""=""
main=interact$concat.map m.lines

The input is taken from the standard input and it will output messages until there is no more input or an invalid input is given.
P.S. : Changing the order in which to apply the bonuses, according to a comment from the OP.

AppleScript, (595-18)*.85 = 490.45 Bytes
I beat somebody.
set a to{"MEDIC!","Thanks!","Go Go Go!","Move Up!","Go Left","Go Right","Yes","No","Incoming","Spy!","Sentry Ahead!","Teleporter Here","Dispenser Here","Sentry Here","Activate ÜberCharge!","ÜberCharge Ready","Help!","FOR APPLESCRIPT!","Cheers","Jeers","Positive","Negative","Nice Shot","Good Job"}
set c to true
considering case
repeat while c
set b to(display dialog""default answer"")'s text returned's characters
set n to 0
set k to item 1 of b
if k="C" then
set n to 0
else if k="X" then
set n to 8
else if k="Z" then
set n to 16
else
exit
end
display dialog(item(n+item 2 of b)of a)
end
end
Basically, I push all the items into an array. I get input through a text window (see gif below) and then an output window displays the referenced text.

The bonuses that apply are for the Battle Cry and the looping until invalid.

I'm laughing at considering case: what is this, INTERCAL?

@sysreq ¯\(ツ)/¯ AppleScript doesn't consider case by default, because logic.

I guess that makes sense, considering HFS didn't support/preserve case-sensitive filenames and HFS+ can, if you do some fiddling

Vitsy, 343 - 15 - 20 = 308 Bytes
I only qualify for the Battle Cry bonus and separating the segments by newline. My language can't do that other stuff. ;(
<OaZm+-1;)D]++2f[)-V'Z']+9[)-V'X']+1[)-V'C'Vi0;)/8^/21^2D-*68i
'!CIDEM'
'!sknahT'
'!oG oG oG'
'!pU evoM'
'tfeL oG'
'thgiR oG'
'seY'
'oN'
'gnimocnI'
'!ypS'
'!daehA yrtneS'
'ereH retropeleT'
'ereH resnepsiD'
'ereH yrtneS'
'!egrahCrebÜ etavitcA'
'ydaeR egrahCrebÜ'
'!pleH'
'syawlA ystiV'
'sreehC'
'sreeJ'
'evitisoP'
'evitageN'
'tohS eciN'
'boJ dooG'
This uses method structuring to push items to the stack according to a specific reference. Since it's easier to understand the way I originally wrote it, I have put the original code down below. The only difference is that the one above uses the < character to loop around the line backwards, one of the special ways that Vitsy loops around the line. The explanation for the top layer of code (in executed order) is below:
i86*-D1-D8M-);0iV'C'V-)[1+]'X'V-)[9+]'Z'V-)[f2++]D(;1-+mZ
i86*-                                                     Get the number value of the ASCII input.
     D1-D8M-);                                            If the number is within the range 0-8, continue the program. Otherwise, end execution.
              0                                           Placeholder of zero.
               iV                                         Get the character component and save it as a global variable.
                 'C'V-)[1+]                               If it's 'C', add 1
                           'X'V-)[9+]'Z'V-)[f2++]         Do the same things with 'X' and 'Z', adding 1 and a multiple of 8.
                                                 D(;      If after all this, the number is still zero, end execution.
                                                    1-+   Subtract one and add the components.
                                                       m  Execute that line number.
                                                        Z Print everything in the stack to STDOUT and quit.