text:
Difference should make no difference
Your company lately hired a new bunch of extremely dedicated sysadmins. They feel that just watching computer screens is quite limiting (I mean, 60Hz refresh rate is just NOT enough), so they hooked up the CPU data bus to an DAC and play that on a speaker through the server room so that they can hear up to 20kHz. One problem: they're sysadmins, not electrical engineers, and their speaker setup keeps breaking. They figured that this is caused by too abrupt changes in byte values in the code that the software engineers compile on the mainframe. The sysadmins are now hosting a little competition to see who can make code that is the most gentle to their speaker setup.
Challenge
Your mission is to create a program or function in a language of choice that has as little difference as possible between consecutive bytes (see the Calculation section). This program will have the task of calculating its own score.
Input
An ASCII string on stdin or your language's closest equivalent, or as a function input if you're creating a function. Since your program will have to take itself as input to calculate your score, your program should support Unicode if it contains any Unicode. Otherwise, ASCII is sufficient. Input can be assumed to be at least 2 bytes long.
Calculation
Each character of the string will be converted to it's numerical equivalent, using the ASCII standard. Then, the difference between all characters will first be squared and then summed. For example, the string abd will get a score of 1²+2²=5.
Output
Output will be the title to your entry. This means that it should be prepended by a # or appended by a newline and a - (dash). Then, it should output the name of your programming language, followed by a comma, a space and then an integer representing the result of the calculation. For example
#C++, 98

would be valid output. Output should be given on stdout or your language closest equivalent, or as a return value to your function.
Scoring
Your score will be the calculated value by your program, with the program itself as input.
Edit: Should handle newlines now, sorry for before, folks
Here is a Pyth script to verify the score calculation.

Can we assume that input is at least two characters long?

Yes, unless you create a 1-byte entry.

I added a script that should calculate the score accurately, feel free to remove it if you don't like it

@FryAmTheEggman Thanks! I didn't really feel like looking up how to make a runnable stack snippet, but this works just as well.

Will the program have to interpret anything other than its own code? And just to clarify, two consecutive equal characters are a value of 0?

@DanielM. It should be capable of arbitrary strings - and the output would be just the same (except the score), since our sysadmins will want to see how languages perform on their testcases. And yes, aa would result in a value of 0.

uh.

@bopjesvla Fine. Arbitrary strings, but you may assume them to be able to fit in the universe. Or on your computer, for that matter.

First person to create a valid answer in Unary wins!

@ETHproductions Yes, and zero upvotes will be given to an answer that requires zero skill to win.

They hooked the CPU data bus up to an Attack Damage Carry? Nice!

@mbomb007 Oops, wrong acronym. I meant the Danish Architecture Centre,

Too late now, but one option to prevent Unary-style answers would have been to define the difference between equal characters as 1. Also would have made the logic slightly more interesting.

FWIW a 60Hz 1920*1080 32-bit monitor carries more than ten thousand times the baud rate of a stereo 192 kbps speaker system.

@FryAmTheEggman Your script does not seem to handle newlines in the input...

@sanchises If the best scoring answer requires 0 skill, that is usually a problem in the question not in the answer. You should defend against these kind of loopholes e.g. with RetoKoradi's suggestion in this case.

@randomra I know, but I feel that by the time that suggestion was made, it was too late to change the rules.

@sanchises True, I just mentioned it for the future.

@randomra Yeah, thanks - I quite honestly forgot about Unary and Lenguage. It would have prevented the CJam answer, too. Perhaps I'll make another challenge sometime with that scoring - or someone else will,  I'm not copyrighting this scoring mechanism.

Your optional output format involving the newline and dash is somewhat confusing to me. Can you give an example?

@Mwr247 It's just another way of formatting headers around here. It's literally C++, 98\n- with of course \n an actual newline.

Is it largest score or smallest score wins?

@ASCIIThenANSI Read the start of the question. If you still can't figure it out, pick the one where you think you can do better than a bunch of monkeys mashing at a keyboard.

CJam, 1051 827 643 569 545 407 327 279 235 233 229
''"','#'C'J'a'm',' qYew::-Yf#:+e#'''''''''"
f{-ci'(*''2*\}'^,40>"*/:N"-"][ZZ[\^__`bcdgimpstsz{}~~~"

The above program generates the actual source code, which is 1,179,112 bytes long.
Testing
Using the Java interpreter, the source code can be generated and tested like this:
$ alias cjam='java -jar cjam-0.6.5.jar'
$ cjam gen.cjam > diff.cjam
$ cksum diff.cjam
896860245 1179112 diff.cjam
$ cjam diff.cjam < diff.cjam
#CJam, 229

Alternate version
At the cost of 36 points – for a final score of 265 – we can make the source code 99.92% shorter:
'''()))))(''''(((('''())))))))))))))))))))))))))))('''()))))))))))))))))))))))))))))))))))('''())))))))))))))))))))))))))))))))))))))))))))))))))))))))))('''())))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))('''()))))(''''((((((('())))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))('())))))))))))))))))))))))))))))))))))))))))))))))))('())))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))('())))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))('()))))))))))))))))))('()))))))))))))))))))('())))))('())))))))))))))))))))))))))))))))))))))))))))))))))('()))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))(''(((('()))))))))))))))))))('())))('())))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))(''((((''''''''''''''''''()+,-.0123456789;<=>?@ABCDEFGHIJKLMOPQRSTUVWXYZ[\]][ZZ[\^__`bcdgimpstsz{}~~~

You can try this version online in the CJam interpreter.
Idea
We want to execute the code
'#'C'J'a'm',' qYew::-Yf#:+

keeping the score as low as possible. To achieve this, we're going to build that string character by character (with a few no-ops before and after) and evaluate the result.
Fortunately, ' (push character literal), ( (decrement) and ) (increment) are consecutive ASCII characters, so pushing arbitrary characters is relatively inexpensive.

ASCII characters after ' can be pushed as '()…)(, where the number of ) depends on the code point.
For example, + can be pushed as '())))(. The distance between ' and (, and ( and ) is 1. The trailing )( cancel each other; their only function is to pave the way for the following ' (corresponding to the next character) with consecutive characters.
Characters pushed in this fashion will raise the score by 4 points.
ASCII characters before ' can be pushed as ''(…(, where the number of ( depends on the code point.
For example, # can be pushed as ''((((. The distance between ' and ( is 1.
Characters pushed in this fashion will raise the score by 2 points.
''(…( actually works for all ASCII characters, since Character is 16 bits wide and wraps around. For example, + can be pushed as '', followed by 65,532 (s.
This technique is used in the 1.2 megabyte version of the code.
The character ' can be pushed as '', leaving the score unaffected.

Code
e# Push these characters on the stack: ','#'C'J'a'm',' qYew::-Yf#:+e#'''''''''

''
'()))))(
''
''((((
''
'())))))))))))))))))))))))))))(
''
'()))))))))))))))))))))))))))))))))))(
''
'())))))))))))))))))))))))))))))))))))))))))))))))))))))))))(
''
'())))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))(
''
'()))))(
''
''(((((((
'())))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))(
'())))))))))))))))))))))))))))))))))))))))))))))))))(
'())))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))(
'())))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))(
'()))))))))))))))))))(
'()))))))))))))))))))(
'())))))(
'())))))))))))))))))))))))))))))))))))))))))))))))))(
'()))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))(
''((((
'()))))))))))))))))))(
'())))(
'())))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))(
''((((
''
''
''
''
''
''
''
''
''()

+                         e# Concatenate the two topmost single quotes.
,                         e# Push the length of the resulting string (2).
-.0123456789              e# Push that number.
;                         e# Discard it from the stack.
<                         e# Compare a single quote with 2. Pushes 0.
=                         e# Compare a single quote with 0. Pushes 0.
>                         e# Compare a single quote with 0. Pushes 1.
?                         e# Ternary if. Discards a single quote and 1.
@                         e# Rotate the remaining three single quotes.
ABCDEFGHIJKLMOPQRSTUVWXYZ e# Push 25 items on the stack.
[\]                       e# Swap the last two and wrap them in an array.

e# So far, we've pushed the elements of "','#'C'J'a'm',' qYew::-Yf#:+e#'''"
e# followed by the elements of [10 11 12 13 14 15 16 17 18 19 20]
e# and ["" "" "" 3.141592653589793 "" "" " " 0 0 0 -1 1 [3 2]].

]    e# Wrap the entire stack in an array.
[    e# Begin an array. Does nothing.
ZZ   e# Push 3 twice.
[    e# Begin an array. Does nothing.
\^   e# Swap both 3s and push the bitwise XOR. Pushes 0.
__   e# Push two copies.
`    e# Inspect the last copy. Pushes the string "0".
b    e# Convert "0" from base 0 to integer. Pushes 48.
cd   e# Cast 48 to Character, then Double. Pushes 48.0.
gi   e# Apply the sign function, then cast to integer. Pushes 1.
mp   e# Check 1 for primality. Pushes 0.
s    e# Cast the result to string. Pushes the string "0".

e# We now have three elements on the stack: an array, 0, and "0"

t    e# Set the element at index 0 of the array to the string "0".
s    e# Cast the array to string.

e# This pushes the string consisting of the characters
e#     0,'#'C'J'a'm',' qYew::-Yf#:+
e# and
e#     e#'''10111213141516171819203.141592653589793 000-1132
e#
e# When evaluated this does the following:
e#   0,                Push an empty array. Does not affect output.
e#   '#'C'J'a'm','     Push the characters of "#CJam, ".
e#   q                 Read all input from STDIN.
e#   Yew               Push the overlapping slices of length 2.
e#   ::-               Reduce each pair of characters to their difference.
e#   Yf#               Square each difference.
e#   :+                Add the results.
e#   e#…               Comment. Does nothing.

z    e# Zip. This wraps the string on the stack in an array.
{}~  e# Execute an empty block.
~    e# Unwrap the array.
~    e# Evaluate the string.

........... wat

It almost looks like this language was built for this exact challenge. Nice!

Damn. I thought I finally made a challenge that would put CJam at a disadvantage since it's often a mix of 'early' symbols and 'late' letters. But nooooo, you show up and ruin it again... Cheers!

Haskell, 152827 95742 91196 83921 77447 71742
a=(.);_ZYXWVUTSRQPONMLKJIHGFEDCBA=("#Haskell, "++)`a`show`a`sum`a`fmap(^2)`a`(tail>>=zipWith(-))`a`fmap fromEnum`a`(""++)

Usage (note: " has to be escaped):
_ZYXWVUTSRQPONMLKJIHGFEDCBA   "a=(.);_ZYXWVUTSRQPONMLKJIHGFEDCBA=(\"#Haskell, \"++)`a`show`a`sum`a`fmap(^2)`a`(tail>>=zipWith(-))`a`fmap fromEnum`a`(\"\"++)"

"#Haskell, 71742"

I prepend the empty string "" to the input string to help the Haskell interpreter figuring out the types. Without it type inference fails, the code is too polymorphic. The rest is business as usual: map each character to ascii, make a list of neighbor differences, square, sum and prepend language name.

><>, 30227
0&ii:0(?v:@-:*&+&20.
'#><>, '<;n&oooooo

Gah, the title doubled my score; in the words of my own program, n&oooooo! I'll take some time later to make this better. I also know that this score may be off since I can't really enter newlines on the online interpreter and I'm not sure there's a way to populate an input stack on the official one.
By no means completely optimized, but takes full some advantage of the relative proximity (at least in terms of ASCII characters) of the commands in ><>. I couldn't easily submit the newline as input, so I used the Pyth score checker, but it matches for a bunch of random test cases I used so it should be fine with regards to that.
Here's one with a score of 30353 (which ought to be correct since it's one line):
0&l1=66+*77++0.$:@-:*&+&10.' ,><>#'oooooo&n;

Nice, a competitive entry in ><>!

Java, 66465 65506 62434
Surprisingly short. Accepts a char array instead of a string.
ABCD->{int A98=0,GFEDCBA=1,A987;for(;GFEDCBA<ABCD.length;A98=A98+(A987=ABCD[GFEDCBA]-ABCD[GFEDCBA++-1])*A987-0);return"#Java, "+A98;}

I used a program to generate the best variable names.

How would you use this in a program? (I'm not entirely familiar with java 8 features yet)

@aditsu http://ideone.com/0yy6id

Oh, so you have to define a target functional interface for it... not exactly a first-class object.

@aditsu You could also use Function<char[],String> if you wanted.

Oh I see… ((Function<char[],String>) ABCD->{…}).apply(…), thanks. These lambdas seem to be quite incomplete without the type context.

QBasic, 38140
YAY FOR SHOUTY SYNTAX
LINE INPUT A9876543210$:AAA=ASC(A9876543210$):WHILE A<LEN(A9876543210$):AA9876543210=AAA:A=1+A:AAA=ASC(MID$(A9876543210$,A)):A98765432100=A98765432100+(AA9876543210-AAA)*(AA9876543210-AAA):WEND:?"QBasic,";A98765432100

(Tested with QB64.)
This is a full program that inputs the string and outputs the answer. The only limitation here is that the program can't take multiline input (LINE INPUT can handle anything as long as it's a single line).
Deobfuscated:
LINE INPUT line$
b=ASC(line$)
WHILE i<LEN(line$)
    a=b
    i=i+1
    b=ASC(MID$(line$,i))
    score=score+(a-b)*(a-b)
WEND
PRINT "#QBasic,"; score

Conveniently, passing a multi-character string to ASC gives the ASCII value of the first character. Also conveniently, numeric variables are auto-initialized to zero.

I've never coded in QBasic before, so forgive me if I'm wrong, but would it be possible to replace the variables with uppercase letters to save some extra points?

@DLosc Ah, OK. I was reading the deobfuscated version as the actual program. :|

Windows PowerShell ISE Host, 62978 63894 67960 77050
PARAM($4)($4.LENGTH-2)..0|foreach{$9=+$4[$_]-$4[$_+1];$0+=$9*$9};'#'+$HOST.NAME+', '+$0

Edit -- saved some points by getting rid of the $A variable and instead counting backwards through the string, and also by converting some keywords to CAPS
Edit2 -- saved some more points by using $($HOST.NAME) instead of PowerShell
Edit3 -- saved some more points by swapping variable names and changed how the output is generated.
Uses variables named with numbers, as they're "closer" to $ so our penalty is less.
It's interesting to not use regular golfing techniques. For example, |%{$ is 22534, while |foreach{$ is only 8718.
This is probably close to optimal without changing techniques.

This was exactly what I was hoping for. Cheers!

K5, 25478
"#K5, ",$+/1_{x*x}'-':

Pretty simple solution. This is a function that takes its input via a string.

@TimmyD Fixed!!

MATLAB, 19214 39748 39444 38785 37593
@(A9876543210)sprintf('#MATLAB, %d',diff(A9876543210)*diff(A9876543210'))

Thanks to Luis Mendo for reducing the difference count further!
Thanks to NumberOne for reducing the noise count by changing the input variable name!
How this works

Declares an anonymous function that is stored in the default ans variable in MATLAB
The function takes in a string stored in A9876543210 and prints out the sum of squared neighbouring differences of the string.
diff finds pairwise neighbouring differences in an array and produces an array of length(A9876543210)-1.  By using diff on a string array, this gets cast to a double array where the ASCII codes of each character are generated and the differences of the consecutive pairs results in another array.
To find the sum of squared differences, you simply take the dot product of this difference array with itself transposed.  Doing diff(A9876543210)' actually produced more noise than with A9876543210.' (thanks Luis Mendo!)
The result is printed to the screen.

It's usual in PPCG to allow unnamed functions. So you can remove A=

Also, norm(diff(B))^2 is shorter

@LuisMendo - Tried that.  It prints out scientific notation and doesn't respect the %d.

Why do you use B as a variable name? A=@(A)... is valid MATLAB, since A is scoped.

@sanchises - To be different.  In addition, A and B have the same number of bits set.  A --> 10000001, B --> 10000010.

@sanchises - Hmm... thanks for that.  It reduces it some more.  I'll update.

This challenge is not this challenge...

@sanchises - Yes I'm aware.  Thanks.

A -> A9876543210

@TheNumberOne - Woah.. that just blew my mind.  That sequence of characters makes less noise!  Thanks man!

Python 2, 91026
lambda A:"#Python 2, "+`sum((ord(A9876543210)-ord(A98765432100))**2for A9876543210,A98765432100 in zip(A,A[1:]))`

Defines an anonymous function that takes a string and returns the score. Try it online.
Most of this is a pretty straightforward functional implementation: zip A with A[1:] to get a list of letter pairs, then subtract their ords, square, and sum with a generator expression.
Observe that the two variables inside the generator expression are only ever followed by the following characters: ), ,, and space. All three of these have very low ASCII values, so it behooves us to end each variable with as low-ASCII-valued a character as possible. The lowest character that can end a variable in Python is 0. Furthermore, every opportunity we have to split a single large jump into two smaller jumps will lower the score: A0 costs 289, but A90 is only 145 and A9876543210 is a paltry 73.
(This approach didn't help the lambda variable A, probably because it's followed by [ in one occurrence.)

CJam, 23663 19389 11547
"#CJam,"32A;clYew[]ULC;;;;::- 0$.*:+

Try it online
It's starting to feel like this can be pushed almost endlessly by strategically adding more characters. But I think that I'm starting to reach a point of diminishing returns here, so I'll stop for now. For example, where I have ULC;;;, I could use the whole alphabet backwards followed by 26 ;, but the gains get smaller and smaller.
By far the biggest gap I have left is between the m and the , in the initial string. I haven't found anything reasonable to get rid of it. I'm sure there are ways. But if I push it to the limit, it might start looking like Dennis' solution...

JSFuck, 144420642
Build it from:
t=arguments[0];n=0;for(u=1;u<t.length;++u)n+=(f=t.charCodeAt(u)-t.charCodeAt(u-1))*f;return'#JSFuck, '+n

Paste this into JSFuck.com's small input box to compile it to JSFuck. The result is a 112701 characters long script, so I can't put it here. The last two characters of this script are parentheses, put the input between them.
...)[+!+[]])('abd')

It takes the program almost 20 seconds on my computer to evaluate itself.

Explanation
I got more time to work on this, so I sat down and tried to optimize the variable names. Here are the variable names worth using, in order of their score.
u     ([][[]]+[])[+[]]                    17237
n     ([][[]]+[])[+!+[]]                  17437
f     (![]+[])[+[]]                       18041
t     (!![]+[])[+[]]                      18041
a     (![]+[])[+!+[]]                     18241
r     (!![]+[])[+!+[]]                    18241
d     ([][[]]+[])[!+[]+!+[]]              23405
N     (+[![]]+[])[+[]]                    23669
e     (!![]+[])[!+[]+!+[]+!+[]]           29217
i     ([![]]+[][[]])[+!+[]+[+[]]]         33581
l     (![]+[])[!+[]+!+[]]                 24209
s     (![]+[])[!+[]+!+[]+!+[]]            29217
uu    ([][[]]+[])[+[]]+([][[]]+[])[+[]]   36983

Here is the JavaScript I've translated to JSFuck:
score = 0;
for (u = 1; u < input.length; ++u)
  score += (difference = input.charCodeAt(u) - input.charCodeAt(u-1)) * difference;
return '#JSFuck, ' + score;

I gave a closer look at JSFuck.com's translator and figured out how its evaluation function works. With "Eval source" checked, the code will become a self-executing JSFuck function. To get the input, however, we need to access arguments[0] from within the function. This brings our final JS code to...
t=arguments[0];n=0;for(u=1;u<t.length;++u)n+=(f=t.charCodeAt(u)-t.charCodeAt(u-1))*f;return'#JSFuck, '+n

(If you're wondering why my previous version had a lower score than this, it's because it was a JSFuck program that returned a string that needed to be evaluated as JS. This is also why I didn't leave it in the post)

Your abs is unnecessary. I guess that might just make the difference... :)

I found the score confusing. You should remove the spaces. Especially since the output of your program should be JSFuck, 102280181.

@sanchises indeed, I had actually forgotten to put the square two at first, which is why there was a Math.abs. Will fix.

@mbomb007 Oh, ok then, will fix too.

JAVASCRIPT, 33911
$0123456789ABCDEFGHIJKLMNOPQRS=>/**/('#')+('JAVASCRIPT,')+(" ")+(($)/**/=0,($0123456789ABCDEFGHIJKLMNOPQRS[`split`]``[`map`]/**/(($$,$$$)/**/=>/**/($)/**/=Math[`pow`]/**/($0123456789ABCDEFGHIJKLMNOPQRS[T=`charCodeAt`]/**/($$$)+-($0123456789ABCDEFGHIJKLMNOPQRS[T]/**/(($$$)/**/>=6-5?/**/($$$)+-1:0.)),2)+($))),($))

This is by far one of the silliest optimizations I have ever done in a code golf...
Props to Neil for the "comment spam" suggestion =P

I think you can save 5180 simply by inserting /**/ in appropriate places.

JAVASCRIPT, 31520
This solution was significantly more ridiculous very different from my other one, and so I felt it deserved it's own answer.
A=>/**/(($)/**/=/**/(''),('[encoded data, 6815 characters],+*)(')/**/[`split`]``[`reduce`]/**/(($$,$$$,$$$$)/**/=>/**/($$$)/**/>7.-07?/**/(($)+=/**/((/**/String[`fromCharCode`]/**/)(($$$$)+-($$))),($$$$))/**/:/**/($$)),/**/eval/**/($))

That's 7306 characters, most of which is the actual program encoded into that 0/1 string, and the rest simply to decode it. It works by getting the index of each '1' minus the index of the previous '1' to get the necessary character value. It then eval's the resulting string into the actual function, which is essentially a standard-golf program to solve the problem (which is only about 105 characters itself).

Java, 129300 128400 110930 106581 105101
B->{int A=0,C=A;char[]Z=B.toCharArray();for(;++C<Z.length;A=A+(Z[C]-Z[C-1])*(Z[C]-Z[C-1]));return\"#Java, \"+A;}

This challenge actually got me thinking deeper about characters to use and optimization more so than finding the shortest solution. I'll keep working to bring the number down.
This is a lambda function, with B being the string representing the function. Don't forget to escape the quotes (") when passing this as a string.

M, 47033 52798
A9876543210(A9876543210) F AA9876543210=2:1:$L(A9876543210) S AAA9876543210=$A($E(A9876543210,AA9876543210-1))-$A($E(A9876543210,AA9876543210))**2+AAA9876543210
    Q "#M, "_AAA9876543210

To use this, we have to escape quotes and "escape" whitespace characters (which are significant in MUMPS!) like so:
>$$A9876543210^MYROUTINE("A9876543210(A9876543210)"_$C(9)_"F AA9876543210=2:1:$L(A9876543210) S AAA9876543210=$A($E(A9876543210,AA9876543210-1))-$A($E(A9876543210,AA9876543210))**2+AAA9876543210"_$C(10,9)_"Q ""#M, ""_AAA9876543210")
#M, 47033

Note that "M" is an alternative name for "MUMPS" - there is disagreement among practitioners about which one is correct. Naturally, I have chosen the shorter option here.

Shouldn't you initialise AAAA?

Also because of lack of operator priorities, you can just S AAA=$A($E(A,AA-1))-$A($E(A,AA))**2+AAA -- should give a lower score...

@SSH I'm assuming a clean symbol table before calling the function (so I don't have to NEW stuff). So when I start doing arithmetic on AAAA (now AAA9876543210), it gets coerced to 0 (maybe that's just a Caché implementation detail? I don't have a GT.M install to test against). Good call on the operator priorities thing; I always find it difficult to think in terms of purely left-to-right operations. (I also forgot that M has an exponentiation operator - it's not something that comes up often when you're writing CRUD applications.)

Nice! Also, because of left-to-right execution, you don't need brackets before **2

@SSH Thanks, dunno how those got in there. The version I actually measured doesn't have it, so the score is still the same.

Mathematica, 33552
A=ToExpression;A@ExportString[A@Characters@(**)"001000100010001101001101011000010111010001101000011001010110110101100001011101000110100101100011011000010010110000100000001000100011110000111110010101000110111101010011011101000111001001101001011011100110011101011011001000110010111000100011001001100100000001000100011010010110011001100110011001010111001001100101011011100110001101100101011100110100000001010100011011110100001101101000011000010111001001100001011000110111010001100101011100100100001101101111011001000110010101000000001000110101110100100110"(**),(**)"Bit"(**)]

This code evaluates to an unnamed function, which calculates the "noise" of an input string. It makes use of the fact that the ASCII representation of binary data is essentially "noiseless". The binary data you see is the string
"#Mathematica, "<>ToString[#.#&@Differences@ToCharacterCode@#]&

which would have been a valid answer on its own, scoring 37848.
Everything else
A=ToExpression;A@ExportString[A@Characters@(**)"001..110"(**),(**)"Bit"(**)]

just decodes the binary string and interprets it as Mathematica code. Note that Mathematica's empty comment (**) is very "low-noise" and actually removes noise from the "s.

Java8 : 117170 100508 99062 98890
With the help of lambada expression and inline assignment of variable can shorten this code a bit.
A->{int B=0,D=0,E=0;char[] C=A.toCharArray();for(;D<C.length-1;)B+=(E=C[D]-C[++D])*E;return"#java, "+B;}

A -> A9876543210; B -> $0123456; C -> A; D -> AA; E -> $0123456789

Pyth, 16391
++C38828542027820dsm^-ChdCed2,Vztz

The only trick of note used here is base-256 encoding #Pyth,, which costs far less than the string itself.
++C38828542027820dsm^-ChdCed2,Vztz    Implicit: d=' ', z=input()
                             ,Vztz    Pair each char in the input with its neighbour
                   m                  Map d in the above to:
                      Chd               ASCII code of 1st char
                         Ced            ASCII code of 2nd char
                     -                  Difference between the two
                    ^       2           Squared
                  s                   Take the sum
  C38828542027820                     '#Pyth,'
++               d                    '#Pyth,' + ' ' + result, implicit print

R, 68911 57183 53816 52224
Takes a string from STDIN and converts it to an integer via raw.  Diffs, squares and sums the resulting vector.  The result is returned as a string.  Thanks to @nimi for the variable name tip.
'&&'=sum;'&&&'=diff;'&&&&'=as.integer;'&&&&&'=charToRaw;'&&&&&&'=readline;'&&&&&&&'=paste;'&&&&&&&'('#R,','&&'((A='&&&'('&&&&'('&&&&&'('&&&&&&'()))))*A))

@nimi Thanks for that, was 2 stuck it trying to keep it short :)

Ruby, 118402
puts "#Ruby, #{a=0;aa=nil;File.read(ARGV[0]).each_byte{|aaa| aa||=aaa;a+=(aaa-aa)**2;aa=aaa};a}"

It reads in a file through command line, such as ruby diff.rb /path/to/file. There's room to improve, and that's something I'm working on right now.

POSIX Shell, 172026
{ while IFS= read -N 1 A; do A1=$(printf %d \'"$A");test "$A1" -eq 0 && break;case $A11 in "")A111=0;;*)A111=$((A1-A11));;esac;A11="$A1";A1111=$((A111**2+A1111));done;echo "# POSIX Shell, $A1111";}

too bad I can't get the same result as the Pyth checker (178386)...

"Shell" is not a programming language. This looks like Bash. 2. You can simply read from STDIN. No need to read the source code itself.

@Dennis Thanks, edited... Although I can't get the same result, maybe there's a bug still (at least once I got the same result but not in the "compressed" version)...

F#, 136718 130303
let(A)=Seq.map;
(stdout.Write(Seq.sum(A(fun(AA)->AA*AA)(A((<||)(-))(((Seq.pairwise(A(int)(stdin.ReadToEnd())))))))))

Where there is a \n after the ;.

C++ 166345
void n(){int b=0,c,d;string a;cin >>a;for(c=1;c<a.length();++c){d=(a[c]-a[c-1]);b+=d*d;}cout<<"#C++, "<<b;}

Lua, 171078 117896
Golfed:
A=string AA=A.sub AAA=io.read()AAAA=#AAA AAA=AAA..AA(AAA,AAAA,AAAA)AAAAA=0 AAAAAA=A.byte for AAAAAAA=1,AAAA do AAAAAAAA=AAAAAA(AA(AAA,AAAAAAA,AAAAAAA))-AAAAAA(AA(AAA,AAAAAAA+1,AAAAAAA+1))AAAAA=AAAAA+AAAAAAAA*AAAAAAAA end print(AAAAA)

Ungolfed:
A=string
AA=A.sub
AAA=io.read()
AAAA=#AAA
AAA=AAA..AA(AAA,AAAA,AAAA)
AAAAA=0
AAAAAA=A.byte
for AAAAAAA=1,AAAA do
    AAAAAAAA=AAAAAA(AA(AAA,AAAAAAA,AAAAAAA))-AAAAAA(AA(AAA,AAAAAAA+1,AAAAAAA+1))
    AAAAA=AAAAA+AAAAAAAA*AAAAAAAA
end

print(AAAAA)

Perl, 93556
chomp($A=<>);$AAA=$AAAA=0;foreach$AAAAA(split'',$A){$AA=ord($AAAAA);$AAA+=($AAAA-$AA)**2 if($AAAA!=0);$AAAA=$AA}print'#Perl, '.$AAA

I'll try to cut this down some more.
It turns out that curly braces ({ and }, ASCII 123 and 125) and the underscore (_, ASCII 95) are very expensive since all the other characters are around the range 30-70, which is why I formatted the if the way I did, and why I'm using $AAAAA instead of Perl's beloved $_.
Sadly, all the variables with symbols in them are read-only, so I can't take advantage of combinations like $# and $$.

C++, 49031
a C++ macro that takes a c-string and writes the result to the standard output
<::>(auto(A))<%long(AAA)=0,AA=A<:0:>;while(*++A)<%AAA+=(*A-AA)*(*A-AA);AA=A<:0:>;%>cout<<"#C++, "<<AAA;%>

Try it online!


text:
Escape control characters in a C string
C/C++ use double quotes "" for making string literals. If I want the double-quote itself, or certain other characters, to appear in the string, I have to escape them, like so:
char *s2 = "This is not \"good\".\nThis is awesome!\n";

Here, I used \" to represent a double-quote, and \n to represent the newline character. So, if my program prints the string, I see

This is not "good".
This is awesome!

However, if I examine the string in a debugger (Visual Studio or gdb), it shows me the escaped form - the one that would appear in the source code. This is good because it allows to unambiguously identify whether the string contained that \ backslash character verbatim or as part of an escape-sequence.
The goal of this challenge is to do the same job the debuggers do, but better - the escaped string must contain as few escaping characters as possible! The input to your program (or subroutine) is a string of arbitrary 8-bit bytes, and the output must be suitable for putting into the following boilerplate C code:
#include <stdio.h>
int main() {char str[] =
"### the escaped string goes here ###";
puts(""); // put a breakpoint here to examine the string
puts(str); return 0;}

For example:
Input (hexdump, 3-byte string): 64 0a 06
Output: d\n\6
Here, \006 or \x6 have the same meaning as \6, but longer and are therefore unacceptable. Likewise, \012 and \xa have the same meaning as \n, but only \n is an acceptable encoding for the byte with the value 10.

Another example:
Input (hexdump, 5-byte string): 61 0e 38 02 37
Output: a\168\0027
Here, code 0x0e is escaped as \16, and parsed successfully by the C compiler because 8 is not a valid octal digit. However, the code 0x02 is escaped as \002, not \2, to avoid confusion with the byte \27.
Output: a\168\2\67 - another possible form

See Wikipedia for the exact definition of escaping in C.
Additional (reasonable) rules for this challenge:

Output must be printable ASCII (no tab characters; no characters with codes above 126)
The input can be in the form of a string or an array of 8-bit elements. If your language doesn't support it, use the closest alternative. In any case, there should be no UTF encoding for input.
No trigraphs, so no need to escape the ? character
No need to handle the null character (code 0) in input - let it be an end-of-string marker, or a regular byte like others - whatever is more convenient
Code golf: shortest code is the best
You are not allowed to vandalize the Wikipedia article to bend the rules :)

P.S. Summary of the Wikipedia article:

Input byte | Output | Note
0x01       | \1     | octal escape
0x02       | \2     | octal escape
0x03       | \3     | octal escape
0x04       | \4     | octal escape
0x05       | \5     | octal escape
0x06       | \6     | octal escape
0x07       | \a     | alarm
0x08       | \b     | backspace
0x09       | \t     | tabulation
0x0a       | \n     | newline
0x0b       | \v     | vertical tabulation
0x0c       | \f     | form feed
0x0d       | \r     | return
0x0e       | \16    | octal escape
0x0f       | \17    | octal escape
...        |        | octal escape
0x1f       | \37    | octal escape
0x22       | \"     | escape with a backslash
0x5c       | \\     | escape with a backslash
0x7f       | \177   | octal escape
0x80       | \200   | octal escape
...        |        | octal escape
0xff       | \377   | octal escape
other      |        | no escape

solutions can be in any language, or must be C ?

Any language, of course!

In your hexdump example, I assume you mean 64 0A 06?

@Alchymist I do! Confusion fixed.

JavaScript (ES6) 152
First time ever that .reduceRight seems useful. (But probably the good old .map can do better). The point is, I need to see the next character before deciding whether to output a short or long octal escape.
f=s=>[...s].reduceRight((a,c)=>
((x=c.charCodeAt())==34|c==(q='\\')?q+c:x>31&x<127?c:q+('abtnvvr'[x-7]||(a>='0'&a<'8'?512+x:x).toString(8).slice(-3)))+a
)

source: Stack Exchange

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

sort: votes


text:
Tree traversing
Have you heard about trees?
When performing DFS on a binary tree, you can traverse it in 3 possible orders.

Root, left node, right node (Pre-order)
Left node, Root, right node (In-order)
Left node, right node, root (Post-order)

Check wikipedia to know more.
For this challenge, you have to provide a program that, given the pre and in order traverses of a tree returns the original tree.
Example 1:
Inputs
Preorder:
[1 2 3 4 5 6 7]

In order:
[2 1 4 3 6 5 7]

Returns:
[1 [2 3 [4 5 [6 7]]]]

NOTES:
Result notation
[a [b c]]

Node a is the parent of nodes b and c. However in this one
[a [b [c]]]

Node a is the parent of node b, but it's b in this case the parent of c.
More considerations

The tree might not be balanced.
For every 2 traverses, the original tree is unique.
Submissions can be programs and functions.
The input format has to be a sequence of numbers representing the order in which the nodes are visited.
The output format must be exactly as specified above.
Shortest code in bytes wins.

Good luck

Are the elements guaranteed to be distinct?

So in the result, if there's only a single child, it's not defined whether the child is the left or the right?

Haskell, 114 bytes
[a]#_=show a
(a:b)#c|(d,_:e)<-span(/=a)c,(f,g)<-splitAt(length d)b=[a]#c++" ["++f#d++' ':g#e++"]"
a?b='[':a#b++"]"

Example run:
*Main> [1,2,3,4,5,6,7]?[2,1,4,3,6,5,7]
"[1 [2 3 [4 5 [6 7]]]]"

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


text:
Greater Average Submatrix
Objective
Write a program in any language that reads a matrix from stdin in which all columns are space delimited and all rows are newline delimited. The program must output a sub matrix so as that there is no other sub matrix with greater average, this sub matrix' average value, as well as the starting and ending coordinates. Each sub matrix must be at least 2x2. The initial matrix can be an m x n matrix where 2 < m < 256 and 2 < n < 512. For each element e, you know that -1000000 < e < 1000000
Example Inputs
A)
1 2 3 4 5 6
7 8 9 10 11 12
13 14 15 16 17 18

B)
1 1 1
1 1 1
1 1 1

Example Output
A)
Sub Matrix:
11 12
17 18
Average of all values:
14.5
Starting Coordinates:
[4,0]
Ending Coordinates:
[5,1]

B)
Sub Matrix:
1 1
1 1
Average of all values:
1
Starting Coordinates:
[0,0]
Ending Coordinates:
[1,1]

Rules
You may not use any matrix related library provided for your language but you may use lists, arrays, tables, dictionaries and all the operations that can be performed without including / importing anything in your language.
Scoring

You get one point for every additional byte of code.
You get one point for every variable you use (even if it's a list).
You get one point for every function / method (including lambda / anonymous) you use.
The winner is the solution with the fewest points.

What if there are multiple solutions (like your B example all non-empty submatricies are valid answers.)

@Zereges This is why the question states that there shouldn't be a sub matrix with greater average. This essentially means that if there are duplicates, any one of them is welcome.

The required output is somewhat unclear. In the text, it says "must output a sub matrix". But then in the examples, it also shows the average value, and the coordinates of two corners. Is all of this required?

@RetoKoradi Sorry, answer edited. These are actually required.

Surely there's always a maximum-average matrix of the smallest allowed size 2x2, since the average of a matrix is the average of its 2x2 submatrices?

@xnor I'm not sure I understand the question but you're not looking only for 2x2. You have to compare all the 2x2's to all the 2x3's and the 3x2's and the 3x3's etc. I can think of certain cases where a 3x3 can have a greater average than a 2x2.

Is the submatrix a single contiguous block, or can it be an arbitrary subset of the rows and columns? Apparently the term is ambiguous. I was thinking of the second, but since you mention starting and ending coords, you probably mean the first, in which case the best submatrix indeed might not be 2x2.

@xnor No, a sub matrix is a rectangle so the first case is true.

Well, since avg(a,b) <= max(a,b), there will always exist submatrix of size 1x1 which has greatest avg. So the question can be reformulated as find maximum of following numbers.

@Zereges It does say that the submatrix must be at least 2x2.

@xnor On the theory that there is always a 2x2 that has the maximum average. I don't think that's true. Counter-example: a 3x3 matrix with values ((9 0 9) (0 9 0) (9 0 9)). The average of the whole matrix is 45/9 = 5. Each 2x2 submatrix has the values ((9 0) (0 9)) or ((0 9) (9 0)), which all have an average of 18/4 = 4.5.

@RetoKoradi Yes, that's true. I had mistakenly understood submatrix to allow a non-contiguous of the rows and columns, where taking the first and last of each would give average 9.

@DaKnOb What if all arrays/lists available in your language are matrices, and almost every command there is is about manipulating matrices?

@flawr If you are not including a library and these are built in functions (MatLab comes to mind) then you are free to use them.

If elements can be negative, is greatest defined as max(abs()) or most +ve?

@TomCarpenter The greatest is defined as the maximum numerical value. No absolute value is put in place. Between -10 and 2, 2 is the greatest number.

That's what I figured, just wanted to check.

Example output A, starting should be 4,1 ending should be 5,2

MATLAB, 332 + 9 + 7 = 348
The code:
v=str2num(input(''));s=size(v);d=[];e={};for m=1:s(1)-1 for n=1:s(2)-1 for o=1:s(1)-m for p=1:s(2)-n q=v(o:m+o,p:n+p);e=[e {q}];d=[d;mean(q(:)) o p o+m p+n];end;end;end;end;[~,m]=max(d(:,1));disp('Sub Matrix:');disp(e{m});fprintf('Average of all values:\n%f\nStarting Coordinates:\n[%d,%d]\nEnding Coordinates:\n[%d,%d]\n',d(m,1:5))

And an explanation
%Functions used (7):
%    input str2num size mean max disp fprintf
%Variables used (9):
%    v s d e m n o p q

v=str2num(input('')); %Convert to matrix (new lines and spaces are correctly handled by str2num to form dimensions)
s=size(v); %Dimensions of n.
d=[];
e={};
for m=1:s(1)-1
    %Loop through all widths from 2 up to the width of the matrix (-1 to save doing that later)
    for n=1:s(2)-1
        %Loop through all heights from 2 up the the width of the matrix (-1 to save doing that later)
        for o=1:s(1)-m
            for p=1:s(2)-n
                %Extract the sub array
                q=v(o:m+o,p:n+p);
                %Store the sub array in a cell array so we don't have to extract it later.
                e=[e {q}];
                %Append to the list the details (mean and indicies) of this sub array.
                d=[d;mean(q(:)) o p o+m p+n];
            end
        end
    end
end
%Find the index of the sub array with the largest mean
[~,m]=max(d(:,1));
%And print the output
disp('Sub Matrix:');
disp(e{m});
fprintf('Average of all values:\n%f\nStarting Coordinates:\n[%d,%d]\nEnding Coordinates:\n[%d,%d]\n',d(m,1:5))

input asks for you to enter the matrix. Because MATLAB struggles with new lines, you need to type something like ['1 2 3 4' 10 '5 6 7 8'] Note that the 10 is the new line character. This basically just forms the array exactly as your string would be (the ' and [] are not passed in to the code)

I'm not a Matlab expert (I only used it like 2-3 times) but is the last semicolon necessary?

@DaKnOb good point :)

Matlab, 386 = 366 + 12 + 8
I assumed that we have to make outputs exactly formatted like the output example.
Variables:
a,N,r,c,M,i,j,k,l,P,p,n

Functions:
input,char,str2num,numel,reshape,mean,disp,sprintf

Code (added newlines and indenteation for readability):
a=input('');
N=char(10);
r=sum(a==N);
a(a==N)=32;
a=str2num(a);
c=numel(a)/r;
a=reshape(a,r,c);
M=-inf;
for i=1:r-1;
    for j=1:c-1;
        for k=i+1:r;
            for l=j+1:c;
                P=a(i:k,j:l);
                p=mean(P(:));
                if p>M(1);
                    M=[p,i,j,k,l];
                    n=P;
                end;
            end;
        end;
    end;
end;
disp('Sub Matrix:');
disp(n);c='ing Coordinates:\n[%d,%d]\n';
disp(sprintf(['Average of all values\n%d\nStart',c,'End',c],M(1),M(2),M(3),M(4),M(5)))

You can save a variable (N) and some code by getting rid of N=char(10); and simply putting 10 in place of every N


text:
The Attack of the Knights
Objective
You have two knights on a standard chessboard labelled 1-8 and A-H, one knight is located at 1C and the other at 2G. You have to write a program in the language of your choosing that accepts a set of coordinates from stdin, like 2C, and then calculates which of the two knights you have to move in order to capture the enemy pawn at the provided coordinates with the least amount of moves assuming it is standing still. The program must also output which are these moves that the knight has to make.
Example Usage
# echo 1C|./faster
Move Knight: 1C
Moves:

Also
# echo 3B|./faster
Move Knight: 1C
Moves: 1C -> 3B

One more
# echo 5A|./faster
Move Knight: 1C
Moves: 1C -> 3B
Moves: 3B -> 5A

Output shall be exactly as shown.
Useful Resources
Knight's Tour
Bonuses
You get -50 Bytes if your program is expandable and works with N knights.

You posted two challenges in rapid succession. Did you get these challenges from some external website? In that case, you should link to them. If you wrote these challenges yourself, that's rather impressive :-).

Suggestion: remove the [code-challenge] tag; I think there's a [chess] tag, instead of "you get one point ..." or "you lose 50 points", remove the three points of the Scoring System and instead put under "Bonuses", "-50 chars if your code works with N knights". Also, I recommend using the sandbox in the future.

@Justin I just started posting in Code Golf. I actually have a collection of them and I came up with most of them. Now some of them may be duplicates because someone else must have thought of it too, but I haven't checked. I just hope you like them..

@Justin Thanks. Suggestions implemented. I'm still learning

Very closely related -- http://codegolf.stackexchange.com/q/2645/42963

@TimmyD Well spotted. One could go ahead and use these algorithms and just add the comparison logic. This still has some challenge in it but you're definitely right.

The choice of squares is interesting. Because a knight always hops to an opposite coloured square, and these squares are opposite coloured, it means there is never a "draw." By convention, squares are normally labelled A1 instead of 1A, but that doesn't make any difference.

Do we have to consider an 8x8 board, i.e. 1-8 and A-H? Do we have to output exactly as shown in the example? If so, what do we do if more than one move is required? Continue on the same line?

@steveverrill Yes, this is an 8x8 board. If there are more than one moves you can output them however you want as long as it's humanly understandable without much effort. You can use for example a comma separated list or a new line. It's up to you.

@DaKnOb So there is no need for the superfluous Move Knight 1C \n Moves:  then? For example 1 I can output simply 1C, for example 2 1C 3B and for 5C I can output either 1C 3B 5C  or 1C 3D 5C ?

@steveverrill I've updated the question. You must have the same output as above. I'm standardizing this so different answers don't get a head start because of less verbose output.

@DaKnOb That's fine. It's really important with Codegolf it's really important to specify exactly what output is allowed.

@DaKnOb  BTW you still haven't said what we should do if there is more than one path of the same length. I guess any valid output is OK?

@steveverrill Yes, any path in that case is correct. In general I want a path such as that there are no shorter paths than this one.

I don't see how the Knight's Tour is relevant to this challenge.

@Doorknob First of all it proves that this challenge is possible and second of all it might help in finding the perfect algorithm for knight movement.

For the N knights bonus version, where are the knights?

@AndersKaseorg Their positions should be configurable. For example you could have a list of all Knight positions and then your program could iterate over the list when given a point in the chess board.

Mathematica  1183 483 bytes (or 190) bytes
Approach 1
240-50 (bonus) = 190 bytes
The knight's tour can be represented as a graph.  So the issue becomes simply to find the shortest path from each knight to the pawn.  Mathematica offers both KnightTourGraph and FindShortestPath as built-in functions.
w@p_:=Characters@p/.{r_,s_}:>(ToCharacterCode[s][[1]]-65)*8+ToExpression@r
z@v_:=ToString@(v~Mod~8/.{0->8})<>FromCharacterCode[Quotient[v-1,8]+65]
p_~h~k_:=Row[SortBy[(z/@FindShortestPath[8~KnightTourGraph~8,#,w@p])&/@w/@k,Length][[1]],"->"]

Examples
h["5A",{"1C","2G"}]

1C -> 3B -> 5A

h["8G",{"1C","2G"}]

2G -> 3E -> 5D -> 7E -> 8G

Approach 2
(533-50 (bonus)= 483  bytes)
Here the knight's tour graph is constructed without using KnightTourGraph.
s@v_:=
Sort[{v,#}]/.{{a_, b_}:>UndirectedEdge[a,b]}&/@(
If[If[#4==1,Greater,Less][Mod[v-1,8]+1,#1]&&If[#5==1,Greater,Less][Quotient[v-1,8]+1,#2],v+#3,Nothing]&@@@{{1,2,-17,1,1},{8,2,-15,0,1},{2,1,-10,1,1},{7,1,-6,0,1},{2,8,6,1,0},{7,8,10,0,0},{1,7,15,1,0},{8,7,17,0,0}})
w@p_:=Characters[p]/.{r_,q_}:>(ToCharacterCode[q][[1]]-65)*8+ToExpression@r
z@v_:=ToString@(Mod[v,8]/.{0 -> 8})<>FromCharacterCode[Quotient[v-1,8]+65]
p_~f~k_:=Row[SortBy[(z/@FindShortestPath[Graph[Range@64,Union@Flatten[s/@Range@64]],#,w@p])&/@w/@k,Length][[1]],"->"]

Explanation
Below are two views of the chessboard.
On the left, each chessboard position corresponds to vertex bearing an integer name.   On the right, the positions have been labelled according to the convention suggested by the OP.
In both figures, White sits on the right, Black sits on the left.

Legal moves of a knight are paths along a knight tour graph.
The function, s, generates all 512 moves (as if each square allowed for 8 knight moves), eliminates inverses, and then weeds out the moves that would land off the board.  There are 168 edges on the graph.
edges consists of a list of elements of the form, UndirectedEdge[a,b]. For instance, the edge, UndirectedEdge[1,11]corresponds to the idea that a knight at vertex 1, that is, at "A1" in standard notation, may jump to vertex 11, or "B3", and vice-versa.
toVertex takes a position (see right board) and returns a vertex (see left board).  For instance toVertex["3H"] returns 59.
toChessPosition does the opposing conversion, namely from a vertex to a chess position.
vertexNames is a list of replacements: {1->"1A",2->"2A"...64->"8H"}.
This is only needed for the right chessboard figure shown above.
numberedKnightsTouris the graph displayed above on the left.
chessKnightsTouris the graph displayed above on the right.
The graphs are constructed using the above-defined vertices and edges.
findShortestPath receives the position of the pawn and a list of positions of the knights and finds the shortest path along the graph from a knight to the pawn.
    s@v_:=
Sort[{v,#}]/.{{a_, b_}:>UndirectedEdge[a,b]}&/@(
If[If[#4==1,Greater,Less][Mod[v-1,8]+1,#1]&&If[#5==1,Greater,Less]
edges=Union@Flatten[s/@Range@64];
toVertex[p_]:=Characters[p]/.{rank_,file_}:> (ToCharacterCode[file][[1]]-65)*8+ToExpression[rank]
toChessPosition[v_]:=ToString@(Mod[v,8]/.{0->8})<>FromCharacterCode[Quotient[v-1,8]+65]
vertexNames=Thread[Range@64->(toChessPosition[#]&/@Range[64])];
numberedKnightsTour=Graph[Range@64,edges,VertexLabels->"Name",GraphLayout->"SpringEmbedding"];
vertexNames=Thread[Range[64]->(toChessPosition[#]&/@Range[64])];
chessKnightsTour=Graph[Range@64,edges,ImageSize->Large,VertexLabels-> vertexNames,GraphLayout->"SpringEmbedding"];
GraphicsGrid[{{numberedKnightsTour,chessKnightsTour}},PlotLabel->"For each board below, \nWhite sits at Right, Black at Left\nNumbers refers to rank, letters refer to file",ImageSize->Large]
    findShortestPath[pawn_,knights_]:=Row[SortBy[(toChessPosition/@FindShortestPath[chessKnightsTour,#,toVertex@pawn])&/@toVertex/@knights,Length][[1]],"->"]