text:
Inverse Deltas of an Array
Your task is to, given an array of signed 32 bit integers, recompile it with its inverse deltas. For example, the list
1  3  4  2  8

holds the deltas:
  2  1 -2  6

which are then negated, yielding:
 -2 -1  2 -6

and recompiled, yielding:
1 -1 -2  0 -6

as the final result.
Input/Output
You will be given a list/array/table/tuple/stack/etc. of signed integers as input through any standard input method.
You must output the modified data once again in any acceptable form, following the above delta inversion method.
You will receive N inputs where 0 < N < 10 where each number falls within the range -1000 < X < 1000
Test Cases
5 6 7 8          -> 5 4 3 2
1 3 4 2 8        -> 1 -1 -2 0 -6
32 18 25 192 199 -> 32 46 39 -128 -135

Notes

You are not restricted to the delta based method: if you can work out the easier method (which shouldn't be too hard), you're free to use it.
As stated in above, you will always receive at least 1 input, and no more than 9.
The first number of the output must always be the first number of the input, if this is not the case, your method is incorrect.
Only Standard Input Output is accepted
Standard loopholes apply
This is code-golf, so the lowest byte-count wins!
Have fun!

We have a winner.
Dennis's Jelly Answer at a Tiny 3 Bytes has taken home the gold, due to the fact that I am under the impression it cannot be beaten.
I was mildly disappointed I didn't get to see an answer based on the original spec, however, I may later put a bounty on precisely that.

I don't understand the recompile step? How do you get from -2, -1, 2, -6 to 1, -1, -2, 0, -6??

@Fogmeister you start from the same initial value and then apply these differences instead of the original ones.

Standard Input Output - I haven't heard that used in a challenge before, but I infer that it does NOT mean stdin/stdout, since otherwise all replies here seem to be wrong. I guess it means that you can't take input as Church numerals or something? Anyway, if that's what it means, it should probably be called something else since standard output/input has another meaning as well.

@MartinEnder 1+0=1, 3-2=-1?, 4-1=-2?? That's what I thought but those numbers don't add up. Oh! Never mind. I just saw it. You create a new array starting at the original value but with the new differences. So 1 with a diff of -2 goes to -1, then with a diff of -1 this goes to -2 and so on.

@HaraldKorneliussen It's probably referring to this (and that's likely what everyone is assuming)

@Fogmeister You start from 1 3 4 2 8. Then 3 - 1 = 2, 4 - 3 = 1, 2 - 4 = -2, 8 - 2 = 6, gives 2 1 -2 6. You negate those to get -2 -1 2 -6. Then you start from 1 and apply these differences: 1 + (-2) = -1, -1 + (-1) = -2, -2 + 2 = 0, 0 + (-6) = -6, so you end up with 1 -1 -2 0 -6.

does "any acceptable format" include outputting backwards?

also, you said the input would be signed integers at the beginning, and unsigned integers later on.

All these  questions use one function sxs->s in list...

@Flp.Tkc Missed that, sorry. Signed was the intention, although none of the test cases have signed inputs.

Jelly, 7 3 bytes
ḤḢ_

Try it online!
Background
The deltas of (a, b, c, d) are b - a, c - b, and d - c. Cumulatively reducing (a, b - a, c - b, d - c) by subtraction yields a - (b - a) = 2a - b, 2a - b - (c - b) = 2a - c, and 2a - c - (d - c) = 2a - d, so the correct result is (2a - a, 2a - b, 2a - c, 2a - d).
How it works
ḤḢ_  Main link. Argument: A (array)

Ḥ    Unhalve; multiply all integers in A by 2.
 Ḣ   Head; extract first element of 2A.
  _  Subtract the elements of A from the result.

Well, pack it up.  There's nothing to be done here except crawl away in defeat.

Dennis just waits for me to post a question and Snipes me with these tiny Jelly Answers. I have no complaints.

Python 2, 30 bytes
lambda x:[x[0]*2-n for n in x]

Test it on Ideone.
How it works
The deltas of (a, b, c, d) are b - a, c - b, and d - c. Cumulatively reducing (a, b - a, c - b, d - c) by subtractiong yields a - (b - a) = 2a - b, 2a - b - (c - b) = 2a - c, and 2a - c - (d - c) = 2a - d, so the correct result is (2a - a, 2a - b, 2a - c, 2a - d).

Mathematica, 8 bytes
2#-{##}&

Unnamed function taking an indeterminate number of arguments. This uses an "easy" way: negates the entire list and adds twice the (original) first element.
Called for example like 2#-{##}&[1,3,4,2,8]; returns a list like {1,-1,-2,0,-6}.

Indeed, thanks—merely a typo.

JavaScript (ES6), 21
Thx @Dennis
l=>l.map(v=>l[0]*2-v)

That's... short.

05AB1E, 4 bytes
¬·s-

Try it online! or as a Test suite
Explanation
¬     # head of input list
 ·    # multiplied by 2
  s   # swap with input list
   -  # subtract

Perl 6,  40  16 bytes
{[\+] .[0],|.rotor(2=>-1).map({[-] @_})}

{.map(.[0]*2-*)}

Expanded:
{ # bare block lambda with single implicit parameter ｢$_｣ ( input is a List )

  [\[+]]  # triangle reduce the following using ｢&infix:<+>｣

    .[0], # the first value

    |(    # Slip this list into outer one ( Perl 6 doesn't auto flatten )

      .rotor( 2 => -1 ) # take the input 2 at a time, backing up 1
      .map({ [-] @_ })  # reduce the pairs using ｢&infix:<->｣

    )
}

{ # bare block lambda with single implicit parameter ｢$_｣ ( input is a List )

  .map(          # map over the inputs
    .[0] * 2 - * # take the first value multiply by 2 and subtract the current value
    #          ^- this makes the statement a WhateverCode, and is the input
  )
}

ARM (Thumb), 16 bytes
.section .text
.global func
.thumb
// void func(int* arr, int len)
// arr[i] = 2*arr[0] - arr[i] for each i
// r0 = arr, r1 = len, r2 = arr[0], r3 = arr[i]
func:
    ldr r2, [r0, #0]         // 6802        int head = *arr;
.loop:                       //             do {
    ldr r3, [r0, #0]         // 6803        int cur = *arr;
    rsb r3, r3, r2, lsl #1   // ebc3 0342   cur = (head << 1) - cur;
    stmia r0!, {r3}          // c008        *arr++ = cur;
    sub r1, #1               // 3901        len -= 1;
    bne .loop                // d1f9        } while (len != 0);
    bx lr                    // 4770        return;

Uses the formula, which nicely fits into exactly four registers in use. The stm tip was used to overwrite the value and advance the pointer in a single narrow instruction, and a wide rsb instruction was used to evaluate exactly what we want. (I know it's possible to do with a 3-operand sub and then an add for the same byte count, but I figured a single instruction would add some coolness.)

Labyrinth, 34 bytes
?:_2*}
@    _
)\?_1"
,    ;
!`-}:{

Try it online!
Uses @Dennis's (2a - a, 2a - b, 2a - c, 2a - d) approach.

The yellow tiles are for control flow. In this 2D programming language, the program starts at the top-left-most tile moving east to start. At junctions, the direction is determined by the sign of the top of the main stack. Blank tiles are walls.
Green
This section saves 2a to the auxilary stack.

? Get the first number and push it to the top of the main stack
: Duplicate the top of the stack
_2 Push two to the top of the stack
* Pop y, pop x, push x*y
} Move the top of the main stack to the top of the auxilary stack.
_ Push zero to the top of the stack

Orange
This section subtracts 2a from the current number, negates the result, outputs the result, gets the next character (the delimeter), exits if EOF, outputs a newline, gets the next number.

" Noop. If coming from the north, the top of the stack will be zero and the program will continue south. If coming from the west, the top of the stack will be one and the program will turn right (continuing south)
; Discard the top of the stack. As the zero or one is only used for control flow, we need to discard these
{ Move the top of the auxilary stack (2a) to the top of the main stack
: Duplicate the top of the main stack
} Move the top of the main stack to the top of the auxilary stack
- Pop y, pop x, push x-y
\`` Negate the top of the stack. This and the previous three operations have the effect of-(x-2a) = 2a-x`
! Pop the top of the stack and output it as a number
, Push the next character (which will be the delimiter) or negative one if EOF
) Increment the top of the stack. If the last character is EOF, then the top of the stack will now be zero and the program will continue straight to the @ and exit. If the last character was a delimeter, then the top of the stack will be positive causing the program to turn right and continue east to the \
\ Output a newline
? Get the next number
_1 Push one to the top of the stack in order to turn right at the junction

Huh, this reminds me that I also solved this challenge but completely forgot to post the solutions. I've got three different solutions at 24 bytes (and I'm pretty sure they aren't optimal), so I guess I'll give you a couple of days or so to match or beat that before I post mine. Nice work, still! :)

@MartinEnder, no need to wait on me. I doubt I'll be able to think of a better solution any time soon. I'm still getting used to stack-based problem solving. I'm just enjoying learning a new way to think about programming.

Python, 44 bytes
lambda l:[l[0]]+[x-(x-l[0])*2for x in l[1:]]

This uses the "Easier method".

Pyth, 5 bytes
-LyhQ

Online Interpreter!

R, 23 18 17 bytes
x=scan();2*x[1]-x

auto-vectorisation and default print to the rescue!

Why not 2*x[1]-x instead?

Had to leave something to optimise, right? (thank you)

Haskell, 20 19 bytes
f(x:r)=x:map(2*x-)r

Same solution as Dennis, thank you for your idea of 2a - x.
Saved one byte thanks to Christian Severs.

save one byte: f(x:r)=x:map(2*x-)r

Thanks, I had tried several different approaches with @ and without, but didn't think of just putting x in front.

Ruby, 23 bytes
->l{l.map{|x|l[0]*2-x}}

Not particularly original.

Brain-Flak, 76 Bytes
([][()]){{}(({})<(({}){}[{}]<>)<>>)([][()])}{}({}<<>([]){{}({}<>)<>([])}<>>)

Try it Online!
Explanation:
Part 1:
(      )                                        # Push:
 []                                             # the height of the stack
   [()]                                         # minus 1
        {                                  }    # While the height - 1 != 0:
         {}                                     # Pop the height
           (({})<                               # Hold onto the top value, but put it back.
                                                # This ensures that the top value is always
                                                # what was the first element of input
                 (            )                 # Push:
                  ({}){}                        # Top * 2
                        [{}]                    # minus the next element
                            <> <>               # onto the other stack

                                 >)             # Put back the element we held onto.
                                   (      )     # Push:
                                    []          # The height of the stack
                                      [()]      # Minus 1
                                            {}  # Pop the counter used for the height
Part 2:
({}<                                            # Hold onto the top element.
                                                # This was the first number for input
                                                # so it needs to end up on top
    <>                                          # Switch stacks
      ([])                                      # Push the height of the stack
          {              }                      # While the height != 0:
           {}                                   # Pop the height
             (    )                             # Push:
              {}                                # The top element of this stack
                <>                              # onto the other stack
                   <>                           # and switch back
                     ([])                       # Push the new height of the stack
                          <>                    # After every element has switched stacks
                                                # (which reverses their order),
                                                # switch stacks
                            >)                  # Push the first element back on

Vyxal, 3 bytes
dh-

Try it Online!
Dennis port

d   # Double the array
 h  # Take the first
  - # Subtract

Or, by implementing the original spec,
Vyxal 2.5, 5 bytes
¯?hp¦

Try it Online!
¯     # Deltas (negated, this is a bug, and will be fixed, that is why it's 2.5)
 ?hp  # Prepend the first item of input
    ¦ # Take the cumulative sum

Labyrinth, 24 bytes
+:}:?
}
<}}?;%):,\!-{:{>

Input and output format are linefeed-separate lists (although the input format is actually a lot more flexible). The program terminates with an error.
Try it online!
I've got two other solutions at this byte count, which work basically the same but use somewhat different control flow.
:+:}:?
{
,}-!
?  {
:";\@

{:+:}:?
_
<>__-?:;%):,\!

Explanation
The instruction pointer (IP) starts moving east along the first line, but all the commands before the ? are basically no-ops on the global state, since we're not using stack depth commands anywhere. So the code really starts at the ? going west, since the IP turns around when it hits the dead end.
The code therefore starts with the following linear bit of code:
?:}:+}

This simply sets us up with a copy of 2a to use the [2a - a, 2a - b, 2a - c, ...] formula.
?   Read first integer a.
:}  Move a copy off to the auxiliary stack.
:+  Multiply a by 2 (by adding it to itself).
}   Move that off to the auxiliary stack as well.

We now enter the main loop of the program, using a fairly standard trick to loop through a single line of code:
<...>

Note that the stack will be empty whenever we hit the < so we know we'll get zeros there. The < then rotates the entire line left, taking the IP with it, so we get this:
...><

The IP then has to move left, where the > shifts the line back into its original place (to prepare it for the next iteration). Then the line is simply executed from right to left, so a single loop iteration is this:
{:{-!\,:)%;?}}

The catch when working with a loop of this type is that you can't work with any form of conditional execution, since Labyrinth doesn't have a way to skip code. Therefore, we will terminate the program with a division by zero when we hit EOF. Here is a breakdown of each loop iteration.
{:   Pull 2a back to the main stack and make a copy.
{    Pull the latest value i of the input list back to main as well.
-    Compute 2a-i/
!\   Print it with a trailing linefeed.
,    Read a character. If there are input elements left, this will be some
     form of separator character, and therefore a positive value x. However,
     at the end of the program, this will give -1.
:)   Make an incremented copy.
%    Try to to compute x%(x+1). This will error out at EOF.
;    Discard the result of the division.
?    Read the next input value.
}}   Move that and the remaining copy of 2a back to the auxiliary stack.

These solutions are great. It's great to examine these and learn about thinking in Labyrinth.

Pyke, 5 4 bytes
h}m-

Try it here!

PHP, 48 bytes
for(;''<$c=$argv[++$i];)echo-$c+2*$a=$a??$c,' ';

Using the technique from Dennis. Use like:
php -r "for(;''<$c=$argv[++$i];)echo-$c+2*$a=$a??$c,' ';" 1 3 4 2 8

Non-Dennis 55 byte version:
for(;''<$c=$argv[++$i];$l=$c)echo$a+=($l??$c*2)-$c,' ';

Save one byte with a& instead of ''< and two bytes with _ instead of ' '.

APL, 8 bytes
+\⊃,2-/+

Explanation:
+\           ⍝ running sum of
  ⊃          ⍝ first item of list
   ,         ⍝ followed by
    2-/      ⍝ differences between every pair in
       +     ⍝ input list

Test cases:
      ( +\⊃,2-/+ ) ¨ (5 6 7 8) (1 3 4 2 8) (32 18 25 192 199)
┌───────┬────────────┬──────────────────┐
│5 4 3 2│1 ¯1 ¯2 0 ¯6│32 46 39 ¯128 ¯135│
└───────┴────────────┴──────────────────┘

Factor, 26 bytes
[ dup first 2 * v-n vneg ]

Try it online!

J, 7 bytes
-~+:@{.

Try it online!

-~0{+: for -1 byte

Dyalog APL, 5 bytes
-+2×⊃
this is a 5-train, it parses like two nested 3-trains ("forks"): -+(2×⊃)
reads like: the negation (-) of the whole array plus (+) twice (2×) the first element (⊃)

ised, 11 bytes
2*$1_0-$1

Invocation: ised --l 'file with input.txt' '2*$1_0-$1
(edit: corrected by stealing the algebra from Dennis)

Wonder, 17 bytes
@->#@- *2:0#1#0#0

Not sure why I didn't post this earlier. Usage:
(@->#@- *2:0#1#0#0)[5 6 7 8]

More readable:
@(map @
  - (
    * 2 get 0 #1
  ) #0
) #0

C++14, 36 bytes
As unnamed lambda modifying its input:
[](auto&c){for(auto&x:c)x=2*c[0]-x;}

Using the technique from Dennis. Works for any container like int[] or vector<int>.
Usage:
#include<iostream>

auto f=
[](auto&c){for(auto&x:c)x=2*c[0]-x;}
;

int main(){
  int a[] = {1,  3,  4,  2,  8};
  f(a);
  for(auto&x:a)
    std::cout << x << ", ";
  std::cout<<"\n";
}

CJam, 16 bytes
Input format: [1 2 3 4]. Uses the easy formula.
l~_(2*/;a/,@@*.-

Explanation:
l~_(2*/;a/,@@*.-
l~_                     e#Read input twice into an array. Stack: [1 2 3 4] [1 2 3 4]
   (                    e#Get first element of the array. Stack: [1 2 3 4] [2 3 4] 1
    2*                  e#Multiply by two. Stack: [1 2 3 4] [2 3 4] 2
      /;                e#Discard second element. Stack: [1 2 3 4] 2
        a               e#Wrap into an array. Stack: [1 2 3 4] [2]
         /,             e#Rotate and get length. Stack: [2] [1 2 3 4] 4
           @@           e#Rotate twice. Stack: [1 2 3 4] 4 [2]
            *           e#Repeat len times. Stack: [1 2 3 4] [2 2 2 2]
             .-         e#Vectorized substraction. Stack: [-1 0 1 2]
                        e#Implictly print

Sorry for no test link. I guess SE don't like it's links with brackets inside.

There's also http://cjam.tryitonline.net, which base64 encodes all fields. Both interpreters give me an error though.

Pushy, 9 bytes
{&}2*K~-_

Give arguments as comma-seperated values on cmd line: $ pushy invdeltas.pshy 1,3,4,2,8. Here's the breakdown, with example stack:
           % Implicit: Input on stack              [1, 3, 4, 2, 8]
{&}        % Copy first item, put at end of stack  [1, 3, 4, 2, 8, 1]
   2*      % Multiply by 2                         [1, 3, 4, 2, 8, 2]
     K~    % Negate everything on stack            [-1, -3, -4, -2, -8, -2]
       -   % Subtract last item from all           [1, -1, -2, 0, -6]
        _  % Print whole stack

Note: this can be 8 bytes if backwards output is allowed: @&2*K~-_

Perl, 26 + 3 (-pla flag) = 29 bytes
$_="@{[map$F[0]*2-$_,@F]}"

or
$_=join$",map$F[0]*2-$_,@F

Using:
perl -plae '$_="@{[map$F[0]*2-$_,@F]}"' <<< "32 18 25 192 199"

Zsh, 18 bytes
for a;<<<$[$1*2-a]

Try it online!

Japt -m, 4 bytes
nWÎÑ

Try it here

Halfwit, 3.5 bytes
+><iN+

Try It Online!
Dennis port.
+      # Double the input, adding it to itself
 ><i   # Get the first one
    N+ # Subtract from the input

Once again, I'm reminded of how annoying Halfwit's minimalism is to program with.

Desmos, 12 bytes
f(l)=2l[1]-l

Try It On Desmos!

Thunno 2, 3 bytes
Ḍh_

Try it online!
Port of Dennis's Jelly answer.
Explanation
Ḍh_  # Implicit input
Ḍ    # Double each number
 h   # Take the first item
  _  # Subtract input from this
     # Implicit output

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


text:
Building Demolition
Challenge
Write a full program/function to Demolish a given building at the rate 1 floor per second.
INPUT
Input is a building through STDIN(or whatever is called in your language) or through an ARGUMENT of a function.
t=0 s
   |
  |#|
  {#}
 |# #|
|# # #|
|# # #|
|# # #|
TTTTTTT

input consists of :

| marks start and end of a floor.
{,} marks the floor with explosives.
# is a window which is for decoration .
 is space, which is everywhere inside the floors where # is not there.
T marks ground(cannot be demolished).
* marks the detonated floor.

Input rules :

building starts from top with one | and ends on ground(with no(T)=no (char used in ground floor)).
a window # is at every odd place inside every floor.
T marks the end of your input.
only one floor consists of explosives.
every floor is made of odd no. of chars.
as you ascend down the floors, the floors can either be of equal size of that of previous floor or can be 2 chars bigger.
Input can be taken as an array of chars or strings.

Output :
t=0.5 s
   |
  |#|
  ***
 |# #|
|# # #|
|# # #|
|# # #|
TTTTTTT

t=1 s
   |
  |#|
 |# #|
|# # #|
|# # #|
|# # #|
TTTTTTT

t=1.5 s
   |
  ***
 |# #|
|# # #|
|# # #|
|# # #|
TTTTTTT

t=2 s
   |
 |# #|
|# # #|
|# # #|
|# # #|
TTTTTTT

t=2.5 s
   *
 |# #|
|# # #|
|# # #|
|# # #|
TTTTTTT

t=3 s
 |# #|
|# # #|
|# # #|
|# # #|
TTTTTTT

t=3.5 s
 *****
|# # #|
|# # #|
|# # #|
TTTTTTT

t=4 s
|# # #|
|# # #|
|# # #|
TTTTTTT

t=4.5 s
*******
|# # #|
|# # #|
TTTTTTT

t=6.5 s
*******
TTTTTTT

t=7 s
TTTTTTT

Output rules :

every floor ends with one newline character.
ground may/may not have a trailing newline.
output the building(or whats left of it) every 0.5 s.
Output is like animation which is modified every 0.5 s and is displayed.
(Also feel free to post GIFs with your answer)

This is a Code-Golf so the code in shortest bytes wins!
last date of submission is exactly 5 days from now
(But you know what ? Winning is not everything, feel free to try this challenge in your favorite language, even after a winner has been declared :] ).
EDIT : I changed the way you take input (my bad actually).

What is answers are supposed to be posted after 1 hrs from now about?

1 hr from the time of my post. so that I get at least 1 hr to rectify any question related doubts.

I'm not sure if the community would be willing to enforce this kind of limitation. If you're not sure that your specification is solid, you can post the challenge draft in our sandbox to get feedback before posting it on main.

@dennis Hmm...removed

Two questions:  (1) May we assume there's no trailing whitespace on any floor? (2) May we assume there are no more lines of input after the ground?

@walters No trailing whitespace = true(every floor ends with a newline). No lines of output after ground = true.

Vim, 41 38 bytes
qw:sl 500m␍q/{␍qqjk^v$r*@wdd:-␍@w@qq@q

Here, ^ is used for a literal caret; ␍ is used for CTRL-M.
Explanation
qw:sl 500m␍q sleeps half a second, while recording the half second sleep as macro w. /{␍ moves to the floor with explosives.  qq begins recording macro q, which will recursively call itself.
jk moves down and up; this generates an error if you're on the last line (ground); the error terminates the recursive macro.  ^v$r* replaces everything from the first non-whitespace character to the end of the line with *'s.  @w waits half a second, then dd deletes the current floor.  :-␍ moves up a floor without terminating the macro if you're on the top line.  @w then waits another half second, and @q calls the q macro (initially empty).
q@q stops recording the macro q, then calls it, triggering the recursion.
Animation

I was starving to see a gif!!

I noticed nobody else put a gif in, but you said "feel free to", so for my post it was a must!  Anyhow, my answer could be "golfed" further if rewritten in V.

my answer could be "golfed" further...ain't that enough? :P

JavaScript (ES6), 208 198 bytes

f=
(t,s=f=>setTimeout(f,500),v=t.value.split(/(\S.*\n)/),i=v.findIndex(s=>/}/.test(s)),c=_=>t.value=v.join``,d=_=>c(v.splice(--i,2),v[3]&&s(e,i?--i:++i)),e=_=>c(v[i]=v[i].replace(/./g,'*'),s(d)))=>s(e)
<textarea id=t rows=9>
   |
  |#|
  {#}
 |# #|
|# # #|
|# # #|
|# # #|
TTTTTTT
</textarea><input type=button value=Go! onclick=f(t)>

Java 7, 589 477 476 bytes
import java.util.*;void x(List<String>b,int x)throws Exception{Thread.sleep(500);int i=0,l=b.size(),z=x;String w;for(;i<l;i++){System.out.println(w=b.get(i));if(w.contains("{"))x=i;}System.out.println();w=b.get(x);i=w.contains("*")?1:0;if(i>0)b.remove(x);else b.set(x,z<0?r(w,'{','}'):r(w,'|','|'));if(l>1)x(b,i>0&x>0?x-1:x);}String r(String s,char y,char z){int a,b;return s.substring(0,a=s.indexOf(y))+s.substring(a,b=s.lastIndexOf(z)+1).replaceAll(".","*")+s.substring(b);}

Ok, it's a mess/long, but this challenge has so many annoying things for Java.. Printing multi-line; Thread.sleep(500) which requires a throws Exception; replacing a substring between two delimiters with an equal amount of *; etc.
All this causes the program to be pretty big.. It can defintely be golfed some more, maybe even halved with a different approach, but at least there is an answer now. ;)
Ungolfed:
void x(List<String>b, int x) throws Exception{
  Thread.sleep(500);
  int i = 0,
      l = b.size(),
      z = x;
  String w;
  for(;i<l; i++){
    System.out.println(w=b.get(i));
    if(w.contains("{")){
      x = i;
    }
  }
  System.out.println();
  w = b.get(x);
  i = s.contains("*")
       ? 1
       : 0;
  if(i>0){
    b.remove(x);
  }
  else{
    b.set(x, z < 0
              ? r(s, '{', '}')
              : r(s, '|', '|'));
  }
  if(l>1){
    x(b, i > 0 & x > 0
          ? x-1
          : x);
  }
}

String r(String s, chary, char z){
    int a, b;
    return s.substring(0, a=s.indexOf(y)) + s.substring(a, b=s.lastIndexOf(z) + 1).replaceAll(".", "*") + s.substring(b);
}

Test code:
import java.util.*;

class M{
  void x(List<String>b,int x)throws Exception{Thread.sleep(500);int i=0,l=b.size(),z=x;String w;for(;i<l;i++){System.out.println(w=b.get(i));if(w.contains("{"))x=i;}System.out.println();w=b.get(x);i=w.contains("*")?1:0;if(i>0)b.remove(x);else b.set(x,z<0?r(w,'{','}'):r(w,'|','|'));if(l>1)x(b,i>0&x>0?x-1:x);}String r(String s,char y,char z){int a,b;return s.substring(0,a=s.indexOf(y))+s.substring(a,b=s.lastIndexOf(z)+1).replaceAll(".","*")+s.substring(b);}

  public static void main(String[] a){
    try{
        List<String> l = new ArrayList(){{
            add("   |   ");
            add("  |#|  ");
            add("  |#|  ");
            add(" {# #} ");
            add("|# # #|");
            add("|# # #|");
            add("|# # #|");
            add("TTTTTTT");
        }};
        new M().c(l, -1);
    }
    catch(Exception e){}
  }
}

Try it here. (On ideone it outputs at once and ignores the sleep..)

Catching the exception might save you a few bytes. Or maybe try{...}finally{return;}?

@Neil Thanks, but I've managed to merge both methods, so now I have a single throws Exception

C, 314 287 281 271 bytes
s,e,t,i;f(char**b){char*p;do{system("CLS");i=0;do{while(!(p=b[i]))i++;if(!*b&&e==1)e=i;while(*p<33)putchar(*p++);if(!t)e=*p=='{'?i:e,s+=2;do{putchar(e==i&&t%2&&*p>16?'*':*p);}while(*p&&*p++>16);}while(*b[i++]-84);if(t++%2)b[e]=0,*b&&e>0?e--:e++;Sleep(500);}while(t<s-1);}

-10 after changing != to - and avoiding char literals when it is possible, as well as isspace (many thanks to H Walters). But ungolfed code remains unchanged.
s,e,t,i;f(char**b){char*p;do{system("CLS");i=0;do{while(!(p=b[i]))i++;if(!*b&&e==1)e=i;while(isspace(*p))putchar(*p++);if(!t)e=*p=='{'?i:e,s+=2;do{putchar(e==i&&t%2&&*p>0xF?'*':*p);}while(*p&&*p++>0xF);}while(*b[i++]!='T');if(t++%2)b[e]=0,*b&&e>0?e--:e++;Sleep(500);}while(t<s-1);}

-6 bytes after applying coma and deletion of {} after two if.
s,e,t,i;f(char**b){char*p;do{system("CLS");i=0;do{while(!(p=b[i]))i++;if(!*b&&e==1)e=i;while(isspace(*p))putchar(*p++);if(!t){s+=2;e=*p=='{'?i:e;}do{putchar(e==i&&t%2&&*p>0xF?'*':*p);}while(*p&&*p++>0xF);}while(*b[i++]!='T');if(t++%2){b[e]=0;e=*b&&e>0?e-1:e+1;}Sleep(500);}while(t<s-1);}

-26 bytes after little optimization, removal unnecessary parentheses, as well as change local variables to global (with auto 0 initialization) and b[0] by *b.
f(char**b){int s=0,e=0,t=0;char*p;do{system("CLS");int i=0;do{if(!t){s+=2;if(strchr(b[i],'}'))e=i;printf(b[i]);}else{while(!(p=b[i]))i++;if(!b[0]&&e==1)e=i;do{putchar((e==i&&t%2&&!isspace(*p))?'*':*p);}while(*p&&*p++!='\n');}}while(b[i++][0]!='T');if(t%2){b[e]=0;e=(b[0]&&e)?e-1:e+1;}t++;Sleep(500);}while(--s>1);}

Test code with ungolfed f:
#include <stdio.h>
#include <windows.h> // to use Sleep and system

s, e, t, i;
f(char**b)
{
    char*p;
    do{
        system("CLS");
        i = 0;
        do
        {
            while (!(p=b[i]))i++; // skip demolished floors
            if (!*b && e==1) e = i;
            while (isspace(*p)) putchar(*p++); // print spaces
            if (!t){ s += 2; e = *p == '{' ? i : e; } // find a bomb and count steps at the first iteration
            do{
                putchar(e == i && t%2 &&*p>0xF ? '*' : *p); // print floor or * for next floor at odd step
            } while (*p && *p++ >0xF); // >0xF is instead of !='\n'
        } while (*b[i++] != 'T'); // until the ground
        if (t++ % 2)
        {
            b[e] = 0; // delete the demolished floor
            e = *b&&e>0 ? e-1 : e+1; // and determine next floor to be demolished
        }
        Sleep(500);
    } while (t<s-1);
}

int main(void)
{
    char * arr[] = { "   |\n",
                     "  |#|\n",
                     "  {#}\n",
                     " |# #|\n",
                     "|# # #|\n",
                     "|# # #|\n",
                     "|# # #|\n",
                     "TTTTTTT" };
    f(arr);
}

You can define s,e,t outside globally like this s,e,t;

@MukulKumar you sure?

Yea sure go ahead and try it...,also include i with others.

I will try some other optimization and use your suggestions as well

@MukulKumar Thanks for advice... -23 bytes

@voland int is not required in declaration and i=0 is also not required

@MukulKumar So more -4 with deleted int , but i=0 is needed for each iteration in the do..while loop. Thanks!

e = *b&&e>0 ? e-1 : e+1; = *b&&e>0?e--:e++; saves 2 more

Haven't looked too carefully, but you can golf this a bit more: Don't use!= (2 chars) in a boolean condition; use - instead; e.g., *b[i++]!='T' => *b[i++]-'T'.  Only, 'T' is 3 characters, but 84 is 2 characters, so make this*b[i++]-84 (there are other char literals here whose ASCII code is <100; apply the same trick).

@HWalters Thanks! That trick can really save some bytes

Haskell, 245 221 bytes
import System.Posix.Unistd
r=reverse
c#l|(i,j)<-span(<'!')l=i++(c<$j)
f[b]=[[b]]
f s|(h@(a:b),d:c)<-break(elem '{')s=(h++'*'#d:c):(h++c):f(init h++'{'#last h:c)|1<2=r<$>(f$r s)
mapM((usleep 500000>>).mapM putStrLn).init.f

Usage example:
mapM((usleep 500000>>).mapM putStrLn).init.f $ ["  |"," {#}"," |#|","|# #|","|# #|","TTTTT"]

How it works:
c#l|(i,j)<-span(<'!')l=i++(c<$j)    -- helper function that takes a char c and
                                    -- a string l and keeps the leading spaces
                                    -- of l and replaces the rest with c

                                    -- f takes a building (list of strings) and
                                    -- makes the sequence of collapsing buildings
                                    -- as a list of list of strings
f[b]=[[b]]                          -- base case. Stop when there's only a single
                                    -- floor left
f s                                 -- if the building has at least two floors
   |(h@(a:b),d:c)<-break(elem '{')s --   if there is at least one floor above the
                                    --   explosion
        =(h++'*'#d:c) :             --     return the current building with the
                                    --     floor to explode replaced by *
        (h++c) :                    --     followed by the current building with
                                    --     the exploded floor removed
        f(init h++'{'#last h:c)     --     followed by a recursive call
                                    --     with the next to explode floor marked
                                    --     with '{'
   |1<2=r<$>(f$r s)                 --   if all top floors have exploded, reverse
                                    --   the left over floors, let them explode
                                    --   and reverse the floors of each building
                                    --   again.

                      f             -- let the building collapse
                 init               -- f comes with an additional building with
                                    -- a single floor of * only -> drop it
mapM(     )                         -- for every building
     (usleep 500000>>)              --   delay 0.5 sec
             mapM putStrLn          --   and print the floors

Note: there's also threadDelay from GHC.Conc instead of usleep from System.Posix.Unistd which is a little bit shorter, but it only works with the GHC compiler, so it wouldn't be a generic Haskell answer.

PHP, 286 282 274 234 229 bytes
<?for($a=$argv,array_shift($a);!strstr($a[+$i++],"{"););while($a[0][0]!=T){$x=&$a[$i-=$i>0];$x=str_pad(substr($x,0,strspn($x," ")),strlen($x),"*");eval($p='echo join("\n",$a),"\n\n";usleep(5e5);');array_splice($a,$i,1);eval($p);}

takes input as list of strings from command line arguments (no newline character!)
save to file, run with
php <filename> '   |' '  |#|' '  {#}' ' |# #|' '|# # #|' '|# # #|' '|# # #|' 'TTTTTTT'
breakdown
<?
for($a=$argv,array_shift($a);   // import input
    !strstr($a[+$i++],"{"););   // find explosives
while($a[0][0]!=T)              // loop while ground not reached:
{
    $x=&$a[$i-=$i>0];               // move up if possible, reference floor
    $x=str_pad(
        substr($x,0,strspn($x," ")  // keep leading spaces
    ),strlen($x),"*");              // replace rest with asterisks
                                    // print and wait
    eval($p='echo join("\n",$a),"\n\n";usleep(5e5);');
    array_splice($a,$i,1);          // remove current floor
    eval($p);                       // print and wait
}

Perl, 153 bytes
for(@a=<>;$a[$i]!~/{/;$i++){}for(;$a[0]!~/^T/;`sleep .5`){if($P=!$P){$a[$i]=~s/(\S.*\S|\S)/"*" x length($1)/e}else{splice(@a,$i,1);if($i){$i--}}print@a}

This uses GNU sleep command to wait for 500 milliseconds.
Ungolfed version
for(@a=<>;$a[$i]!~/{/;$i++){}
for(;$a[0]!~/^T/;`sleep .5`){
    if($P=!$P){
       $a[$i]=~s/(\S.*\S|\S)/"*" x length($1)/e
    } else {
       splice(@a,$i,1);
       if($i){$i--}
    }
    print @a
 }

source: Stack Exchange

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

sort: votes


text:
Help Me Count to Ten!
You will write a simple program that prints exactly 1 2 3 4 5 6 7 8 9 10 to STDOUT, Console, or your language's closest output method. No other visible output should be seen. Any other code executed must be back-end only.
This is answer-chaining, so the catch is that you must include the previous answer's source code in your code ("included code"), comments and all. I have started the first answer down below.
Included code must be an exact replica of the previous code, unchanged and whole. To keep this challenge fair, the included code must not be in a comment. No language may be used twice. You may use languages created after this contest, but it must not be made for this challenge specifically. Please do not use any libraries or frameworks made for this challenge specifically, either.
This is a popularity-contest, so most vote score wins! Please vote on creativeness of code inclusion, which means that if someone who puts included code in a string and throws it away should not score very high. To make sure everyone gets a chance, discourage answers that do not follow the rules. Also, if you give an answer, please do not downvote other answers if they do not deserve it.
Please use the following draft for your answer:
#Answer Number: (your number in the chain)
##Language: (programming language used, hyperlinked to official website of language or hyperlink to download compiler)

**Previous Answer:**
(prev answer language)
(link to prev answer)

code

Any additional info. Try it on web and an explanation are highly encouraged.

Bytes Added: (optional, just for my musings. how many bytes you added to previous person's code)

There's two problems with this challenge. 1) There's really no reason it should be a popularity contest. An objective goal would be better. And 2) There's nothing to make new answers harder. They could just go on and on

Order answers by oldest for it to make sense: http://codegolf.stackexchange.com/questions/101121/help-me-count-to-ten?answertab=oldest#tab-top

Answer Number: 4
Language: CSS
Previous answer
body:before{content:"0 1 2 3 4 5 6 7 8 9 10";}TLðý?0i<?php echo implode(" ",range(1,10)); die;?>
var textToPrint = '';
for (var i = 1; i < 11; i++) {
  textToPrint += i;
  if (i != 10)
    textToPrint += " ";
}
console.log(textToPrint);

https://jsfiddle.net/3tLpp4r2/

Answer Number: 1
Language: Javascript
Previous Answer:
First Answer, NA

var textToPrint = '';
for (var i = 1; i < 11; i++) {
  textToPrint += i;
  if (i != 10)
    textToPrint += " ";
}
console.log(textToPrint);

Bytes Added: 139

Please note that I've added a Bash answer 5 minutes earlier, so that is not really a "First Answer"  :)

Answer Number: 2
Language: PHP
Previous answer: https://codegolf.stackexchange.com/a/101123/38505
<?php echo implode(" ",range(1,10)); die;?>
var textToPrint = '';
for (var i = 1; i < 11; i++) {
  textToPrint += i;
  if (i != 10)
    textToPrint += " ";
}
console.log(textToPrint);

https://eval.in/685567
I'm unsure if I'm doing this right for the tag answer-chaining.
Prints the desired output, then dies.

Answer Number: 3
Language 05AB1E
Previous answer
TLðý?0i<?php echo implode(" ",range(1,10)); die;?>
var textToPrint = '';
for (var i = 1; i < 11; i++) {
  textToPrint += i;
  if (i != 10)
    textToPrint += " ";
}
console.log(textToPrint);

Try it online!

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


text:
Program template for printing *any* string
Write a program with the following properties:

When run as-is, the program produces no output (i.e. 0 bytes of output).
There is a location within the program (of your choice: it could be at the start, end, or somewhere in the middle) with the following property: modifying the program via placing any string there will cause the resulting program to print that string when executed.
This must work regardless of whether the string contains quotes, backslashes, comment marks, delimiters, NUL bytes, etc.; no matter what you place there, the string is still interpreted as a string and printed entirely verbatim. You can, however, fail to handle very very long strings if they would cause the compiler to run out of memory, or the like (to be precise, you should at least be able to handle strings up to 1000 bytes long or three times the length of your program, whichever is longer).

An example of an invalid solution would be
print("");
#      ^ text goes here

in Python, Perl, Ruby, etc.; although it works for many strings, it will not work for a string containing a double quote, or a string containing the substring \n (which would be interpreted as a newline).
Note that this problem is probably impossible in most languages; the challenge is at least partially about finding a language where it works. Your chosen language must be a programming language under this site's definition, e.g. no submitting a solution in Text.
As this is a code-golf, the shortest program template wins. However, do not be discouraged from submitting solutions even if they can't beat the current winner! You can still compete for second, third, etc. place, or simply to find as many answers where it works as possible. You should, however, ensure that your program meets the entire specification before submitting it; approximate solutions would miss the point of the problem.

The relevant Sandbox post is here.

Can you clarify the range of characters we need to support for the inserted string? ASCII? ASCII + unprintable? All of unicode?

All 256 octets. Whether you interpret those as bytes or Unicode is up to you; it won't make much difference when it's printed.

When outputting the string, does it have to be only the string that's output or can there be extra stuff (along the lines of this is the string: '<string_here>')?

The intent of the question (and the way it's currently worded) is that you can't have any additional output. Did you have a solution in mind that can't be adapted to avoid it? (Using extra bytes to avoid stray output is preferable to creating stray output and not complying with the spec.)

My idea was to write a program that doesn't print anything, but adding any string makes it output syntax error: '<string_here>' when run. ;p I guess I'll try to think of something else...

I suspect that doesn't work because syntax errors tend to stop at newlines rather than printing the whole of the rest of the program source. Interesting idea, though.

Newlines are allowed in ruby strings, and I think python strings as well. Just to be pedantic.

That's why I didn't specify newline as a character that would break. Rather, the two characters backslash, n break in the example because they're incorrectly interpreted as a newline.

@jimmy23013 Well, I don't know. Can you prove that it's impossible? It seems impossible, but I'm not 100% sure. (If replacements weren't done in a loop, it would be as simple as //\\/.) If you're sure it's impossible then we might as well delete the comments.

@MartinEnder Let S be the first matched string, A be a character different from the first and last character of S. A len(S) times cannot be changed by the first replacement. Let X be A len(S) times concatenated with S, and Y be the result of the first replacement applied to X. Y cannot contain S, so applying the first replacement to it yield itself too. Prefixing a string won't make a difference either, because of the A len(S) times part. X and Y would be indistinguishable afterwards.

If the string will never have either of these characters ｢｣ that will be as simple as print ｢｣ in Perl 6.

Do trailing newlines count?

You should aim to reproduce the trailing newlines of the strings. You're trying to make a byte-by-byte copy of them.

If this didn't require a code change, it'd be trivial in AWK, just 1 would do it.

Excel, 1 byte
'

Ungolfed version
'        <-- print the following text,
             and exit the current formula

I don't think this can accept newlines.

@ConorO'Brien it does with shift+enter

@MrPaulch This was quite a lot of retro engineering. I am pretty sure this command hides some other unknown functionnalities, like crashing the system.

This also works on OpenOffice Calc. It is used automatically when you set a cell to the format @.

Personally I think this answer is fine.  @Dennis deleted my Mathematica post which uses the same concept.  The front end of excel will store test // " "" /// as a non-verbatim string so by his logic, this should be deleted.  Here is how it's stored
test // " "" ///

Jolf, 6 bytes
a Lq6(

Explanation
a Lq6(
a       print
  L 6   all but the first 6 characters of
   q    the source code
     (  and exit

Zsh, 6 bytes
<<'
'

There is a trailing newline. The string is inserted at the end of the program.
Bash, 20 17 bytes
Thanks to Adam for removing 3 bytes.
exec sed 1d "$0"

*nix shell script, 21 14 bytes
Thanks to Adam for removing 7 bytes.
#!/bin/sed 1d

@Copper There is a trailing newline. The string is inserted after that.

Ah, I see. Thanks for correcting me!

The 6/9-byte solutions look like they're exploiting a bug in the interpreter to me (not that that's disallowed, of course). (AFAICT with some experimentation, they're looking for a newline on a line by itself, but the lines are defined by splitting on newlines, so a newline on a line by itself can never happen.) The zsh solution seems correct; however, the 9-byte bash solution is wrong (it adds a trailing newline if the file doesn't have one).

@ais523 Seemed to be a bug to me too. And I didn't expect them to be allowed by the interpreters. Removed the Bash solution.

for bash you can use sed 1d instead of tail -n+2

Perl 5, 30 21 19 bytes

print<DATA>__END__

Try it online!
Trailing newline. This makes use of a Perl feature which allows arbitrary data to be appended to the source file, which can then be read via the DATA filehandle. When we give a filehandle as an argument to print, it's given a list context, which causes the filehandle to return a list of all the lines in the file, newlines included (likewise, a newline on the final line will be omitted). Then print implicitly concatenates them all, undoing the splitting into lines and giving us the exact original string regardless of where the newlines were.
Thanks to @Dada, who realised there was no need to handle newlines manually, and @ninjalj and @b_jonas, who each spotted a character which could be golfed off.

I don't think you need undef$/. As an argument of print, <DATA> is called in list context, so it should read every line there is.

You're right. It reads the input a line at a time, keeping the line separators, then implicitly concatenates them all when printing, so there's no need to slurp in the first place. That's an 8-byte saving, as well; I'll go fix the post.

You can use __END__ instead of __DATA__.

What @ninjalj says, plus you can omit the newline after the greater than sign (but you do need the newline at the end of the program).

brainfuck (Unreadable Brainfuck), 9 bytes
,+[-.,+]!

Append the input to the end. There isn't a trailing newline, this time.
Looking for languages which would accept input appended to the end of the program, brainfuck seemed like a distinct possibility; many brainfuck interpreters written in esolangs take both the program and the program's input from standard input, and thus need some way to tell between them. There's a convention that's used in this case that a ! character differentiates between the program and the input, a trick that's often used to write short brainfuck programs like ,[.,]!Hello, world!; this basically creates a different dialect of brainfuck in which ! has a different meaning from normal.
In theory, therefore, we could just find one of these interpreters and give it a cat program in order to fulfil the spec. There's a major subtlety, though; brainfuck typically uses 256 values for each cell, there are 256 octets, and one needs to be used for EOF. So if we want to be able to echo all 256 octets literally, we can't detect EOF at all and will need to end the program some other way. In other words, we need to find an implementation that either gives the 256 octets and EOF 257 different values, or that crashes on EOF.
Enter Unreadable. There's a brainfuck interpreter in Unreadable that predates this challenge, and which accepts input after an !; additionally, unlike most brainfuck interpreters, it uses bignum cells and -1 for EOF, allowing EOF to be distinguished from the other 256 possible octets. Thus, by use of Unreadable Brainfuck as the specific interpreter for the program, we can solve the challenge in just 9 bytes, via writing a brainfuck cat program that halts on EOF=-1.
Is it possible to do better? Well, we could try the following 7-byte program, which attempts to output EOF at the end of the string before it breaks out of the loop:
+[,.+]!

The behaviour of this program depends on the behaviour of the Unreadable interpreter on error conditions (thus, it depends not only on the implementation of brainfuck, but on the implementation used to run the implementation of brainfuck). Unfortunately, the Unreadable interpreter I use outputs errors on standard output, meaning that this saving doesn't work. If anyone knows of an Unreadable interpreter that exits on an attempt to output EOF, or silently skips the attempt, let me know; that would be a seven-byte solution right there.

,[.,]! works here and is 6 bytes (just tick the box marked !). Also it terminates.

@FinW: I can't figure out how to enter a NUL byte into that website, but that code would definitely terminate early if it saw one.

it worked fine without a NUL byte when I did it.

You literally have a , (read standard input to the current tape element) followed by a ] (exit loop if current tape element is 0). Thus, reading an input byte with value 0 (i.e. NUL) would break the loop.

But if the interpreter reads no input, (e.g. the end of the string after the !) it automatically sets the current tape element to 0, therefore ending the loop.

Yes, and if it reads a NUL that isn't the end of the input, it also sets the current tape element to 0, therefore ending the loop. You not only have to handle exiting at the end of the file; you also have to handle not exiting not at the end of the file.

Dyalog APL, 11 bytes
The following is the body of the function f:
2↓⎕CR'f'⋄→

There is a trailing newline, after which anything may be inserted.
2↓ drop the first two lines (header and this line) of
⎕CR'f' the Character Representation of f
⋄ then
→ quit

Ruby, 20 bytes

print *DATA
__END__

Input goes at the end (after the trailing newline). The DATA idiom is one of many that Ruby stole from Perl.
Try it on eval.in: https://eval.in/684370

It not only stole it, it even is shorter...

JavaScript + HTML5 DOM, 163 Bytes

You may insert anything you like directly before the closing body tag. This works by fetching the page source and stripping the opening code and the closing tags.
The real kicker was figuring out how to escape an infinite loop. Putting while(true){} in the page blocks all callbacks forever, freezing the execution, and JavaScript has no way of pausing the main thread. However, code that no longer exists never runs, so the document body commits seppuku in the very last command, deleting itself while it waits for its clone to load.
Yeah, it's long and roundabout, but the mere fact that it's possible in JS is kind of amazing.

Chrome's got all annoyed at parser-blocking scripts recently, and complains about them a bunch. I like the idea of blocking the parser intentionally to prevent any script in it from ruining your printing attempt.

PHP, 46 bytes
(including the trailing linebreak)
<?=join([""]+file(__FILE__));halt_compiler();
STRING HERE

Yes: even the file function is binary safe.
[""]+ replaces the 0-index (first line of the file) with an empty string

gs2, 4 bytes
╥¶=☼

Uses CP437 encoding. The string goes at the end. ╥ gets the source code, ¶ pushes 4, = drops that many leading characters, and ☼ exits.
Try it online!

PHP 94 bytes
<?$f=fopen(__FILE__,'rb');fseek($f,93);while(false!==($c=fgetc($f)))echo$c;__halt_compiler();

Place your string after the final semicolon.
Yay for obscure features I guess? __halt_compiler() does exactly what you'd expect from the name. The prior code just opens the file and writes any bytes after that last semicolon to stdout. NUL, BEL etc come out fine. Unicode literals (♪) get screwed up on Windows but I think that's just Windows cmd failing at unicode.

I count 93 bytes, not 94.
false!==$c=... needs no parentheses.
rb needs no quotes.
You can save one byte with for($f=fopen(...),fseek($f,88);false!==(...);)echo$c;
another two bytes shorter:
<?for($f=fopen(__FILE__,rb);false!==$s=fgets($f,86);)echo$i++?$s:"";__halt_compiler();

and another two bytes if you omit the second parameter for fgets and add a trailing linebreak to the template.

Perl 6, 23 bytes
print $=finish
=finish

The string is placed starting on the newline after =finish.

PHP, 48 60 bytes
<?=substr(file_get_contents(__FILE__),60);__halt_compiler();STRING HERE

Just became aware that closing PHP does not prevent the string from containing <?.

You've got a misplaced closing bracket. Much neater file dump than my attempt though, I thought substr() would choke on null bytes - guess not.

Try this: <?die(substr(file_get_contents(__FILE__),48))?>STRING HERE. Should work. I've tried with <?die('a')?> and it worked.

@IsmaelMiguel will not work. die does not print it´s parameter, but send it as exit code. That would have to ´be die(print ...).

@ToXik-yogHurt most string functions are binary safe. even file. Actually I currently can´t think of any that´s not.

@Titus Try die('text');

I know I'm repeating myself, but die() outputs text. It was used a lot like mysql*_connect(...) or die('Error while connection to DB');

@IsmaelMiguel It may, but it won´t stop the compiler from parsing.

Oh, you changed your answer. Sorry.

Bash, 17 bytes
tail -n+3 $0
exit
<string here>

Developed independently of jimmy23013's answer.

Don't you mean $0? Apart from that, I think it works (I've confirmed that it doesn't parse anything after exit).

@ais523 Fixed! Thanks.

Binary Lambda Calculus, 1 byte
 [text goes here]

That’s a single space (0x20) before the text.
Try it online!
How it works
0x20 = 001000002 is parsed as
00    λx.
01        x
0000  (ignored, can be anything)

(So in fact, any of the characters !"#$%&\'()*+,-./ will work equally well.)
Since this is a complete expression, the remainder of the program is interpreted as input data, and under the binary lambda calculus I/O conventions, the identity function λx. x copies the input directly to the output.

Out of interest, why don't the trailing zero bits between the identity function and insertion get echoed?

@ais523 The interpreter reads a byte at a time, and once λx. x has been parsed, the padding has already been consumed.

RProgN, 19 Bytes
Q 19 Q L sub exit

Note the trailing space.
Insert any text after that chunk and it will be printed.
Based off of Lynn's gs2 answer.
Try it Online!

Excel VBA, 6 Bytes
This is mainly to answer the question of how to print the text as held in Adam's Answer to the Immediates Window in the VBA environment
Basic Setup:
In cell A1 in the activesheet the use the formula below to hold the string to be printed. For the sake of byte counting this shall add 1 Byte
'[Your Text Here]

eg:
'Hello
World

Immediates Window Function, 5 + 1 = 6 Bytes
?[A1]

+1 Byte for a ' in cell A1

Vim (in ex mode), 28 bytes
#!/bin/ex -c ':1d' -c ':wq'
[string]

28 bytes is including the last newline.

Vim, 738 bytes
:imap <esc> <c-v><esc>
:imap <c-a> <c-v><c-a>
:imap <c-b> <c-v><c-b>
:imap <c-c> <c-v><c-c>
:imap <c-d> <c-v><c-d>
:imap <c-e> <c-v><c-e>
:imap <c-f> <c-v><c-f>
:imap <c-g> <c-v><c-g>
:imap <c-h> <c-v><c-h>
:imap <c-i> <c-v><c-i>
:imap <c-j> <c-v><c-j>
:imap <c-k> <c-v><c-k>
:imap <c-l> <c-v><c-l>
:imap <c-m> <c-v><c-m>
:imap <c-n> <c-v><c-n>
:imap <c-o> <c-v><c-o>
:imap <c-p> <c-v><c-p>
:imap <c-q> <c-v><c-q>
:imap <c-r> <c-v><c-r>
:imap <c-s> <c-v><c-s>
:imap <c-t> <c-v><c-t>
:imap <c-u> <c-v><c-u>
:imap <c-v> <c-v><c-v>
:imap <c-w> <c-v><c-w>
:imap <c-x> <c-v><c-x>
:imap <c-y> <c-v><c-y>
:imap <c-z> <c-v><c-z>
:imap <c-@> <c-v><c-@>
:imap <c-\> <c-v><c-\>
:imap <c-]> <c-v><c-]>
:imap <c-^> <c-v><c-^>
:imap <c-?> <c-v><c-?>
i

Rebinds all control characters in insert mode to <c-v>, followed by that control character, which will enter them literally.
^_ (unit seperator) doesn't seem to need rebinding, as it gets outputted literally by default.
The variable text comes at the end, of course.

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


text:
Help me I'm lost in the ocean!
Introduction
Today I went fishing alone with my canoe, unfortunately I fell asleep and the stream brought me away, I lost my oars, now it's night and I am lost in the ocean! I can't see the coast so I must be far away!
I have my cell phone but is malfunctional because it got wet by the salty water, I can't talk or hear anything because the mic and phone speaker are broken, but I can send SMS to my friend who is on the coast's beach!
My friend has a very powerful torch and he raised it on top of bamboo's canes to show me the right direction, but I can’t row because I have no oars, so I must tell him how far I am so he can send someone to catch me!
My friend told me that he is keeping the torch at 11.50 meters on the sea level, and I can see the light right over the horizon. Now I only remember from the school that the Earth radius should be 6371 Km at the sea level, and I’m sittin in my canoe so you can assume that my eyes are at sea level too.
Task
Since the currents are moving me moment by moment, my friend is raising the torch from time to time (now it’s at 12.30 meters), please write a full program or function that will help me to calculate the distance from my friend’s position!
Here is a diagram (not to scale):

The orange point labelled M is me, the red point labelled T is the torch. The green line is the linear distance between M and T
Input
Take from standard input the torch height h in meters at the sea level, which I see right on top of the horizon, in the form of a floating point number with two decimals precision (with the accuracy of 1 centimeter or 0.01 meters), in the range from 0 to 100 included.
Output
You should return the euclidean length of the green line with the accuracy of 1 cm. For example if you output in meters, should be with two decimals (at least). The output can be either meters or kilometers, but respecting the accuracy.
Test cases:
All values in meters.
11.5 > 12105.08
13.8 > 13260.45

Rules
Shortest code wins.

Does the result have to be mathematically correct or is it ok if the first 2 decimals are ok? I mean that hxh is small in comparison to 2xRxh and can be neglected for small distances. (R is the radius of Earth and h is the height of the torch).

@Osable first 2 decimals are ok if you output in meters

What is the range of input?

@Osable you can consider the input to be from 0 to 100 (even too much than necessary/possible in this case).

Ok maybe h² is not that negligible within a centimeter if it goes up to 100 meters.

You should have tried the Coast Guard Stack Exchange - code golferse can't help you get out of the ocean, man!

How are you measuring the "distance from my friend's position"? Euclidean distance to his feet? Great circle distance to his feet, assuming a spherical Earth? Euclidean distance to the torch? 2. What is the range of possible input? 3. What accuracy is required in the output?

@PeterTaylor please see this Meta post

I've seen that meta post. I'm still waiting for an answer to my questions.

@PeterTaylor I edited the question adding explicitly all the specifications.

05AB1E, 13 12 10 bytes
Saved 2 bytes thanks to Emigna.
Since there is no trigonometric functions to be called using OP's assumption that the earth is locally a plane, it becomes possible to make an 05AB1E solution.
•1#oC•+¹*t

           For understanding purposes input is referred to as 'h'
•1#oC•     Push 12742000 [ = 2*R, where R is the radius of earth]
      +    Compute 2*R+h
       ¹*  Multiply by h. Result is (2*R*+h)*h
         t Take the square root of it and implicitly display it

Try it online!

12742000 can be written as •1#oC•

For reference, it would have been 9 bytes: •1#oC•+*t in 2sable

Does a string sourrounded with • depict a... base 214 number? 05AB1E suffers a lack of documentation on such special functions sometimes. Nice 2sable answer also. I found out about it a few days ago but I didn't think about using it for this question.

Correct. It is a base 10 number encoded in base 214.

The result can be achieved also by trigonometry but is probably longer.

I meant that there is no trigonometric function in the current version of 05AB1E. However I found a Taylor series of acos(1/(1+x)) when x is close to 0, which is the case since x=h/R. It turns out that it's close to sqrt(2*h*R) as I mentionned earlier on another answer. This formula is then doable, but its accuracy is larger than one centimeter for the given input range.

Python, 34 26 bytes:
(-8 bytes thanks to Osable!)
lambda i:(i*(i+12742))**.5

An anonymous lambda function. Takes input in kilometers and outputs in kilometers. Invoke as print(<Function Name>(<Input>)).

lambda i:(i*(i+12742))**.5 would be even shorter.

@Osable Nice! I was just about to do that. :)

If there is mathematical tolerance, given the discrepancy between i and 12742, the expression can be shortened so: (i*12742)**.5

Results are wrong. 11.5m -> ~380km instead of ~12km

@GB The program reads its input as kilometers.

Oops, you are right, sorry.

PHP, 34 bytes
<?=sqrt((12742e3+$h=$argv[1])*$h);

breakdown
   r^2+x^2=(r+h)^2      # Pythagoras base
   r^2+x^2=r^2+2rh+h^2  # right term distributed
       x^2=    2rh+h^2  # -r^2
       x =sqrt(2rh+h^2) # sqrt

so far, this is identical to the old Mathematica answer
sqrt(2*6371e3*$h+$h*$h) # to PHP
sqrt(14742e3*$h+$h+$h)  # constants combined
sqrt((14742e3+$h)*$h)   # conjugation to save a byte
((14742e3+$h)*$h)**.5   # same size

now all that´s left to do is to add input =$argv[1] and output <?= - done

dc, 16 11 bytes:
?d12742+*vp

Prompts for input through command line in kilometers and then outputs distance in kilometers.
Explanation
?           # Prompt for input
 d          # Duplicate the top-of-stack value
  12742     # Push 12,742 onto the stack
       +    # Pop the top 2 values of the stack and push their sum
        *   # Pop top 2 values of the stack and push their product
         v  # Pop the remaining value and push the square root
          p # Output the result to STDOUT

This takes advantage of the following:
((6371+h)**2-6371**2)**.5
=> ((6371**2+12742h+h**2)-6371**2)**0.5
=> (h**2+12742h)**0.5
=> (h*(h+12742))**0.5

jq, 18 characters
(12742e3+.)*.|sqrt

Yet another copy of the same formula.
Sample run:
bash-4.3$ jq '(12742e3+.)*.|sqrt' <<< 11.5
12105.087040166212

On-line test

Haskell, 22 bytes
d h=sqrt$h*(h+12742e3)

Usage:
Prelude> d 11.5
12105.087040166212

Pointfree: (23 bytes)
sqrt.((*)=<<(+12742e3))

R, 29 bytes
h=scan();sqrt(h^2+2*h*6371e3)

Takes input from stdin

A couple of bytes shorter is (h=scan())*(1+12742e3/h)^.5.

Mathematica, 16 bytes
Either of these works for both input and output in kilometres:
(12742#+#*#)^.5&

((12742+#)#)^.5&

This is a simple application of Pythagoras to the problem:
   x*x + R*R = (R+h)*(R+h)
=> x*x = (R+h)*(R+h) - R*R
       = R*R + 2*R*h + h*h - R*R
       = 2*R*h + h*h
=>   x = √(2*R*h + h*h)

Jelly, 9 bytes in Jelly's code page
I decided to have a go at writing the program in a golfing language. I actually found a more efficient algorithm than the one other people are using (at least over short distances like the one in the question), but it requires literal floating-point numbers which Jelly doesn't seem to be able to compress, so Pythagoras it is.
+“Ȯịż’×µ½

Explanation:
 “Ȯịż’     12742000, compressed base-250
+          add to argument
      ×    multiply with original argument
       µ   separator to avoid what would otherwise be a parsing ambiguity
        ½  square root everything seen so far
           implicit output at EOF

The need for the µ separator irks me, but I think it's unavoidable; Jelly has already saved a byte over 05AB1E via being able to guess what arguments many of the commands need, but in this case it can't correctly guess to the end, so I needed to give it a hint.
Jelly, 7 bytes in Jelly's code page
×“Ȯịż’½

As I explained in my other answer, the series approximation to the Pythagoras approximation actually produces better results over the lengths included in the question (at least, they're closer to the example outputs), and also has a shorter formula. While I was writing it, I realised that instead of calculating the square root of 12742000 in advance, I could multiply the number by 12742000 first, and then square root both at the same time. This is basically equivalent to the other formula without the addition, and as such, it can be produced from the previous program via removing the addition from it. This saves two bytes, as it now parses unambiguously and so we don't need a µ any more.

I decided not to use this optimization because it doesn't yield the same values if you look at the centimeters (cf. requested output) given the range of h.
It would also save 2 bytes in 05AB1E.

With the optimization, I get outputs of 12105.081577585506 and 13260.452480967608; those are very close to the test case's output, and round to them. Without, I get 12105.087040166212 and 13260.459661716106, which are further away (and the latter is incorrect in the centimeters, rounding to 13260.46). As mentioned in the other answer, the optimization happens to be closer to the correct value than the optimized code because it contains two errors that largely cancel each other out, rather than just one which has nothing to cancel it.

Since you just voted to "Leave open" in the review queue, I assume that you believe you know the answers to the questions for which I requested clarification in the comments. Please therefore edit the question so that it is unambiguous.

The question is unambiguous: the author needs to know the distance to his friend to help navigate. He can determine the position of the torch to an accuracy of 0.1 metres (we can determine this from the story that's told). This is inevitably going to give approximately 1 metre of uncertainty from the output at the current distance (note: the author is drifting around, thus is unlikely to move very far very quickly…), and therefore anything that's approximately that accurate is likely to be acceptable. Part of the problem is determining how accurate you'd need to be in this situation!

Requested output shows 2 decimals in meters. So accuracy is expected to be 1 centimeter. In the comments to the question, OP said that h could go up to 100. With h=100 there is a discrepancy of 14 centimeters from the original algorithm.

Ruby, 23
23 bytes, in Km
->h{(h*h+h*12742)**0.5}

25 bytes, in m
->h{(h*h+h*12742e3)**0.5}

Tcl, 49 bytes:
set A [get stdin];puts [expr ($A*($A+12742))**.5]

Well, I am brand new to Tcl, so any tips for golfing this down is highly appreciated. Like my other answers, prompts for command line input in kilometers and outputs in kilometers. Essentially a Tcl adaptation of my existing dc and python answers.

there is an s missing on gets

Minkolang v0.15, 22 bytes
ndd*$r'12742000'*+1MN.

Try it online!
n                               gets input in the form of a number
 dd                             duplicates it twice
   *                            multiplies 2 of the duplicates with each other
                                STACK: [h, h*h]
    $r                          swap top two stack values
                                STACK: [h*h, h]
      '12742000'*               push this number and multiply the original input by it
                                STACK: [h*h, h*12742000]
                 +1M            adds the two values and takes their square root
                                STACK: [sqrt(h*h+h*12742000)]
                    N.          output as a number and end program

x86_64+SSE machine code, 16 bytes
The bytes of the program are on the left (in hexadecimal), there's a disassembly on the right to make it a bit easier to read. This is a function that follows the normal x86_64 convention for functions taking and returning a single-precision floating point number (it takes the argument in %xmm0 and returns its answer in the same register, and uses %xmm1 and %eax as temporaries; these are the same calling conventions a C program will use, and as such you can call the function directly from a C program, which is how I tested it).
b8 80 19 5f 45          mov    $0x455f1980,%eax
66 0f 6e c8             movd   %eax,%xmm1
0f 51 c0                sqrtps %xmm0,%xmm0
0f 59 c1                mulps  %xmm1,%xmm0
c3                      retq

Even with a disassembly, though, this still needs an explanation. First, it's worth discussing the formula. Most people are ignoring the curvature of the earth and using Pythagoras' formula to measure the distance. I'm doing it too, but I'm using a series expansion approximation; I'm only taking the term relating to the first power of the input, and ignoring the third, fifth, seventh, etc. powers, which all have only a very small influence at this short distance. (Besides, the Pythagoras approximation gives a low value, whereas the later terms in the series expansion serve to reduce the value; as such, by ignoring a minor factor that would serve to push the approximation in the wrong direction, I actually happen to get a more accurate result by using a less accurate formula.) The formula turns out to be √12742000×√h; as a single-precision floating-point number, √12742000 is 0x455f1980.
The next thing that might confuse people is why I'm using vector instructions for the square root and the multiply; %xmm0 and %xmm1 can hold four single-precision floating point numbers each, and I'm operating on all four. The reasoning here is really simple: their encoding is one byte shorter than that of the corresponding scalar instructions. So I can make the FPU do a bunch of extra work square-rooting and multiplying zeroes in order to save myself two bytes, in a method that's very reminsicent of the typical golfing language algorithm. (I called x86 assembler the golfing language of assemblers in chat a while back, and I still haven't changed my mind on that.)
From there, the algorithm's very simple: load %xmm1 with √12742000 via %eax (which is shorter in terms of bytes than loading it from memory would be), square-root the argument (and three zeroes), multiply corresponding elements of %xmm1 and %xmm0 (we only care about the first element), then return.

JavaScript (ES6), 31 25 bytes
Displays the value in metres

//the actual code
f=h=>(h*h+12742e3*h)**0.5

console.log(f(11.5));
console.log(f(13.8));


text:
Find the rows which make each column have one True (was: Knuth's Algorithm X)
Task
Given a Boolean matrix, find one (or optionally more) subset(s) of rows which have exactly one True in each column. You may use any algorithm, but must support very large matrices, like the last example.
One possible algorithm (Knuth's Algorithm X)
While there is no requirement to use this algorithm, it may be your best option.

If the matrix A has no columns, the current partial solution is a valid solution; terminate successfully.
Otherwise choose a column c.
Choose* a row r such that Ar, c = 1.
Include row r in the partial solution.
For each column j such that Ar, j = 1,
 for each row i such that Ai, j = 1,
  delete row i from matrix A.
 delete column j from matrix A.
Repeat this algorithm recursively on the reduced matrix A.

* Step 3 is non-deterministic, and needs to be backtracked to in the case of a failure to find a row in a later invocation of step 3.
Input
Any desired representation of the minimum 2×2 matrix A, e.g. as a numeric or Boolean array
1 0 0 1 0 0 1
1 0 0 1 0 0 0
0 0 0 1 1 0 1
0 0 1 0 1 1 0
0 1 1 0 0 1 1
0 1 0 0 0 0 1

or as Universe + Set collection
U = {1, 2, 3, 4, 5, 6, 7}
S = {
    A = [1, 4, 7],
    B = [1, 4],
    C = [4, 5, 7],
    D = [3, 5, 6],
    E = [2, 3, 6, 7],
    F = [2, 7]
    }

or as 0 or 1 indexed sets;
{{1, 4, 7}, {1, 4}, {4, 5, 7}, {3, 5, 6}, {2, 3, 6, 7}, {2, 7}}.
Output
Any desired representation of one (or optionally more/all) of the solutions, e.g. as numeric or Boolean array of the selected rows
1 0 0 1 0 0 0
0 0 1 0 1 1 0
0 1 0 0 0 0 1

or as Boolean list indicating selected rows {0, 1, 0, 1, 0, 1} or as numeric (0 or 1 indexed) list of selected rows {2, 4, 6} or as list of set names ['B', 'D', 'F'].
More examples
In:
1 0 1
0 1 1
0 1 0
1 1 1

Out: 1 3 or 4 or 1 0 1 0 or 0 0 0 1 or [[1,3],[4] etc.

In:
1 0 1 0 1
0 1 0 1 0
1 1 0 0 1
0 1 0 1 1

Out: 1 1 0 0 etc.

In:
0 1 0 1 1 0 1
1 1 0 0 1 1 1
0 1 0 0 1 0 0
1 1 1 0 0 0 1
0 0 0 1 1 1 0

Out: 0 0 0 1 1 etc.

In:
0 1 1
1 1 0

Out: Nothing or error or faulty solution, i.e. you do not have to handle inputs with no solution.

In: http://pastebin.com/raw/3GAup0fr
Out: 0 10 18 28 32 38 48 61 62 63 68 86 90 97 103 114 120 136 148 157 162 174 177 185 186 194 209 210 218 221 228 243 252 255 263 270 271 272 273 280 291 294 295 309 310 320 323 327 339 345 350 353 355 367 372 373 375 377 382 385 386 389 397 411 417 418 431 433 441 451 457 458 459 466 473 479 488 491 498 514 517

In: https://gist.github.com/angs/e24ac11a7d7c63d267a2279d416bc694
Out: 553 2162 2710 5460 7027 9534 10901 12281 12855 13590 14489 16883 19026 19592 19834 22578 25565 27230 28356 29148 29708 30818 31044 34016 34604 36806 36918 39178 43329 43562 45246 46307 47128 47906 48792 50615 51709 53911 55523 57423 59915 61293 62087 62956 64322 65094 65419 68076 70212 70845 71384 74615 76508 78688 79469 80067 81954 82255 84412 85227

You need to point out that step 3 is nondeterministic, and needs to be backtracked do in the case of a failure to find a row in a later invocation of step 3. Without that, the algorithm won't reliably work.

If we could go through every single one of the algorithms from Knuth's books, one by one, that would make an awesome collection!

@LuisMendo Done.

Isn't your first test case wrong? Shouldn't it be {2, 4, 6} if returned as row indices?

@Billywob Yes, typo. Thanks.

Can we assume that there are at least two rows of the matrix?

@Billywob Yes, added.

"Only solutions using this algorithm are eligible to win" but what exactly counts as "this algorithm"? How literally is it necessary to take "delete row" and "delete column"? And does the algorithm have to use the heuristic which is an key part of Knuth's presentation of the algorithm but which isn't mentioned at all in your description?

It might be better to make a question which only asks for exact set cover but which has some hefty test cases which can't be handled by naïve brute force but can be handled by Knuth's algorithm.

Relevant to Peter's comments.

@PeterTaylor Very good point. If you edit in one or more such test cases, I will change the rules.

An actual Sudoku is too big to fit in the post: http://pastebin.com/raw/3GAup0fr

@PeterTaylor Added. Thank you.

All algorithms are now equally allowed.

"must support very large matrices" is quite ambiguous, especially since Knuth's algorithm can't handle the large test case without the column selection heuristic. Maybe have this question as pure [tag:code-golf] and have another as [tag:fastest-code]?

Here's an even larger problem in case anyone's interested – pentomino cover presented as an exact cover problem.

@Angs Thanks. Added. Run less than 5 seconds on my old slow laptop.

Haskell, 100 93 92 87 83 80 bytes
Knuth's algorithm:

g&c=filter(g.any(`elem`c))
(u:v)%a=[c:s|c<-id&u$a,s<-(not&c)v%(not&c$a)]
x%_=[x]

Calculates all covers nondeterministically depth-first in the list monad. Use head to calculate only one since Haskell is lazy. Usage:
*Main> [[1],[2],[3],[4],[5],[6],[7]]%[[1, 4, 7], [1, 4], [4, 5, 7], [3, 5, 6], [2, 3, 6, 7], [2, 7]]
[[[1,4],[2,7],[3,5,6]]]

For more speed by using Knuth's suggestion of selecting column with least ones, use this: (115 bytes, flat list for universe). Finds first solution to the large pentomino cover problem in under a minute when compiled.
import Data.List
[]%_=[[]]
w%a=[c:s|c<-a,c\\(head.sortOn length.group.sort$w:a>>=id)/=c,s<-(w\\c)%[b|b<-a,c\\b==c]]

Thanks to @Zgarb for saving 1+3 bytes!
Thanks to @ChristianSievers for his sage advice and saving 5 bytes and some.
Ungolfed (with flat list universe):
knuthX [] _ = [[]]
knuthX (u:niverse) availableRows = --u chosen deterministically
  [ chosen:solution
  | let rows = filter (elem u) availableRows
  , chosen <- rows  --row chosen nondeterministically in list monad
  , solution <- knuthX
                  (filter (not.(`elem`chosen)) niverse)
                  (filter (not.any(`elem`chosen)) availableRows)
  ]

Might be worth adding some explanation on how it works for people unfamiliar with Haskell. You're using the List monad in order to handle the nondeterminism, I think?

You can save 3 bytes by changing the filter into a list comprehension and defining an auxiliary function h!x=h(\elem`(x>>=id))`.

I think it is more Algorithm X (and more efficient) if you really do step 2: take (and remove) the first element of the universe; and then select rows that contain it. That also simplifies the base case to the form in the description.

Alg. X can select a column and realize there is no corresponding row  containing it, so it can abort  this branch of the backtracking tree. Your alg. will continue trying combinations of rows in this case. I don't think it amounts to the same work. - I think null rows can be combined with the general case. You probably shouldn't pattern match anyway, but get the candidate lines by filtering. And I think you can do without accumulator.

Great to see it didn't get longer! You can also do (!)=elem, and swap the two % lines and replace []%_ by _%_. Can't f be used in the computation of the partly collapsed universe?

@ChristianSievers I'm running into the monomorphism restriction with (!)=elem, hence the a's. And yes, f can definitely be used there. Thanks! The different combinations of filter … elem beg to be unified…

I claim this code does what is demanded, but I tried the big example from the comments and it is slooowww... The running time changes from not finished yet to almost immediate when we don't use the first element of the universe, but the rarest. For universe univ in this strange list of singletons form and rows a my ungolfed proof-of-concept uses [snd.head.sort.map(\l->(length l,head l)).group.sort.concat$univ++a].

Add some $s to get rid of parentheses: filter$g.any(\elem`c), id&u$aandnot&u$a. Also, the last line can be x%_=[x]`.

You find the column with the least positive number of ones, but miss the ones with no one. That's why my version appended the universe. - We can use nub to get from a list with identical entries to a singleton list with that entry and drop the outer [].

@ChristianSievers the outer [] is because I use <- instead of let (singleton universe), can't take it out. Otherwise good points. I'm not sure if the fast alternative should be optimized for golfing or speed as it's fast enough as it is (without u++).

Oh, those were not the same [] as in my version, the take 1 already produced a singleton. I somehow read it as head that also handles the case of empty lists, which could only be replaced by nub after the u++ change. I don't see why it works in this form (oh maybe laziness: when generating c, u is not needed if a is empty), but I agree it's fast enough. I was afraid the changes for the fast version would more than double the size, nice job to keep it small!

We can go back to flat universe, use the version that should generally be faster but makes no difference in the big example, and save some bytes by using w%a=[c:s|(u:_)<-[sortOn length.group.sort$w++concat a],c<-id&u$a,s<-(w\\c)%(not&c$a)]. Note that now u is a list that may contain the chosen column repeatedly, but that doesn't matter for correctness.

And it should be possible to inline u (then we need head again, or !!0)

@ChristianSievers clever! Found the way to take only +2 bytes for "optimal" speed, so it'll stay. I managed to save a few bytes in the fast version by removing (&) altogether.

Wow, that looks like it might be inefficient, but the compiler gets it! There is no need for the inner d list, just do c<-a,c\\(...)/=c,s<-...

@ChristianSievers hooray, less than +50% length from slow to fast! There was a slight regression in speed when u was inlined since it's calculated once per element in a , but we're aiming for golfed speed, not optimal speed. c\\b==c probably isn't that bad since it can stop lazily. Not inlining u and using Data.Map.Strict for finding the rarest element would be on a totally different level.

Python, 482 bytes
r=lambda X,Y:u({j:set(filter(lambda i:j in Y[i],Y))for j in X},Y)
def u(X,Y,S=[]):
 if X:
  for r in list(X[min(X,key=lambda c:len(X[c]))]):
   S.append(r);C=v(X,Y,r)
   for s in u(X,Y,S):yield s
   w(X,Y,r,C);S.pop()
 else:yield list(S)
def v(X,Y,r):
 C=[]
 for j in Y[r]:
  for i in X[j]:
   for k in Y[i]:
    if k!=j:X[k].remove(i)
  C.append(X.pop(j))
 return C
def w(X,Y,r,C):
 for j in reversed(Y[r]):
  X[j]=C.pop()
  for i in X[j]:
   for k in Y[i]:
    if k!=j:X[k].add(i)

r is the function to call with the Universe + Set collection.
Golfed a little from this page
Usage:
X = {1, 2, 3, 4, 5, 6, 7}
Y = {
    'A': [1, 4, 7],
    'B': [1, 4],
    'C': [4, 5, 7],
    'D': [3, 5, 6],
    'E': [2, 3, 6, 7],
    'F': [2, 7]}

for a in r(X,Y): print a

You should be able to remove the cast to list in the  first for loop and the yield, and change reversed(...) to ...[::-1]

Every time you use S.append(x) you can do S+=x, (with the trailing comma): for example C+=X.pop(j),.

R, 124 117 115 113 bytes
Very inefficient, but not that long in code. Tries all possible subsets of rows and checks if all the rows sum to 1.
f=function(x,n=nrow(x))for(i in 1:n)for(j in 1:ncol(z<-combn(n,i)))if(all(colSums(x[k<-z[,j],,drop=F])==1))cat(k)

Takes a matrix as input. Returns the rownumbers of the first solution encountered. Returns nothing if there are no solutions, but might take a long while terminating if the input is big.
Ungolfed:
f=function(x, n=nrow(x)){

    for(i in 1:n){
        z=combn(n,i)

        for(j in 1:ncol(z)){
            k=x[z[,j],,drop=F]

            if(all(colSums(k)==1)){
                print(z[,j])
            }
        }
    }
}

7 bytes saved thanks to Billywob
Another 2 bytes saved thanks to Billywob

Thanks, I didn't know you could assign variables inline like that. Also, if you drop the drop=F statement, it doesn't work for subsets of only one row. I never worked with scan before, and just assumed it would work like that, my bad. Changing it to a named function.

Also changed output to returning the indices of the solution, saving 2 more bytes.

In general you don't need to use named functions (unless they are nested). Also, if you assign the row counter as an implicit argument to the function, you can again skip the curly brackets: function(x,n=nrow(x))for(i in 1:n)for(j in 1:ncol(z<-combn(n,i)))if(all(colSums(x[k<-z[,j],,drop=F])==1))cat(k)

Ah right, I thought about doing that with n but somehow it slipped my mind. Thanks again :)

APL (Dyalog), 81 bytes
{×≢⍉⍵:⍵∇{~1∊⍵:0⋄0≡s←⍺⍺c/⍺⌿⍨r←~∨/⍺/⍨~c←~,⍺⌿⍨f←<\⍵:⍺∇f<⍵⋄f∨r\s},⍵/⍨<\n=⌊/n←+⌿⍵⋄∧/⍵}

Try it online!
{ anonymous function:
 : if…
  ⍵ If the argument
  ⍉ when transposed
  ≢ has a row-count
  × which is positive
 then
  ⍵∇{… then apply this function with the right argument as left argument (constraint matrix), but only after it has been modified by the following anonymous operator (higher-order function):
   : if…
    1∊⍵ there are ones in the right argument
    ~ NOT
   then…
    0 return zero (i.e. fail)
   ⋄ else:
   : if…
    <\⍵ the first true of the right argument (lit. cumulative less-than; first row)
    f← assign that to f
    ⍺⌿⍨ use that to filter the rows of the left argument
    , ravel (flatten)
    ~ negate
    c← assign that to c
    ~ negate
    ⍺/⍨ use that to filter the columns of the left argument
    ∨/ which rows have a true? (OR reduction)
    ~ negate that
    ⍺⌿⍨ use that to filter the rows of the left argument
    c/ use c to filter the columns of that
    ⍺⍺ apply the original outer function (the left operand; sub-matrix covers)
    s← assign that to s
    0≡ …is identical to zero (failure), then (try a different row):
    f<⍵ right-argument AND NOT f
    ⍺∇ recurse on that (preserving the original left argument)
   ⋄ else:
    r\s use zeros in r to insert zero-filled columns in s
    f∨ return f OR that (success; row f included)
  }… … on
  +⌿⍵ the sum of the argument
  n← assign that to n
  ⌊/ the minimum of that
  n= Boolean where n is equal to that
  <\ the first one of those (lit. cumulative less-than)
  ⍵/⍨ use that to filter the columns of the argument (gives first column with fewest ones)
  , ravel that (flatten)
 ⋄ else
  ∧/⍵ rows which are all ones (none, so this gives a zero for each row)
} end of anonymous function


text:
The Golfer Adventure - Chapter 1 : The vase
The Golfer Adventure
This is the first challenge ! There will be more challenges later that will require data from the previous challenge :)
Chapter 1 : The Vase
Let's imagine a minute.. You are a powerful God, your powers are limitless but require one thing : Souls.
Each soul is here represented by a byte, each byte you use does sacrifice a soul.
So the goal is obviously to save the biggest amount of people while sacrificing the least amount of souls.
Your first challenge is to save a little village, the devil is willing not to destroy the entire village if you resolve his challenge.
The Challenge :
You have a vertical vase which can contain exactly 10 things (Air included).
If you put a thing in that vase, gravity will make that thing fall to the bottom.
If the vase is already full (and it's always full if you consider it as "full of air"), the input will replace the element at the top of the vase.
Here is the set of allowed things :

Air 0 /
A Rock 1 / -
A Leaf 2 / ~
A Bomb 3 / x

If there is a rock or a leaf on top of "A Bomb", it will explode and destroy the thing on the top of it.
The input is the list of the things you'll put in the vase every turn.
Example : 11231 : You'll put 2 rocks, then a leaf, then a bomb and finally a last rock.
When the vase is static, you can begin to count with the following rule :

Rock adds 1 unit to the accumulator
Leaf multiplies the accumulator by 2
Bomb decrement the accumulator by 1
Air does nothing

(You need to start counting from the top of the vase)
Here is the simulation we get using "11231" as input :
|-|  |-|  |~|  |x|  |-|  | |  | |  | |  | |  | |  | |
| |  |-|  |-|  |~|  |x|  |-|  | |  | |  | |  | |  | |
| |  | |  |-|  |-|  |~|  |x|  |-|  | |  | |  | |  | |
| |  | |  | |  |-|  |-|  |~|  |x|  |-|  | |  | |  | |
| |  | |  | |  | |  |-|  |-|  |~|  |x|  |-|  | |  | |
| |  | |  | |  | |  | |  |-|  |-|  |~|  |x|  |-|  | |
| |  | |  | |  | |  | |  | |  |-|  |-|  |~|  |x|  | |
| |  | |  | |  | |  | |  | |  | |  |-|  |-|  |~|  |~|
| |  | |  | |  | |  | |  | |  | |  | |  |-|  |-|  |-|
| |  | |  | |  | |  | |  | |  | |  | |  | |  |-|  |-|

And the output will be 2 (calculated as ((0 x 2) + 1) + 1)
No need to print all the states of the vase !
The base program (Python3)
You can execute it to understand how it works.
def printVase(vase):
  for i in vase:
    if i == 1:
      print("|-|")
    elif i == 2:
      print("|~|")
    elif i == 3:
      print("|x|")
    else:
      print("| |")

def updateVase(vase):
  changed = False
  for i in range(len(vase), -1, -1):
    if i < len(vase) - 1:
      if vase[i+1] == 3 and vase[i] in [1,2]:
        vase[i], vase[i+1] = 0, 0
        changed = True
      if not vase[i+1] and vase[i] in [1, 2, 3]:
        vase[i], vase[i+1] = vase[i+1], vase[i]
        changed = True
  return changed

userInput = input("Vase : ")
vase = [0 for i in range(0, 10)]
oldVase = vase
while updateVase(vase) or userInput != "":
  if userInput != "":
    vase[0] = int(userInput[0])
  userInput = userInput[1::]
  printVase(vase)
  input()

accumulator = 0
for i in vase:
  if i == 1:
    accumulator += 1
  if i == 2:
    accumulator *= 2
  if i == 3:
    accumulator -= 1
print(accumulator)

Golfed version (Python3, no Vase Display) : 360 bytes = 360 points
def u(v):
  c=0
  for i in range(len(v),-1,-1):
    if i<len(v)-1:
      if v[i+1]==3 and v[i]in[1,2]:v[i],v[i+1],c=0,0,1
      if not v[i+1]and v[i]in[1,2,3]:v[i],v[i+1],c=v[i+1],v[i],1
  return c
l,v=input(),[0 for i in range(0, 10)]
while u(v)or l!="":
  if l!="":v[0],l=int(l[0]),l[1::]
a=0
for i in v:
  if i==1:a+=1
  if i==2:a*=2
  if i==3:a-=1
print(a)

If you want to test if your program works correctly, you can test this input : 12122111131
Correct answer is 43 :) (Thanks Emigna)
Now for the points :

(x) points where : x is the amount of bytes needed to write your program.
If you answer after the next challenge is posted, points for this challenge won't be added to your total amount of points.

The goal is to keep a minimum amount of points during the whole challenge :)
If you skip one of the part of the challenge, you'll have (wx + 1) points by default for the skipped part (where wx is the worst score for that challenge).
Data that will be required for the next challenge :
Output when input = 10100000200310310113030200221013111213110130332101
Current Champion : Emigna
Good luck everyone !

What's with the "can contain exactly 10 things"? Does "Air" count as a thing? Is input guaranteed to be such that the vase will only contain 10 things (I don't see it catered for in the reference implementation)? Also the input that produces the data for next challenge seems to have more than 10 things (even if air is like nothing and bombs blow up the next thing on top of the air there will be 14 things, I think).

An input 333 constructs a vase [0, 0, 0, 0, 0, 0, 0, 3, 3, 3] in your golfed algorithm and hence a score of -3, but shouldn't it be [0, 0, 0, 0, 0, 0, 0, 0, 0, 3] and then a score of -1 according to your specification?

@JonathanAllan the vase can ONLY contains 10 elements, Air is also an element. At start the vase will be [0,0,0,0,0,0,0,0,0,0] (so it is already full of air), when the vase is full, the input will replace the element at the top of the vase. Thanks for noticing :)

@Laikoni I forgot to specify that bombs doesn't explode when a bomb is on top of another one, thanks !

Output for 10100000200310310113030200221013111213110130332101 seems to be 22, right?

Yup :) But it's a secret !

Adding a tricky test-case like 12122111131 might be a good idea.

Nice one, I edited the question to add your test-case, thanks :)

If the input is "3311", will the vase then be empty? Ie. [..1,1,3,3] -> [.. , ,1,3] -> [.. , , , ]

"If you answer after the next challenge is posted, points for this challenge won't be added to your total amount of points." What's the reason for this?

Python 2 - 208 191 185 180 172 164 156 bytes
t=filter(bool,map(int,input()))
i=a=0
n=len(t)
while 0<n-1>i<11:
 if(t[i]>=3>t[i+1]):del t[i:i+2];i,n=0,n-2
 i+=1
for x in t[9::-1]:a+=a+x%2*(2-x-a)
print a

The breakdown is it removes air and the bombs if it is on the stack then counts.
EDIT : I swapped to Python 2 to save a byte, but now the input should be put in braces like '3312123'
EDIT2 : Im also kinda proud of the accumulator count
EDIT3 : Thanks for all your suggestions I would never have thought I could get it so low

Nice first answer! I was thinking with Python as well but short of time today. Think you would have beaten my approach anyway.

Thanks for the kind comment :) First time I'm doing a code golf and I've got to say it's quite fun.

Use t[:10][::-1] instead of reverse() to save 4 bytes and also maybe use Python 2 to save a bracket on the print? Comes to 5 more souls saved for me :)

No Python2 for me since I would have to cast input() to str for it to work, killing 5 more souls. Nice catch on the [::-1]

btw, I didn't see anything in the question that says the input can' be wrapped in quotes. Just says "The input is the list of the things". Works in Python 2 :)

Nah this is kinda cheating, it's like removing the print and saying "The answer is in a"... well actually now that I look on the other code golfs thats exactly what they do.. I don't know.

but the input can be any combination of 0,1,2,3. How would you deal with a 0 at the start if it is not a string?

Let us continue this discussion in chat.

The input is a "list of things" so you can expect a list to be provided by the user (like [0,1,2,3,0,1,..]) in which case I believe you could do t=filter(None,input()) and save 12 bytes.

...and as it stands you could save 4 with filter(None,map(int,input()))

05AB1E, 28 36 bytes
05AB1E uses CP-1252 encoding.
Î0KDvT¹g‚£`sTØõ:žwõ:ì}ÁT£ÀRS"<>·"è.V

Try it online!

Impressive as always :D It'll be hard to beat that

T£ÀRS -> Tears -> I'm crying alright...

Retina, 58 56  bytes
1+`0|(?<=.{9}).\B|3[12]

+-1=`2
$'
+`13

*\(1`3
-
)T`d
.

Try it online!

Python 2, 150 146 bytes
v=[]
s=0
for c in input():
 v=v[:9]
 if'0'==c:1
 elif 3 in v[-1:]and c in'21':v=v[:-1]
 else:v+=[int(c)]
for x in v[::-1]:s+=s+x%2*(2-x-s)
print s

Thanks to Pâris Douady for the points formula, and for saving 4 bytes.

Did you took my formula for the counting of the point ? Either way nice solution, you beat me and it's much cleaner. also you can save some bytes with by doing for c in input() directly

Javascript, 267 264 249 souls sacrificed
r='replace'
f=t=>{t=t[r](/0/g,'');while(/3[12]/.test(t.substring(0,10)))t=t[r](/3[12]/,'');
a=t.length-1;x=(t.substring(0,9)+(a>8?t[a]:'')).split('').reverse().join('');
c='c=0'+x[r](/1/g,'+1')[r](/2/g,';c*=2;c=c')[r](/3/g,'-1');eval(c);return c}

Edited version, because the previous one was incorrect for larger inputs. Golfed it a little further by making string.prototype.replace() into an array-accessed function call. Explanation:
f=t=>{                                  Function declaration, input t
t=t.replace(/0/g,'');                   Remove air
while(/3[12]/.test(t.substring(0,10)))  Look for bombs; not double bombs, and only in the first 10 chars
    t=t.replace(/3[12]/,'');            Detonate bombs. If this makes a new bomb fall into the vase, or
                                        a double bomb is now a single bomb, it'll detonate that bomb too.
x=(t.substring(0,9)+                    Fill the vase, take the first 9 items
    (t.length>9?t[t.length-1]:''))      If we have more than 9 items, then add the last one
    .split('').reverse().join('');      Flip the instruction string.
c='c=0'+x.replace(/1/g,'+1')            Replace each item with the proper instruction to the ACC
         .replace(/2/g,';c*=2;c=c')
         .replace(/3/g,'-1');
eval(c);return c}                       Eval to get the value of ACC and return it.

f('11231'); returns 2.
Try it online

10100000200310310113030200221013111213110130332101 doesn't return the good result :) You're close though :)

@Sygmei I know, and I've been debugging the crap out of it, but I can't find out why. Can you see me in chat?

Haskell, 221 202 181 177 166 souls bytes
g(0:r)=r++[0]
g(3:x:r)|0<x,x<3=0:0:g r|1<3=3:g(x:r)
g(x:r)=x:g r
g r=r
v%(x:r)=g(init v++[x])%r
v%[]|v==g v=foldr([id,(+)1,(*)2,(-)1]!!)0v|1<3=g v%[]
(([0..9]>>[0])%)

Try it on ideone. Takes items as integer list.
Usage:
*Prelude> (([0..9]>>[0])%) [1,2,1,2,2,1,1,1,1,3,1]
43

(Edit: Old) Explanation:
g [] = []                             -- g simulates gravity in the vase
g ('0':r) = r ++ "0"                  -- the first 0 from the bottom is removed
g ('3':x:r) | elem x "12" = "00"++g r -- if a 1 or 2 is on a bomb, explode
            | True = '3' : g(x:r)     -- else continue
g (x:r) = x : g r                     -- no air and no bomb, so check next item

c x = [id,(+)1,(*)2,(-)1]!!(read[x])  -- map 0, 1, 2, 3 to their score functions

f v w (x:r) =                         -- v is the current vase state, w the previous one
               init v++[x]            -- replace last vase element with input
             g(init v++[x])           -- simulate one gravity step
           f(g(init v++[x]))v r       -- repeat, w becomes v
f v w[] | v==w =                      -- if the input is empty and vase reached a fixpoint
                 foldr c 0 v          -- then compute score
        | True = f (g v) v []         -- else simulate another gravity step

vase input = f "0000000000" "" input  -- call f with empty vase, previous vase state and
                                      -- the input as string of numbers

Good job :) ! What are the last three " ?

@Sygmei it's two strings f "0000000000" "", you just don't need any spaces between them. I added an explanation to the code.

Nice, easier to understand now :)