text:
"Convenient palindrome" checker
If you've ever tried to write palindromic code before, you'd know how much brackets tend to get in your way. ()() is not a palindrome, even though it kinda looks like it should be, while ())( and ()( are both palindromic and both very dumb looking. Wouldn't it be convenient if it was the other way around?
A string is conveniently palindromic if it is equal to the string derived when its reverse has all its parentheses (()), brackets ([]), and braces ({}) flipped. No other characters are special and require flipping. (<> are sometimes paired but often not so they are left out.)
Your task is to write, in your language, a program (taking input on STDIN) or a function (taking a single string argument) which (a) gives a consistent true value* when its argument is conveniently palindromic and a different, consistent false value otherwise, and (b) is itself conveniently palindromic.
For example, the following inputs are conveniently palindromic:
racecar
(a)(bb)(a)
void main(int argc, *char[] argv) {} (vgra []rahc* ,cgra tni)niam diov

And the following are not:
non-palindrome
A nut for a jar of tuna?
(old [style] parens) )snerap ]elyts[ dlo(
ingirumimusnocte)etconsumimurigni

You may not rely on any external state (specific filename, directory structure, other user input, web access, etc) except interpreter/compiler flags.
Also, you may not use "the comment trick" where you comment out or render unused some piece of code by taking advantage of your language's commenting facilities. For instance, all of the following are not allowed, because they contain non-functional parts that can be safely removed or destroyed (at the expense of losing conveniently-palindromic-ness):
{some code} // {edoc emos}
{some code} NB.BN {edoc emos}
"n\" ;{edoc emos} ;"; {some code}; "\n"

Obviously this might not cover every such case, but the spirit of the challenge here is not to use comments and unparsed** code to achieve palindrominess, instead making use of the corrected parens and brackets. I'm looking at you, LISP, Brainfuck.
This is a code-golf, so the shortest code wins, but all lengths of code are welcome.
* By consistent true and false values, I mean that you can return one of a pair of values, such as 1 for true and 0 for false, or False for true and "no" for false, so long as these values are different from each other, and do not change from run to run of your program. Use whatever saves you characters.
** Not to be confused with unexecuted: code that is valid and might do weird things but never called is fine.

What about things like if(false){some code} or unused variables? Are they allowed?

@ace If your language somehow parses or checks the unexecuted code for type agreement or syntactic validity, that's fine. If it is tantamount to a comment because your language doesn't check the inside of that block, when it would throw a syntax error if it did, that's not fine. I think if you can find a valid use for (eslaf)fi, you get to use if(false).

It took me way too long to figure out why ()() is not a palindrome

Does the code have to work with multi-line input?

@Ventero Newlines and carriage returns are characters, and they don't have any pairs to flip with, so I'd say they count as normal characters.

void main() is bad and the correct syntax for argv is char *argv[].

J (60)
(|.-:'())([]][{}}{'&charsub) :: (busrahc&'}{{}][[])(()':-.|)

This is a function that takes an argument:
   (|.-:'())([]][{}}{'&charsub) :: (busrahc&'}{{}][[])(()':-.|) 'ingirumimusnocte)etconsumimurigni'
0
   (|.-:'())([]][{}}{'&charsub) :: (busrahc&'}{{}][[])(()':-.|) '(a)(bb)(a)'
1

Explanation:

f :: g runs the function f over the input, and returns the result if it returns without error. If f fails, it runs g instead.
The f here is (|.-:'())([]][{}}{'&charsub), which does the actual work:

|.: reverse
-:: is equal to
'())([]][{}}{'&charsub: replacing each bracket with its opposing bracket

The g function is (busrahc&'}{{}][[])(()':-.|), which is nonsense but syntactically valid. busrahc is not defined, but that doesn't matter because it is only resolved when it is run (and it won't run).

You can save a character by turning your f :: g into g@-@f. g is equivalent to the hook (-.|) because of : so the outputs become -1 and the empty list for conveniently palindromic and not, respectively.

GolfScript, 107 91
.4:ab-1:ba=;1
%ba%{...fi@@=
c43.=;)('"([{
}])"'~?~'"([{
}])"')(;=.34c
=@@if...}%ab%
1;=ab:1-ba:4.

Newlines are artistic. fi, c43 and c are noops, but the entire code is executed.
Prints -3-1-1 for convenient palindromes, -4-1-1 otherwise. Try it online!
Alternate version, 155 bytes
At the cost of 64 bytes, this can be improved upon:
0!*1{!}\;:);0:f;0:i;-1:ab;9:ba;
...=;1%ab%{....i@f@@fi@@=@.=@\)
+""'"([{}])"'~+?+~'"([{}])"'""+
(\@=.@=@@if@@f@i....}%ba%1;=...
;ab:9;ba:1-;i:0;f:0;(:;\{!}1*!0

As before, the entire code is executed and every single byte affects the output.
Prints 010 for convenient palindromes, -100 otherwise. Try it online!
Tests and examples
$ base64 > palindrome.gs -d <<< LjQ6YWItMTpiYT07MSViYSV7Li4uZmlAQD1jNDMuPTspKCciKFt7fV0pIid+P34nIihbe31dKSInKSg7PS4zNGM9QEBpZi4uLn0lYWIlMTs9YWI6MS1iYTo0Lg==
$ wc -c palindrome.gs
91 palindrome.gs
$ rev palindrome.gs | tr '([{}])' ')]}{[(' | diff - palindrome.gs
$ echo -n 'r(a[c{"e"}c]a)r' | golfscript palindrome.gs
-3-1-1
$ echo -n 'totallynotapalindrome' | golfscript palindrome.gs
-4-1-1
$
$ base64 > pal.gs -d <<< MCEqMXshfVw7Oik7MDpmOzA6aTstMTphYjs5OmJhOy4uLj07MSVhYiV7Li4uLmlAZkBAZmlAQD1ALj1AXCkrIiInIihbe31dKSInfis/K34nIihbe31dKSInIiIrKFxAPS5APUBAaWZAQGZAaS4uLi59JWJhJTE7PS4uLjthYjo5O2JhOjEtO2k6MDtmOjA7KDo7XHshfTEqITA=
$ wc -c pal.gs
155 pal.gs
$ rev pal.gs | tr '([{}])' ')]}{[(' | diff - pal.gs
$ echo -n 'r(a[c{"e"}c]a)r' | golfscript pal.gs
010
$ echo -n 'totallynotapalindrome' | golfscript pal.gs
-100
$ for i in {1..154}; do head -c $i pal.gs > tmp.gs; tail -c +$[i+2] pal.gs >> tmp.gs
> [ "$(echo -n 'r(a[c{"e"}c]a)r' | golfscript tmp.gs 2> /dev/null)" = "010" ] && echo $i
> done; rm tmp.gs
1
for i in {1..154}; do head -c $i pal.gs > tmp.gs; tail -c +$[i+2] pal.gs >> tmp.gs
>  [ "$(echo -n '42' | golfscript tmp.gs 2> /dev/null)" = "-100" ] && echo $i
> done | grep '^1$'; rm tmp.gs

How it works
.             # Duplicate the input string.
4:ab-1:ba     # Save 4 in “ab” and -1 in “ba”.
=;            # Compare 4 to -1 and discard the result.
1%            # Save every element from the input string in a new string.
ab%           # Reverse the input string.
{             # For each character in the input string:
  ...         # Duplicate the character thrice.
  fi          # Variable “fi” is undefined; this does nothing.
  @@=         # Verify that the character is equal to itself; push 1.
  c43         # Variable “c43” is undefined; this does nothing.
  .=;         # Verify that 1 is equal to itself and discard the result.
  )(          # Increment and decrement the character.
  '"([{}])"'~ # Push that string and evaluate it. Result: '([{}])'
  ?           # Retrieve the character's position in '([{}])'. -1 means not found.
  ~           # Negate the position.. Examples: -1 -> 0    0 -> -1    2 -> -3
  '"([{}])"') # Push that string and pop its last element. Result: '"([{}])' 34
  (;          # Decrement 34 (the ASCII code of a double quote) and discard.
  =           # Retrieve the corresponding character.
  .34         # Duplicate the character and push 34.
  c           # Variable “c” is undefined; this does nothing.
  =           # If the character is a double quote, the index was -1.
  @@if        # In that case, replace the double quote with the original character.
  ...         # Duplicate the new character thrice.
}%            #
ab%           # Save every fourth element in a new string to discard dummy values.
1;            # Push 1 and discard.
=             # Push 1 if the modified string matches the original, 0 otherwise.
ab:1-         # Save 4 in “1” and subtract.
ba:4.         # Save -1 in “4” and duplicate.

0!*           # Pop and push the input string.
1{!}\;:);     # Make “)” an alias for “!”.
0:f;0:i;      # Variables.
-1:ab;9:ba;   # Moar variables.
...=;         # Duplicate the input string.
1%ab%         # Reverse the copy.
{             # For each character in the input string:
  ....        # Duplicate the character four times.
  i@          # Push 0 and rotate a string copy on top of it.
  f@@fi@@     # Push 0 and rotate 0 on top of it.
  =@          # Push 1 and rotate a string copy on top of it.
  .=@         # Push 1 and rotate 1 on top of it.
  \)+         # Negate a 1 and add. Result: 1
  ""          # Push that string.
  '"([{}])"'  # Push that string.
   ~+         # Evaluate the second string and concatenate. Result: '([{}])'
   ?          # Retrieve the characters position in '([{}])'. -1 means not found.
   +~         # Add 1 to the position and negate. Ex.: -1 -> -1 | 0 -> -2 | 1 -> -3
  '"([{}])"'  # Push that string.
  ""          # Push that string.
  +           # Concatenate. Result: '"([{}])"'
  (\          # Pop the first double quote and swap it with the rest of the string.
  @=.         # Retrieve the corresponding character and duplicate it.
  @=          # If the character is a double quote, the index was -1.
  @@if        # In that case, replace the double quote with the original character.
  @@          # Rotate the modified character to the bottom.
  f@i....     # Push dummy values.
  }%          #
  ba%         # Save every ninth element in a new string to discard dummy values.
  1;          # Push 1 and discard.
  =           # Push 1 if the modified string matches the original, 0 otherwise.
  ...;        # Duplicate thrice and discard the last copy.
  ab:9;ba:1-; # Variables.
  i:0;f:0;    # Moar variables.
  (:;\        # Negate, override “;” and swap.
  {!}1*!0     # Negate twice and push 0.

Ruby, 110
(z=gets;r=z.tr *["([{}])",")]}{[("];p *z==r.reverse;1)||(1;esrever.r==z* p;[")]}{[(","([{}])"]* rt.z=r;steg=z)

Prints true if the input is a convenient palindrome and false if it isn't. Note that this solution assumes that the input isn't terminated by a newline, so test it with echo -n:
echo -n '(a)(bb)(a)' | ruby convpal.rb
true

echo -n '(a)(bb()a(' | ruby convpal.rb
false

# note that for this to work, the file must not contain a newline
# to remove a trailing newline, pipe it through tr -d $'\n'
cat convpal.rb | ruby convpal.rb
true

This is a somewhat straightforward port of my answer to Palindromic Palindrome Checker (and not really golfed so far). The main trick used is that the first parenthesised expression always returns 1, so the second half of the boolean expression is never evaluated (but it is parsed).
The only difficulty in adapting this was figuring out how to add the call to z.tr so that its "convenient reverse" would also be syntactically valid - but I could simply use the same trick I already used puts: *, which in the first half is parsed as splat operator (use array contents as function parameters) and as array multiplication (or repitition) operator in the second half.
Ruby, 157 297, all code executed
w=tsoh=gets p
o=rt=esrever=Gem
q=tsoh.tr *["([{}])",")]}{[("]
q==esrever.host=w=tsoh.reverse==q
[")]}{[(","([{}])"]* rt.host=q
meG=reverse=tr=o
p steg=host=w

This (slightly longer) version executes all code, and all but two lines affect the output, which is printed in the last line - but all lines are parsed and executed without any errors. This version interprets any trailing newline as part of the input, so use either echo -n to test it, or prepend your input with a newline. It prints true if the input is a convenient palindrome, and false otherwise.
Explanation
# Read the input by calling gets(nil), which is achieved by passing the return
# value of a call to Kernel#p (which returns nil if no argument is supplied) to
# gets.
w=tsoh=gets p
# Assign the global Gem module to three variables.
# The variable names are the reversed names of methods we have to call later.
# This doesn't necessarily have to be the Gem module, any global module/variable
# (or class that allows object creation through a call to the module itself,
# e.g. Hash or GC) with a writable property would do, but Gem#host was
# the shortest one I could find. This is necessary because Ruby doesn't
# allow setting previously undefined properties through the dot syntax.
o=rt=esrever=Gem
# Replace the parentheses with the corresponding flipped one.
# sserts is the reverse of the property name we're going to use later.
q=tsoh.tr *["([{}])",")]}{[("]
# Do the convinient palindrome check and assign its result to a few variables
# and Gem's host property.
q==esrever.host=w=tsoh.reverse==q
# Here, the * is parsed as array join operator.
[")]}{[(","([{}])"]* rt.host=q
# Nothing special here.
meG=reverse=tr=o
# Print the result of the palindrome check, which was stored in w.
p steg=host=w

GolfScript, 61 chars
OK, here's a baseline solution in GolfScript.  I'm sure it could be further improved:
{.-1%{"([{}])".2$?~@[.]@+=}%=}~{=%{=+@[.]@~?$2."([{}])"}%1-.}

As usual for GolfScript, this program reads its input from stdin.  It outputs:
1{=%{=+@[.]@~?$2."([{}])"}%1-.}

if the input is a convenient palindrome, as defined in the challenge above, and:
0{=%{=+@[.]@~?$2."([{}])"}%1-.}

if it is not.
Explanation: This program relies heavily on the ruling that unexecuted code is OK, as long as it gets parsed.  It consists of two code blocks, delimited by curly braces ({ }), which are mirror images of each other.
The first code block is executed by the ~ following it, and checks if the input is a convenient palindrome, outputting 1 if it is and 0 if it isn't.  The second code block is not executed, and so simply remains on the stack until the program ends and everything on the stack gets automatically stringified and printed by the GolfScript interpreter.
It should be noted that the GolfScript interpreter does very few syntax checks at parse time (or ever, for that matter); a GolfScript code block literal can contain almost anything, even if it might crash when executed.  Still, a few syntax errors, such as unterminated string literals, do raise an error even in unexecuted code, so I believe this solution (barely) falls within the rules.
Ps. Looking at the actual executed code, it contains a few conveniently palindromic elements like @[.]@, the string literal "([{}])", and even the loop %{ ... }%.  This offers the tantalizing suggestion that an "intrinsically palindromic" GolfScript solution, where the full palindromic program would be executed and functional, might actually be possible.  As I haven't managed to produce one myself yet, I hereby offer a +100 rep bounty to the first person who manages to come up with one!

wait, ur code is a palindrome itself? :O

I'm inclined to consider this solution more like the "n\";X;";X;"\n"-kind of commenting, but I'll give you the benefit of the doubt. I was really looking for such "intrinsically palindromic" solutions to begin with, however, or at least ones where the non-execution of blocks was a little more underhanded.

My answer has a noop (undefined variable) and a few parts that accomplish nothing (e.g., 1;). Does that still count as fully functional?

@Dennis: Yeah, I think it does. Congratulations, it's certainly impressive enough. The question seems to be new enough that I can't post the bounty on it yet, but you'll have it in a few days.

There's no hurry. I didn't manage to get rid of the undefined variable fi, but at least dropping any of its letters now breaks something.

output format leeway abuuuse :-)

JavaScript (ES6), 245 bytes
I wanted a JS answer that could be run in the browser, so here it is.
eurt=>eurt==(("",eurt))["split"||"nioj"]("")["map"||"esrever"](x=>({'{':'}','}':'{','[':']',']':'[','(':')',')':'('})[x]||x||[x]({')':'(','(':')',']':'[','[':']','}':'{','{':'}'})>=x)["reverse"||"pam"]("")["join"||"tilps"]((true,""))==true>=true

Removing all code that is never actually run, we get this:
eurt=>eurt==(("",eurt))["split"||"nioj"]("")["map"||"esrever"](x=>({'{':'}','}':'{','[':']',']':'[','(':')',')':'('})[x]||x||[x]({')':'(','(':')',']':'[','[':']','}':'{','{':'}'})>=x)["reverse"||"pam"]("")["join"||"tilps"]((true,""))==true>=true
eurt=>eurt==(("",eurt))["split"        ]("")["map"           ](x=>({'{':'}','}':'{','[':']',']':'[','(':')',')':'('})[x]||x                                                           )["reverse"       ]("")["join"         ]((true,""))==true>=true

Which can be simplified to this:
eurt=>eurt==eurt.split("").map(x=>({'{':'}','}':'{','[':']',']':'[','(':')',')':'('})[x]||x).reverse("").join("")

You can save some 60 bytes by using n1/1n instead of true/eurt, commas in some places instead of ||, and fiddling with the bracket switcher: n1=>n1==(('',n1))['nioj','split']``['esrever','map'](c=>`()[]{}`[`()[]{}`['indexOf'](c)^1]||c||[1^(c)['fOxedni']`{}[]()`]`{}[]()`>=c)['pam','reverse']``['tilps','join']((1n,''))==1n>=1n (185 bytes)

Javascript (ES6) 288
Runs in the Spidermonkey command line shell. Reads a single line from STDIN and outputs true or false depending on if the input is a convenient palindrome.
((print)((eval)('r=readline()')==([0]['map']['call'](r,x=>({'{':'}','}':'{','[':']',']':'[','(':')',')':'('})[x]||x)['reverse']()['join']('')))&&((('')['nioj']()['esrever'](x||[x]({')':'(','(':')',']':'[','[':']','}':'{','{':'}'})>=x,r)['llac']['pam'][0])==('()enildaer=r')(lave))(tnirp))

This code is syntactically valid, but everything after && is not executed, as the print function returns a falsey value.
You can run this code in Firefox's console by running this shim first to emulate the readline and print functions. Edit the input inside readline as needed:
readline = function(){
    return "void main(int argc, *char[] argv) {} (vgra []rahc* ,cgra tni)niam diov";
}, print = console.log.bind(console);

And here's a quick example of the output:

Taking advantage of && was really clever, I commend you (but it does seem a little cheaty)

05AB1E, 35 bytes
"{[()]}"DRr‡`rJ¹Q,Q¹Jr`‡rRD"{[()]}"

Try it online!
Explanation:
                     # Implicit input
 "{[()]}"            # Push "{[()]}" onto the stack
         DR          # Pushes a reversed copy onto the stack
           r         # Reverse the order of the stack
            ‡        # Transliterate
             `       # Flatten array on stack
              r      # Reverse order of stack
               J     # Join stack
                ¹Q   # Check equality with first input
                  ,  # Print
                     # Everything after is still syntactically correct, but just does not print anything.

I don't think this will help since the answer is invalid but instead of "()[]{}" you can do žu„<>-

@daHugLenny It's valid now

Is the rest of the program after q at least parsed for syntactic validity? If not, I'd consider this tantamount to commenting out the second half of the code.

@algorithmshark Fixed.

CJam, 38 bytes
Q~"=re%W_@%W_q"`{[()]}`"q_W%@_W%er="~Q

Prints "=re%W_@%W_q"1 if the input is conveniently palindromic and "=re%W_@%W_q"0 otherwise.
Try it online in the CJam interpreter.
How it works
Q~                                     e# Evaluate an empty string.
  "=re%W_@%W_q"                        e# Push that string.
               `                       e# Inspect. Pushes "\"=re%W_@%W_q\"".
                {[()]}                 e# Push that block.
                      `                e# Inspect. Pushes "{[()]}".
                       "           "~  e# Push and evaluate.
                        q              e# Read from STDIN.
                         _W%           e# Push a reversed copy.
                            @          e# Rotate "{[()]}" on top of the stack.
                             _W%       e# Push a reversed copy.
                                er     e# Perform transliteration.
                                  =    e# Compare to the input string.
                                     Q e# Push an empty string.

After executing the program, CJam automatically prints all three items on the stack: the inspected string, the Boolean from the string comparison and the empty string.

Perl, 83 + 2 = 85 bytes
Run with -nl
say$_~~reverse y-"({[]})"-")}][{("-r;exit;tixe;r-")}][{("-"({[]})"-y esrever~~_$yas

The code exits after printing the truthiness of the input.  Everything after the semicolon is interpreted (and would crash when the script reaches that point were it not for the exit it encounters), but not executed.  If I left exit;tixe; out of the code, it would still print the result correctly before it crashed.

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


text:
Recognize handwritten digits
Your task is to read an image containing a handwritten digit, recognize and print out the digit.
Input: A 28*28 grayscale image, given as a sequence of 784 plain-text numbers from 0 to 255, separated by space. 0 means white and 255 means black.
Output: The recognized digit.
Scoring: I will test your program with 1000 of the images from the MNIST database training set (converted to ASCII form). I have already selected the images (randomly), but will not publish the list. The test must finish within 1 hour, and will determine n - the number of correct answers.
n must be at least 200 for your program to qualify. If the size of your source code is s, then your score will be calculated as s * (1200 - n) / 1000. Lowest score wins.
Rules:

Your program must read the image from the standard input and write the digit to the standard output
No built-in OCR function
No third-party libraries
No external resources (files, programs, web sites)
Your program must be runnable in Linux using freely available software (Wine is acceptable if necessary)
The source code must use only ASCII characters
Please post your estimated score and a unique version number every time you modify your answer

Example input:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3 18 18 18 126 136 175 26 166 255 247 127 0 0 0 0 0 0 0 0 0 0 0 0 30 36 94 154 170 253 253 253 253 253 225 172 253 242 195 64 0 0 0 0 0 0 0 0 0 0 0 49 238 253 253 253 253 253 253 253 253 251 93 82 82 56 39 0 0 0 0 0 0 0 0 0 0 0 0 18 219 253 253 253 253 253 198 182 247 241 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 80 156 107 253 253 205 11 0 43 154 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 14 1 154 253 90 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 139 253 190 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 11 190 253 70 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 35 241 225 160 108 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 81 240 253 253 119 25 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 45 186 253 253 150 27 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 16 93 252 253 187 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 249 253 249 64 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 46 130 183 253 253 207 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 39 148 229 253 253 253 250 182 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 24 114 221 253 253 253 253 201 78 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 23 66 213 253 253 253 253 198 81 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 18 171 219 253 253 253 253 195 80 9 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 55 172 226 253 253 253 253 244 133 11 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 136 253 253 253 212 135 132 16 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

By the way, if you prepend this line to the input:
P2 28 28 255

you will obtain a valid image file in pgm format, with inverted/negated colors.
This is what it looks like with correct colors:
Example output:
5

Standings:
No.| Name         | Language   | Alg | Ver | n   | s   |  Score
----------------------------------------------------------------
 1 | Peter Taylor | GolfScript | 6D  | v2  | 567 | 101 |  63.933
 2 | Peter Taylor | GolfScript | 3x3 | v1  | 414 | 207 | 162.702

Related, but not quite the same (not a challenge, but very useful for finding the latex codes): http://detexify.kirelabs.org/classify.html . It also recognizes numbers.

Can we safely assume that we only need to consider the black pixels? The >127 pixels? What can we assume?

@Quincunx I can't get it to recognize 4. And I'm not sure about your question, but you can check some samples from the training set.

That's because Latex is too complex. It gets \Jupiter though (which looks remarkably similar)

Especially if this is a code golf question, please constrain to black and white input.  People make their entire careers out of solving this problem without having to count characters in their code.  Not publishing which characters you've picked is a way of stopping cheating, and makes it sort of a gamble... and given that it's unreasonable for people to be writing AI here, the fun is doing some weird heuristic and then seeing how well it does in the tournament vs. competition.

@Dr.Rebmu if you really need black and white, you are free to convert the image. People maybe used to make careers out of this 50 years ago, but nowadays it's a basic task for a machine-learning student. Oh, you wrote it's unreasonable to write AI here? I think if you use a suitable language, coughoctavecough, it's perfectly reasonable.

@aditsu Yes, anyone can do it poorly.  But you're not asking for it to be done poorly, you want someone to "win" in a competition, where the character count is measured.  I think paring the problem down a bit is more realistic for hobbyist puzzle solvers.  Constraining the input seems a good start on making it reasonable.  I'd suggest a pre-pass on the input to say that it's black and white.

@Dr.Rebmu Well, a 20% success rate is very poor, but would be enough to qualify, and possibly win if nobody else can do better. Or if the better program is MUCH longer.

It seems there are two main hard parts of OCR: figuring out which pixels are part of the character and determining from the shape which character it is. I recommend you emphasize only the second part as @Dr.Rebmu recommends.

Also: what is the winning criterion?  Is it number of characters, or accuracy against your undisclosed test data?  (Please note: I'm not trying to be mean...I got a surprising beat-down on my Beast puzzle which I thought was simple, but turned out to have lots of edge cases that caught me by surprise...)

@Dr.Rebmu, the scoring system is specified. It's a mixture of accuracy and code length, but with sufficient weight on accuracy that [tag:code-challenge] is more appropriate than [tag:code-golf].

@Dr.Rebmu and anybody else who wants black and white input: feel free to convert the input using a threshold such as 128. I checked and the digits are still recognizable (by my brain). You can try other thresholds too, they may give better results.

For the record, I wrote a pretty dumb solution in python and obtained a score of 1157

I wrote a script that just prints . when >0 (and also for >200 just to see the difference) & space otherwise; and I must say, your test case doesn't really look like a 5 to me.

@KyleKanos check the image I added

Okay, that looks a lot more like a 5 than my output (which is my terminal so it isn't really a square & skewed my image). That weird hook hanging down on the top bar is what really threw me off.

GolfScript 6D (v2: estimated score 101 * 0.63 ~= 64)
This is a very different approach to my earlier GolfScript answer, so it makes more sense to post it as a separate answer at v1 than to edit the other answer and make this v2.
~]:B;569'!EM,R.==|%NL2+^=1'{{32-}%95{base}:^~\^}:&~2/{~B=<}%2^10'#]8Y,;KiZfnnRsDzPsvQ!%4C&..z,g,$m'&=

Ungolfed
~]:B;
[30 183 21 378 31 381 7 461 113 543 15 568]
2/{~B=<}%2base
7060456576664262556515119565486100005262700292623582181233639882 10base
=

Explanation
The raw problem is classification of points in a 784-dimensional space. One standard approach is dimension reduction: identifying a small subset of dimensions which provide sufficient distinguishing power to do the classification. I evaluated each dimension and each possible threshold to identify 18 pairs of (dimension, range of threshold) which looked promising. I then picked the centre of each range of threshold, and evaluated 6-element subsets of the 18 pairs. Finally I optimised the threshold for each dimension of the best 6-D projection, improving its accuracy from 56.3% to 56.6%.
Because the projection is into 6 dimensions and for each dimension I apply a simple threshold, the final lookup table only needs 64 elements. It doesn't seem to be particularly compressible, so the main golfing is to base-convert both lookup tables (the list of dimension and thresholds; and the halfspace vector to digit map) and share the base-conversion code.

You lost me at "784-dimensional space" ;-)

I'm afraid there is a mistake somewhere, I'm only getting 37 correct answers. Also, you're making things a bit ambiguous, could you please add (1) and (2) (like I did) or something similar to your headings?

@aditsu, simple logic error. Now fixed.

So basically you're sampling 6 "relevant" pixels, each with a different threshold, obtaining 6 bits?

@aditsu, exactly.

GolfScript 3x3 (v1: estimated score 207 * 0.8 ~= 166)
~]28/10:?/{zip?/{[]*0-!!}/}%2{base}:^~'"yN(YZ5B 7k{&w,M`f>wMb>}F2A#.{E6T9kNP_s 3Q?V`;Z\'C-z*kA5M@?l=^3ASH/@*@HeI@A<^)YN_bDI^hgD>jI"OUWiGct%7/U($*;h*<"r@xdTz6x~,/M:gT|\\:#cII8[lBr<%0r&y4'{32-}%95^?^2/{))*~}%=

Or in overview,
~]28/10:?/{zip?/{[]*0-!!}/}%2{base}:^~'MAGIC STRING'{32-}%95^?^2/{))*~}%=

Explanation
My approach at a high level is:

Threshold the pixels: if the pixel is above t1 then set it to 1; otherwise to 0.
Group the pixels. Initially I broke the 28x28 grid into a 4x4 grid (each subgrid being 7x7 pixels); but breaking it into a 3x3 grid (subgrids being 10x10, 10x8, or 8x8 pixels) gives a massive reduction in lookup table size while dropping accuracy rate from about 56% to about 40%.
Sum the pixels in each group and threshold again: if the number of set pixels is above t2 then score the group as 1; otherwise as 0.
Do a table lookup by the vector of group scores. (The table is compressed using run-length encoding and the standard base-conversion trick. Most choices of t1 and t2 leave between 50% and 63% of the table as "don't care" values, which can be combined with adjacent values to increase run lengths; the average run length in my v1 table is 3.6).

It turns out that setting t1=t2=0, although not optimal, isn't far off the best values of t1 and t2 in terms of accuracy; is pretty good in terms of table compressibility; and allows me to combine the two thresholding operations into []*0-!! (flatten 2D array to 1D; remove 0s; check whether it's empty).
The lookup table gives the most likely candidate for the given vector of group scores. It may well be possible to improve the score by identifying table entries which can be changed such that the improved compressibility of the table outweighs the decreased accuracy.

Awesome, I had a similar idea but didn't imagine it can compress so well. Now I'm thinking I needed greater emphasis on accuracy :p but I don't plan to change it.

source: Stack Exchange

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

sort: votes


text:
Print the Golden Ratio
This was fun! However with only three digits, the fun was over way too soon. This challenge is similar, but we'll keep the fun going.
The Challenge

Print as many digits of the Golden Ratio φ as possible. The Golden Ratio is defined as the number that satisfies φ = (φ + 1)/φ and the first 100 digits are given by:
1.6180339887498948482045868343656381177203091798057628621354486227052604628189024497072072041893911375...
This challenge is not about computing φ! It's about printing as many digits as possible without using any method for doing that twice. So find as many creative ways to get your digits as you can!

Restrictions
By itself, printing the digits of φ would be a bit too simple, so here are the rules:

You have to construct the number in order from left to right, either by printing it piece by piece or by constructing a string from left to right and printing it at the end - you could even generate an array of digit characters and then join it and print it, as long as you do it in order. In the following rules "print" and "output" may refer to any of those processes (e.g. if you're building a string, and the string contains 1.6 that counts as having 1.6 already printed).

For your code you get a budget of 15 characters per digit. The period does not count towards that budget, but has to be printed as well. Note that the restriction is only on total code size: you may use more than 15 characters for any digit as long as you don't use more on average. In fact, you may build up a "debt" in characters and "pay it off" later. E.g. to print 1.618 you have 60 characters.

Standard-library includes/imports do not count towards the code size. But you can't give those includes shorthand aliases for free!

You must not use the digit you are currently generating, nor any you have already printed. E.g. 1 may appear nowhere in your source code, because it's the very first digit. The code that outputs the 8 in 1.618 may use any or all of the digits [0234579], but none of [168]. For this purpose, all literals that are equivalent to a single digit are treated as that digit. So if your language can represent 9 as '\t' you are not allowed to use that anywhere, where you couldn't use an 9 instead.

You must not produce multiple digits at once. It should be possible to clearly split your code into chunks that generate one digit a time.

You must not refer to any built-in function, mathematical/boolean/bit-wise/string operator, variable or constant which you have used in code that generated an earlier digit. Exceptions are integer-to-string conversion, string concatenation and printing functions which you might need for every single digits. Note that it doesn't matter by which name you refer to any built-in: just because you alias a built-in PI to both p and q doesn't mean you get to use p once and q once. Likewise, you are allowed to use a name twice if it refers to two different built-ins, like string length and array length.
If your programming language doesn't have functions use your best judgement on what the equivalent would be - e.g. for bash scripting, invoking other programs should follow the rules imposed on functions

Your submission must be written in a single language. So no executing another language's interpreter to get access to that language's built-ins as well.

Implications
The following points are all implied by the above rules, but I add them here to avoid questions that have already come up in the sandbox:

You're not allowed to overwrite parts of your output by printing some backspaces (usually '\b') in between.
Loops which generate/output multiple digits are forbidden. (Loops that compute a single digit are fine, though.)
Using an obfuscated version (1 + √5)/2 or dividing Fibonacci numbers to obtain more than a single digit is forbidden.
You cannot precalculate the 10 digits and store them in 10 variables and then just refer to those, because those variable references don't generate the digit - the code that fills the variable does, so this is a violation of rule 6.
In fact, you can't reuse any previous (or intermediate results), because that would mean two digits would share code for being generated.
Otherwise, you can use any means whatsoever (which do not have to purely mathematical) to generate the digits. (And you should!)
In fact there is no need to calculate anything, if you can pull out the correct digits from many different places using your standard library.
You may use an operator multiple times while generating a single digit, so 2+2+2 is fair game to generate the first 6 (although it's unlikely the shortest).
You may use any literal as often as you want, because they are not built-in constants. So as long as you don't have to print 5, you can as many 5s in your code as you want.
You can't hardcode the output, because that would involve using the digits you are outputting.

In short: don't use any method of generating digits twice and don't use the digit you are currently outputting or any have already printed.
If you do spot a loophole which allows you to get a (quasi-)infinite score, please don't ruin the challenge by exploiting it, but let me know so I can see if the loophole can be fixed without breaking anything.
Scoring
The program that prints the highest number of digits correctly wins. In case of a tie the shorter code breaks the tie.
Please add an ungolfed commented version that identifies which part of your code generates which digit.
PS: If anyone beats the 100 digits above, here are some more.

Comments purged; please notify me for any possible lost information.

"Using an obfuscated version..." That's just using the quadratic formula on x = (x+1)/x (or x^2 = x+1) (or x^2-x+1).

....Can I refer to an implementation-defined operator more than once?

Also, can I reuse assignment?

PHP, 100 digits
I'm probably bending the rules a bit here, but PHP has dozens of constants to choose from:
<?php
echo TRUE . '.' . PM_STR . DNS_A . MSG_EOR . LC_ALL . T_FMT . LOCK_UN . SQL_DATE
. E_NOTICE . IMG_WBMP . INI_ALL . E_PARSE . SOCKET_EBADF . LOG_USER .
IMAGETYPE_JPC . IMG_PNG . GLOB_MARK . LOCK_NB . LOG_NDELAY . D_FMT . PHP_ZTS .
GLOB_ERR . AM_STR . SQL_DOUBLE . SOL_TCP . FILE_APPEND . LOG_ERR . SORT_ASC .
SOCK_RAW . LOG_INFO . LC_TIME . SQL_FLOAT . SORT_DESC . INFO_MODULES . E_ERROR .
IMG_GIF . SQL_REAL . LOG_DEBUG . DNS_NS . CODESET . CAL_FRENCH . CURLE_OK .
LDAP_OPT_RESTART . LOCK_SH . XML_PI_NODE . SQLITE_INTERRUPT . MYSQLI_ASYNC .
CURLM_OK . SNMP_NULL . SQLITE_NOMEM . LC_MESSAGES . IMG_JPG . SO_KEEPALIVE .
SOCKET_ENXIO . LOCK_EX . D_T_FMT . ENT_QUOTES . LOG_NOTICE . SOCK_RDM .
INPUT_ENV . CURLAUTH_NTLM . INPUT_SESSION . AF_INET . IMG_JPEG . SQL_CONCURRENCY
. SEEK_SET . SOCKET_EIO . LC_CTYPE . PHP_URL_QUERY . LOG_KERN . INI_SYSTEM .
IMAGETYPE_BMP . SEEK_END . JSON_HEX_QUOT . LOG_PID . LIBXML_DTDATTR .
XML_DOCUMENT_NODE . PHP_DEBUG . LOG_CRIT . ENT_IGNORE . LC_NUMERIC .
DOM_NOT_SUPPORTED_ERR . PHP_URL_FRAGMENT . FILE_TEXT . IMAGETYPE_TIFF_II .
LOG_CONS . LOG_EMERG . UPLOAD_ERR_CANT_WRITE . MSG_PEEK . SQLITE_OK . FNM_PERIOD
. AF_UNIX . CURLPROTO_FTPS . STREAM_NOTIFY_FAILURE . MYSQL_BOTH .
CURLE_FTP_ACCESS_DENIED . MSG_OOB . FTP_TEXT . LC_MONETARY .
CURLE_COULDNT_CONNECT . SQLITE_BUSY . "\n";

This probably isn't very portable code, but it works fine on my system. Here's the code that generated it:
<?php
$phi = "6180339887498948482045868343656381177203091798057628621354486227052604628189024497072072041893911375";
echo "<?php\necho TRUE . '.' . ";
$consts = get_defined_constants();
foreach($consts as $k=>$v) if (preg_match('/\d|TRUE|PHP_EOL/',$k)) unset($consts[$k]);
for ($p=0;$p<strlen($phi);$p++) {
  $d = ord($phi[$p]) - 48;
  $min = 999;
  foreach($consts as $k=>$v) {
    if (strlen("$v")==1 && $v==$d && strlen($k)<$min) {
      $min = strlen($k);
      $maxk = $k;
    }
  }
  if ($min==999) break;
  echo "$maxk . ";
  unset($consts[$maxk]);
}
echo "\"\\n\";\n";

Hm, I have to admit that is probably valid. The only thing it might fall under is "multiple names referring to the same constant", but I didn't actually intend that wording to cover this case. I clarified in kernigh's answer that this would be only invalid if the actually pointed to the same integer, but I think that's unlikely. The fact that a lot of this does depend on your system is a shame, but not part of the rules either. So unless someone else can spot a problem here, I'll have to admit that your answer is perfectly valid. ;)

<?for(;;); uses 9MB of memory. Now I know why... I do like @kernigh's self-imposed restriction #7, though, which closes this sort of loophole. Also, for what it's worth, the output on my system is this: http://codepad.org/wSrtJBco

Although, running the generator does produce a valid representation, so +1 for that ;) A version that runs on the codepad server: http://codepad.org/myBpc6cB

Congrats, you broke the challenge. ;) ... Not really... this answer does sidestep the actual challenge somewhat, but it's well within the rules as far as I can see, so I'll have to admit defeat and accept it. :)

Perl - 37 digits
use Math::Trig;
use POSIX;

print
  !0,'.',chop$=||$=,A==A,2**3,$|,++$^F,75/5/5,pi*pi%\_,4+4,a^Y,w&'?',~"\xcb",$^=~y/_//c,
  ord"\b",unpack(h,"\t").@{[c,c,c,c]},$#{[b..j]},"$^W"|'$',$^H>>log$^H,cos()- -cos,$[,
  $-=sqrt%SIG,$%=$],$+[*$=~/($)/],split('',$~).map(glob,"{,,,}{,}"),index(\L,L),
  exp(exp)<<exp,ceil(sinh acosh$^C).keys{stat$0},rindex(\R,R),($s=ssssss)=~s/s//g,
  $?=acos(--$z),$^T=pack(u,$^T.$^T.TTTT),B~~B,C<=C,length$^V,

392 bytes currently, (10.6 per digit).
Output:
1.618033988749894848204586834365638117

Self-imposed Restrictions
I've added a few additional restrictions to limit the use of language features that would trivialize the problem. For example, array dereference @{...} and array final index $#{...} are only used once. Each array used is generated in a different manner (compare [c,c,c,c], [b..j], split('',$~), map(glob,"{,,,}{,}")). Additionally, no symbol or bareword is used more than once, although this is explicitly allowed in the challenge description. I think it's a good idea for perl (or any language with int-only special variables (are there any others?)), because it limits the number of implicit int conversions.

Pieces
!0                       # returns 1
'.'
chop$=||$=               # $= is 60, chop the 0, returns 6
A==A                     # returns 1 (because 0==0)
2**3                     # returns 8
$|                       # auto flush, returns 0
++$^F                    # max system filehandle pre-incremented, returns 3
75/5/5                   # returns 3
pi*pi%\_                 # pi² mod a large value, returns 9
4+4                      # returns 8
a^Y                      # bitwise 'a' xor 'Y', returns 8
w&'?'                    # bitwise 'w' and '?', returns 7
~"\xcb"                  # bitwise inversion of char 203, returns 4
$^=~y/_//c               # count non-underscores in $^, returns 9

ord"\b"                  # returns 8
unpack(h,"\t")           # unpack "\t" as a hex nibble, returns 9
@{[c,c,c,c]}             # anonymous array, returns 4 in scalar context
$#{[b..j]}               # final index of the range b..j, returns 8
"$^W"|'$'                # bitwise '0' or '$', returns 4
$^H>>log$^H              # $^H is 256, log$^H is ~5, returns 8
cos()- -cos              # cos(undef) is 1, subtract -1, returns 2
$[                       # array start index, returns 0

$-=sqrt%SIG              # set $- to sqrt(23), returns 4
$%=$]                    # set $% to the version number, returns 5
$+[*$=~/($)/]            # match end on *$ (aka *main::$), returns 8
split('',$~)             # split "STDOUT" into chars, returns 6 in scalar context
map(glob,"{,,,}{,}")     # an array of 8 empty strings, returns 8 in scalar context
index(\L,L)              # finds 'L' in 'SCALAR(...)', returns 3

exp(exp)<<exp            # 2.718281828 << 1, returns 4
ceil(sinh acosh$^C)      # ceil(2.30129...), returns 3
keys{stat$0}             # stat$0 is an array with 13 entries, which has 6 keys when
                         # interpreted as a hash, returns 6 in scalar context
rindex(\R,R)             # finds 'R' in 'SCALAR(...)' in reverse, returns 5
($s=ssssss)=~s/s//g      # replace the every 's' in 'ssssss' with nothing, returns 6

$?=acos(--$z)            # set $? to 3.14159... implicit int conversion, returns 3
$^T=pack(u,$^T.$^T.TTTT) # set $^T to "8,30P,...", returns 8
B~~B                     # returns 1 (because B represents the same thing as B)
C<=C                     # returns 1 (because 0<=0)
length$^V                # string length of $^V, returns 7

Python 2.7, 19 digits, 231 relevant chars
from math import ceil, pi, trunc, gamma, sin

print ''.join(map(str,
[33-32,
chr(46),
~-7,
8>>3,
trunc(gamma(4.3)),
'x'.find('x'),
22/7,
range(4).pop(),
len('am I phi?'),
52%44,
2*4,
5|2,
ord('/'),
'\b',
5+2+2,
2<<2,
eval("5+2+2"),
ceil(pi),
'\b',
'\b',
str(sin(5))[5],
5&52]))

This answer was posted before the backspace-loophole was closed. As it's quite a clever trick and is not harmful to the challenge in this case (and because this was the answer that actually pointed me to the loophole), this answer may remain as is - so please don't downvote it based on that, rather upvote it for cleverness. :)

Ruby 2.1 for 54 digits, 808 characters
#!ruby -rdate -rdigest -ropenssl -rprime -rset -rsocket
print 2/2,?.,9-3,3&5,2*4,2^2,7%4,55>>4,5+4,2<<2,-~7,5|2,2**2,(2r+2+5).to_i,(2.2+5).ceil,(55r/5-2).floor,(2.2*2).to_i,(2r*2*2).ceil,(2.2**2).floor,2.to_bn<<2,__LINE__,$<.to_i,IO::LOCK_NB,Errno::EIO::Errno,File::APPEND,'aaaaaa'.size,?a.encoding.name.sub(/\D+/,''),%w[a a a].size,%w[a b c d].to_set.size,%w[a a a].count,Socket::AF_NS,Date.jd(Date::ITALY).wday,*Digest::MD5.digest(?j).scan(/\d/),Set[?a,?b,?c].count,SignalException.new('FPE').signo,Float::ROUNDS,begin
exit false
rescue Object
$!.status
end,Process::RLIMIT_NPROC,:aaaaaaa.size,Prime.first,?/.next,{a:p,b:p,c:p}.size,STDIN.lineno,?a.crypt('at')[/\d/],{a: :a}.find_index([:a,:a]),/b/=~'aaaaaaaaab',[?a,?b].index(?b),:aaaaaaab=~/b/,?\t.ord,'aaaaaaaab'=~/b/,open(?/).pos,'aaaaab'.index(?b),?\a.bytes{|b|break b},'aaaaaaa'.rindex(?a),%w[a a].map.size

This program works with ruby 2.1.0p0 (2013-12-25 revision 44422) [x86_64-openbsd]. Systems other than OpenBSD 5.5 might have different values for a few digits.
Interpretations
The restrictions of this challenge, especially restriction 6, are not precise for Ruby. So I add my own interpretations:

The parentheses, dot and double-colon are not operators. The parentheses just change the order of operations. The dot calls methods, as in $<.fileno, and the double colon gets constants, as in IO::LOCK_NB. The name of the method or constant is part of the operation. Because () . :: are not operators, I do not apply restriction 6 to them. I may reuse them to generate more digits.
A method with a different implementation is a different method. For example, Array#count and Enumerable#count are not the same function for restriction 6. Both methods act the same, but Array#count overrides Enumerable#count with a different implementation. If I use Array#count to generate one digit, I may use Enumerable#count to generate another digit.
Class#new is one method. In Ruby, Mutex.new, Random.new, Time.new and so on refer to the same method, Class#new. I use SignalException.new to generate one digit. Because of restriction 6, I may never again use Class#new.
Constants for classes or modules are still constants. In Ruby, class names like Float and IO are constants! I use IO::LOCK_NB to generate one digit. Because of restriction 6, I may never again use IO. This interpretation binds only Ruby, and not other languages where package names are not constants.
Literals are not constants. Though 2 is a mathematical constant (independent of any variables), it is not a constant in Ruby. I do not apply restriction 6 to literals, and I may reuse the literal 2 for more than one digit.
Literals are not operators. I do not apply restriction 6 to the brackets or quotes that form literal arrays, hashes, regular expressions, or strings, as in [] {} // ''. I may always use such literals to generate more digits.
Two constants with the same value are the same constant. File::APPEND and IPSocket::LOCK_UN are two names for the same number 8. Restriction 6 says, "it doesn't matter by which name you refer to any built-in." Because File::APPEND and IPSocket::LOCK_UN differ only by name, they must be the same constant, so I may not use them for two digits.
Two digits may not refer to the same global variable. This closes a loophole. Restriction 6 only applies to functions, operators and constants. Restriction 4 only applies to literals. $SAFE is a built-in global variable, not a function, operator, constant, nor literal. $SAFE has the value 0. With the loophole, I can reuse $SAFE to generate every digit 0 in the program. I close the loophole by interpreting restriction 6 to also restrict global variables.

Comments
The first line is #!ruby -rdate -rdigest -ropenssl -rprime -rset -rsocket. Ruby parses this line and loads six parts of its standard library, as if by require 'date', require 'digest' and so on. I do not count these 56 characters, because restriction 3 exempts "standard library imports/includes".
The rest of the program calls print with a long list of arguments, to convert them to strings and print them in order. The arguments are these:

1 from 2/2: division Fixnum#/
. from ?.: literal single-character string
6 from 9-3: subtraction Fixnum#-
1 from 3&5: bitwise and Fixnum#&

By interpretation 5, I may use 3 again.

8 from 2*4: multiplication Fixnum#*
0 from 2^2: bitwise exclusive-or Fixnum#^
3 from 7%4: modulus Fixnum#%
3 from 55>>4: right shift Fixnum#>>
9 from 5+4: addition Fixnum#+
8 from 2<<2: left shift Fixnum#<<
8 from -~7: negation of complement Fixnum#-@ Fixnum#~

Subtraction Fixnum#- and negation Fixnum#-@ are different methods.

7 from 5|2: bitwise or Fixnum#|
4 from 2**2: exponentiation Fixnum#**
9 from (2r+2+5).to_i: rational addition Rational#+ Rational#to_i

By interpretation 2, Fixnum#+ and Rational#+ are different methods. They both add numbers, but they have different implementations, starting from different types for the left number.
Rational literals like 2r are new in Ruby 2.1. 2r+2 calls Rational#+ and returns another rational; 2r+2+5 calls Rational#+ again.
Ruby prints rationals like 2/1 and floats like 2.0. To fix this, I convert to integer: to_i rounds toward zero, ceil rounds up, floor rounds down.

8 from (2.2+5).ceil: float addition Float#+ Float#ceil

By interpretation 1, I may use parentheses () and dot . again.

9 from (55r/5-2).floor: rational division and subtraction Rational#/ Rational#- Rational#floor
4 from (2.2*2).to_i: float multiplication Float#* Float#to_i
8 from (2r*2*2).ceil: rational multiplication Rational#* Rational#ceil
4 from (2.2**2).floor: rational exponentiation Rational#**
8 from 2.to_bn<<2: left shift with OpenSSL big number Fixnum#to_bn OpenSSL::BN#<<
2 from __LINE__: magic constant for current line number
0 from $<.to_i: file descriptor of standard input IO#to_i
4 from IO::LOCK_NB: flag for non-blocking file lock

This is the first of many constants to depend on system. OpenBSD has 4.
By interpretation 4, I may no longer use IO. By interpretation 7, I may no longer use any constant with the value of 4.

5 from Errno::EIO::Errno: number for input/output error
8 from File::APPEND: flag to append to a file

This is a loophole around interpretation 4. I may not use IO, but File inherits constants from IO, so File::APPEND is a different way to get IO::APPEND.

6 from 'aaaaaa'.size: length of string String#size
8 from ?a.encoding.name.sub(/\D+/,''): part of name of encoding String#encoding Encoding#name String#sub

By interpretation 6, I may use string quotes again.
Since Ruby 2.0, the default encoding is UTF-8. I take the name "UTF-8" and substitute /\D+/ matching "UTF-" with an empty string. This yields "8".

3 from %w[a a a].size: length of array Array#size
4 from %w[a b c d].to_set.size: number of elements in set Array#to_set Set#size
3 from %w[a a a].count: count all elements Array#count

The difference between Array#size and Array#count is that the latter takes optional arguments to choose which elements to count. I pass no arguments, so it counts all elements.

6 from Socket::AF_NS: number for NS address family
5 from Date.jd(Date::ITALY).wday: weekday number for Friday 15 October 1582, when Italy switched to Gregorian calendar Date::jd Date#wday
6 from *Digest::MD5.digest(?j).scan(/\d/): first ASCII digit in binary MD5 digest of "j" Digest::MD5::digest String#scan

String#scan returns an array of all matches. The * passes the array elements as arguments to print. This array is ["6"].

3 from Set[?a,?b,?c].count: count all elements Set::[] Enumerable#count

By interpretation 2, Array#count and Enumerable#count are different methods.

8 from SignalException.new('FPE').signo: number of SIGFPE Class#new SignalException#signo
1 from Float::ROUNDS: rounding mode, here 1 for round-to-nearest
1 from begin (newline) exit false (newline) rescue Object (newline) $!.status (newline) end: exit status for failure

This is the same value as SystemExit.new(false).status, but by interpretation 3, I may no longer call Class#new. Instead I raise and rescue a SystemExit.

7 from Process::RLIMIT_NPROC: number for resource limit for number of processes for one user
7 from :aaaaaaa.size: length of symbol Symbol#size
2 from Prime.first: first prime number Enumerable#first
0 from ?/.next: next string after "?" String#next
3 from {a:p,b:p,c:p}.size: length of hash Hash#size String#p
0 from STDIN.lineno: current line number for standard input IO#lineno

By interpretation 8, I may not reuse $<. I use STDIN. The difference is that $< is a global variable and STDIN is a constant. A program may set $< to a different input, but STDIN is always the original value of $<.

3 from ?a.crypt('at')[/\d/]: first ASCII digit in encrypted password String#crypt String#[]

System with different crypt() function will give different result.

0 from {a: :a}.find_index([:a,:a]): index of first key :a, value :a in hash Enumerable#find_index

I use a hash, not an array, because Array#find_index is an alias for Array#index, which I plan to use soon.

9 from /b/=~'aaaaaaaaab': index where string matches /b/ Regexp#=~
1 from [?a,?b].index(?b): index of first "b" in array Array#index
7 from :aaaaaaab=~/b/: index where symbol matches /b/ Symbol#=~
9 from ?\t.ord: ASCII value of tab "\t" String#ord
8 from 'aaaaaaaab'=~/b/: index where string matches /b/ String#=~

By interpretation 2, Regexp#=~ and String#=~ are different methods.

0 from open(?/).pos: position in file after opening root directory "/" as a file Kernel#open IO#pos
5 from 'aaaaab'.index(?b): index of first "b" in string String#index
7 from ?\a.bytes{|b|break b}: ASCII value of alert "\a" String#bytes

This works by iterating the bytes in "\a", but breaking the loop by returning the first byte.

6 from 'aaaaaaa'.rindex(?a): index of last "a" in string String#rindex
2 from %w[a a].map.size: size of enumerator that maps from array Array#map Enumerator#size

Impressive! Most of your interpretations are in line with the rules anyway. 1. I never intended invocation, dereferencing and access operators to be restricted, which is why I said "mathematical, boolean, bit-wise and string" operators. 2. Covered by rule 6. 3. Reusing new would be fine in other languages, because it's usually an operator - it just can't be reused on the same class because it calls a constructor (built-in function). How is that in Ruby? Does new really always call the same imlpementation or is it overridden in subclasses? [ctd.]

I'd be fine if you made an exception there for Ruby, but thanks for your sportsmanship. ;) 5. and 6. No they aren't, which is why some of the rules are stated the way they are. 7. That's a good subtle point I didn't think about. Technically, if they don't refer to the same 8, it would be fine to use both of them. 8. Good point, I didn't think about built-in variables. I'll check if it doesn't substantially break any other submission and amend rule 6. Thanks for playing fair! :)

I couldn't find any rule violation in this answer so I accepted it. However, I would like to reward your answer, as it's by far the longest one that actually plays by how the challenge was intended. Therefore, I will offer a bounty for this challenge. The bounty will run for seven days though and should an answer come along that beats yours in a "fair" way, I'll award the bounty accordingly. (Of course, you're free to try and beat any contenders ;).) Hope you're alright with that!

Java, 21 digits, 276 characters
class C{public static void main(String[]a){System.out.print((3&5)+"."+(2|4)+Byte.BYTES+2*4+"".length()+(7-4)+~-4+(7+2)+(2<<2)+(int)Math.sqrt('@')+(2^5)+(int)Math.pow(2,2)+32%23+Byte.SIZE+('$'>>2)+Float.BYTES+Long.BYTES+Integer.BYTES+Double.BYTES+Short.BYTES+Math.round(.2));}}

class C {
  public static void main(String[] a) {
    System.out.print(
      (3&5)+       // 1
      "."+         // .
      (2|4)+       // 6
      Byte.BYTES+  // 1
      2*4+         // 8
      "".length()+ // 0
      (7-4)+       // 3
      ~-4+         // 3
      (7+2)+       // 9
      (2<<2)+      // 8
      (int)Math.sqrt('@')+  // 8
      (2^5)+       // 7
      (int)Math.pow(2,2)+   // 4
      32%32+       // 9
      Byte.SIZE    // 8

      // rest of explanation to come later today
    );
  }
}

Ha, I like 7-4 & -4+7, that's clever! :)

clever, but I think it violates the rule of not re-using constants (positive 7 is used in both)

@rangu 7 is not a constant but a literal

So why did you stop there?

Ruby, 74 chars, 10 digits
It's just a start; I have to go so I will improve it later.
$><<[3-2,?.,3+3,?..size,2**3,$*.size,24/8,7%4,[*7..77][2],2*4,7.next].join

I have 76 characters saved up for later, when it will get more difficult!

This a good start! At last an answer in the spirit of the question. :)

Ruby, 17 digits, 168 bytes
$><<[-~0,'.',9-3,3/3,2**3,$.,25%22,'   '=~/$/,2+7,2<<2,"10".oct,2|5,[2,2,2,2].size,[*$....2*5].last,(2^5).succ,'a'.to_i(25).pred,'aaaa'.count('a'),eval(55.chr.next)]*''

Ungolfed:
$><<[
  -~0,                # 1
  '.',                # .
  9-3,                # 6
  3/3,                # 1
  2**3,               # 8
  $.,                 # 0
  25%22,              # 3
  '   '=~/$/,         # 3
  2+7,                # 9
  2<<2,               # 8
  "#{'a'.hex}".oct,   # 8
  2|5,                # 7
  [2,2,2,2].size,     # 4
  [*$....2*5].last,   # 9
  (2^5).succ,         # 8
  'a'.to_i(25).pred,  # 9
  'aaaa'.count('a'),  # 4
  eval(55.chr.next)   # 8
]*''

Haven't been forced to do anything particularly clever yet, I may come back and add digits.

"Haven't been forced to do anything particularly clever yet." Yeah, I figured Ruby, Perl and the usual suspects would not have a really hard time with 15 characters per digit, but I wanted to leave room for things like C-derivatives and Mathematica with large standard-libraries but more convoluted names.

"If they are really only aliases, no [you cannot use them]." succ and next are aliases.

The first is being called on a Fixnum, the second on a String, so I don't think they count as the same method.

Ah, good point. However, the question also says "You must not refer to any... constant which you have used in code that generated an earlier digit," and you use $. twice. Although, gotta love $.... :D

Julia - 23 digits in 345 characters (15 per digit exactly)
print(div(2,2),'.','/'+7,length(" "),2^3,size([])[end],isqrt(9),int(cbrt(27)),54-45,'h'$'P',[2:22][7],endof("2222222"),count(isodd,[5,5,5,5]),search("Hello man",'n'),nextpow2(5),rsearch("Love boat",'t'),sizeof('й'),("I"summary(b"H"))[22],iceil(float(pi)),iround(cosh(e)),ifloor(exp(catalan)),cmp(5,5),itrunc(5sin(one(Int))),uint(erfcx(-ones())))

Output: 1.6180339887498948482045
I interpreted characters and strings as usable, so long as I did not re-use a specific character or string (characters in a string could be re-used, as long as the string was not); however, I did not permit myself to use the int value of a character directly. There is one non-ASCII character (й).
In a more readable fashion (not actual code):
1> div(2,2)
.> '.'
6> '/'+7
1> length(" ")
8> 2^3
0> size([])[end]
3> isqrt(9)
3> int(cbrt(27))
9> 54-45
8> 'h'$'P'
8> [2:22][7]
7> endof("2222222")
4> count(isodd,[5,5,5,5])
9> search("Hello man",'n')
8> nextpow2(5)
9> rsearch("Love boat",'t')
4> sizeof('й')
8> ("I"summary(b"H"))[22]
4> iceil(float(pi))
8> iround(cosh(e))
2> ifloor(exp(catalan))
0> cmp(5,5)
4> itrunc(5sin(one(Int)))
5> uint(erfcx(-ones()))

Golfscript, 17 digits
A straightforward attempt. Golfscript may have a lot of non-alphanumeric one-letter built-ins, but it doesn't have many built-ins as a whole!
".",                         # 1: string length (separate from array length)
'.'
3 3+                         # 6: addition
''[49]+                      # 1: string concatenation
-9~                          # 8: bitwise not
2!                           # 0: boolean not
7 4%                         # 3: modulus
4(                           # 3: decrement
7))                          # 9: increment
257 2/2/2/2/2/               # 8: division
4 2*                         # 8: multiplication
22 5- 5- 5-                  # 7: subtraction
2 2?                         # 4: power
[2 5] 2 base                 # 9: base conversion
[2 2 2 2 2 2 2 2],           # 8: array length (separate from str length)
[2 2 2 2 2 2 2 2 2 5]5?      # 9: array.find()
2 2+                         # 4: addition
"2 2*2*"~                    # 8: eval

I think you could continue with 5,)\; # range, right uncons, flip, and pop.

Bash, 5 digits in 65 chars

I will update this soon! For now, it just prints 1.6180, and does not contain any digits.
false
tr -d ' '<<<$?.`wc -c<<<abcde``nl<<<' '``kill -l FPE`$(())

Explanation
The following methods are used to generate the digits:
1: exit status of false
6: string length
1: nl abuse
8: kill signal numbers
0: numeric value of an empty expression

Mathematica 9 8 digits, in 86 83 78 characters.
10`8FromDigits@#/10^Length@#&@{a/a,3!,-I I,2π/(45°),#&''[],Prime@2,Sqrt@9,4+5}

Output:
1.6180339

Ah, I knew I made a mistake somewhere.Prefix notation doesn't quite seem to work in this case.
Using unicode Pi and Degree, does seem to still work.

Yeah, that #&''[] will generate an error from missing input, while in this form it ignores that it got no input. Still doesn't excuse me from not using it where it works though.

Thx. I personally loved #&''[] (Basically the second derivative of f[x] = x

(Cleaned up the comments.) That is quite nice, but you could probably save a character, by replacing # with an allowed digit, and dropping one of the dashes.

Figured this way I'd be able to save that digit for potential future use.

The only restriction on digits is whether they have appeared in golden ratio or not. You may reuse them in the code. Rule 6 only applies to constants (amongst other things), but not to literals (and a digit is just a literal).

C++ 12.4 chars per line, was 14 chars per line for each digit
Fixed my mistake of reusing operators.
#include <iostream>
#include <math.h>
#define S std::string
#define C(x) std::cout<<x
int main()
{
C(cos(0));
C(char(46));
C('j'%'d');
C('\0'+3-2);
C(sqrt('@'));
C(log(1));
C('c'/'!');
S s("xyz");
C(s.size());
return 0;
}

Not sure if using chars like this counts as char literals or not? If this code is acceptable it can be continued forever and char debt will be paid back.
#include <iostream>
#define C(x) std::cout<<x
int main()
{
C('b'-'a');//1
C(char(46));//.
C('g'-'a');//6
C('b'-'a');//1
C('i'-'a');//8
C('a'-'a');//0
C('d'-'a');//3
C('d'-'a');//3
C('j'-'a');//9
//etc
return 0;
}

The literals are fine (because they are not equivalent to single-digit numbers), but you keep reusing the - operator. Also, I like how you counted the comment for the line length. :D

Yes that looks much better, but you are using 1 to produce a 0 (which is disallowed, because the 1 appeared earlier in the golden ratio). Also you do need to count the #define S (not the other one), as it's not an include but just defining a shorthand alias.

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

authors: Иван Зубарев

authors: บีเฟรนด์ สตูดิโอ


text:
Appended Numbers Game
Appended Numbers Game
Write a function/program that takes 2 integer parameters integer parameters or integer variables, a start number, and a max iterations count. The code should perform the following game example to construct a new number, and repeat until the number is a single digit left. eg.
3 7 2 = (3 + 7) & (7 + 2) = 10 9
1 0 9 = (1 + 0) & (0 + 9) = 1 9
1 9 = (1 + 9) = 10
1 0 = (1 + 0) = 1

Basically, taking each individual digit and adding it to its neighbour, then appending the result of the next addition as well.
Max iteration count is to safeguard infinite loops, and when the max is hit, code should dump the last 5 number steps. The same output should occur when finishing by reaching a single digit. If less than 5 steps occurred, only output the valid numbers.
Output should appear like (Step: Number) including the last 5 steps of the finished or terminated steps:
func(3541, 50) would produce this exact output format:
6: 1411
7: 552
8: 107
9: 17
10: 8

func(3541, 5) would produce:
1: 895
2: 1714
3: 885
4: 1613
5: 774

The entire calculation being:
1: 895
2: 1714
3: 885
4: 1613
5: 774
6: 1411
7: 552
8: 107
9: 17
10: 8

If there are less than 5 steps, just print those steps taken.
Only use built-in libs, parameters can be from anywhere (whatever's easiest for your language of choice). No limit on maximum integer size, and if there are overflows, let it crash.
Given this isn't too difficult from a puzzle point of view, I will give until Sunday 25th, 8PM (UTC+8) for submissions to be considered for the accepted answer, at which point the shortest of any language will be the winner.
EDIT:
Congratulations to Howard, winning with a 48 GolfScript answer.
Special mention to 2nd place marinus with a 66 APL answer.
My personal favourite (being biased towards JavaScript) was core1024's answer.

I don't understand, is func(3541, 5) supposed to print 5 steps or 10?

5 steps. It should stop as it hits iteration 5, perform no more iterations and print out the last 5 steps. I just included the full set of steps to show the full calculation process for that particular input.

GolfScript, 48 46 characters
{.`n*[~]n\{:s++s}*;~}*].,,\]zip{': '*}%1>-5>n*

Thank you to Peter Taylor for a two-character improvement.
Expects both numbers on the stack. Try online.
Examples:
> 4 50

> 141 50
1: 55
2: 10
3: 1

> 3541 50
6: 1411
7: 552
8: 107
9: 17
10: 8

> 3541 5
1: 895
2: 1714
3: 885
4: 1613
5: 774

There's a moderate saving by adding a flip after .,, and turning the final map into just {': '*}%.

APL (66)
{↑¯5↑{(⍕⍵),': ',⍺}/∆,⍪⍳⍴∆←⍺{(1<⍴⍵)∧⍺>0:∆,(⍺-1)∇⊃∆←,/⍕¨2+/⍎¨⍵⋄⍬}⍕⍵}

The left argument is the maximum iteration count and the right argument is the start number.
Explanation:

∆←⍺{...}⍕⍵: pass the left argument as a number and the right argument as a string to the function that calculates the list of numbers, and store it in ∆:

(1<⍴⍵)∧⍺>0:: if the amount of digits is more than 1 and the amount of iterations left is more than 0:

⍎¨⍵: evaluate each digit
2+/: sum each pair
⍕¨: format each number as a string
∆←,/: concatenate the strings and store in ∆
∆,(⍺-1)∇⊃∆: return ∆, followed by the result of applying this function to ∆ with one less iteration allowed

⋄⍬: if not, return the empty list

∆,⍪⍳⍴∆: pair each element of ∆ with its index in ∆
{...}/: for each pair:

(⍕⍵),': ',⍺: return a string with the index, followed by :, followed by the number

↑¯5↑: turn the list of strings into a matrix so they display on separate lines, and take the last 5 items

Test:
      5{↑¯5↑{(⍕⍵),': ',⍺}/∆,⍪⍳⍴∆←⍺{(1<⍴⍵)∧⍺>0:∆,(⍺-1)∇⊃∆←,/⍕¨2+/⍎¨⍵⋄⍬}⍕⍵}3541
1: 895
2: 1714
3: 885
4: 1613
5: 774
      50{↑¯5↑{(⍕⍵),': ',⍺}/∆,⍪⍳⍴∆←⍺{(1<⍴⍵)∧⍺>0:∆,(⍺-1)∇⊃∆←,/⍕¨2+/⍎¨⍵⋄⍬}⍕⍵}3541
6: 1411
7: 552
8: 107
9: 17
10: 8

Does this handle displays of less than 5 steps properly? E.g. 3 {...} 3541.

@algorithmshark It does now (it gave extra lines with : first)

Mathematica, 172 characters
This is way too long, thanks to Mathematica's function names and ugly string handling (the actual "game" is only 76 of those characters), but here it is anyway:
""<>ToString/@(f=Flatten)@Take[Thread@{r=Range@Length[s=Rest@Cases[NestList[FromDigits[f@(d=IntegerDigits)[Tr/@Partition[d@#,2,1]]]&,n,m],i_/;i>0]],": "&/@r,s,"\n"&/@r},-5]

It expects the input number in variable n and the maximum number of iterations in m.
With less golf:
"" <> ToString /@
  (f = Flatten)@
   Take[
    Thread@{
      r = Range@Length[
         s = Rest@Cases[
            NestList[
             FromDigits[
               f@(d = IntegerDigits)[Tr /@ Partition[d@#, 2, 1]]] &,
             n,
             m
             ],
            i_ /; i > 0
            ]
         ],
      ": " & /@ r,
      s,
      "\n" & /@ r
      },
    -5
    ]

Ruby, 106 characters
f=->n,m{s=0
$*<<"#{s}: #{n=n.to_s.gsub(/.\B/){eval$&+?++$'[0]}.chop}"until n.to_i<10||m<s+=1
puts$*.pop 5}

I'm not 100% clear on the input rules, but if I can take n as a string I can save 5 characters, and if I can use predefined variables and write a program instead of a function, I can save another 9.
Creates a function f which can be called as follows:
f[3541, 6]
2: 1714
3: 885
4: 1613
5: 774
6: 1411

f[372, 50]
1: 109
2: 19
3: 10
4: 1

f[9999, 10]
6: 99999999999
7: 18181818181818181818
8: 9999999999999999999
9: 181818181818181818181818181818181818
10: 99999999999999999999999999999999999

Interesting observation that 4 or more "9"s produces a diverging result

J - 96 92 char
I'd first solved this assuming that all games terminated, and this came back to bite me in the ass during testing. Left argument is the number of steps, right argument is the starting position, which can be given as a number or a string.
([(-@(<.5<.#){.])(#\(,': '&,)&":"0,)@}.@({.~,i.0:)@:".@(<@>:@[(' '-.~[:,@":2+/\"."0@]^:)":))

This is a little too golfed and convoluted to degolf satisfyingly, so I'll say this:

(<@>:@[(' '-.~[:,@":2+/\"."0@]^:)":) This part runs the game for the specified number of steps. 2+/\ is responsible for adding each pair of digits, and <@>:@[ in tandem with ^: controls capturing the intermediate steps of the game.
(#\(,': '&,)&":"0,)@}.@({.~,i.0:)@:". This part formats all the results as step: result. ({.~,i.0:) is making sure we don't take too many steps, #\ is the step numbers, and the (,': '&,)&":"0 bit adds the colon and space.
(-@(<.5<.#){.]) This portion cuts the relevant five-or-less steps out of the full list. <. means 'minimum of'.

It works, but if you start with a large enough number, the game's results quickly start growing in size, which makes J switch from integers to the imprecise doubles. Here are some examples:
   f =: ([(-@(<.5<.#){.])(#\(,': '&,)&":"0,)@}.@({.~,i.0:)@:".@(<@>:@[(' '-.~[:,@":2+/\"."0@]^:)":))
   5 f 3541
1: 895
2: 1714
3: 885
4: 1613
5: 774
   50 f 3541
6: 1411
7: 552
8: 107
9: 17
10: 8
   100 f 372
1: 109
2: 19
3: 10
4: 1

Javascript 139 144 150
function f(a,n){for(r=[a+=''];n--&&a[1];r.push(a=t))for(t='',i=0;a[++i];)t+=a[i-1]- -a[i];for(i=0;r[++i];)r[i+5]||console.log(i+': '+r[i])}

Ungolfed
function f(a,n)
{
  for (r=[a+='']; n-- && a[1]; r.push(a=t))
  {
    for (t = '', i = 0; a[++i]; )
    {
      t += a[i-1]- -a[i]; /* -char force conversion to number */
    }
  }
  for (i = 0; r[++i];) r[i+5]||console.log(i+': '+r[i])
}

Perl, 86 84
With newlines for readability:
$s+=$_=<>;
print+(map$s=~s/.(?=(.|))/~$1?$&+$1:''/eg>1?"$_: $s$/":(),/ /..$')[-5..-1]

+ Edit: No excuse for not using -n command line switch, and then score is 82=81+1:
$s+=$_;
print+(map$s=~s/.(?=(.|))/~$1?$&+$1:''/eg>1?"$_: $s$/":(),/ /..$')[-5..-1]

And, possible integer overflow being OK, it's 81=80+1
$.=$_;
print+(map$.=~s/.(?=(.|))/~$1?$&+$1:''/eg>1?"$_: $.$/":(),/ /..$')[-5..-1]

I learned new tings. Awesome!

Javascript, 247 278 288 307 Characters
 var t=[],q=1;function f(a,c){var x=a.toString().split(''),r='',p=parseInt;for(y in x){var i=p(y);if(i){r+=(p(x[i])+p(x[i-1])).toString();}}if(c!=0&&a>10){t.push(q+++':'+r+'\n');if(q>6){t.shift()}f(r,c-1);}console.log(t.join(',').replace(/,/g,''))}

Formatted
var t = [],
q = 1;

function f(a, c) {
 var x = a.toString().split(''),
    r = '',
    p = parseInt;
 for (y in x) {
    var i = p(y);
    if (i) {
        r += (p(x[i]) + p(x[i - 1])).toString();
    }
 }
 if (c != 0 && a > 10) {
    t.push(q+++':' + r + '\n');
    if (q > 6) {
        t.shift()
    }
    f(r, c - 1);
 }
 console.log(t.join(',').replace(/,/g, ''))
}

Edit 1: Removed ternary
Edit 2: Flipped logic for "skipping" 0 index
Edit 3: Reworked recursive calling.
Fiddle

Don't worry, nothing to see here. Thought it was printing first 5 but it should with your fiddle. Nice work :)

Bash + coreutils, 115 bytes
for((a=$1;++i<=$2&a>9;)){
a=`paste -d+ <(fold -1<<<${a%?}) <(fold -1<<<${a#?})|bc|tr -d '
'`
echo $i: $a
}|tail -n5

Output:
$ ./appended-number.sh 3541 50
6: 1411
7: 552
8: 107
9: 17
10: 8
$ ./appended-number.sh 3541 5
1: 895
2: 1714
3: 885
4: 1613
5: 774
$

JavaScript (ECMAScript 6 Draft) - 134 Characters
f=(x,y,i=0,j=[])=>([m=''].map.call(m+x,(z,p,n)=>m+=p?+z+1*n[p-1]:m),j[i++]=i+': '+m,m.length>1&&i<y?f(m,y,i,j):j.slice(-5).join('\n'))

Examples:
f(372,5)
"1: 109
2: 19
3: 10
4: 1"

f(3541,50)
"6: 1411
7: 552
8: 107
9: 17
10: 8"

f(3541,5)
"1: 895
2: 1714
3: 885
4: 1613
5: 774"

Husk, 32 bytes
↑_5Ṡz+(mo`+": "sŀ)mṁs↑htU¡oṁdẊ+d

Try it online!
Output format was cumbersome, but I had to answer this in Husk.
Explanation
↑_5Ṡz+(mo`+": "sŀ)mṁs↑htU¡oṁdẊ+d
                               d convert first input to digits
                         ¡       and iterate:
                             Ẋ+  sum overlapping pairs
                           ṁd    convert to digits and flatten
                        U        truncate till fixed point
                      ht         remove first and last element
                     ↑           take second input number of values from that
                  mṁs            convert all the arrays to strings
   Ṡz+(          )               zip and concat that with:
                ŀ                range 1..length(seq)
       mo`+": "s                 convert each to string, append a colon
↑_5                              take the last 5 elements

Java     524  405 365 chars [414 bytes]
Golfed version: class A{static int n=0;List<String> s=new ArrayList<>();void c(int b,int r){String d=b+"";if(r==0||b <= 9){int m=s.size();for(int i= m>=5?m-5:0;i<m;i++)System.out.println(s.get(i));return;}String l="";for(int i=0;i<d.length()-1;i++)l+=d.charAt(i)+d.charAt(i+1)-96;s.add(++n+":"+l);c(Integer.valueOf(l),--r);}public static void main(String[] a){new A().c(3541,50);}}
Readable version:
class AddDigits {
static int n = 0;
List<String> steps = new ArrayList<>();

void count(int num, int count) {
    String digits = num + "";
    if (count == 0 || num <= 9) {
        int stepsSize = steps.size();
        for (int i = stepsSize >= 5 ? stepsSize - 5 : 0; i < stepsSize; i++) {
            System.out.println(steps.get(i));
        }
        return;
    }
    String line = "";
    for (int i = 0; i < digits.length() - 1; i++) {
        line += digits.charAt(i) + digits.charAt(i + 1) - 96;
    }
    steps.add(++n + ":" + line);
    count(Integer.valueOf(line), --count);
}

public static void main(String[] args) {
    new AddDigits().count(3541, 50);
}
}

You can shrink this by using 1 char for variable and function names.

Done... also changed logic to stop recursion using num<=9 instead of digits.length==1 (Seen in this thread only... didn't hit me before).

you could reduce length of argument name in yout main method, that will give you additional 3 chatacters

you dont need to converting string to array of characters, you can access single character from string using chatAt method

and last thing, you dont need to convert your character to string and then parse it, instead Integer.valueOf(digits[i] + "") + Integer.valueOf(digits[i + 1] + ""); you could do (digits[i] + digits[i+1] - 96)

Done... I'd thought of -96; don't remember why I didn't do that.

Javascript, 182 bytes
function f(I,T){s=[],x=1;for(;;){d=(""+I).split("");l=d.length;if(l==1||x>T)break;for(I="",i=1;i<l;)I+=+d[i-1]+ +d[i++];s.push(x+++": "+I)}s=s.slice(-5);for(i in s)console.log(s[i])}

Perl, 166 147 138 129 bytes
<>=~/ /;for$i(1..$'){@n=split'',$s||$`;$s=join'',map{$n[$_]+$n[$_+1]}0..@n-2;@o=(@o,"$i: $s");$s<10&&last}print join$/,@o[-5..-1]

Ungolfed:
<> =~ / /;
for $i (1..$') {
    @n = split'', $s||$`;
    $s = join'',map {$n[$_]+$n[$_+1]} 0..@n-2;
    @o = (@o, "$i: $s");
    $s<10 && last
}
print join$/,@o[-5..-1]

I hope it's alright that it prints some extra empty lines if the whole thing takes less than 5 steps.

Replace (('')x5, @o, "$i: $s") with (@o, "$i: $s") and join"\n", @o[-5..0] with join"\n", @o[-5..-1]. Then you'll be 3 bytes ahead ;)

I don't have any problem with extra empty lines.

@core1024 Thanks :) I was going to give you a tip as well, but you already got rid of that long "unless" part

Java, 341 chars 371 chars
 class a{public static void main(String[] a){p(3541,50);}static void p(int n,int k){Queue<String>q=new LinkedList();int c=0;while(n>9&&c<k){c++;String r="";String p=""+n;for(int i=0;i<p.length()-1;i++)r+=((p.charAt(i)+p.charAt(i+1)-96));n=Integer.parseInt(r);q.add(c+": "+n);if(q.size()>5)q.remove();}for(String s:q){System.out.println(s);}}}

Formatted:
class a {
public static void main(String[] a) {
    p(3541, 50);
}

static void p(int n, int k) {
    Queue<String> q = new LinkedList();
    int c = 0;
    while (n > 9 && c < k) {
        c++;
        String r = "";
        String p = "" + n;
        for (int i = 0; i < p.length() - 1; i++)
            r += ((p.charAt(i) + p.charAt(i + 1) - 96));
        n = Integer.parseInt(r);
        q.add(c + ": " + n);
        if (q.size() > 5)
            q.remove();
    }
    for (String s : q) {
        System.out.println(s);
    }
}}

Thanks to user902383 i was able to reduce the code by 30 chars, by not splitting the String into an Array an using -96 instead of "Integer.valueOf()

you could still reduce some characters, class a{public static void main(String[] a) {p(3541, 50);}static void p(int n,int k){Queue<String> q=new LinkedList();int c=0;while(n>9&&c<k){c++;String r="";String p=""+n;for(int i=0;i<p.length()-1;i++)r+=((p.charAt(i)+p.charAt(i+1)-96));n=Integer.parseInt(r);q.add(c+": "+n);if(q.size()>5)q.remove();}for(String s:q){System.out.println(s);}}}

JavaScript 133 bytes
function f(n,g){for(c=r=[];g--;(n=s)&&(r[c++]=c+': '+s))for(i=s='',n+=s;n[++i];s+=n[i]-+-n[i-1]);console.log(r.slice(-5).join('\n'))}

Ungolfed:
function sums(num, guard) {
    for(count = res = [];guard--;(num = sum) && (res[count++] = count + ': ' + sum))
        for(i = sum = '',num += sum;num[++i];sum += num[i] -+- num[i-1]);
    console.log(res.slice(-5).join('\n'))
}

Only problem is the function name is the same as one of your variables :) But the technique is awesome.

Good point! I renamed the function ;)

**C 186 179174 **
f(int a,int z){for(int c,d,i,j=0,m[5];m[j++%5]=a,j<=z&&a/10;a=c)for(c=0,i=1;a/10;d=a%10+(a/=10)%10,c+=d*i,i*=d<10?10:100);for(i=j<5?0:j-5;i<j;printf("%d: %d\n",i,m[i++%5]));}

Slightly less golfed (mini-golfed?)
f(int a, int z)
{

for(int c,d,i,j=0,m[5];m[j++%5]=a,j<=z&&a/10;a=c)
    for(c=0,i=1;a/10;d=a%10+(a/=10)%10,c+=d*i,i*=d<10?10:100);

    for(i=j<5?0:j-5;i<j;printf("%d: %d\n",i,m[i++%5]));

}

Just allocate enough memory to store five results cyclically.  The outer loop keeps going until we hit the limit or reach a single digit.  The inner loop adds the last digit of the number to last digit of 1/10 of the number and adds this, multiplied by the relevant power of 10 to the result.  Divide the number you first though of by 10 and repeat to get the total.  Then print out up to the last five results.
Next challenge is to see if I can shave off enough to beat some scripting languages at golf.
Edit: Now compiles with warning but five characters shaved off by removing "void " declaration

Golf tips: f(int a, int z) -> f (a,z) and could use t=10 saving 2 more chars. But using a and a/=10 in the same expression is undefined

Dart, 602 588 bytes
Dart is probably one of the worst languages to do this in... I'll need to find a better way to do this.
Anyway, Here's my entry:
Input through console
var steps={};void main(a){c(a[0],int.parse(a[1]));}void c(inp,m){int i=0;int n=int.parse(inp);while(++i<=m){n=addUp(n.toString());steps[i]=n;if(n<10)break;}printSteps();}int addUp(n){var ns=[];for(int i=0;i<n.length;i++){try{ns.add(n[i]+n[i+1]);}catch(e){}}return addNumbers(ns);}int addNumbers(ns){var it=ns.iterator;var s="";while(it.moveNext()){int i=0;for(var t in it.current.split('')){i+=int.parse(t);}s=s+i.toString();}return int.parse(s);}void printSteps(){int l=steps.length;for(int i=getStart(l);i<=l;i++){print("${i}:\t${steps[i]}");}}int getStart(l){int m=l-4;return m>0?m:1;}

And the ungolfed, slightly unminified version:
var steps = {};

void main(a)
{
    c(a[0], int.parse(a[1]));
}

void c(String input, int max)
{
    int i = 0;
    int n = int.parse(input);

    while(++i <= max)
    {
        n = addUp(n.toString());

        steps[i] = n;

        if(n < 10)
            break;
    }

    printSteps();
}

int addUp(String n)
{
    List numbers = [];

    for(int i = 0; i < n.length; i++)
    {
        try
        {
            numbers.add(n[i] + n[i + 1]);
        }
        catch(e){}
    }

    return addNumbers(numbers);
}

int addNumbers(List numbers)
{
    Iterator it = numbers.iterator;

    String s = "";

    while(it.moveNext())
    {
        int i = 0;
        for(String s in it.current.split(''))
        {
            i += int.parse(s);
        }

        s = s + i.toString();
    }

    return int.parse(s);
}

void printSteps()
{
    int l = steps.length;

    for(int i = getStart(l); i <= l; i++)
    {
        print("${i}:\t${steps[i]}");
    }
}

int getStart(int l)
{
    int m = l - 4;
    return m > 0 ? m : 1;
}

C# - 309 330 320 306 Bytes
Golfed Version:
private static void F(int aN,int aM){var s=new List<string>();var n=aN.ToString();for(int i=1;i<=aM;i++){int z=n.Length;if(z==1){break;}var a=n;n="";for(int j=0;j<z-1;j++){int r=a[j]-'0'+a[j + 1]-'0';n=n+r;}s.Add(i+": "+n);}int l=s.Count;int p=5;if(l<5){p=l;}for(int k=l-p;k<l;k++){Debug.WriteLine(s[k]);}}

Usage: F(3541,50);
Ungolfed version for readability:
private static void AppendNumbers(int aNum, int aMaxSteps)
    {
        var results = new List<string>();
        var numString = aNum.ToString();
        for (int i = 1; i <= aMaxSteps; i++)
        {
            int stringLength = numString.Length;
            if (stringLength == 1)
            {
                break;
            }
            var a = numString;
            numString = "";
            for (int j = 0; j < stringLength-1; j++)
            {
                int additionResult = a[j]-'0' + (a[j + 1]-'0');
                numString = numString + additionResult;
            }
            results.Add(i+": "+ numString);
        }
        int numberOfResults = results.Count;
        int p = 5;
        if (numberOfResults < 5)
        {
            p = numberOfResults;
        }
        for (int k = numberOfResults - p; k < numberOfResults; k++)
        {
            Debug.WriteLine(results[k]);
        }
    }

Suggestions for improvement are always welcome! ;)
Edit: Removed String.Empty and replaced it with "" to save 10 Bytes.
Edit 2: Thanks to malik for the tipp with the strings!

You dont need .ToCharArray(). A string = char array

Oh, and another thing you can do is, instead of .ToString(), do +""

PERL 135 129/125 125/121 bytes
It has the same bug as Tal's answer
sub c{($e,$l)=@_;print join"\n",(grep/\d$/,map{$s="";{$e=~/(.)(.)/;redo if""ne($e=$2.$')and$s.=$1+$2};++$c.": ".($e=$s)}1..$l)[-5..-1]}

Edit 129 bytes as a function:
sub c{($e,$l)=@_;print join$/,(grep/\d$/,map{$s="";{$e=~/(.)(.)/;redo if""ne($e=$2.$')and$s.=$1+$2}"$_: ".($e=$s)}1..$l)[-5..-1]}

125 bytes as a function:
sub c{($e,$l)=@_;print+(grep/\d$/,map{$s="";{$e=~/(.)(.)/;redo if""ne($e=$2.$')and$s.=$1+$2}"$_: ".($e=$s).$/}1..$l)[-5..-1]}

125 bytes as a console script (without the hashbang):
($e,$l)=@ARGV;print join$/,(grep/\d$/,map{$s="";{$e=~/(.)(.)/;redo if""ne($e=$2.$')and$s.=$1+$2}"$_: ".($e=$s)}1..$l)[-5..-1]

121 bytes as a console script (without the hashbang):
($e,$l)=@ARGV;print+(grep/\d$/,map{$s="";{$e=~/(.)(.)/;redo if""ne($e=$2.$')and$s.=$1+$2}"$_: ".($e=$s).$/}1..$l)[-5..-1]

Expanded:
sub c
{
    ($e, $l) = @_;
    print +(grep /\d$/, map {
        $s="";
        {
            $e =~ /(.)(.)/;
            redo if "" ne ($e = $2.$') and $s .= $1 + $2
        }
        "$_: ".($e = $s).$/
    } 1 .. $l)[-5 .. -1]
}

Test with c(372,4);:
[blank line]
1: 109
2: 19
3: 10
4: 1

Test with c(3541,50);:
6: 1411
7: 552
8: 107
9: 17
10: 8

I believe you're only supposed to print the last 5 steps though.

Got it fixed ;)

And you're still 3 bytes ahead of me... blast it! :p

@Tal We're even now :D

Python 2.7, 174 173 158 characters
Using a lot of strings to do the task.
x,n=raw_input().split()
o,i=[],0
while int(n)>i<o>9<x:x="".join(`sum(map(int,x[j:j+2]))`for j in range(len(x)-1));i+=1;o+=[`i`+": "+x]
print"\n".join(o[-5:])

Python 2.7, 155 characters
Version defining a function
def a(x,n):
 o,i,x=[],0,`x`
 while n>i<o>9<int(x):x="".join(`sum(map(int,x[j:j+2]))`for j in range(len(x)-1));i+=1;o+=[`i`+": "+x]
 print"\n".join(o[-5:])

Slightly ungolfed version:
x,n=map(int,raw_input().split())
o,i=[],1
while i<=n and x>9:
  x=int("".join(`sum(map(int,`x`[j:j+2]))` for j in range(len(`x`)-1)))
  o.append("%d: %d"%(i,x))
  i+=1
print "\n".join(o[-5:])

Cobra - 363
A rather depressing result... but hey, I still beat Java.
It should be immune to integer overflows for practical test cases.
class P
    cue init(a,b)
        base.init
        l=[]
        c=.p(a.toString)
        for x in b
            l.add("")
            y=l.count
            for i in c.count-1,l[y-1]+=(c[i]+c[i+1]).toString
            if l.last.length<2,break
            c=.p(l.last)
        z=if(y>5,y-5,0)
        for x in l[z:y],print"[z+=1]:",x
    def p(n) as List<of int>
        c=List<of int>()
        for i in n,c.add(int.parse(i.toString))
        return c

Groovy - 191 182 chars
Based on Thomas Rüping's solution, ported to Groovy 2.2.1:
f={it as int};n=args[0];s=f args[1];q=[];x=0;while(f(n)>9&&x<s){x++;d=n.split("");n="";for(i in 1..d.length-2)n+=f(d[i])+f(d[i+1]);q << "$x: $n"};q[-1..5].reverse().each{println it}

Execution and output:
bash$ groovy Numbers.groovy 3541 50
6: 1411
7: 552
8: 107
9: 17
10: 8

Ungolfed:
f = {it as int}
n = args[0]
s = f args[1]

queue = []
stepCounter = 0

while (f(n) > 9 && stepCounter < s) {
    stepCounter++
    digits=n.split("")
    n=""
    for(i in 1..digits.length-2) {
        n += f(digits[i]) + f(digits[i+1])
    }
    queue << "$stepCounter: $n"
}

queue[-1..5].reverse().each{ println it }

C# - 269
void F(int x,int y){var o=new List<string>();var i=x+"";for(int n=1;n<y&&i.Length>1;n++){var s="";for(int z=0;z<i.Length;z++){int a=i[z]-'0';var t=a+(z+1!=i.Length?i[z+1]-'0':-a);if(t!=0)s+=t;}i=s;o.Add(n+": "+i);}foreach(var p in o.Skip(o.Count-5))Debug.WriteLine(p);}

Readable:
void F(int x,int y){
    var o=new List<string>();
    var i=x+"";
    for(int n=1;n<y&&i.Length>1;n++)
    {
        var s="";
        for(int z=0;z<i.Length;z++){
            int a=i[z]-'0';
            var t=a+(z+1!=i.Length?i[z+1]-'0':-a);
            if(t!=0)
                s+=t;
        }
        i=s;
        o.Add(n+": "+i);
    }
    //Output
    foreach(var p in o.Skip(o.Count-5))
        Debug.WriteLine(p);
}

Usage:
F(3541, 50)

Output:
6: 1411
7: 552
8: 107
9: 17
10: 8

Haskell, 154
s=show
z=zipWith
m#n=concat.z(\a b->s a++": "++b++"\n")[1..].(\x->drop(length x-n)x).takeWhile(/="").iterate((\x->z(+)x(tail x)>>=s).map(\x->read[x]))$s m

example usage:
λ> 3541#5
"1: 1411\n2: 552\n3: 107\n4: 17\n5: 8\n"

To make it more readable, use putStr:
λ> putStr $ 3541#5
1: 1411
2: 552
3: 107
4: 17
5: 8

You have to list only the last 5 steps out of the computation. Try putStr $ 3541#50 and compare it with the OP's example. Otherwise I'm glad there's a Haskell guy here.

@core1024 It does! Athough I did label them wrong, you're right. I'll fix that tomorrow.

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