text:
Books Algorithm Dealing with Square Digit Sums
A little context:

Book has 411 Pages
Read a random number of pages on the first day which is unknown
Number of pages to read next day is the square of the sum of the digits of the page currently on
I.e. on Page 36: read 81 pages next day
On day 6 The square answer directly adds to current page number to make 411
Finish Book

How many pages did she read on the first day and how many pages did
  she read on the 6 days?

This is what I have so far:
from itertools import accumulate, count

def read_book( start ):
    for i in range( 6 ): yield start; start += sum( int( digit ) for digit in str( start ) ) ** 2

def find_start( pages ):
    for start in count( 1 ):
        for read in read_book( start ): pass
        if read == pages: return start

previous_answer, start = 0, find_start( 411 )
for i, read in enumerate( read_book( start ), 1 ):
    print( "Pages read on day", i ,"was", read-previous_answer ,"\t(Now on page", str(read) + ")\n")
    previous_answer += read-previous_answer

Output:

Pages read on day 1 was 61 (Now on page 61)
Pages read on day 2 was 49 (Now on page 110)
Pages read on day 3 was 4 (Now on page 114)
Pages read on day 4 was 36 (Now on page 150)
Pages read on day 5 was 36 (Now on page 186)
Pages read on day 6 was 225 (Now on page 411)

Is there a more efficient way? Who can do it in the least no. chars

This has a fixed answer, so the shortest program will be just to print a single number. So, it doesn't make for a good challenge. Also, your code looks pretty un-compressed. Are you sure you're actually looking for a way to do it in few characters?

Yes I want all the functions to run (maybe as one mega-function if it has to be) but in the least amount of code possible: not just printing as this does not do any of the calculations/working out...

@Coolstar161 In that case you might want to make a few things variable (e.g. the number of days and the total number of pages). Otherwise it's really hard to draw the line on how much knowledge can be assumed for the problem.

I also think this would actually be an interesting challenge in general, if the input is variable. In that case you should remove the language-restriction to Python though.

I'm sorry, I'm 16 and new to more complex coding so forgive me but I don't know what you mean...

def read_book( start, days=6 ):     for i in range( days ): yield start; start += sum( int( digit ) for digit in str( start ) ) ** 2;  this makes days variable???

@Coolstar161 Okay. Two things: 1. On this site we basically have two kinds of questions. a) Challenges, in which you people compete to solve a given problem while optimising towards a certain winning criterion (in this case, shortest code size). We like these to not be language-specific, so everyone can participate. b) Questions that ask for help shortening a specific piece of code. These will obviously be limited to the language of the reference code in the question. You should decide which of these you want. [cont.]

Currently there is no variable input to your problem. That means the output is also fixed as xnor mentioned, and in theory the problem can be reduced to a print. Now obviously, that's not what you want, because you don't want to assume you already know the solution. Then the question is, which parts of the challenge are variable? Only the number of days, the number of pages or both? Basically, the problem should be such that either 6, 411 or both are passed in through parameters and the code will work correctly for any other number. (Which raises the question if every input has a solution.)

Oh okay well I fall under Option 2: Shorten this code using Python Programming Language... (I think)

There is a problem with Part 2 of what you said: There is a very specific algorithm and this code will only work for certain book pages. The starting page and how many days are proportional so This makes it really hard!!! I don't know... I was advised by Stack Overflow to post on Code Review and Code Review advised to post it on Code-Golf: so where are you going to refer me to...

It's fairly common that people on one programming-related site in the StackExchange network will say that a question really belongs on a second one even though they don't participate much in the second one and might not really understand what its community considers on-topic. I don't see why your original question wasn't fine on StackOverflow, but since I don't participate there very much... I have one question about your goal: you ask whether there's a more efficient way and who can golf it the most. Are you asking two separate questions? Normally the shortest approach is the least efficient.

Possibly. I want one solution which has been golfed (least number of lines). the second would be the most efficient solution

Is this still up? Because I think I might be able to help.

gcc - 176 chars
I don't grok Python (it is Python right?) so I don't understand how your example works.  Is it actually treating the page number as a string?
I'm not sure but (at least in C) string handling uses more characters than integers.  So to sum the digits of an integer between 0 and 1000 I use:
for(s=0,i=1;i<1001;i*=10)s+=(x%i*10)/i;

Where x is the input and s is the sum.
If you want the sum from some x for 7 days you could:
for(c=2;c<7;x+=s*s,c++)
  for(s=0,i=1;i<1001;i*=10)s+=(x%i*10)/i;

Where x is the input and the output.
To find the sum for 7 days which matches the number of pages in the book (p):
for(y=1;y<p&&x!=p;y++)
  for(x=y,c=2;c<7;x+=s*s,c++)
    for(s=0,i=1;i<1001;i*=10)s+=(x%i*10)/i;

Where y-1 is the calculated starting page when the sum adds up to p.
The whole program with which reads from the command line and prints to stdout:
main(_,a)char**a;{
  int p=atoi(a[1]),s,i,y,x,c;
  for(y=1;y<p&&x!=p;y++)
    for(x=y,c=2;c<7;x+=s*s,c++)
      for(s=0,i=1;i<1001;i*=10)s+=(x%i*10)/i;
  if(x==p)printf("%d",y-1);else puts("n/a");
}

It surely is possible to golf it some more.  If you see something that would help please comment.


text:
"Compile" a simple C program inside a different language
Your task is to take the following simple C code and make a program which will interpret this code and produce a correct output, and be able to handle small modifications to the original code. The C code is
int x = 4;
int y = 5;
int z;

z = x * y;

if(z>10)
{
    printf("%d is bigger than 10!",z);
}

Or as one line of text.
int x = 4; int y = 5; int z; z = x * y; if(z>10){ printf("%d is bigger than 10!",z); }

The program must satisfy the following conditions:

x and y can be changed to any integer.
"is bigger than 10!" must not be printed if z is smaller than 10.
The value of 10 can be changed to any integer (not including the 10 in the printed text).
The program must be able to read the c program in as one line of text.
Adding spaces shouldn't break the program.

The winning solution is the shortest code to satisfy the criteria. Libraries are not allowed.

What's the objective winning criterion?

What would be considered a small modification?

Changing values of x, y and 10, and renaming variables.

A program in any language that can be given the above program  and interpret it character by character and reproduce the same results in its own language dealing with variable changes and integer changes in any combination in exactly the same way the program would compiled in a C compiler. So in effect a C compiler that only handles multiplication, if statements and printing.

Sorry my apologies. The winning code is the shortest code to satisfy that criteria.

Can x and y become a and b resp. ? like int a = 9; int b = 10; ... ?

Also , is the z only created by multiplication ? is the z>10 sign always remains > ? if yes, then this is a simple task of printing the text when product of 2 integers is greater than something.

Yes that's correct. The program must accept the line of code above as it's only input though. The challenge is more in efficiently parsing in a way that works if the things mentioned above are changed.

@tomnomnom my two comments above specifically call out the things that you forgot to mention. Without those things being mentioned, the spec is unclear right now.

That is not a valid c program.

Perl 5, 76 bytes
$_=<>,s/ //g,s/[=>](-?\d+)/$.*=$1/ge,($./=$1)>$1&&say"$. is bigger than $1!"

Input must be in one line. Negative integers are allowed. Tabs may break program (but spaces are fine, even between - and the number).
Ungolfed:

$_ = <>; # read input
# $. = 1; $. is the number of lines read on STDIN, which should be 1.
s/ //g; # remove whitespace from $_
s/[=>](-?\d+)/ $. *= $1 /ge; # get product of all integers after = or >
$. /= $1; # divide away the last integer found (inside the if)
if($. > $1){
   say "$. is bigger than $1";
}

This simply extracts the integers and does the product/comparison afterwards.
Example:
$ perl -E '$_=<>,s/ //g,s/[=>](-?\d+)/$.*=$1/ge,($./=$1)>$1&&say"$. is bigger than $1!"'
> int x =4; int y = -  5 ; int f0_23; f0_23 = x* y ; if ( f0_23> -  30){ printf("%d is bigger than 10!",f0_23) ;  }
-20 is bigger than -30!

The spec is not clear right now. z can be a product or a sum too.

source: Stack Exchange

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

sort: votes


text:
Hereditary Base Change
Background
In this challenge, a base-b representation of an integer n is an expression of n as a sum of powers of b, where each term occurs at most b-1 times. For example, the base-4 representation of 2015 is
4^5 + 3*4^4 + 3*4^3 + 4^2 + 3*4 + 3

Now, the hereditary base-b representation of n is obtained by converting the exponents into their base-b representations, then converting their exponents, and so on recursively. Thus the hereditary base-4 representation of 2015 is
4^(4 + 1) + 3*4^4 + 3*4^3 + 4^2 + 3*4 + 3

As a more complex example, the hereditary base-3 representation of
7981676788374679859068493351144698070458

is
2*3^(3^(3 + 1) + 2) + 3 + 1

The hereditary base change of n from b to c, denoted H(b, c, n), is the number obtained by taking the hereditary base-b representation of n, replacing every b by c, and evaluating the resulting expression. For example, the value of
H(3, 2, 7981676788374679859068493351144698070458)

is
2*2^(2^(2 + 1) + 2) + 2 + 1 = 2051

The Challenge
You are given as input three integers b, c, n, for which you may assume n >= 0 and b, c > 1. Your output is H(b, c, n). The shortest byte count wins, and standard loopholes are disallowed. You can write either a function or a full program. You must be able to handle arbitrarily large inputs and outputs (bignums).
Test Cases
4 2 3 -> 3
2 4 3 -> 5
2 4 10 -> 1028
4 4 40000 -> 40000
4 5 40000 -> 906375
5 4 40000 -> 3584
3 2 7981676788374679859068493351144698070458 -> 56761
2 3 2051 -> 35917545547686059365808220080151141317047

Fun Fact
For any integer n, the sequence obtained by
n1 = n
n2 = H(2, 3, n1) - 1
n3 = H(3, 4, n2) - 1
n4 = H(4, 5, n3) - 1
....

eventually reaches 0. This is known as Goodstein's theorem.

CJam, 60 58 45 43 41 38 36 bytes
Thanks to Optimizer for saving two bytes.
l~:C;:B;{Bb)1$,,@f{1$~=C@)F#*+}~}:F~

Test it here.
Takes input in order n b c.
You can use this to test run all test cases:
"3 4 2
3 2 4
10 2 4
40000 4 4
40000 4 5
40000 5 4
7981676788374679859068493351144698070458 3 2
2051 2 3 "N/
{
~:C;:B;{Bb)1$,,@f{1$~=C@)F#*+}~}:F~
p}/

Explanation
This is a fairly direct implementation of the process explained in the challenge, except that I interleave recursive base expansion, base substitution and computation of the final result:
l~:C;:B;{Bb)1$,,@f{1$~=C@)F#*+}~}:F~
l~:C;:B;                             "Read and evaluate input, store b and c in B and C.";
        {                       }:F  "Define a block F. This performs the required conversion.";
         Bb                          "Get digits of input number in base B.";
           )                         "Split off 0-power digit.";
            1$,                      "Copy remaining digits. Get their length n.";
               ,                     "Make array [0 1 ... n-1].";
                @                    "Pull up remaining digits.";
                 f{           }      "Map this block onto the range, passing in the digits
                                      as a second argument each time.";
                   1$~=              "Copy current i, bitwise complement, access digit array.
                                      This accesses the digits in reverse order.";
                       C             "Push the new base C.";
                        @)           "Pull up current i and increment to get power.";
                          F          "Apply F recursively.":
                           ~         "Raise C to the resulting power.";
                            *        "Multiply by digit.";
                             +       "Add to running total.";
                               ~     "The result will be in an array. Unwrap it.";
                                   ~ "Execute F on the input n.";

Python 2, 55
H=lambda b,c,n,s=0:n and n%b*c**H(b,c,s)+H(b,c,n/b,s+1)

A recursive solution. Like the recursive algorithm to convert between bases, except it recurses on the exponent as well.
We split n into two parts, the current digit n%b, and all other digits n/b. The current place value is stored in the optional parameter s. The current digit is converted to base c with c** and the exponent s is converted recursively. The remainder is then converted the same way, as +H(b,c,n/b,s+1) but the place value s is one higher.
Unlike base conversion, hereditary base conversion required remembering the current place value in the recursion for it to converted.
For ease of reading, here's what it looks like when b and c are fixed global constants.
H=lambda n,s=0:n and n%b*c**H(s)+H(n/b,s+1)

I've posted this mostly because I didn't realize you could use named arguments in pyth: D(GHY=Z0)R&Y+*%YG^H(GHZ)(GH/YGhZ. Feel free to add it if you want (I'm off to tips for golfing in pyth :D )

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


text:
Print the fingering for the note on a saxophone
Your challenge is, given a series of notes, print the fingerings that minimize the amount of movements you need to make (explained below).
My not standard way of transforming fingerings to text:
The | line separates the left and right hand. Use 1 for the index finger, 2 for the middle finger and 3 for the ring finger. Use a-d for the right hand to represent the side keys played by the pinkies (and just a and b for the left hand).
An example for low A#/Bb:

which would be written as 123d|123b.
The side keys, which are hit with the part of your hand between the thumb and index finger, are labeled as e, f, and g.
In addition, there is a little key between the right hand's 1 and 2 used for playing Bb. This is called the i key.
The octave key is labeled o
These are the fingerings (note that b means flat, not the note B which is uppercase):
A#3 or Bb3: 123d|123b
B3 or Cb4: 123c|123b
B#3 or C4: 123|123b
C#4 or Db4: 123b|123b
D4: 123|123
D#4 or Eb4: 123|123a
E4 or Fb4: 123|12
E#4 or F4: 123|1
F#4 or Gb4: 123|2
G4: 123|                // Note that the | is still necessary
G#4 or Ab4: 123a|
A4: 12|
A#4 or Bb4: 12|g OR 1i| OR 1|1 OR 1|2
B4 or Cb5: 1|
B#4 or C5: 2| OR 1|f
C#5 or Db5: |  OR o3|  // No fingers down for first fingering
D5: o123|123
/* All fingerings from D5 - B#5/C6 are the same as the lower octave
   but with the octave key (prefixed with o) */
C#6 or Db6: o|
D6: of|
D#6 or Eb6: oef|
E6 or Fb6: oef|e
E#6 or F6: oefg|

Input:
A series of notes separated by semicolons.
Output:
A series of fingerings separated by semicolons.
If there is more than one way to finger a certain note, the program must chose the fingering that minimizes distance from its neighbors. If it is the only note or there is a tie, you may output any fingering.
A fingering's distance from another is how many fingers you would have to lift/press to change the note.
Example: 12| --> 1| has a distance of 1 because you have to lift finger 2.
Example: 12|g --> 12| has a distance of 1 because you only have to lift one side key.
Test cases:
C#5;D5;C#5 --> o3|;o123|123;o3|

Bonus: -100 if your program takes an audio file (probably midi) as input and outputs the fingering corresponding to the notes played.

Is C#5 o13| (as in the test case) or o3| (as in the spec)?

Sorry it should be o3

Python 3, 528 525 bytes (ouch!)
Not the prettiest code in the world, but I think it works. Calculates the shortest overall distance by trying all possible fingering combinations, so also not the most efficient.
from itertools import*
def f(x,y):a,b=x.split('|');c,d=y.split('|');return len(set(a)^set(c))+len(set(b)^set(d))
print(";".join(min(product(*["zd|zb zc|zb z|zb zb|zb z|z z|za z|12 z|1 z|2 z| za| 12| 12|g&1i|&1|1&1|2 1| 2|&1|f |&o3| oz|z oz|za oz|12 oz|1 oz|2 oz| oza| o12| o12|g&o1i|&o1|1&o1|2 o1| o2|&o1|f o| of| oef| oef|e oefg|".replace('z','123').split()["C D EF G A B".find(n[0])+" #".find(n[1:-1])+12*int(n[-1])-46].split('&') for n in input().split(';')]),key=lambda x:sum(f(x[i],x[i+1]) for i in range(len(x)-1)))))

Not many tricks. Saved a bit by a string-replace on "123". Simplified distance calculation by doing each half separately. Note name to pitch calculation is fairly tight but should be able to golf the rest down.


text:
Golfing at the Bank
Our new bank needs a teller transaction system but there is a problem. There is
only a few hundred bytes of space left on our server, so you will have to write
very compact code.
Database
Thankfully our database is very simple (it was built by the schoolboy son of our
bank president), and we only have a few customers so far.
file Bank.data is:
Account Firstname Lastname Balance Date
123 Maree Jones 346.22 2014-12-13
035 Thomas Breakbone 3422.02 2015-01-03
422 Henrietta Throsby-Borashenko 277847.74 2014-11-21
501 Timmy Bongo 7.95 2014-11-04
105 William Greene 893.00 2015-01-06
300 Mary Galoway 1228.73 2014-12-28
203 Samantha Richardson 2055.44 2014-11-01
151 Bruce Wayne 956119.66 2014-10-09
166 Chip Stonesmith 266.71 2014-12-15
888 Alexandria Cooper 1299.82 2014-12-30

Application Specification
Our bank application must implement the following commands:
open <firstname> <lastname>
Creates (opens) a new account printing a unique 3 digit account number.
withdraw <account> <amount>
Withdraw amount from an account.
deposit <account> <amount>
Deposit amount into an account.
close <account>
Close account if empty.
report <fieldname>
Print a report of the database sorted by fieldname. Move the fieldname column
to the first position. Each column width will be the maximum of the widest data
and fieldname width, separated by one space. The first line will be the field
titles. The balances only must be right justified with a leading $ sign.
print <account>
Print the fieldnames and record for this account formated like the report.
Each time a record is changed, the Date field in the record must be updated to
the current date.
The application will show a "# " prompt when waiting for a command. If a command
fails (such as an operation on an unknown account or insufficient funds), the
application must print the informative error message "failed". The program must
write changes back to the file after each change, and read from the file on each
command as there are many teller programs around the world operating on the file
concurrently (we don't need file locking - that may reduce performance).
EDIT: String fields are simple ASCII (a-z,A-Z,-) without white space and the amount will always be between 0.00 and 1000000000.00 (1 billion) dollars with 2 decimal places indicating cents. The date will be in local time at each branch (a simple solution but may lead to some problems later...).
Output
Answers will need to demonstrate that they meet the specification. Please attach the output from your program after processing the following commands:
report Balance
open Clark Kent
print 001
deposit 001 4530
withdraw 105 893
close 105
report Date

Ensure you use an original copy of the Bank.data file given above.
Scoring
This is code-golf, so your score will be the byte count of your code. Standard
loopholes are prohibited.

Should be a way to exit program?

We don't want to pack too many features into this application ;-) A control-C type exit is fine.

What constraints may be assumed on the characters in <firstname> and <lastname> and the range and precision of <amount>? (E.g. there may be some optimisations which are possible if <amount> always has exactly two decimal places - or you may want the program to be usable by the Middle Eastern branch, where most currencies use three decimal places).

Thanks Peter. I have added some clauses on string type and amount range as suggested.

Maybe I should have been more explicit in my question about the names. The most useful restriction would be that <firstname> and <lastname> both only use a-zA-Z, but even a simple statement that they never contain tab characters allows using TSV. If they could be any sequence of ASCII characters, some form of escaping or delimiting other than with a one-char delimiter is necessary.

Oops. Got it now. Edited to answer your question. There is no white space in any fields. Data fields are separated by a single space.

So your server only has a hundred bytes left for a program, but it contains a 4MB Golfscript interpreter? Not to mention the whole python library, which is over 100MB. Just saying :)

It does sound a bit contrived doesn't it. Then again, I think you have spotted a flaw in this whole site. Where in the real world would you need to write golfed code?

This kind of looks like a homework assignment, just my 2¢…

It's a long long time since I have been in school. I will take your comment to mean that the problem is very clearly written so that even first year computer science students can understand it ;-)

Can I assume that Bank.data already exists and is in the proper format?

Yes. The initial Bank.data file is given in the question. You can assume your program has access to this file in the current directory (or anywhere else you would like).

Can I assume the file headers are only there for reference? ;)

The titles in the first line of the file must be maintained (thats what you get when you take on a cheap DBA ;-)

I have never golfed anything more in my entire life... O.O

I failed to make explicit that you need to show the output from your program. I have added the Output section to the question. You will not need to change your code. Just add the output of your program to your answer. It is the only way I can tell if they work as advertised ;)

Ruby, 918
This question is quite long to golf as it consists of many small parts. For a moment, I almost wanted to define some additional classes to make things neater with polymorphism etc... (but in the end I didn't).
l=->a,i{a.map{|x|x[i].to_s.size}.max}
y=1..-1
d=File.open(f="bank.data").each.map(&:split)
j=[k=%w{Account Firstname Lastname Balance Date}]
_=->{puts"Failure"}
q=->t,v=0{z=-1;puts t.map{|r|([v]+((0..4).to_a-[v])).map{|c|b=l[t,c];c!=3?r[c].ljust(b):(?$*(z+=z<1?1:0)+r[c]).rjust(b>7?b+1:b)}*' '}}
w=->d{File.open(f,?w).write(d.map{|x|x*' '}*?\n)}
s=->i,m=!0{o=d.select{|r|r[0]==i};o==[]?_[]:m ?q[[k]+o]:1}
u=->{Time.now.to_s[0..9]}
($><<"# ";i=gets.split;o=i.size;("report"==h=i[0])?((v=k.index i[1])?q[j+d[y].sort_by{|x|v!=3?x[v]:x[v].to_f},v]:_[]):h=="print"?s[i[1],0]:h=="close"?(s[m=i[1]]?w[d=j+d[y].select{|r|r[0]!=m}]:0):h=="open"?((o==3&&t=((1..999).map{|x|'%03d'%x}-d.map{|x|x[0]})[0])?(w[d=d+[[t,i[1],i[2],'0.00',u[]]]];puts t):_[]):h=="withdraw"||h=="deposit"?(o==3&&s[i[1]]?w[d=j+d[y].map{|r|i[1]==r[0]?(b=(c=r[3].to_f)+i[2].to_f*(i[0][0]==?w?-1:1);0>b&&(b=c;_[]);r[0..2]+["%.2f"%b,u[]]):r}]:_[]):_[])while 1

Probably can be golfed further.
But as of now, I can't even keep track of what I did in the last line.
Output:
# report Balance
   Balance Account Firstname  Lastname           Date
     $7.95 501     Timmy      Bongo              2014-11-04
   $266.71 166     Chip       Stonesmith         2014-12-15
   $346.22 123     Maree      Jones              2014-12-13
   $893.00 105     William    Greene             2015-01-06
  $1228.73 300     Mary       Galoway            2014-12-28
  $1299.82 888     Alexandria Cooper             2014-12-30
  $2055.44 203     Samantha   Richardson         2014-11-01
  $3422.02 035     Thomas     Breakbone          2015-01-03
$277847.74 422     Henrietta  Throsby-Borashenko 2014-11-21
$956119.66 151     Bruce      Wayne              2014-10-09
# open Clark Kent
001
# print 001
Account Firstname Lastname Balance Date
001     Clark     Kent       $0.00 2015-02-01
# deposit 001 4530
# withdraw 105 893
# close 105
# report Date
Date       Account Firstname  Lastname              Balance
2014-10-09 151     Bruce      Wayne              $956119.66
2014-11-01 203     Samantha   Richardson           $2055.44
2014-11-04 501     Timmy      Bongo                   $7.95
2014-11-21 422     Henrietta  Throsby-Borashenko $277847.74
2014-12-13 123     Maree      Jones                 $346.22
2014-12-15 166     Chip       Stonesmith            $266.71
2014-12-28 300     Mary       Galoway              $1228.73
2014-12-30 888     Alexandria Cooper               $1299.82
2015-01-03 035     Thomas     Breakbone            $3422.02
2015-02-01 001     Clark      Kent                 $4530.00
#

It would be very helpful if you could add a sample of the program output (see updated question). Thanks.

I kno this is a byproduct of misapplied syntax highlighting, but the dollar amounts look so cool with the whole numbers in black and the cents in pale red.

Cobra - 1505
class P
    var m='Account Firstname Lastname Balance Date'
    def main
        while[d=DateTime.now.toString('yyyy-MM-dd'),z='0.00']
            print'#'stop
            try,branch (c=Console.readLine.split)[r=0]
                on'open'
                    post while u in for x in.f get x[0],u=(r+=1).toString('000')
                    print u
                    .f=.f.toList+[@[u,c[1],c[2],z,d]]
                on'deposit'or 'withdraw'
                    n=.z(if(c[0]>'deposit','-','')+c[2])
                    assert.z(.i(c[1])[3])+n>=0
                    .f=for x in.f get if(x[0]==c[1],@[x[:3].join(' '),'[(.z(x[3])+n).toString(z)]',d],x)
                on'close'
                    assert.i(c[1])[3]==z
                    .f=for x in.f where.i(c[1])<>x
                on'report',.a(.f,c[1])
                on'print',.a([.i(c[1])])
                else,assert 0
            catch
                print'failed'
    def z(s='')as float
        return float.parse(s)
    pro f as String[]?*
        get
            return for x in File.readAllLines('Bank.data')[1:]get x.split
        set
            File.writeAllLines('Bank.data',[.m]+for x in value get x.join(' '))
    def a(f as String[]?*,c='Account')
        i,l=(m=.m.split).toList.indexOf(c),[7,9,8,8,4]
        assert c in m
        print (for q in (for z in (for x in[m]+f.toList.sorted(do(a as String[],b as String[]))get for y in 5 get[t=try' '.repeat(l[y]-x[y].length)catch get'',if(y-3,x[y]+t,t+if(x==m,' ','$')+x[y])][1])get[z[i]]+for p in z where p<>z[i])get q.join(' ')).join('\n')
            for v in[a,b],for k in 5,if (u=v[k].length)>l[k],l[k]=u
            return[d=a[i].compareTo(b[i]),d,d,.z(a[3]).compareTo(.z(b[3])),DateTime.parse(a[4]).compareTo(DateTime.parse(b[4]))][i]
    def i(s='')as String[]?
        return (for x in.f where x[0]==s)[0]

Output:
#report Balance
   Balance Account Firstname  Lastname           Date
     $7.95 501     Timmy      Bongo              2014-11-04
   $266.71 166     Chip       Stonesmith         2014-12-15
   $346.22 123     Maree      Jones              2014-12-13
   $893.00 105     William    Greene             2015-01-06
  $1228.73 300     Mary       Galoway            2014-12-28
  $1299.82 888     Alexandria Cooper             2014-12-30
  $2055.44 203     Samantha   Richardson         2014-11-01
  $3422.02 035     Thomas     Breakbone          2015-01-03
$277847.74 422     Henrietta  Throsby-Borashenko 2014-11-21
$956119.66 151     Bruce      Wayne              2014-10-09
#open Clark Kent
001
#print 001
Account Firstname Lastname   Balance Date
001     Clark     Kent         $0.00 2015-02-04
#deposit 001 4530
#withdraw 105 893
#close 105
#report Date
Date       Account Firstname  Lastname              Balance
2014-10-09 151     Bruce      Wayne              $956119.66
2014-11-01 203     Samantha   Richardson           $2055.44
2014-11-04 501     Timmy      Bongo                   $7.95
2014-11-21 422     Henrietta  Throsby-Borashenko $277847.74
2014-12-13 123     Maree      Jones                 $346.22
2014-12-15 166     Chip       Stonesmith            $266.71
2014-12-28 300     Mary       Galoway              $1228.73
2014-12-30 888     Alexandria Cooper               $1299.82
2015-01-03 035     Thomas     Breakbone            $3422.02
2015-02-04 001     Clark      Kent                 $4530.00

Thanks for your entry. I had to look up Cobra to see what it was. It might be time for me to learn another language.

It would be very helpful if you could add a sample of the program output (see updated question). Thanks.

@CarpetPython will be done this afternoon.

T-SQL 1919
Called with "exec q 'Your command here'" I don't think T-SQL can actually get user input, so I think this is as close as it can be.
Uses the bcp utility for I/O which I haven't tried before because it comes with SQL Server 2014.
I'm not sure if it would be better or worse to use only the main stored procedure and put the rest of the code in there.
CREATE PROC q @ CHAR(99)AS
CREATE TABLE ##(A CHAR(3),F CHAR(99),L CHAR(99),B MONEY,D DATE)bcp ## in Bank.data -t " " -T
DECLARE @g INT,@w MONEY,@z CHAR(9),@y CHAR(99),@x CHAR(99)SET @g=patindex('% %',@)SET @z=substring(@,1,@g-1)SET @=substring(@,@g+1,99)SET @g=patindex('% %',@)SET @y=substring(@,1,@g-1)SET @=substring(@,@g+1,99)SET @g=patindex('% %',@)SET @x=substring(@,1,@g-1)SET @w=CONVERT(MONEY,@x)*2*(LEN(@z)-7.5)IF @z='open'exec o @y,@x
IF @z='close'exec c @y
IF @z='withdraw'exec w @y,@w
IF @z='deposit'exec w @y,@w
IF @z='print'exec p @y
IF @z='report'exec r @y
bcp ## out Bank.data -t " " -T
SELECT'#'
CREATE PROC r @q CHAR(9)AS
DECLARE @a char(9)='A Account',@f char(11)='F Firstname',@l char(10)='L Lastname',@b char(45)='CONCAT(''$'',SPACE(9-LEN(B)),B) Balance',@d char(6)='D Date',@ varchar(999)='SELECT '
IF @q='Account'SET @+=@a+','+@f+','+@l+','+@b+','+@d
IF @q='Balance'SET @+=@b+','+@a+','+@f+','+@l+','+@d
IF @q='Date'SET @+=@d+','+@a+','+@f+','+@l+','+@b
IF @q='Lastname'SET @+=@l+','+@a+','+@f+','+@b+','+@d
IF @q='Firstname'SET @+=@f+','+@a+','+@l+','+@b+','+@d
IF LEN(@)<9
BEGIN
SELECT'failed'RETURN
END
SET @+=' FROM ## ORDER BY '+@q
exec(@)CREATE PROC p @ CHAR(3)AS
DECLARE @r CHAR(9)=(SELECT 1 FROM ## WHERE A=@)IF @r IS NULL SELECT'failed'ELSE SELECT*FROM ## WHERE A=@
CREATE Proc o @f CHAR(99),@l CHAR(99)AS
DECLARE @ INT=0,@r CHAR(9)=(SELECT 1 FROM # WHERE A='000')WHILE @r IS NOT NULL
BEGIN

SET @+=1
SET @r=(SELECT 1 FROM # WHERE CONVERT(INT,A)=@)END
IF @>999 SELECT'failed'ELSE INSERT INTO # OUTPUT Inserted.A VALUES(REPLICATE('0',3-LEN(@))+CONVERT(CHAR(3),@),@f,@l,0,GETDATE())CREATE PROC w @ CHAR(3),@b MONEY AS
DECLARE @r CHAR(9)=(SELECT 1 FROM ## WHERE A=@ AND B>@b)IF @r IS NULL SELECT'failed'ELSE UPDATE ## SET B=B-@b,D=GETDATE()WHERE A=@
CREATE Proc c @q CHAR(3)AS
DECLARE @r CHAR(9)=(SELECT 1 FROM ## WHERE A=@q AND B=0)IF @r IS NULL SELECT'failed'ELSE DELETE FROM ## WHERE A=@q

It would be very helpful if you could add a sample of the program output (see updated question). Thanks.

Python 2 - 2205 bytes
Here is a rather verbose attempt at a solution.
import sys, time, re
def db(recs):
    text = '\n'.join(' '.join(row) for row in [titles]+recs)
    open('Bank.data', 'wt').write(text+'\n')
def wid(col, recs):
    w = max(len(r[col]) for r in [titles]+recs)
    return w if col == 3 else -w
while 1:
    inp=raw_input('# ').split()
    try:
        cmd = inp.pop(0)
        data = [d.split() for d in open('Bank.data', 'rt').readlines()]
        titles = data.pop(0)
        today = '-'.join('%02u' % v for v in time.localtime()[:3])
        alist = set(int(r[0]) for r in data)
        if cmd == 'open':
            assert re.match(r'[-a-zA-Z]{2,}', inp[0]+inp[1])
            acct = '%03u'%([n for n in range(1, 1000) if n not in alist][0])
            rec = [acct] + inp + ['0.00', today]
            db(data+[rec])
            print acct
        elif cmd == 'withdraw':
            a, m = inp[0], float(inp[1])
            rec = [r for r in data if r[0] == a][0]
            b = float(rec[3])
            assert b >= m
            rec[3] = '%.2f' % (b-m)
            rec[4] = today
            db(data)
        elif cmd == 'deposit':
            a, m = inp[0], float(inp[1])
            rec=[r for r in data if r[0]==a][0]
            rec[3]='%.2f'%(float(rec[3])+m)
            rec[4]=today
            db(data)
        elif cmd=='close':
            rec=[r for r in data if r[0]==inp[0]][0]
            assert int(rec[3])==0
            data=[r for r in data if r!=rec]
            db(data)
        elif cmd=='report':
            for r in data: r[3]='$'+r[3]
            fmtlist=['%'+str(wid(c,data))+'s' for c in range(5)]
            loc=titles.index(inp[0])
            for r in data: r.insert(0,r.pop(loc))
            data.sort(key=lambda x: float(x[0][1:]) if loc==3 else x[0])
            titles.insert(0,titles.pop(loc))
            fmtlist.insert(0,fmtlist.pop(loc))
            for r in [titles]+data: print ' '.join(fmtlist)%tuple(r)
        elif cmd=='print':
            for r in data: r[3]='$'+r[3]
            rec=[r for r in data if r[0]==inp[0]][0]
            fmt=' '.join('%'+str(wid(c,[rec]))+'s' for c in range(5))
            for r in [titles,rec]: print fmt%tuple(r)
        else: raise()
    except:
        print 'failed'

Here is a sample of the application in use:
# report Balance
   Balance Account Firstname  Lastname           Date
     $7.95 501     Timmy      Bongo              2014-11-04
   $266.71 166     Chip       Stonesmith         2014-12-15
   $346.22 123     Maree      Jones              2014-12-13
   $893.00 105     William    Greene             2015-01-06
  $1228.73 300     Mary       Galoway            2014-12-28
  $1299.82 888     Alexandria Cooper             2014-12-30
  $2055.44 203     Samantha   Richardson         2014-11-01
  $3422.02 035     Thomas     Breakbone          2015-01-03
$277847.74 422     Henrietta  Throsby-Borashenko 2014-11-21
$956119.66 151     Bruce      Wayne              2014-10-09
# open Clark Kent
001
# print 001
Account Firstname Lastname Balance Date
001     Clark     Kent       $0.00 2015-01-13
# deposit 001 4530
# withdraw 105 893
# close 105
# report Date
Date       Account Firstname  Lastname              Balance
2014-10-09 151     Bruce      Wayne              $956119.66
2014-11-01 203     Samantha   Richardson           $2055.44
2014-11-04 501     Timmy      Bongo                   $7.95
2014-11-21 422     Henrietta  Throsby-Borashenko $277847.74
2014-12-13 123     Maree      Jones                 $346.22
2014-12-15 166     Chip       Stonesmith            $266.71
2014-12-28 300     Mary       Galoway              $1228.73
2014-12-30 888     Alexandria Cooper               $1299.82
2015-01-03 035     Thomas     Breakbone            $3422.02
2015-01-13 001     Clark      Kent                 $4530.00
#

STATA 1506
Didn't try to golf it too much. I figured a statistical language would be better at this, but apparently.
set more off
while 1<2{
qui insheet using Bank.data,delim(" ")clear case
form A %-03.0f
form B %10.2f
form D %-10s
form F %-50s
form L %-50s
g K="$"+string(B,"%10.2f")
di"#",_r(q)
loc s: di %tdCCYY-NN-DD date(c(current_date),"DMY")
if word("$q",1)=="open"{
forv x=0/999{
egen c=anymatch(A),v(`x')
if c<1{
egen m=min(A)
cap expand 2 if A==m,gen(z)
replace A=`x' if A==m&z>0
replace B=0 if A==`x'
replace F=word("$q",2) if A==`x'
replace L=word("$q",3) if A==`x'
replace D="`s'" if A==`x'
di"`x'"
outsheet A-D using Bank.data,delim(" ")replace
continue, br
}
if `x'==999{
di"failed"
}
drop c
}
continue
}
if word("$q",1)=="report"{
ren B R
ren K Balance
if word("$q",2)=="Account"{
so A
l A-L B D,clean noo
}
else if word("$q",2)=="Date"{
so D
l D A-L B,clean noo
}
else if word("$q",2)=="Lastname"{
so L
l L A F B D,clean noo
}
else if word("$q",2)=="Balance"{
so R
l B A-L D,clean noo
}
else if word("$q",2)=="Firstname"{
so F
l F A L B D,clean noo
}
else{
di"failed"
}
continue
}
gen i=real(word("$q",2))
egen p=min(abs(A-i))
if p>0{
di"failed"
continue
}
if word("$q",1)=="close"{
egen c=count(i)
drop if A==i&B==0
qui cou
if c==r(N){
di"failed"
continue
}
}
if word("$q",1)=="print"{
drop Balance
ren K Balance
l A-L B D if A==i,noo clean ab(9)
continue
}
gen j=real(word("$q",3))
if word("$q",1)=="withdraw"{
replace B=B-j if A==i
egen c=min(B)
if c<0{
di"failed"
continue
}
}
if word("$q",1)=="deposit"{
replace B=B+j if A==i
}
replace D="`s'" if A==i
outsheet A-D using Bank.data,delim(" ")replace
}

It would be very helpful if you could add a sample of the program output (see updated question). Thanks.

Batch - 1827
Batch is not built for this kind of thing.
@echo off&setLocal enableDelayedExpansion&set B=Bank.data&echo wscript.echo eval(wscript.arguments(0))>%temp%\eval1.vbs&set Z=goto :EOF&set V=call&set F=for /l %%a in (1,1,
:m
set C=-1&set D=%date:~-4%-%date:~-7,2%-%date:~-10,2%
for /f "tokens=1-5" %%a in (%B%)do set/aC+=1 &set !C!=%%a %%b %%c %%d %%e&set !C!n=%%a&set !C!f=%%b&set !C!s=%%c&set !C!b=%%d&set !C!d=%%e&set A=%%a&set/aA+=1
set/pI="#"
%V% :%I% 2>nul||echo failed&goto m
goto m
:open
echo %A% %1 %2 0.00 %D%>>%B%&echo %A%&%Z%
:close
echo !0!>%B%&%F%!C!)do if "!%%an!" NEQ "%1" (echo !%%a!>>%B%)else if !%%ab! GTR 0.00 echo failed & echo !%%a!>>%B%
%Z%
:deposit
%F%!C!)do if "!%%an!"=="%1" set p=%%a
%V% :c "!%p%b!+%2"
set %p%b=%r%&set %p%d=%D%&%V% :u
%Z%
:withdraw
%F%!C!)do if "!%%an!"=="%1" set p=%%a
%V% :c "!%p%b!-%2"&if "%r:~0,1%"=="-" echo failed&%Z%
set %p%b=%r%&set %p%d=%D%&%V% :u
%Z%
:report
for /l %%a in (1,1,50)do set H= !H!
for /l %%a in (0,1,!C!)do (
%V% :l !%%an!&set %%anl=!l!&if !l! GTR !tn! set/atn=!l!
%V% :l !%%af!&set %%afl=!l!&if !l! GTR !tf! set/atf=!l!
%V% :l !%%as!&set %%asl=!l!&if !l! GTR !ts! set/ats=!l!
%V% :l !%%ab!&set %%abl=!l!&if !l! GTR !tb! set/atb=!l!
)
for /l %%a in (0,1,!C!)do %V% :c "%tn%-!%%anl!"&set sn=!r:~0,-3!&%V% :t !sn!&set pn=!x!&%V% :c "%tf%-!%%afl!"&set sf=!r:~0,-3!&%V% :t !sf!&set pf=!x!&%V% :c "%ts%-!%%asl!"&set ss=!r:~0,-3!&%V% :t !ss!&set ps=!x!&%V% :c "%tb%-!%%abl!"&set sb=!r:~0,-3!&%V% :t !sb!&set pb=!x!&echo !%%an!!pn! !%%af!!pf! !%%as!!ps! !pb!$!%%ab! !%%ad!
%Z%
:l
set S=%1&for /f usebackq %%a in (`Powershell "'!S!'.Length"`)do set l=%%a
%Z%
:t
set x=!H:~0,%1!
%Z%
:u
echo !0!>%B%&%F%!C!)do echo !%%an! !%%af! !%%as! !%%ab! !%%ad!>>%B%&%Z%
:c
for /f %%a in ('cscript //nologo %temp%\eval1.vbs "round(%1,2)"')do set r=%%a
if "%r:~-3,1%" NEQ "." set r=%r%.00

Yet to implement Sort (within report), and Print functions.

It would be very helpful if you could add a sample of the program output (see updated question). Thanks.

C# - 1870 1881 Bytes
Abusing using aliases, Action, Func, exceptions for flow control and more.  Was considering exploiting that "report" didn't specify how things should be sorted.  Bank.data must use unix line breaks or this code will break.
Edited to fix a potential issue sorting by fields other than Date and Balance.
using System;using System.Collections.Generic;using System.IO;using System.Linq;using Ac=System.Action;using Cn=System.Console;using F1=System.Func<string,int>;using F2=System.Func<string>;using S=System.String;class P{static void Main(S[] args){S fn="Bank.data";List<S>ad=null;F1 L=(s)=>s.Length;F2 dt=()=>S.Format("{0:yyyy-MM-dd}",DateTime.Now);Func<S,S[]>sp=(s)=>s.Split(' ');Action<S,S>wl=(s,fm)=>Cn.WriteLine(S.Format(fm,sp(s)));Func<S,S>rs=(s)=>{var t=sp(s);t[3]="$"+t[3];return S.Join(" ",t);};F2 fs=()=>{int[]sz={7,9,8,7};ad.Skip(1).ToList().ForEach(b=>{for(int c=0;c<4;c++){sz[c]=Math.Max(sz[c],L(sp(rs(b))[c]));}});return"{0,-"+sz[0]+"} {1,-"+sz[1]+"} {2,-"+sz[2]+"} {3,"+sz[3]+"} {4,-10}";};F1 k=(s)=>sp(ad[0]).ToList().FindIndex(a=>a==s);Ac Sv=()=>File.WriteAllText(fn,S.Join("\n",ad));Ac Ld=()=>ad=File.ReadAllText(fn).Split('\n').ToList();Action<int,S>R=(r,a)=>{var s=sp(ad[r]);s[3]=S.Format("{0:#.00}",Convert.ToDouble(s[3])+Convert.ToDouble(a));s[4]=dt();ad[r]=S.Join(" ",s);};Ac f=()=>wl("failure","{0}");F1 ri=(n)=>{for(int w=1;w < ad.Count;w++){if(ad[w].StartsWith(n))return w;}return -1;};F2 nm=()=>{var s="";for(int i=1;i<1000;i++){s=S.Format("{0:000}",i);if (ri(s)<0)break;}return s;};for(;;){Cn.Write("# ");S i=Cn.ReadLine();var it=sp(i+" ");Ld();var n=ri(it[1]);it=sp(i);var a=new Dictionary<S,Ac>(){{"deposit",()=>R(n,it[2])},{"withdraw",()=>R(n,"-"+it[2])},{"close",()=>(sp(ad[n])[3]==".00"?()=>ad.RemoveAt(n):f)()},{"open",()=>{var nn=nm();ad.Add(S.Format("{0} {1} {2} .00 {3}",nn,it[1],it[2],dt()));wl(nn,"{0}");}},{"print",()=>{wl(ad[0],fs());wl(rs(ad[n]),fs());}},{"report",()=>{var ks=sp(fs()).ToList();var ki=k(it[1]);ks.Insert(0,ks[ki]);ks.RemoveAt(ki+1);var kf=S.Join(" ",ks);wl(ad[0],kf);ad.Skip(1).OrderBy(b=>(ki==3?new S('0',11-L(sp(b)[ki])):"")+sp(b)[ki]).ToList().ForEach(b=>wl(rs(b),kf));}}};try{a[it[0]]();Sv();}catch(Exception){f();}}}}

Output:
# report Balance
   Balance Account Firstname  Lastname           Date
     $7.95 501     Timmy      Bongo              2014-11-04
   $266.71 166     Chip       Stonesmith         2014-12-15
   $346.22 123     Maree      Jones              2014-12-13
   $893.00 105     William    Greene             2015-01-06
  $1228.73 300     Mary       Galoway            2014-12-28
  $1299.82 888     Alexandria Cooper             2014-12-30
  $2055.44 203     Samantha   Richardson         2014-11-01
  $3422.02 035     Thomas     Breakbone          2015-01-03
$277847.74 422     Henrietta  Throsby-Borashenko 2014-11-21
$956119.66 151     Bruce      Wayne              2014-10-09
# open Clark Kent
001
# print 001
Account Firstname  Lastname              Balance Date
001     Clark      Kent                     $.00 2015-02-03
# deposit 001 4530
# withdraw 105 893
# close 105
# report Date
Date       Account Firstname  Lastname              Balance
2014-10-09 151     Bruce      Wayne              $956119.66
2014-11-01 203     Samantha   Richardson           $2055.44
2014-11-04 501     Timmy      Bongo                   $7.95
2014-11-21 422     Henrietta  Throsby-Borashenko $277847.74
2014-12-13 123     Maree      Jones                 $346.22
2014-12-15 166     Chip       Stonesmith            $266.71
2014-12-28 300     Mary       Galoway              $1228.73
2014-12-30 888     Alexandria Cooper               $1299.82
2015-01-03 035     Thomas     Breakbone            $3422.02
2015-02-03 001     Clark      Kent                 $4530.00
#

C# - 1952 1883
I will show some output when I get in tomorrow. For now, here's the submission:
using System;using System.Collections.Generic;using System.IO;using System.Linq;using S=System.String;using O=System.Func<dynamic,string,string>;class I{char[]c={' '};Action<string>w;Func<S,S,S,S,S,dynamic>n;Func<string>N;List<dynamic>T;private static void Main(string[]a){while(true){Console.Write("# ");new I().Parse(Console.ReadLine());}}I(){w=Console.WriteLine;n=(g,h,i,j,k)=>new{a=g,f=h,l=i,b=j,d=k};N=()=>DateTime.Now.ToString("yyyy-MM-dd");}List<dynamic>G(){return File.ReadAllLines("test.data").Select(l=>l.Split(c)).Select(ac=>n(ac[0],ac[1],ac[2],ac[3],ac[4])).ToList();}void W(){File.WriteAllLines("test.data",T.Select(a=>(S)(a.a+" "+a.f+" "+a.l+" "+a.b+" "+a.d)));}void Parse(string inp){var C=true;try{Func<object,float>v=Convert.ToSingle;Func<string,bool>s=string.IsNullOrEmpty;var i=inp.Split(c);T=G();Func<S,int>F=m=>T.IndexOf(T.FirstOrDefault(a=>a.a==m));C=!s(i[1]);var g=F(i[1]);switch(i[0]){case"open":if(C){int an=0;var cs="000";while(T.Any(A=>cs==A.a)){an++;cs=an.ToString("D3");}T.Add(n(cs,i[1],i[2],"0.00",N()));w(cs);}break;case"withdraw":case"deposit":var D=i[0]=="deposit";C=(D||v(T[g].b)>=v(i[2]));var ba=(v(T[g].b)+v(i[2])*(D?1:-1)).ToString("F");if(C)T[g]=n(T[g].a,T[g].f,T[g].l,ba,N());break;case"close":C=g>-1&&v(T[g].b)<=0;if(C)T.RemoveAt(g);break;case"report":case"print":var X=i[0]=="print";var B=1;O o=(x,p)=>((Type)x.GetType()).GetProperty(p).GetValue(x);O K=(k,j)=>{var r=(j=="b"?"$":"");var P=T.Max(_=>(o(_,j)).Length);return r==""?(o(k,j)).PadRight(P):((B<1?r:"")+(o(k,j))).PadLeft(P+1);};var q=i[1];Action<dynamic,S>U=(u,t)=>{S l=""; foreach(var h in t)l+=K(u,h.ToString())+" "; w(l);};q=q=="Account"?"a":q=="Firstname"?"f":q=="Lastname"?"l":q=="Balance"?"b":q=="Date"?"d":"a"; var V=(q+"afldb".Replace(q,""));U(T.First(),V);B=0;foreach(var M in(X?T.Skip(1).Take(1):T.Skip(1).OrderBy(df=>o(df,q))))U(M,V);break;}W();}catch{}if(!C)w("Failed");}}

It would be very helpful if you could add a sample of the program output (see updated question). Thanks.


text:
Code Golf Image Downloader

In many image-processing challenges, the post contains images, which must be saved to a file in order to be able to work on the problem. This is an especially tedious manual task. We programmers should not have to be subjected to such drudgery. Your task is to automatically download all the images contained in a Code Golf.SE question.
Rules

Your program may connect to any part of stackexchange.com, but may not connect to any other domains, excepting the locations of the images (i.e., don't bother with a URL shortener).
An integer N is given as input, on the command line or stdin.
The URL http://codegolf.stackexchange.com/questions/N is guaranteed to be a valid link to a Code Golf question.
Each image displayed in the body of question N must be saved to a file on the local computer. Either of the following locations is acceptable:

The current directory
A directory input by the user

Your program must not save files other than the images in the question body (e.g. user avatars, or images contained in answers).
Images must be saved with the same file extension as the original.

This is a code-golf — write the shortest program you can.
Validity criterion for answers
There are various possible edge cases with multiple images of the same name, text with the same name as HTML elements, etc. An answer will be invalidated only if it can be shown to fail on some revision of a question posted before January 10, 2015.

Should the image names be kept the same or can we do like 0.png, 1.png etc

@stokastic You can name the part before the extension to whatever you want (as long as you don't use the same name twice, overwriting a previous file).

Mathematica, 211 210 bytes
i=Import;FileNameTake@#~Export~i@#&/@ImportString["body"/.("items"/.i["http://api.stackexchange.com/2.2/questions/"<>InputString[]<>"?site=codegolf&filter=!*Lgp.gEWHA6BNP.l","JSON"])[[1]],{"HTML","ImageLinks"}]

Ungolfed:
i = Import;
FileNameTake@#~Export~i@# & /@
 ImportString[
  "body" /. (
    "items" /.
      i["http://api.stackexchange.com/2.2/questions/" <>
        InputString[] <> "?site=codegolf&filter=!*Lgp.gEWHA6BNP.l",
       "JSON"]
  )[[1]],
  {"HTML", "ImageLinks"}
 ]

It's pretty straightforward. I've set up a filter for the StackExchange API, which returns only the body of a question. The code retrieves the question information with that filter and parses it as JSON. I select the correct element (the body), and use ImportString to parse the HTML and filter out all image URLs. FileNameTake@#~Export~Import@# then downloads each of the images and stores it in the current working directory with the same file name as that in the URL.
You can find out the current working directory with Directory[].
In principle, there's a much shorter version, because ImportString can actually download all the files right away, instead of just giving me the URLs. But then I lose information about the original file type (since they are converted to Image objects upon download), so I can only save them all as the same type (PNG, say).

Javascript - 149 161 bytes
$.get("http://codegolf.stackexchange.com/q/"+prompt(),function(e){$(".post-text:first img",e).each(function(e,t){$('')[0].click()})})

with whitespace
$.get('http://codegolf.stackexchange.com/q/' + prompt(), function(d) {
  $('.post-text:first img',d).each(function(i,e){
   $('')[0].click();
  })
})

script has to be run from stackexchange site to work. Will default to the current page if no question number is specified in the prompt

As @doorknob mentioned above, you can save a bit by swapping q for question. And if you don't mind getting all the images in the posts on the page, you can do $('[src*="imgur"]',d) I believe. I like that this can be run in the console - instant gratification.

questions can be shortened to q, but it should include the codegolf.stackexchange.com part instead of relying on being at that page. @Josiah it is possible to include images from other domains in posts.

The selector #question .post-text img can be shortened to .post-text:first img or .post-text:eq(0) img.

Python 2 - 241 bytes
Pretty straightforward, can probably be golfed further. I search the site for all occurrences of img src= between the first occurrence of post-text and the /div immediately following that. Each image url is then read and saved to the working directory.
import string,sys,urllib,re;o=string.find;u=urllib.urlopen
r=u("http://codegolf.stackexchange.com/q/"+sys.argv[1]).read()
i=o(r,"post-text")
for p in re.findall(r'img src="([^"]*)',r[i:o(r,"/div",i)]):f=open(p[-9:],"wb");f.write(u(p).read())

Filenames are kept as is - the name is taken as the last 9 bytes ([-9:]) of the image url, which should keep its 5 character name and a .png or .jpg etc. It will chop off bytes of the filename if the extension is longer than 3 characters.

What if the file name is shorter than 9 bytes? Wouldn't that include a slash in the file name?

you can save 2 bytes by making the for loop one line. for p re.findall(...):f=open(...);f.write(...)

@mar I don't think the file name can be less than 9 bytes, but I might be mistaken

@MartinBüttner I think 9 bytes is a reasonable assumption, but I can change it if you think I should. For what it's worth - using only 6 or 7 bytes is probably enough and will still pretty much guarantee distinct file names.

You can save 8 chars by replacing questions with q (in the URL).

Mathematica, 195
x=XMLElement;c=Cases;i=Import;l=Infinity;FileNameTake@#~Export~i@#&/@(((c[#,x["img",{"src"->e_,_},___]:>e,l]&)@*(c[#,x[_,{__,"id"->"question",__},e_]:>e,l]&)@*(i[#,"XMLObject"] &))@InputString[])

This exports images in the same way that Martin did in his Mathematica solution, read his answer for more information about that. This approach is very different from his, instead of parsing the result from the API I parse the HTML page directly. Or rather, I parse the symbolic XML that Mathematica can generate from HTML.

Python 2 - 398 342 334 bytes
The program download the SE page, extracts the post part (the post-text div element), finds urls that end in an image extension and downloads them. The images are saved as img<n>.<ext> in the current directory.
import urllib2 as u,re,sys
z=u.urlopen;i=1
p=z('http://codegolf.stackexchange.com/q/'+sys.argv[1]).read()
s=re.search(r'ss="po(.+?)/di',p,16).group(1)
for L in re.findall('"(h.+?://.*?)"',s):
 b=L.rsplit('.',1)
 if len(b)==2 and b[1].lower() in 'jpg jpeg png gif bmp'.split():
  open('img%u.%s'%(i,b[1]),'wb').write(z(L).read());i+=1

This program will also download images that are supplied as a link, not only embedded images. By giving each image a unique filename, name clashes are also avoided.

You can save 8 chars by replacing questions with q (in the URL).

In question 43274, I see only 11 images, but 21 are downloaded.

My program downloads the 10 high resolution images as well as the 10 thumbnails. I am not sure the other entries fetch the high resolution versions.

@Doorknob - thanks. I missed that. I will need much more though to catch the other guys.

@CarpetPython although that's arguably more useful...the intention of the spec was to download only images which are visible.

Bash - 86 bytes
wget -r -l1 -np -Ajpg,jpeg,png,bmp,gif http://codegolf.stackexchange.com/questions/$1

Nothing wget won't fix.
-np prevents wget from entering upper directories(User Imgs)
-A only grabs files with the extension matching the list presented. -r is a recursive download. -l prevents wget from going too deep. $1 is the question to grab.

Is there something specific I need to do for this to work? I tried it on a couple questions, but no good. Output here.

I think ou can save 8 chars by replacing questions with q in the URL.

Node.js, 251 247 Bytes
r=require,g=r('request'),g('http://codegolf.stackexchange.com/q/'+process.argv[2],function(_,_,b){r('cheerio').load(b)('#question .post-text img').each(function(i,a){s=a.attribs.src,g(s).pipe(r('fs').createWriteStream(i+r('path').basename(s)))})})

Uses request to make HTTP GETs and cheerio to parse the HTML. Name collisions are resolved by prepending the index of the current image to the basename of the file's URL. Images are saved to same directory as the current file.

Lua, 200 bytes
r=require'socket.http'.request r('http://codegolf.stackexchange.com/questions/'.. ...):gsub('post.text(.-)div',function(p)p:gsub('src="(.-)"',function(i)io.open(i:sub(-9),'wb'):write((r(i)))end)end)

Accepts the number as a command-line argument.
Assumes any src= attribute will be for an img tag since these are the only tags with src attributes that stack exchange allows (right?).
Also note the .. .... I'm particularly proud of that one.


text:
Score a game of Kingdom Builder
I want to try a new form of code golf here. Similar to bonuses, not all parts of the challenge have to be completed, but each answer has to implement a subset of certain size (and there is a core that every answer has to implement). So besides the golfing this challenge also involves choosing a set of features that go well together.
The Rules
Kingdom Builder is a board game, played on a (pointy-top) hex grid. The board is made up of four (randomised) quadrants, each of which has 10x10 hex cells (so a full board will be 20x20). For the purposes of this challenge, each hex cell contains either water (W), mountain (M) a town (T), a castle (C) or is empty (.). So a quadrant could look like
. . W . . . . . . .
 . M W W . . . . . .
. M . . W . . . T .
 M M . W . . . . . .
. . M . W W . . . .
 . . . . . W W W W W
. T . . . . . . . .
 . . W . . C . . . .
. . W W . . . . M .
 . . . . . . . M M .

The second row will always be offset to the right from the first row. Players 1 to 4 can place up to 40 settlements each on empty cells (following some rules which we will ignore for this challenge). A possible board at the end of the game is the following:
3 3 W . . . 4 . 4 . . 2 W . 4 . . 4 . 4
 3 M W W . 1 1 . . 4 2 W . 3 C 4 4 . . 4
3 M 2 2 W 1 1 1 T 3 2 W 4 3 . 1 4 . 4 .
 M M . W 2 2 . . . 2 2 W 3 . 1 1 1 . . .
. 4 M . W W 2 2 2 2 W W 3 . 1 4 . T . .
 . . . . . W W W W W . 3 C 1 . . 2 2 2 2
. T 1 1 1 1 . . 2 . . 4 . . . 2 2 M M M
 4 . W 4 . C 4 4 . . . . . . 2 M M M M M
. 4 W W . . . 4 M . . W . W . 2 2 2 M M
 . . . . . . . M M . . W W . . . . 2 M .
. . . 3 3 3 3 3 3 3 3 3 3 3 3 3 3 2 . 1
 M 3 3 . . . . . . . . 4 . T 2 . 2 4 1 .
M M . C . 4 . 4 . . . . . 1 2 4 2 1 1 .
 M . . 1 . 4 . . . . M M 1 2 . . 2 1 . .
. . . W 1 1 4 1 1 . . . 1 2 . . 2 W W W
 . . 1 1 W 1 T . 1 1 1 1 T . . 2 W . 4 .
. 1 1 W . 3 3 . . . . . . . . 2 W 4 C 3
 C 1 3 3 3 . 3 . 4 . 4 . 4 . . 2 W 1 1 M
4 3 3 4 . M 4 3 . . . . . . . 2 W . . .
 . . . 4 . M M 3 . . 4 4 . 4 . 2 W W . .

We'll label the quadrants like
1 2
3 4

Your task will be to score such a board. There is one core score which is always used, and 8 optional scores, 3 of which are chosen for each game.† In the following, I'll describe all 9 scores and use the above setup as an example for how many points each player would get.
† There are 10 scores in the actual game, but I'll leave out two because no one wants to golf them.
The core score. A player gets 3 points for each Castle they have a settlement next to. Example scores: 18, 0, 15, 12.
The optional scores.

A player gets 1 point for each horizontal row on which they have at least one settlement.
Example scores: 14, 20, 12, 16.
For each player, find the horizontal row on which they most of their settlements (pick any in case of a tie). A player gets 2 points for each settlement on that row.
Example scores: 14 (row 16), 8 (row 4, 5 or 6), 28 (row 11), 10 (row 1).
A player gets 1 point for each settlement that is build next to Water.
Example scores: 13, 21, 10, 5.
A player gets 1 point for each settlement next to a Mountain.
Example scores: 4, 12, 8, 4.
Count the settlements of each player in each quadrant. Per quadrant, the players with the largest number of settlements get 12 points each, the players with the second-largest number of settlements get 6 points each.
Example scores: 18 (6 + 0 + 6 + 6), 36 (12 + 12 + 0 + 12), 12 (0 + 0 + 12 + 0), 18 (12 + 6 + 0 + 0).
For each player determine the quadrant in which they have the least number of settlements. A player gets 3 points for each settlement in that quadrant.
Example scores: 18 (Quadrant 2), 0 (Quadrant 3), 15 (Quadrant 1 or 2), 27 (Quadrant 3).
A player gets 1 point for each connected group of settlements.
Example scores: 7, 5, 6, 29.
A player gets 1 point for every 2 settlements in the player's largest group of connected settlements.
Example scores: 4, 10, 8, 2.

The Challenge
As in the game you will choose 3 of the optional scores, and score a given board based on the core score and those three scores. Your code should produce a list of 4 scores. There is one restriction on the choice though: I have grouped the scores into 3 groups, and you are to implement one of each group:

Implement one of 1 and 2.
Implement one of 3, 4, 5 and 6.
Implement one of 7 and 8.

You may write a program or function, taking input via STDIN, command-line argument, prompt or function parameter. You may return the result or print it to STDOUT.
You may choose any convenient 1D or 2D list/string format for the input. You may not use a graph with full adjacency information. Here is some good reading on hex grids if you need inspiration.
Your output may also be in any convenient, unambiguous list or string format.
This is code golf, so the shortest answer (in bytes) wins.
Further Assumptions
You may assume that ...

... each player has at least 1 settlement and there are no more than 40 settlements of each player.
... each quadrant contains either one town and two castles, or two towns and one castle.
... towns and castles are far enough apart, such that no settlement can be adjacent to two of them.

Test Cases
Still using the above board, here are the individual scores for all possible choices of scoring mechanisms:
Chosen Scores      Total Player Scores
1 3 7              52 46 43 62
1 3 8              49 51 45 35
1 4 7              43 37 41 61
1 4 8              40 42 43 34
1 5 7              57 61 45 75
1 5 8              54 66 47 48
1 6 7              57 25 48 84
1 6 8              54 30 50 57
2 3 7              52 34 59 56
2 3 8              49 39 61 29
2 4 7              43 25 57 55
2 4 8              40 30 59 28
2 5 7              57 49 61 69
2 5 8              54 54 63 42
2 6 7              57 13 64 78
2 6 8              54 18 66 51

Is there a board in which one player always wins, regardless of the combination?

@ThreeFx Since the lower bound on the number of settlements per player is 1, that's fairly simple to set up. ;) But with the same number of settlements for each player, I don't actually know.

Python 2, 367 bytes
T=range(20)
N=lambda r,c:{(a,b)for a,b in{(r+x/3-1,c+x%3-1+(x/3!=1)*r%2)for x in[0,1,3,5,6,7]}if-1<b<20>a>-1}
def S(B):
 def F(r,c):j=J[r][c]!=i;J[r][c]*=j;j or map(F,*zip(*N(r,c)));return j
 J=map(list,B);X=lambda r,c,x,y:x+y in{B[r][c]+B[a][b]for a,b in N(r,c)};return[sum((i in B[r])+20*(3*X(r,c,"C",i)-~X(r,c,i,"W")-F(r,c))for r in T for c in T)/20for i in"1234"]

The program uses scores 1, 3, 7. Input is a list of lists of chars representing each cell. To test the example board easily, we can do:
board = """
3 3 W . . . 4 . 4 . . 2 W . 4 . . 4 . 4
 3 M W W . 1 1 . . 4 2 W . 3 C 4 4 . . 4
3 M 2 2 W 1 1 1 T 3 2 W 4 3 . 1 4 . 4 .
 M M . W 2 2 . . . 2 2 W 3 . 1 1 1 . . .
. 4 M . W W 2 2 2 2 W W 3 . 1 4 . T . .
 . . . . . W W W W W . 3 C 1 . . 2 2 2 2
. T 1 1 1 1 . . 2 . . 4 . . . 2 2 M M M
 4 . W 4 . C 4 4 . . . . . . 2 M M M M M
. 4 W W . . . 4 M . . W . W . 2 2 2 M M
 . . . . . . . M M . . W W . . . . 2 M .
. . . 3 3 3 3 3 3 3 3 3 3 3 3 3 3 2 . 1
 M 3 3 . . . . . . . . 4 . T 2 . 2 4 1 .
M M . C . 4 . 4 . . . . . 1 2 4 2 1 1 .
 M . . 1 . 4 . . . . M M 1 2 . . 2 1 . .
. . . W 1 1 4 1 1 . . . 1 2 . . 2 W W W
 . . 1 1 W 1 T . 1 1 1 1 T . . 2 W . 4 .
. 1 1 W . 3 3 . . . . . . . . 2 W 4 C 3
 C 1 3 3 3 . 3 . 4 . 4 . 4 . . 2 W 1 1 M
4 3 3 4 . M 4 3 . . . . . . . 2 W . . .
 . . . 4 . M M 3 . . 4 4 . 4 . 2 W W . .
"""

board = [row.split() for row in board.strip().split("\n")]
print S(board)

# [52, 46, 43, 62]

Handling the hex grid
Since we are on a hex grid, we have to deal with neighbours a little differently. If we use a traditional 2D grid as our representation, then for (1, 1) we have:
. N N . .       . N N . .                (0, 1), (0, 2)            (-1, 0), (-1, 1)
 N X N . .  ->  N X N . .  -> Neighbours (1, 0), (1, 2) -> Offsets (0, -1), (0, 1)
. N N . .       . N N . .                (2, 1), (2, 2)            (1, 0), (1, 1)

On closer inspection, we realise that the offsets depend on the parity of the row you're on. The above example is for odd rows, but on even rows the offsets are
(-1, -1), (-1, 0), (0, -1), (0, 1), (1, -1), (1, 0)

The only thing that has changed is that the 1st, 2nd, 5th and 6th pairs have had their second coordinate decremented by 1.
The lambda function N takes a coordinate pair (row, col) and returns all neighbours of the cell within the grid. The inner comprehension generates the above offsets by extracting them from a simple base 3 encoding, incrementing the second coordinate if the row is odd and adds the offsets to the cell in question to give the neighbours. The outer comprehension then filters, leaving just the neighbours that are within the bounds of the grid.
Ungolfed
def neighbours(row, col):
    neighbour_set = set()

    for dr, dc in {(-1,-1), (-1,0), (0,-1), (0,1), (1,-1), (1,0)}:
        neighbour_set.add((row + dr, col + dc + (1 if dr != 0 and row%2 == 1 else 0)))

    return {(r,c) for r,c in neighbour_set if 20>r>-1 and 20>c>-1}

def solve(board):
    def flood_fill(char, row, col):
        # Logic negated in golfed code to save a few bytes
        is_char = (dummy[row][col] == char)
        dummy[row][col] = "" if is_char else dummy[row][col]

        if is_char:
            for neighbour in neighbours(row, col):
                flood_fill(char, *neighbour)

        return is_char

    def neighbour_check(row, col, char1, char2):
        return board[row][col] == char1 and char2 in {board[r][c] for r,c in neighbours(row, col)}

    dummy = [row[:] for row in board] # Need to deep copy for the flood fill
    scores = [0]*4

    for i,char in enumerate("1234"):
        for row in range(20):
            for col in range(20):
                scores[i] += (char in board[row])                        # Score 1
                scores[i] += 20 * 3*neighbour_check(row, col, "C", char) # Core score
                scores[i] += 20 * neighbour_check(row, col, char, "W")   # Score 3
                scores[i] += 20 * flood_fill(char, row, col)             # Score 7

        # Overcounted everything 20 times, divide out
        scores[i] /= 20

    return scores

Can't the def F be a separate function rather than an internal function? Can't k be removed from def F:?

@Quincunx F is the flood fill function and needs access to J, so it's on the inside to save on passing J as a parameter (I'll experiment a bit to see if I can get around the deep copying). You're right about k though, thanks :) (the new code looks a little funky however, due to relying on short circuiting)

Answer Set Programming, 629 bytes
d(X,Y):-b(X,Y,_).p(1;2;3;4).n(X,Y,(((X-2;X+2),Y);((X-1;X+1),(Y-1;Y+1)))):-d(X,Y).n(X,Y,I,J):-n(X,Y,(I,J));d(I,J).t(X,Y,P):-n(X,Y,I,J);b(I,J,P).s(c,P,S*3):-S={t(X,Y,P):b(X,Y,"C")};p(P).s(1,P,S*1):-S=#count{r(Y):b(_,Y,P)};p(P).s(3,P,S):-S={b(X,Y,P):t(X,Y,"W")};p(P).o(X,Y,Y+X*100):-d(X,Y).h(P,X,Y,I,J):-o(X,Y,O);o(I,J,Q);O<Q;n(X,Y,I,J);b(X,Y,P);b(I,J,P);p(P).h(P,X,Y,I,J):-o(X,Y,O);o(I,J,Q);O<Q;h(P,X,Y,K,L);n(K,L,I,J);b(I,J,P);p(P).c(P,X,Y):-h(P,X,Y,_,_);not h(P,_,_,X,Y).c(P,X,Y):-{h(P,X,Y,_,_);h(P,_,_,X,Y)}0;b(X,Y,P);p(P).s(7,P,S):-S=#count{c(P,X,Y):c(P,X,Y)};p(P).s(t,P,C+S+T+U):-s(c,P,C);s(1,P,S);s(3,P,T);s(7,P,U).#shows/3.

ASP belongs to the logic programming language family, here incarnated by the Potassco framework, in particular Clingo(grounder Gringo + solver Clasp). Because of the paradigm limitation, it can't take given board directly as an output, so a preprocessing of the data is necessary (here performed in python). This preprocessing in not counted in the total byte score.
Its my first code golf, and the objective is more to show a language i love that i never seen before in golf, than really win the game.
Moreover, i'm far from an expert in ASP, so many optimizations of the code can certainly be perform for results in less bytes.
knowledge representation
There is the python code that convert board in atoms :
def asp_str(v):
    return ('"' + str(v) + '"') if v not in '1234' else str(v)

with open('board.txt') as fd, open('board.lp', 'w') as fo:
        [fo.write('b('+ str(x) +','+ str(y) +','+ asp_str(v) +').\n')
         for y, line in enumerate(fd)
         for x, v in enumerate(line) if v not in ' .\n'
        ]

For example, atoms b (for __b__oard) given for the first line of example board are the followings :
b(0,0,3).
b(2,0,3).
b(4,0,"W").
b(12,0,4).
b(16,0,4).
b(22,0,2).
b(24,0,"W").
b(28,0,4).
b(34,0,4).
b(38,0,4).

Where b(0,0,3) is an atom that describes that player 3 has a settlement at coordinates (0;0).
ASP solving
There is the ASP code, with many optional scores implemented :
% input : b(X,Y,V) with X,Y the coordinates of the V value

domain(X,Y):- b(X,Y,_).
player("1";"2";"3";"4").

% neighbors of X,Y
neighbors(X,Y,((X-2,Y);(X+2,Y);((X-1;X+1),(Y-1;Y+1)))) :- domain(X,Y).
neighbors(X,Y,I,J):- neighbors(X,Y,(I,J)) ; domain(I,J).

% Player is next to X,Y iff has a settlement next to.
next(X,Y,P):- neighbors(X,Y,I,J) ; b(I,J,P).

% SCORES

% Core score : 3 point for each Castle "C" with at least one settlement next to.
score(core,P,S*3):- S={next(X,Y,P): b(X,Y,"C")} ; player(P).

% opt1: 1 point per settled row
score(opt1,P,S*1):- S=#count{row(Y): b(_,Y,P)} ; player(P).

% opt2: 2 point per settlement on the most self-populated row
% first, defines how many settlements have a player on each row
rowcount(P,Y,H):- H=#count{col(X): b(X,Y,P)} ; domain(_,Y) ; player(P).
score(opt2,P,S*2):- S=#max{T: rowcount(P,Y,T)} ; player(P).

% opt3: 1 point for each settlements next to a Water "W".
score(opt3,P,S):- S={b(X,Y,P): next(X,Y,"W")} ; player(P).

% opt4: 1 point for each settlements next to a Mountain "M".
score(opt4,P,S):- S={b(X,Y,P): next(X,Y,"M")} ; player(P).

% opt5:
%later…

% opt6:
%later…

% opt7: 1 point for each connected component of settlement
% first we need each coord X,Y to be orderable.
% then is defined path/5, that is true iff exists a connected component of settlement of player P
%   that links X,Y to I,J
% then is defined the connected component atom that give the smaller coords in each connected component
% then computing the score.
order(X,Y,Y+X*100):- domain(X,Y).
path(P,X,Y,I,J):- order(X,Y,O1) ; order(I,J,O2) ; O1<O2 ; % order
                  neighbors(X,Y,I,J) ; b(X,Y,P) ; b(I,J,P) ; player(P). % path iff next to
path(P,X,Y,I,J):- order(X,Y,O1) ; order(I,J,O2) ; O1<O2 ; % order
                  path(P,X,Y,K,L) ; neighbors(K,L,I,J) ; % path if path to next to
                  b(I,J,P) ; player(P).
concomp(P,X,Y):- path(P,X,Y,_,_) ; not path(P,_,_,X,Y). % at least two settlements in the connected component
concomp(P,X,Y):- 0 { path(P,X,Y,_,_) ; path(P,_,_,X,Y) } 0 ; board(X,Y,P) ; player(P). % concomp of only one settlements
score(opt7,P,S):- S=#count{concomp(P,X,Y): concomp(P,X,Y)} ; player(P).

% opt8: 0.5 point for each settlement in the bigger connected component
%later…

% total score:
score(total,P,C+S1+S2+S3):- score(core,P,C) ; score(opt1,P,S1) ; score(opt3,P,S2) ; score(opt7,P,S3).

#show. # show nothing but the others show statements
#show total_score(P,S): score(total,P,S).
%#show score/3. % scores details

This program can be launched with the command:
clingo board.lp golf.lp

And will find only one solution (its a proof that there is only one way to distribute the points):
s(c,1,18) s(c,2,0) s(c,3,15) s(c,4,12) s(1,1,14) s(1,2,20) s(1,3,12) s(1,4,16) s(3,1,13) s(3,2,21) s(3,3,10) s(3,4,5) s(7,1,7) s(7,2,5) s(7,3,6) s(7,4,29) s(t,1,52) s(t,2,46) s(t,3,43) s(t,4,62)

Where s(7,3,6) says that player 3 gains 6 points with optional score 7, and s(t,4,62) says that player 4 gains 62 points in total (core + 1 + 3 + 7).
Easy to parse to have a fancy table !