text:
Consolidate an Array
The task is simple: consolidate an array of ints. Consolidating this array consists of the following:

All instances of 0 need to be moved to the end of the array.
There should be no 0s between the non-zero integers.
All non-zero indices should retain their order.

Challenge
Consolidate an array in the least amount of bytes.
You are consolidating an array of random length with a size up to your language's max with random integers. Input may be any natural way for your language.
Examples
Input
0 5 8 8 3 5 1 6 8 4 0 3 7 5 6 4 4 7 5 6 7 4 4 9 1 0 5 7 9 3 0 2 2 4 3 0 4 8 7 3 1 4 7 5 1 2 1 8 7 8 7 7 2 6 3 1 2 8 5 1 4 2 0 5 0 6 0 3
Output
5 8 8 3 5 1 6 8 4 3 7 5 6 4 4 7 5 6 7 4 4 9 1 5 7 9 3 2 2 4 3 4 8 7 3 1 4 7 5 1 2 1 8 7 8 7 7 2 6 3 1 2 8 5 1 4 2 5 6 3 0 0 0 0 0 0 0 0
Input
-1 -7 -6 5 1 -5 -2 7 -3 -8 0 8 9 1 -8 -1 6 -4 1 -2 1 -7 5 4 -6 7 -3 9 8 3 -1 0 -5 -7 3 8 1 1 3 -3 -2 -2 0 -7 0 -4 8 6 -3 6 0 5 3 2 2 2 -2 -7 -3 9 -1 6 0 6 -7 9 4 -2 8 -8 -4 1 -8 4 3 7 3 5 1 0 3 3 7 -1 -5 1 -3 4 -7 0 3 2 -2 7 -3 0 0 2 -5 8 -3 -2 -7 -5 7 -3 -9 -7 5 8 -3 9 6 7 -2 4 7
Output
-1 -7 -6 5 1 -5 -2 7 -3 -8 8 9 1 -8 -1 6 -4 1 -2 1 -7 5 4 -6 7 -3 9 8 3 -1 -5 -7 3 8 1 1 3 -3 -2 -2 -7 -4 8 6 -3 6 5 3 2 2 2 -2 -7 -3 9 -1 6 6 -7 9 4 -2 8 -8 -4 1 -8 4 3 7 3 5 1 3 3 7 -1 -5 1 -3 4 -7 3 2 -2 7 -3 2 -5 8 -3 -2 -7 -5 7 -3 -9 -7 5 8 -3 9 6 7 -2 4 7 0 0 0 0 0 0 0 0 0 0
Example Code (Java)
public class Consolidate {
    public static void main(String[] args) throws Exception {
        int[] toConsolidate = new int[args.length];
        for (int i=0; i<args.length; i++){
            toConsolidate[i]=Integer.parseInt(args[i]);
        }
        for (int i=0; i<toConsolidate.length; i++) {
            for (int k=0; k<toConsolidate.length-1; k++) {
                if (toConsolidate[k] == 0){
                    toConsolidate[k] = toConsolidate[k+1];
                    toConsolidate[k+1] = 0;
                }
            }
        }
        for (int i:toConsolidate)
            System.out.print(i+" ");
    }
}

Any integer or single digits like the examples?

@edc65 Any integer that your language supports.

How can the example be so complex when the shortest answers are 3 characters long? Is Java that much verbose?

@A.L in fairness, it is fully ungolfed and a terrible algorithm.

Isn't "There should be no 0s between the non-zero integers." redundant?

What if our language only supports one possible value besides the one that delimits the end of the array?

@MartinBüttner Yes, but I put it there to make sure that I was understood (didn't have people shift all the zeroes one to the right or something like that.

@immibis Might not be the right language for this challenge. :P

@VoteToClose Did you see my recent answer? This would be a zero-terminated cat program in Boolfuck: ,[;,] - although it's still larger than the Pyth one.

Pyth, 3 bytes
!DQ

Explanation:
  Q    Input
!D     Sort by logical NOT

Try it here.

Q can be implicit at the end of any Pyth script (assuming it's outside of a lambda, which this is), making this 2 bytes.

@hakr14 That feature didn't exist 2 years ago.

Jelly, 3 bytes
¬Ụị

Sorts the list by the logical NOT of its values. Try it online!
How it works
¬Ụị    Main link. Input: A (list)

¬      Compute the logical NOT of each element of A.
 Ụ     Grade up; sort the resulting list's indices by their corresponding values.
  ị    Retrieve the elements of A at that indices.

Oh hey, modern Jelly can do a 2-byte ¬Þ, even!

Octave, 18 bytes
@(A)[A(~~A) A(~A)]

sort() takes too many bytes. I'll just use logical indexing.
Examples on ideone.

Nicely done. +1.

Wow, works in Matlab too! I didn't know that such indexing is possible

R, 29 23 21 bytes
As noted by MarcoBreitig, we can shorten it to 21 bytes if we don't need to provide it as a function:
x=scan();x[order(!x)]

Previous versions:
function(x)x[order(!x)]

The function takes a vector as input and orders by the logical vector that results from negating the input.
Original answer:
function(x)c(x[x!=0],x[x==0])

The function takes a vector as input and the concatenates (c()) the non-zero values and then the zero-values.

x=scan();x[order(!x)] is only 21 bytes long.

@MarcoBreitig, that's right. I thought it should be a function (and initially, the requirement was a "full-fledged program"). Will update my answer

Retina, 15
Simple repeated regex substitution:
+`\b0 (.*)
$1 0

Try it online.

I used the same method in my Java answer (if I'm reading this right). :D

Python, 32 bytes
lambda x:sorted(x,key=0..__eq__)

Takes argument as any iterable (list, tuple, etc.). Thanks to @xnor for teaching me a new trick!

It's a bit shorter to use key=0..__eq__ (yes, two dots).

@xnor That's neat... How does it work?

Most Python objects have an equality method, so for example "abc".__eq__("abc")==True. It's what's called when you do "abc"==. For reasons, Python integers don't have it but floats do, and since 0. == 0, we can substitute its equality operator., which is 0..__eq__.

@xnor ahh, I knew about the .__eq__ method, but the double dots were confusing me. I didn't catch that the first one was the decimal point in a float literal.

ES6, 23 bytes
a=>a.sort((x,y)=>!x-!y)

It used to be the case that sort wasn't stable, in which case you needed 41 bytes:
a=>a.filter(x=>x).concat(a.filter(x=>!x))

Python byte code (2.7.9), 252 bytes, 33 opcodes, 0.0228 seconds
This was build when the contest was still a fastest-code contest
Opens a file in the current directory called 'SourceArray' for use
LOAD_CONST          ''
STORE_FAST          no_zeroes#  no_zeroes = ''

LOAD_NAME           open
LOAD_CONST          'SourceArray'
CALL_FUNCTION       0,1#  open('SourceArray')
LOAD_ATTR           read
CALL_FUNCTION       0,0#  .read()

LOAD_ATTR           split
CALL_FUNCTION       0,0#  .split()

DUP_TOP
DUP_TOP             #Start if
BUILD_LIST          0
COMPARE_OP          ==
POP_JUMP_IF_TRUE    35#  if list == [], GOTO 35
LOAD_ATTR           pop
LOAD_CONST          0
CALL_FUNCTION       0,1#  list.pop(0)
DUP_TOP
LOAD_CONST          '0'
COMPARE_OP          ==
POP_JUMP_IF_TRUE    28#  if list.pop(0) == '0', GOTO 28
PRINT_ITEM          #  print list.pop(0)
JUMP_ABSOLUTE       13

POP_TOP
LOAD_CONST          '0%_'#  '0 '
LOAD_FAST           no_zeroes
INPLACE_ADD
STORE_FAST          no_zeroes#  no_zeroes = no_zeroes + '0 '
JUMP_ABSOLUTE       13

LOAD_FAST           no_zeroes
PRINT_ITEM          #  print no_zeroes

LOAD_CONST          None
RETURN_VALUE

The co_code (The actual codey bit)
'd\x01\x00}\x00\x00\te\x00\x00\x83\x00\x00\tj\x01\x00\x83\x00\x00\t\x04\x04g\x00\x00k\x02\x00sG\x00j\x02\x00d\x02\x00\x83\x01\x00\x04d\x03\x00k\x02\x00s8\x00Gq\x15\x00\t\x01d\x04\x00|\x00\x007}\x00\x00q\x15\x00\t|\x00\x00G\td\x00\x00S'

Or a .pyc file version 03F3
03 F3 0D 0A 40 FD B0 56 63 00 00 00 00 01 00 00 00 03 00 00 00 00 00 00 00 73 59 00 00 00 64 01 00 7D 00 00 09 65 00 00 64 02 00 83 01 00 6A 01 00 83 00 00 09 6A 02 00 83 00 00 09 04 04 67 00 00 6B 02 00 73 50 00 6A 03 00 64 03 00 83 01 00 04 64 04 00 6B 02 00 73 41 00 47 71 1E 00 09 01 64 05 00 7C 00 00 37 7D 00 00 71 1E 00 09 7C 00 00 47 09 64 00 00 53 28 06 00 00 00 4E 74 00 00 00 00 74 0B 00 00 00 53 6F 75 72 63 65 41 72 72 61 79 69 00 00 00 00 74 01 00 00 00 30 73 02 00 00 00 30 20 28 04 00 00 00 74 04 00 00 00 6F 70 65 6E 74 04 00 00 00 72 65 61 64 74 05 00 00 00 73 70 6C 69 74 74 03 00 00 00 70 6F 70 28 01 00 00 00 74 09 00 00 00 6E 6F 5F 7A 65 72 6F 65 73 28 00 00 00 00 28 00 00 00 00 74 09 00 00 00 70 79 6B 65 5F 63 6F 64 65 52 08 00 00 00 01 00 00 00 52 00 00 00 00

You can try to compile my source code yourself using my library on github. I just posted a commit to it that allowed comments so I hope this is still competing as far as fastest-code goes ;)
Roughly equivalent to
no_zeroes = ''
unamed_variable = open('SourceArray').read().split()
while unamed_variable != []:
    unamed_variable_2 = unamed_variable.pop()
    if unamed_variable_2 == '0':
        no_zeroes += '0 '
    else:
        print unamed_variable_2,
print no_zeroes,

Wooow. You cut a ton of time off of that.

@VoteToClose that's about 1.5x the speed it ran on my laptop :O Who said Python was that slow?

Matlab: 21 bytes
@(a)[a(a~=0),a(a==0)]

Prints nonzero elements first, then concatenates with zero elements
@(a)____ create an anonymous function with one input argument a
[___,___] concatenates horizontally vectors inside brackets, separated by commas
a(a~=0) returns vector with all nonzero elements of vector a
a(a==0) returns vector with all zero elements of vector a

APL: 8 bytes
(⍴a)↑a~0

a~0        remove zeros from a (read "a without 0")
(⍴a)       original length of a (read "shape of a")
↑          pad a without zeros to a's original length
Try it in http://ngn.github.com/apl/web/index.html
Test data:  a←1 0 1 2 3 4 0 1 0 0 0 0 1 2 3 4 5

You should either write a full program and read the input from stdin, or write a function and read the input from its parameters. But you can use ⍴↑{⍵~0} and that's even shorter.

Not so fast.  ⍴↑{⍵~0} won't work everywhere, not in APL2000, nor in IBM APL2.

⍴↑{⍵~0} will return an empty vector.  ⍴⍴↑{⍵~0} is a (one element vector) zero.

Zsh, 22 bytes
(input passed as arguments to the script/function ($@ aka $argv array), output on stdout as space separated list, newline terminated)
<<<${@:#0}\ ${(M)@:#0}

<<< string: here-string here passed as stdin to the $NULLCMD command (cat by default).
${@:#0} $@ except elements being 0.
${(M)@:#0} reverse of the above

That assumes (like several other answers here) that zeroes in the input are all expressed as 0 (no 00 nor 0x0 nor 36#0).

verified on tio :)

Haskell, 26 bytes
f x=filter(/=0)x++[0|0<-x]

Take all non-zero numbers followed by all zeros. Filtering constants (here: 0) is quite short when using a list comprehension: [0|0<-x].

Mathematica, 14 bytes
Sort[#,#!=0&]&

Sort[#!=0&] should be enough.

Javascript, 52 54 51 bytes
s=>s.replace(/\b0 /g,x=>++i&&'',i=0)+' 0'.repeat(i)

This doesn't work when the input does not contain any zeroes

@rink.attendant.6. Thanks, I've updated and still looking for some bytes off :)

Common Lisp, 46 bytes
(lambda(a)(stable-sort a(lambda(_ b)(= 0 b))))

Sort the array so that for each couple (a,b), we have a < b if b is zero. When neither a < b or b < a, the sort is stable: the original order between elements is retained.
I also tried with adjust-array and remove, but this was too long:
(lambda(a)(adjust-array(remove 0 a)(length a):initial-element 0))

Java 7, 78 bytes
void g(int[]a){int c=0;for(int o:a)a[o==0?c:c++]=o;for(;c<a.length;a[c++]=0);}

I'm not sure why the other Java entries are using strings. If you want to filter an integer array, it seems best to use an integer array. This modifies the input in place by keeping two indices, then just filling the remaining slots with zeros.

Heh, I used it because I felt like it. I think you should be able to declare o with int c=0,o;for(o:a).... You can also convert to Java 8 lambda syntax: a->{int c=0;for(int o:a)a[o==0?c:c++]=o;for(;c<a.length;a[c++]=0);} and state that it expects input as an int array.

Wait, scratch the o declaration thingy. But still, java 8 lambda. :D

@VoteToClose I thought it had to be self-contained. If I can declare types and stuff elsewhere without counting it, that doesn't seem right.

Since this is a function, input is passed to it by a previously executed statement anyways. The lambda can assume an input type, so its essentially the same.

Vyxal, 3 2 bytes
µ¬

Try it Online!
Sort by logical negation. The header puts the input into a list format.

Perl 5, 26 bytes
23 plus three for -an (-E is free)
say for sort{!$a-!$b}@F

Thanks to Dennis for reminding me of -a, saving two bytes.

PHP, 73 71 70 52 49 48 46 bytes - BIG thanks to Ismael Miguel
// Assuming
$a = array(4,8,6,1,0,8,0,0,0,0,0,-4,'-5',-1,564,0);

// Produces a notice-level error
foreach($a as$v)$v?print"$v ":$b.="0 ";echo$b;

$v==0 can be replaced with !$v, saving you 2 bytes.

@IsmaelMiguel thanks!

You're welcome. I see you did manage to cut a byte. Try this: foreach($argv as$v)$v?$f.=" $v":$b.=" $v";echo$f.$b;. It is.... some bytes, I don't know...

Or foreach($a as$v)$v?print("$v "):$b.="$v ";echo$b; for a more neat way, that looks exactly the same

@IsmaelMiguel Nice! I would cry if I ever had to pick up someone else's project and found this level of code-golfing lol

@IsmaelMiguel Shaved a few more!

I would cry as well. Good thing I also practice good coding conventions... Well, as far as Javascript and PHP allow. And I see you keep on improving it! Quite nice the few edges you're cleaning! They were nasty hick-ups I left behind. You deserve more upvotes.

Sadly, with the last change, your input method to run the code is invalid. However, you can say your code is PHP5.4, since it is now allowed to use POST/GET parameters as input. This allows you to say that your code is PHP4.1 and that you expect that the script is executed through Apache, with the GET key a[]=<value>. This will create your $a array for you. It relies on PHP4.1 directive register_globals that was enabled by default on that version.

Bash + GNU utilities, 23
grep -v ^0 a
grep ^0 a

Assumes input is newline-separated entries in a file called a.  Score includes +1 for this filename.

@sch Yes, it should be bash - fixed.

@TimmyD yes - thanks for the reminder.

JavaScript ES6, 16 bytes
x=>x.sort(t=>!t)

Works on firefox

AWK, 34 bytes
{for(;a++-NF;c?$++b=c:0)$a-=c=$a}1

Try it online!
This code runs through all the commandline arguments, shifts non-zero values to the left and clears arguments as it processes them.
The top of loop "should we iteration" condition expression is:
a++-NF

which increments a until it hits the number of commandline arguments NF.
The body of the loop,
$a-=c=$a

saves the value of the current commandline argument in variable c, then sets the current argument to 0.
At the end of each iteration, the ternery:
c?$++b=c:0

checks to see if the current argument c is non-zero and if so, increments the b (the number of non-zero argument found so far) and stores the current argument value in that slot.
After the code block processes the commandline arguments, the only left to do is trigger AWK to print all the commandline arguments with a truthy test without a code block.
1

Uiua, 5 bytes
⊏⍏=0.

Try it!
⊏⍏=0.
    .  # duplicate
  =0   # where is it equal to zero?
 ⍏     # rise (grade up)
⊏      # select

MATL, 7 bytes
t~FT#S)

Try it online!
t      % input array. Duplicate
~      % logical negate: nonzero values become false, zeros become true
FT#S   % sort (false, then true) and output a vector with the indices of the sorting
)      % apply that vector of indices to original array

CJam, 6 bytes
{{!}$}

An anonymous function. Sort using “whether or not an element is zero” as a key.

Clojure/ClojureScript, 18 bytes
#(sort-by zero? %)

Seriously, 12 bytes
4,n`Y`M@░)░+

Try it online!
Explanation:
4,n`Y`M@░)░+
4,n           push 4 copies of input
   `Y`M       map logical negate
       @░)    filter (take zeroes) and push to bottom of stack
          ░   filter (take non-zeroes)
           +  append zeroes

Swift, 13 bytes
a.sort{$1==0}

TeX (Plain format), 160 bytes
Make the 0 character active (that is, make the interpreter process it as a command), then define that command to skip the character and increment a counter. At the end of the string, print as many zeros as were counted.
Save this as zero.tex and give the input through the command line with this command:
pdftex "\def\I{0 1 0 3 2 0 0 8 0 5 0 1 9 4}\input zero"

\def\I{}\newcount\Z\def\L{\loop\advance\Z by-1\ifnum\Z>00 \repeat}
\begingroup\catcode`\013 \def0{\advance\Z by1}
\scantokens\expandafter{\I\empty}\endgroup\L\bye

(Newlines added for clarity)

Perl6, 11 bytes
{.sort(!*)}

Produces a Block - which can be called on an array:
{.sort(!*)}.([1,2,0,3]).say

Although it would be more natural (and shorter) to write:
[1,2,0,3].sort(!*).say

How it works: if the perl6 sort routine is called with a block which accepts only one argument, the list elements are sorted according to by($a) cmp by($b). In this case, the block is !*, i.e. a negation of the whatever operator.
I notice that:

The example in the question is a class which provides a method, not including boilerplate required to read in
The description of the task does not require printing, and, except for the fact that the example prints, implies that an array might be returned

J, 4 bytes
/:0=

Explanation:
/:      NB. upward sort on
  0=    NB. equality to zero

The sort function in J is guaranteed to be stable by the specification.
Alternative solution, 6 bytes:
#{.*#+

   *#+  NB. replicate each item by its sign (removing zeroes)
#{.     NB. take as many items from this as the original list had
        NB.  (taking more items than there are in a list results in extra zeroes)

Straw, 30 29 bytes
<:([^0 ])()/,0()/ +,+( +) /}>

Use the CP437 encoding
Explanation
<:([^0 ])()/,0()/ +,+( +) /}>
<                             Take input
 :                            Duplicate
  ([^0 ])()/                  Remove every character that is not a 0 or a space
            ,                 Swap the two items on the top of the stack
             0()/             Remove every 0 on the top of the stack
                  +           Push a space and concatenate
                   ,          Swap
                    +         Concatenate
                     ( +) /   Remove duplicate spaces
                           }  Get the 'tail' of the string
                            > Output

Try it online! (The added code is to test all test cases)

K (ngn/k), 7 bytes
{x@<~x}

Try it online!
{ } anonymous function with argument x
~ "not" - turn 0s into 1s, and everything else into 0s
< return the permutation for a stable ascending sort
@ indexing

Ruby, 25 bytes
->a{a-[0]+[0]*a.count(0)}

Try it online!

Brachylog, 6 bytes
{0∨>}ᵒ

Try it online!
Other languages' "sort by logical negation" approach doesn't work here, because 1. Brachylog doesn't even have a concept of a Boolean and 2. ᵒ applies the default sort to elements that produce the same output to the given predicate, rather than preserving their order. Although, if the output is unbound but constrained... this happens.
{   }ᵒ    Sort the input by:
 0        this element is 0
  ∨       and the output is whatever, or whatever
   >      is greater than the output.

The very first solution I attempted was simply >ᵒ, which didn't rearrange anything at all, and when it came time to include that as an aside in my explanation of my original solution, I found I couldn't quite explain the circumstances, which led me to this.
The original, which is not without its own share of magic to begin with:
Brachylog, 10 bytes
~b{ȧ>≜}ᵍcb

Try it online!
I arrived at this solution by trying the longer ~b{ȧ>≜}ᵍ↔ck, only to discover that ᵍ... I actually don't know how this works. Not a clue. Somehow, the unbound variable created by ~b always ends up non-zero, causing the group of non-zero items to appear before the group of zeroes, as intended (since groups are sorted by first appearance of their earliest elements).
~b{ȧṡ}ᵍ↔ck has the same length, and works on the same principle, but involves only more understandable behaviors of CLP(FD)--ṡ checks the case where its input and output are zero first, so the unbound variable created by ~b simply ends up being zero:
~b            Un-behead the input, i.e. append something.
  {  }ᵍ       Group the elements by
    ṡ         sign of
   ȧ          absolute value.
       ↔      Reverse the groups, so that the one containing the first element is last,
        c     concatenate them,
         k    and remove the last element (the "something" from ~b).

x86 machine code, 17 bytes
Hexdump:
57 8b fa 33 c0 86 02 42 84 c0 74 01 aa e2 f4 5f
c3

A fastcall function: receives pointer to array in edx and its length in ecx.
Disassembled code:
    doit:
00D815D0 57                   push        edi
00D815D1 8B FA                mov         edi,edx
    myloop:
00D815D3 33 C0                xor         eax,eax
00D815D5 86 02                xchg        al,byte ptr [edx]
00D815D7 42                   inc         edx
00D815D8 84 C0                test        al,al
00D815DA 74 01                je          myskip (0D815DDh)
00D815DC AA                   stos        byte ptr es:[edi]
    myskip:
00D815DD E2 F4                loop        doit+3h (0D815D3h)
00D815DF 5F                   pop         edi
00D815E0 C3                   ret

ArnoldC, 3752 bytes
Input is a 16 bit positive integer, where the first digit is disregarded. Wrote my own 'power' function, but I used the stock standard example for modulo function as per the ArnoldC website.
e.g. If you want to consolidate the array [3,1,0,2] you would do so as per the example below:
IT'S SHOWTIME
HEY CHRISTMAS TREE out
YOU SET US UP 0
GET YOUR ASS TO MARS out
DO IT NOW consolidate 13102
TALK TO THE HAND out
YOU HAVE BEEN TERMINATED

LISTEN TO ME VERY CAREFULLY consolidate
I NEED YOUR CLOTHES YOUR BOOTS AND YOUR MOTORCYCLE n
GIVE THESE PEOPLE AIR
HEY CHRISTMAS TREE ZeroCount
YOU SET US UP 0
HEY CHRISTMAS TREE NewNumber
YOU SET US UP 0
HEY CHRISTMAS TREE Modulus
YOU SET US UP 10
HEY CHRISTMAS TREE Power
YOU SET US UP 0
HEY CHRISTMAS TREE Decimal
YOU SET US UP 0
HEY CHRISTMAS TREE Digits
YOU SET US UP 0
GET YOUR ASS TO MARS Digits
DO IT NOW modulo n Modulus
HEY CHRISTMAS TREE Loop
YOU SET US UP 1
HEY CHRISTMAS TREE Cond1
YOU SET US UP 1
HEY CHRISTMAS TREE Cond2
YOU SET US UP 1
HEY CHRISTMAS TREE Val1
YOU SET US UP 0
HEY CHRISTMAS TREE Val2
YOU SET US UP 0
HEY CHRISTMAS TREE Val3
YOU SET US UP 0
HEY CHRISTMAS TREE FinalZeros
YOU SET US UP 1
GET TO THE CHOPPER Loop
HERE IS MY INVITATION n
LET OFF SOME STEAM BENNET Digits
ENOUGH TALK
GET TO THE CHOPPER Cond1
HERE IS MY INVITATION Modulus
HE HAD TO SPLIT 100
LET OFF SOME STEAM BENNET Digits
HE HAD TO SPLIT 10
CONSIDER THAT A DIVORCE Digits
YOU ARE NOT YOU YOU ARE ME 0
ENOUGH TALK
STICK AROUND Loop
BECAUSE I'M GOING TO SAY PLEASE Cond1
GET TO THE CHOPPER ZeroCount
HERE IS MY INVITATION ZeroCount
GET UP 1
ENOUGH TALK
BULLSHIT
GET YOUR ASS TO MARS Val1
DO IT NOW pow 10 Power
GET TO THE CHOPPER Val1
HERE IS MY INVITATION Digits
HE HAD TO SPLIT Val1
ENOUGH TALK
GET YOUR ASS TO MARS Val2
DO IT NOW pow 10 Decimal
GET TO THE CHOPPER Val1
HERE IS MY INVITATION Val1
YOU'RE FIRED Val2
ENOUGH TALK
GET TO THE CHOPPER NewNumber
HERE IS MY INVITATION NewNumber
GET UP Val1
ENOUGH TALK
GET TO THE CHOPPER Decimal
HERE IS MY INVITATION Decimal
GET UP 1
ENOUGH TALK
YOU HAVE NO RESPECT FOR LOGIC
GET TO THE CHOPPER Modulus
HERE IS MY INVITATION Modulus
YOU'RE FIRED 10
ENOUGH TALK
GET TO THE CHOPPER Power
HERE IS MY INVITATION Power
GET UP 1
ENOUGH TALK
GET YOUR ASS TO MARS Digits
DO IT NOW modulo n Modulus
GET TO THE CHOPPER Val3
HERE IS MY INVITATION Digits
HE HAD TO SPLIT 10
ENOUGH TALK
GET TO THE CHOPPER Cond1
HERE IS MY INVITATION Modulus
HE HAD TO SPLIT 100
LET OFF SOME STEAM BENNET Val3
ENOUGH TALK
GET TO THE CHOPPER Cond2
HERE IS MY INVITATION Digits
YOU ARE NOT YOU YOU ARE ME 0
ENOUGH TALK
GET TO THE CHOPPER Cond1
HERE IS MY INVITATION Cond1
CONSIDER THAT A DIVORCE Cond2
ENOUGH TALK
GET TO THE CHOPPER Loop
HERE IS MY INVITATION n
LET OFF SOME STEAM BENNET Digits
ENOUGH TALK
CHILL
GET YOUR ASS TO MARS FinalZeros
DO IT NOW pow 10 ZeroCount
GET TO THE CHOPPER NewNumber
HERE IS MY INVITATION NewNumber
YOU'RE FIRED FinalZeros
ENOUGH TALK
I'LL BE BACK NewNumber
HASTA LA VISTA, BABY

LISTEN TO ME VERY CAREFULLY pow
I NEED YOUR CLOTHES YOUR BOOTS AND YOUR MOTORCYCLE base
I NEED YOUR CLOTHES YOUR BOOTS AND YOUR MOTORCYCLE exponent
GIVE THESE PEOPLE AIR
HEY CHRISTMAS TREE result
YOU SET US UP 1
STICK AROUND exponent
GET TO THE CHOPPER result
HERE IS MY INVITATION base
YOU'RE FIRED result
ENOUGH TALK
GET TO THE CHOPPER exponent
HERE IS MY INVITATION exponent
GET DOWN 1
ENOUGH TALK
CHILL
I'LL BE BACK result
HASTA LA VISTA, BABY

LISTEN TO ME VERY CAREFULLY modulo
I NEED YOUR CLOTHES YOUR BOOTS AND YOUR MOTORCYCLE dividend
I NEED YOUR CLOTHES YOUR BOOTS AND YOUR MOTORCYCLE divisor
GIVE THESE PEOPLE AIR
HEY CHRISTMAS TREE quotient
YOU SET US UP 0
HEY CHRISTMAS TREE remainder
YOU SET US UP 0
HEY CHRISTMAS TREE product
YOU SET US UP 0
GET TO THE CHOPPER quotient
HERE IS MY INVITATION dividend
HE HAD TO SPLIT divisor
ENOUGH TALK
GET TO THE CHOPPER product
HERE IS MY INVITATION divisor
YOU'RE FIRED quotient
ENOUGH TALK
GET TO THE CHOPPER remainder
HERE IS MY INVITATION dividend
GET DOWN product
ENOUGH TALK
I'LL BE BACK remainder
HASTA LA VISTA, BABY

Try it online!

Julia, 22 bytes
l->[l[l.!=0];l[l.==0]]

Try it online!

Thunno 2, 2 bytes
Þ~

Attempt This Online!
Sort the input (Þ) by logical NOT (~).

05AB1E, 15 14 bytes
Code:
ED0¢r0KR`rFZ}|

Explanation:
E               # Evaluate input
 D              # Duplicate top of the stack
  0¢            # Count zeroes
    r           # Reverse stack
     0K         # Delete all zeroes
       R        # Reverse top of the stack
        `       # Flatten
         r      # Reverse stack
          FZ}   # For N in range(amount zeroes): push zero
             |  # Print full stack

Uses CP-1252 encoding. Takes an array like this:
[0, 5, 8, 8, 3, 5, 1, 6, 8, 4, 0, 3, 7, 5, 6, 4, 4, 7, 5, 6, 7, 4, 4, 9, 1, 0, 5, 7, 9, 3, 0, 2, 2, 4, 3, 0, 4, 8, 7, 3, 1, 4, 7, 5, 1, 2, 1, 8, 7, 8, 7, 7, 2, 6, 3, 1, 2, 8, 5, 1, 4, 2, 0, 5, 0, 6, 0, 3]

Java, 131 138 136 bytes
Thanks to @t0r0X for pointing out a flaw in my code! (and @Mego for pointing out how to fix it!)
void x(String y){int z=y.length(),i=0;System.out.print(y=y.replaceAll("( 0)|(0 )",""));for(;i<z-y.length();i+=2)System.out.print(" 0");}
Expects input as a string in the format "1 2 3 4 5 0 6 0 7 8 9".

@t0r0X I don't think so; do you mean that it's missing a space after the 0? or it looks like 00?

Cool. Space is missing before 0 in last print(). I.e. print("0") should be print(" 0"). Code length is indeed 138 chars.

@t0r0X I guess that got clipped somehow. ;P

Groovy, 28 chars
Given input array i, e.g. def i = [ 0, 5, -1, 3... ], the following delivers the solution:
i.findAll{it}+i.findAll{!it}

Japt, 8 bytes
Un@!X-!Y

Test it online!
Joining the "sort by logical NOT" party, as that's literally all it is.

Java 8, 84 99 chars
Now even shorter than ever... based on previous answer and suggestions by @VoteToClose ;-)
y->{int z=y.length();for(y=y.replaceAll(" 0|0 ","");y.length()<z;)y+=" 0";return y;}

Java <= 7 version, 99 chars:
String x(String y){int z=y.length();for(y=y.replaceAll(" 0|0 ","");y.length()<z;)y+=" 0";return y;}

Use Java 8 lambda syntax: y->{int z=y.length(),i=0;y=y.replaceAll("0 *","").trim();for(int n=y.length();i<z-n;i+=2)y+=" 0";return y;}

Nah, you take it. c: Keep it in this answer, though.

Sorry, I mean to replace the for loop with for(;z!=y.length();)y+=" 0";.

You can get rid of ,i=0 now.

You can use y=y.replaceAll("( 0)|(0 )","") instead of y=y.replaceAll("0 *","").trim().

Yeah, I realized that after I commented. The suggestion I just put is a byte shorter. :P

Shaving another byte: int z=y.length();for(y=y.replaceAll("( 0|0 )","");y.length()<z;)y+=" 0";

And again two. THX for the fun!

Mathematica 33 bytes
DeleteCases[#,0]~Join~Cases[#,0]&

PowerShell, 31 bytes
param($a)($a|?{$_})+($a|?{!$_})

Takes input $a, then does a Where-Object (the ?) for all elements that are true (i.e., not zero), and joins that with another Where-Object for all elements that are false (i.e., zero).

You can make it even shorter by using splatting Try it online!

And using the -ne and -eq operators Try it online!

8th, 75 bytes
First create an array with elements not equal to zero. Then append all found zeros to resulting array.
SED (Stack Effect Diagram) is a -- a
Code
0 swap ( not if n:1+ false else true then ) a:filter ( 0 a:push ) rot times

Example
ok> [0, -3, 7, 0 ,0 , 14, -1] 0 swap ( not if n:1+ false else true then ) a:filter ( 0 a:push ) rot times .
[-3,7,14,-1,0,0,0]

Tcl, 47 bytes
proc D L {proc S x\ y {expr !$x}
lsort -c S $L}

Try it online!

Tcl, 47 bytes
proc S x\ y {expr !$x}
proc D L {lsort -c S $L}

Try it online!

Tcl, 53 bytes
proc D L {lsort -c [list apply {x\ y {expr !$x}}] $L}

Try it online!

Tcl, 55 bytes
proc S x\ y {expr abs($x)<!$x}
proc D L {lsort -c S $L}

Try it online!

Tcl, 61 bytes
proc D L {lsort -c [list apply {x\ y {expr abs($x)<!$x}}] $L}

Try it online!

Tcl, 70 bytes
proc D L {concat [lsearch -al -inl -not $L 0] [lsearch -al -inl $L 0]}

Try it online!

Failed outgolf: https://tio.run/##LVFBisMwDLz3FUPpVRAnTuz23GNuPZYeginsQrYJbRYWgt@e1cjBhI6kkWakLmnctvk9JdyQsI6f5/BOX5BhhHy/RpwSTpdLjyrjYLQr/rCm6ZWGBfcb5DUtDwPPR97Gn2FGj/WwVmgR9TX669Ap8qg0Chp3iv2OguGzctgRFDWKan3ekNfOoMjtHU4rznL8gkadVWuNW2PVNqnSvOrlwyoOEiCdlaWF1NomDSQqIZq0QqFJ8QwoINTy7DLu2TYRmuQEGorKckw27BCqar7ijMhRjRlolVHbI2mfZVo0KNzXsxTNgy9evN2pXI43YyTm3XGAL0JNGWozK7uZ8OS7n8Co7Hku28QibhvxuiFn/aPm3@WD@xWn/lHw8Zi37R8

Failed outgolf: https://tio.run/##LVFBjoMwDLzzCm/VqyVCAgn3HvuD3T1UaG@siiiVWEV5OzvjoAgYx@Px2GzTfBzL@pzkJnfJ8@u5bqKT5MeyzH@S9y/B@2dfVvm47qUUud7LMf8@FtKb3EovCcfj62QACtIiiogH4HCiaHgEhxURyAN1OMFQQGUEcmeFQ8bZHZ@IaLBsh7g3VmdKLe7RrzRZnWgUHSytvWiHMvWiCYRkrQGVJjUwYANlr8Aq4442idIkFWgogeV46Vmh7Ir7lhqJUt4M9GB0dkg6tawXDSrnDUwl8xCql2B7qpvjzhipeXcUCLWRr6Km2drOlCs//URGdc6xTpNqc5uI2434Z7lZ3ttLPm/4e98VXy7lOP4B

Stax, 4 bytes
{!oJ

Run and debug it
Sort using x!=0 as the key.
5 bytes
╦╤∩öµ

Run and debug it
Filter out zeros and pad to input length.

Pyth, 2 bytes
o!

Test suite
Python 3 translation:
print(sorted(eval(input()),key=lambda x:not x))

Kotlin, 44 bytes
{i:List<Int>->i.sortedBy{if(it==0)1 else 0}}

Try it online!
Explanation
{ i: List<Int> ->             // lambda taking a List<Int> i
    i.sortedBy {              // sort List by the result of function
        if(it == 0) 1 else 0  // if item is 0 return 1 else 0
    }                         // this will sort i ascending
}                             // while leaving 0s at the end

05AB1E, 2 bytes
ΣĀ

Try it online!

Python 2.7, 31 30 bytes
-1 thanks to dennis
Takes input as array.
def f(i):i.sort(key=0..__eq__)

@MuhammadSalman Correct how? The code works, as you can verify in the permalink I left. The function f modifies the array in place.

@Dennis : not that, I know it works, what I meant was whether this comment : "You cannot provide snippet as answer" was correct or not ?

@MuhammadSalman Yes, snippets are disallowed by default. REPL answers are allowed, but they still have to adhere to our defaults for I/O.

Factor, 29 bytes
[ [ sgn abs ] inv-sort-with ]

Try it online!
Inverse sort with key function 0 -> 0, not 0 -> 1.

Interestingly [ [ 0 = ] partition prepend ] has the same byte count.

@Bubbler Nice. All the same, your solution runs an order of magnitude faster. On an array of 100,000 items on my machine, sorting takes around ~40ms in the listener, but partitioning takes ~4ms.

Japt, 3 bytes
ñ¶T

Try it
ñ¶T     :Implicit input of array
ñ       :Sort by
 ¶      :Is equal to
  T     :0

Batch 93 bytes
Input is provided as arguments when running the script in windows cmd.exe
:l
@(Set/A1/%1 2>nul&&Set .=%.%%1 ||set t=%t%%1 )
@If not %1.==. Shift&Goto:l
@Echo %.%%t%

Explainer:
 @Set/A1/%1                   Attempt to Provoke divide by 0 error
 2>nul                        Redirect STDERR to nul
    &&                        If not 0
      Set .=%.% %1            Append to '.' list
    ||                        Else
      'Set t=%t%%1 '          Append to 't'rail list
 @If not %1.==. Shift&Goto:l  If argument remains, Shift Argument, repeat loop
 @Echo %.%%t%                 Output

Note:
@     Suppress command Echo

Raku, 10 bytes
*.sort(!*)

Try it online!
An anonymous function that calls sort on its argument, where the sort-by function is !*, another anonymous function that boolean-inverts its argument.

Desmos, 19 bytes
f(x)=sort(x,0^{xx})

Try it on Desmos!

Erlang 86 bytes
f(L)->M=lists:filter(fun(E)->E /= 0 end,L),M++lists:duplicate(length(L)-length(M),0).

Arturo, 36 29 26 bytes
$=>[arrange&=>[&0compare]]

Try it
-7 bytes from Arturo 0.9.83 providing the arrange function (higher-order sort).
-3 more by using compare over switch.

Go, 111 bytes, using golang.org/x/exp/slices
import."golang.org/x/exp/slices"
func f(I[]int)[]int{SortStableFunc(I,func(a,b int)bool{return b==0});return I}

Attempt This Online!
Go, 199 bytes, using sort
import."sort"
type L[]int
func(l L)Len()int{return len(l)}
func(l L)Less(i,j int)bool{return l[j]==0}
func(l L)Swap(i,j int){l[i],l[j]=l[j],l[i]}
func f(I[]int)[]int{l:=L(I);Stable(l);return[]int(l)}

Attempt This Online!

F#, 28 bytes
Based on the answers that use booleans:
let s=Seq.sortBy(fun x->x=0)

Try it online!
Another longer, but possibly more interesting way, is to use Seq.mapFold for 120 bytes:
let m=Seq.mapFold(fun c n->if n=0 then None,c+1 else Some n,c)0>>fun(i,c)->Seq.concat[Seq.choose id i;Seq.replicate c 0]

which counts and strips out the zeros from the collection, then appends that number of zeros at the end of the collection.
Try this online too!

Vitsy, 18 bytes
lDv\[}D(X]lv-i*\0r

l                  Get length of stack
 Dv                Duplicate and grab for later
   \[    ]         Do everything in the loop that many times.
     }             Rotate the stack right.
      D(X          If the item is 0, delete it.
          lv-i*    Get the value of original length - current length.
               \0  Push that many zeroes.
                 r Reverse the stack.
This leaves the sorted array on the stack.
** Note that this no longer works for the current version! **

GNU Sed, 25
Score includes +1 for use of -E option.
(Almost) direct port of my Retina answer:
:
s/\b0 ([^0].*)/\1 0/
t

Only GNU sed versions from before this commit (discussion)

@sch Dammit - that adds 2 bytes to lots of my sed answers :(

sed, 16 bytes
$G
/[^0]/b
G
h
d

it expects a newline delimited stdin input array

SmileBASIC, 77 64 62 bytes
DEF C A
DIM B[LEN(A)]ARYOP 2,B,A,A
ARYOP 6,B,B,2,1SORT B,A
END

Modifies input array in-place.
Explanation
DEF CONSOLIDATE ARRAY
 DIM B[LEN(ARRAY)] 'create another array of the same length
 ARYOP #AOPMUL,B,ARRAY,ARRAY 'square each element in ARRAY and store the result in B
 ARYOP #AOPCLP,B,B,2,1 'clamp each element in B to be "between" 2 (min) and 1 (max)
 SORT B,ARRAY 'sort A and B, using B
END

ARYOP is a function that does simple operations to entire arrays at once.
My goal is to convert all 0s into one value, and every other number into another value. It is important that 0 turns into a HIGHER value than the other numbers, so they will be placed at the end during sorting.
(It would be simpler to convert non-zero numbers to 1, and leave 0 unchanged, but this doesn't work. There is a RSORT function, but it actually just sorts the array and reverses it, so it would not leave the order of other numbers unchanged.)
First, the negative numbers need to be made positive. The simplest way to do this is by squaring them. The result is stored in B.
Next, these values are clamped into the range [2,1]. Technically this is an invalid range, but it works due to the way clamping is implemented.
if (number >= start)
   number = start
else if (number <= end)
   number = end

Notice that it checks >= rather than >, and that if the first check happens, the second is skipped.
For example:
0 is not greater than or equal to 1, but it is smaller than 2, so it is set to 2.
1 IS greater than or equal to 1, so it is set to 1.
(The second check is skipped, even though 1 is smaller than 2)
2 is greater than or equal to 1, so it is set to 1.
etc.
So now, we have converted all 0s into 2s, and every other number into a 1.
We can now use SORT to sort the input array by our modified array. This will put all the 0s at the end, and leave the nonzero numbers in the same order (SORT uses a stable sorting algorithm)

Husk, 2 bytes
Ö¬

Try it online!
order by negation.


text:
Build a twisted "Hello world!"
Your job is quite simple, write a program that prints Hello, world!, that when twisted creates a program that prints Twister!.
How strings are twisted
The twisting algorithm is very simple. Each column is shifted down by its index (col 0 moves down 0, col 1 moves 1, ...). The column shift wraps to the top. It kinda looks like this:
a
ba
cba
----
 cba
  cb
   c

With everything under the line wrapping to the top. Real example:
Original:
\\\\\\\\\\\\
............
............
............

Twisted:
\...\...\...
.\...\...\..
..\...\...\.
...\...\...\

(Further examples and a twisters in your favorite language are here)
Scoring
Your program must be a padded rectangle. This is code-golf so lowest byte count wins!
Rules

Your first program must print Hello, world!. Only one trailing newline is allowed.
Your first and second programs must be in the same language.
Your second program must print Twister!. Only one trailing newline is allowed.
Your program must have at least 2 rows and 2 columns.

In Jelly's code page, the character that corresponds to (and, for all purposes, acts like) the linefeed has the code point 127 (ASCII DEL). The character with code point 10 (ASCII linefeed) has the glyph ½ and takes the square root of a number. Which one of the two should be considered the newline for this challenge?

Darn, was I the only one that hoped "Twisted Hello World" was using "twisted" in the perverse sense so we'd be outputting something like "Goodbye Cruel World" instead..

@Dennis I suppose the better one to use in this case would be the jelly newline.

@JAtkin OK, thanks for clarifying. I've updated my answer accordingly.

Jelly, 33 31 29 bytes
Original
“ɗ⁻%OḶ$“¡¦ḟṠ»Ṫ
“ɗ⁻%OḶ$“¡¦ḟṠ»Ḣ

Try it online.
Twisted
“ɗ⁻%OḶ$“¡¦ḟṠ»Ḣ
“ɗ⁻%OḶ$“¡¦ḟṠ»Ṫ

Try it online!
How it works
In each program, each line defines a link. The last one is the main link, and it is executed when the program starts. Since there are no references to the first link, it is simply ignored.
For both programs, “ɗ⁻%OḶ$“¡¦ḟṠ» yields the list ['Hello, world!', 'Twister!'], using Jelly's static dictionary compression.
The only difference between the original and the twisted code is the last character of the main link. Ḣ selects the first string of the list, and Ṫ selects the last one.

It looks like it's screaming "Holy Sh*t"

Python 2, 59 bytes
print "  Hello, world!"[ 2::]
#rint "T w i s t e r !"[ ::2]

Twisted:
print "T weils,twerrd!"[ ::2]
#rint "  H l o   o l !"[ 2::]

Basically, puts the Twister! data in the odd indices of the string and then changes from removing the first two (padding) characters to removing every other character instead.

This is so much smarter than my approach

This is kinda ridiculous, 40 upvotes?

@JAtkin I've noticed that some Python solutions tend to get huge amounts of them. Not that I'm complaining :~)

Cooler way: print "  Hello, world!" [2::]

@EʀɪᴋᴛʜᴇGᴏʟғᴇʀ Works, but I'll just keep it as is for now.

Fission, 215 162 56 53 50 bytes
Here is a start:
D1
\\
""
TH
we
il
sl
to
e,
r
!w
"o
1r
;l
1d
;!
 "
Try it online!
When twisted:
D"
\1
"\
T"
wH
ie
sl
tl
eo
r,
!
"w
1o
;r
1l
;d
 !
Try it online!
Explanation
The Hello, world! code is fairly simple:

D spawns a single atom, going downwards.
The two \ (mirrors) deflect it onto the second column.
"Hello, world!" prints the required string.
1 is a portal. It teleports the atom to the next 1 in reading order, retaining its direction (that's the one next to the r).
The atom still moves down, into the ; which destroys the atom and terminates the program.

The control flow for the Twister! code is a bit more... twisted...

Again, D spawns the atom.
\ deflects it to the right, into the 1.
Now the portal sends the atom to the next 1. The atom hits the o which just changes its mass, but we can ignore that. The code wraps around so the atom hits the same 1 again, skipping down two rows. Again, we can ignore the l, the atom wraps around and hits the 1 again. Now there is no further 1 in the code so the atom skips all the way back to the 1 at the top.
After wrapping around the edges once more, the atom is deflected again by \, now going down again.
"Twister!" prints the required code.
1 teleports the atom once more, past the first ;, but there is another ; waiting for it to terminate the program.

Wow, very close now! :) I'm sure there's a way to be shorter...

Why do you guys like fission?

@JAtkin Why wouldn't we? :)

@MartinBüttner I was thinking specifically why for this challenge?

@JAtkin 2D languages seemed suitable, and Fission seemed particularly simple because you can choose one or more arbitrary entry points into the program.

Fission, 35 bytes
Fission approach #3 (#4 counting the one I edited out of my first post).
R"Hello, " \"tri"
T;L"!dlrow"/"es!w

Try it online!
R;H"ldor w /"er!"
T"Le!ll,o""\"tsiw

Try it online!
Explanation
This one is actually the simplest of the Fission solutions yet. In both programs there are two entry points: R creates a right-going atom and L a left-going atom. In either case, the ; destroys one of them immediately.
Now in the Hello, world! program, the atom first prints half the string with "Hello, ", then \ and / (which are mirrors) deflect the atom onto the second line going left. "world!" (read in the direction of the moving atom) prints the rest of the string. L is now a no-op and ; destroys this atom as well, terminating the program.
The Twister! program is essentially the same but rotated by 180 degrees. This time, the L atom survives, and starts printing with "Twist". The \ and / again deflect it onto the other line, now going right. "er! prints the remainder of the string, R is a no-op and ; terminates the program.

Amazing! I think this is about as small as it can get, the amount of reuse is  impressive.

Fission, 53
R"Hello, world!";
R;."..!..!!.!".\.
.;T..w..i".se.t/.

Try it online!
and twisted:
R;.e..o..w..l..".
R"T"lw!,i!os!dt\;
.;H..l.. "!re"!/.

Try it online!

Python, 398 414 380 456 bytes*
Managed to update so that it is compliant with the rules, but I still hesitate to call this competitive.  Since the commented lines are needed for it to run, I've included them in the byte count
This solution does not follow the rules, as it will print error messages in addition to the allowed output.
I just wanted to see if this could be done in python.  It can, but it is not pretty.
print'Hello, world!'
#rint'Twister!'
#rint'Twister!'
#rint'Twister!'
#rint'Twister!'
#rint'Twister!'
#rint'Twister!'
#rint'Twister!'
#rint'Twister!'
#rint'Twister!'
#rint'Twister!'
#rint'Twister!'
#rint'Twister!'
#rint'Twister!'
#rint'Twister!'
#rint'Twister!'
#rint'Twister!'
#rint'Twister!'
#rint'Twister!'

When twisted becomes
print'Twister!'
#rint'Twister!'
#rint'Twister!'
#rint'Twister!'
#rint'Twister!'
#rint'Twister!'
#rint'Hwister!'
#rint'Teister!'
#rint'Twlster!'
#rint'Twilter!'
#rint'Twisoer!'
#rint'Twist,r!'
#rint'Twiste !'
#rint'Twisterw'
#rint'Twister!o
#rint'Twister!'r
#rint'Twister!' l
#rint'Twister!'  d
#rint'Twister!'   !

I think you could remove the space in each line, then remove the last line altogether.

I didn't think to do that since it was against the rules of the initial twisting challenge, but thanks!

You forgot to update the code ;)

I figured it wouldn't really matter, but I did it for good measure

I think you have misunderstood. The code is required to be a padded rectangle, but you can remove the space from rint ' on every line.

You are absolutely right, silly me

@wnnmaw The only thing to fix now is the excessively long bytecount.

@EʀɪᴋᴛʜᴇGᴏʟғᴇʀ, interesting my usual counter comes up with a different count... wonder why?

@wnnmaw That one is completely broken, so use mothereff.in

Japt, 67 61 57 bytes
Saved 6 bytes thanks to @JAtkin, 4 bytes thanks to @Ian
"Tzwzizsztzezzzzzzrzzzz!"rz;
"Hzezlzlzoz,z zwzorlzdz!"rz;

Twisted:
"Hzezlzlzoz,z zwzorlzdz!"rz;
"Tzwzizsztzezzzzzzrzzzz!"rz;

Test it online: Original, Twisted
How it works
"Tzwzizsztzezzzzzzrzzzz!"rz;  // Take this string and remove all "z"s.
"Hzezlzlzoz,z zwzorlzdz!"rz;  // Take this string and remove all "z"s.
                              // Implicit: output *last* expression

If this works like I think it does, you can remove the trailing space after Twister! by replacing the spaces with ..

@JAtkin It actually doesn't work like that, but I can save a bunch of bytes that way. Thanks!

"T.w.i.s.t.e.r.!. . . . . "k".(newline)"H.e.l.l.o.,. .w.o.r.l.d.!"k".

Could be much easier to read with a different filler character...

@mbomb007 Since when is "easy to read" an achievement? :D

C (gcc), 87 bytes
Untwisted
main(){puts(1?"Hello, world!":"Twister!");}
mai (){puts(0?"Hello, world!":"Twister!");}

Try it online!
Twisted
mai (){puts(1?"Hello, world!":"Twister!");}
main(){puts(0?"Hello, world!":"Twister!");}

Try it online!

Brainfuck, 467 367 285 bytes
Untwisted
 +[  [[-->-[>>+>-----<<]<--<---]>-.>>>+.>>..+++[.>]<<<<.+++.------.<<-.>>>>+.>>] [[--[<++++>--->+<]>-]<<<<.<<<-.<<+.>-.+.<----.>--.>>---.[-]]]
  [ -[[-->-[>>+>-----<<]<--<---]>-.>>>+.>>..+++[.>]<<<<.+++.------.<<-.>>>>+.>>]+[[--[<++++>--->+<]>-]<<<<.<<<-.<<+.>-.+.<----.>--.>>---.[-]]]

Try it online!
Twisted
  [  [[-->-[>>+>-----<<]<--<---]>-.>>>+.>>..+++[.>]<<<<.+++.------.<<-.>>>>+.>>] [[--[<++++>--->+<]>-]<<<<.<<<-.<<+.>-.+.<----.>--.>>---.[-]]]
 +[ -[[-->-[>>+>-----<<]<--<---]>-.>>>+.>>..+++[.>]<<<<.+++.------.<<-.>>>>+.>>]+[[--[<++++>--->+<]>-]<<<<.<<<-.<<+.>-.+.<----.>--.>>---.[-]]]

Try it online!

You can save bytes by using the current shortest known "Hello, world!" program

@JoKing Thank you for the suggestion! Any ideas how to find a smaller "Twister!" program as well?

Using bf-crunch I can get a 56 byte "Twister!" program

source: Stack Exchange

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

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

sort: votes


text:
Spiral Permutation Sequence
We can roll up the natural numbers in a rectangular spiral:
 17--16--15--14--13
  |               |
 18   5---4---3  12
  |   |       |   |
 19   6   1---2  11
  |   |           |
 20   7---8---9--10
  |
 21--22--23--24--25

But now that we have them on a rectangular grid we can unwind the spiral in a different order, e.g. going clockwise, starting north:
 17  16--15--14--13
  |   |           |
 18   5   4---3  12
  |   |   |   |   |
 19   6   1   2  11
  |   |       |   |
 20   7---8---9  10
  |               |
 21--22--23--24--25

The resulting sequence is clearly a permutation of the natural numbers:
1, 4, 3, 2, 9, 8, 7, 6, 5, 16, 15, 14, 13, 12, 11, 10, 25, 24, 23, 22, 21, 20, 19, 18, 17, ...

Your task is to compute this sequence. (OEIS A020703, but spoiler warning: it contains another interesting definition and several formulae that you might want to figure out yourself.)
Fun fact: all 8 possible unwinding orders have their own OEIS entry.
The Challenge
Given a positive integer n, return the nth element of the above sequence.
You may write a program or function, taking input via STDIN (or closest alternative), command-line argument or function argument and outputting the result via STDOUT (or closest alternative), function return value or function (out) parameter.
Standard code-golf rules apply.
Test Cases
1       1
2       4
3       3
4       2
5       9
6       8
7       7
8       6
9       5
100     82
111     111
633     669
1000    986
5000    4942
9802    10000
10000   9802

For a complete list up to and including n = 11131 see the b-file on OEIS.

Jelly, 11 10 bytes
’Æ½ð²+ḷ‘Ḥ_

Another Jelly answer on my phone.
’Æ½ð²+ḷ‘Ḥ_   A monadic hook:
’Æ½          Helper link. Input: n
’             n-1
 Æ½            Atop integer square root. Call this m.
   ð         Start a new dyadic link. Inputs: m, n
    ²+ḷ‘Ḥ_    Main link:
    ²+ḷ       Square m, add it to itself,
       ‘      and add one.
        Ḥ     Double the result
         _    and subtract n.

Try it here.

Any tips on getting started with Jelly? I can't tell how the forks/hooks get parsed at all.

Learn APL or J first. Chains are actually easier than trains because the functions all have fixed arity.

I see. Yeah, I have J experience. I suppose I will try to read jelly.py and figure out which chains are supported.

How the hell did you type that on your phone!? That's more impressive than the code itself is!

Japt, 20 19 16 bytes
V=U¬c)²-V *2-U+2

Test it online!
Based on the observation that

 F(N) = ceil(N^.5) * (ceil(N^.5)-1) - N + 2

Or, rather, that

 F(N) = the first square greater than or equal to N, minus its square root, minus N, plus 2.

I don't know if this explanation is on the OEIS page, as I haven't looked at it yet.

Julia, 28 bytes
n->2((m=isqrt(n-1))^2+m+1)-n

This is a lambda function that accepts an integer and returns an integer. To call it, assign it to a variable.
We define m to be the largest integer such that m2 ≤ n-1, i.e. the integer square root of n-1 (isqrt). We can then simplify the OEIS expression 2 (m + 1) m - n + 2 down to simply 2 (m2 + m + 1) - n.
Try it online

CJam, 14 bytes
qi_(mQ7Ybb2*\-

Using Alex's approach: 2*(m^2+m+1)-n where m = isqrt(n-1).

ES7, 31 28 26 bytes
n=>(m=--n**.5|0)*++m*2-~-n

I had independently discovered Alex's formula but I can't prove it because I wasn't near a computer at the time.
Edit: Saved 3 bytes partly thanks to @ETHproductions. Saved a further 2 bytes.

n=>((m=--n**.5|0)+m*m)*2-n+1 would work, I think.

@ETHproductions Thanks, I was wondering to myself how to get that --n in there...

@ETHproductions Heh, I managed to shave 2 bytes from your answer.

APL (Dyalog Extended), 25 19 14 bytes
{2⊥⍨3⍴⌊√⍵-1}-⊢

-6 bytes from Adám.
-5 bytes from Bubbler.
Try it online!
A direct implementation of the last function mentioned on the OEIS page:
\$a(n)=2×\Big(\big\lfloor\sqrt{n-1}\big\rfloor+1\Big)×\big\lfloor\sqrt{n-1}\big\rfloor-n+2\$
Explanation:
{(2-⍵)+2×(1+⌊√⍵-1)×⌊√⍵-1} ⍵ → n
                   ⌊√⍵-1  floor of root of n-1
         (1+⌊√⍵-1)×       times 1 + floor of root of n-1
       2×                 times 2
 (2-⍵)                    plus 2-n

Try it online!

If you remove the redundant parentheses (remember APL's long right-scope, a.k.a. "right-to-left" rule), you may find that you've not translated the formula right.

yup, it was wrong. I think this solution works correctly. Thanks for telling me.

19: {2-⍵-2×1(+×⊢)⌊√⍵-1}

I think {2⊥⍨3⍴⌊√⍵-1}-⊢ should work?

Yup it does. Try it online!

Explaining the 14-byte solution is left as an exercise to the reader. :P

I am almost as confused as the readers at this point

Pyth, 21 bytes
K2-h+^.E@QKK^t.E@QKKQ

Try it online!
Nothing fancy going on. Same method as in the JAPT answer.

MATL, 16 13 bytes
qX^Y[tQ*Q2*G-

Based on Lynn's CJam answer.
Try it online! (Y[ has been replaced by k according to changes in the language)
q       % input n. Subtract 1
X^      % square root
Y[      % floor
tQ      % duplicate and add 1
*       % multiply
Q       % add 1
2*      % multiply by 2
G-      % subtract n

This uses a different approach than other answers (16 bytes):
6Y3iQG2\+YLt!G=)

It explicitly generates the two spiral matrices (actually, vertically flipped versions of them, but that doesn't affect the output). The first one is
17    16    15    14    13
18     5     4     3    12
19     6     1     2    11
20     7     8     9    10
21    22    23    24    25

and the second one traces the modified path:
25    10    11    12    13
24     9     2     3    14
23     8     1     4    15
22     7     6     5    16
21    20    19    18    17

To find the n-th number of the sequence it suffices to find n in the second matrix and pick the corresponding number in the first. The matrices need to be big enough so that n appears, and should have odd size so that the origin (number 1) is in the same position in both.
Try it online too! (6Y3 has been moved according to changes in the language)
6Y3      % 'spiral' string
i        % input n
QG2\+    % round up to an odd number large enough
YL       % generate spiral matrix of that size: first matrix
t!       % duplicate and transpose: second matrix
G=       % logical index that locates n in the second matrix
)        % use that index into first matrix

Brachylog, 20 bytes
-1$r$[I*I+I+1=*2-?=.

This uses the same technique as pretty much all other answers.
Explanation
-1                   § Build the expression Input - 1
  $r                 § Square root of Input - 1
    $[I              § Unify I with the floor of this square root
       *I+I+1        § Build the expression I * I + I + 1
             =*2-?   § Evaluate the previous expression (say, M) and build the expression
                     § M * 2 - Input
                  =. § Unify the output with the evaluation of M * 2 - Input

A midly interesting fact about this answer is that it is easier and shorter to use = rather than parentheses.

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


text:
The confused twister
The basic idea is to write a program that twists itself, and the twisted version untwists itself. The first program will just be the twisting algorithm described here, and when given its own source code as input, outputs a program that reverses the twisting algorithm.
How strings are twisted
The twisting algorithm is very simple. Each column is shifted down by its index (col 0 moves down 0, col 1 moves 1, ...). The column shift wraps to the top. It kinda looks like this:
a
ba
cba
----
 cba
  cb
   c

With everything under the line wrapping to the top. Real example:
Original:
\\\\\\\\\\\\
............
............
............

Twisted:
\...\...\...
.\...\...\..
..\...\...\.
...\...\...\

(Further examples are here)
Input
Input is either an array of strings, or a multi-line string. All lines have the same length.
Output
The (un)twisted string, multi-line output to std-out (or closest alternative).
Example
I'm not quite sure what this is written in but oh well ;)
Twisting:
magic  TwistingAlgo
magic ntwistingAlgo
magicU twistingAlgo

Untwisting:
magic  twistingAlgo
magicUnTwistingAlgo
magic  twistingAlgo

Other notes

Your first and second program must be in the same language.
The programs must work for any input, not just itself.
Your program must have at least 2 rows and 2 columns.

CJam, 21 bytes
qN/zee::m>
zN*z e#: <

Test it here.
When you twist it, you get:
qN/zee::m<
zN*z e#: >

Explanation
This is based on my CJam answer to the original challenge and works basically the same.
The e# is a comment, so we can ignore it and the stuff after it. The means the code boils down to
qN/zee::m>zN*z

Which is the same as in the previous answer, plus a trailing z which just wraps the string in an array but that doesn't affect the output.
Notice that the two rows match up in all columns which are rotated (N, z, e, :) except for the last one. That means all the twisting will do is swap > and < which switches the direction of the column rotation.

Japt, 63 bytes
Uy m@XsV=(Y*Xl +Y %Xl)+X¯V}R y;
Uy m@XsV=(Y*Xl -Y %Xl)+X¯V}R y;

Twisted:
Uy m@XsV=(Y*Xl -Y %Xl)+X¯V}R y;
Uy m@XsV=(Y*Xl +Y %Xl)+X¯V}R y;

Test it online: Original, Twisted
How it works
I hadn't posted yet on the original twisting challenge, but the shortest answer I could come up with is 31 bytes:
Uy m@XsV=(Y*Xl -Y %Xl)+X¯V}R y;

The untwisting algorithm I came up with is a lot shorter:
Uy m@XsV=Y%Xl)+X¯V}R y;

However, this won't work very well when intertwined with the other program. Fortunately, there's a way to make the two more similar:
Uy m@XsV=(Y*Xl -Y %Xl)+X¯V}R y;
Uy m@XsV=(Y*Xl +Y %Xl)+X¯V}R y;

Now all that's different between the two is the +/-, which is already properly aligned to switch places when twisted!
Uy m@XsV=(Y*Xl -Y %Xl)+X¯V}R y;
Uy        // Transpose rows and columns in U.
m@     }R // Map each item X and index Y in the result, split at newlines, to:
Y*Xl -Y   //  Take Y times X.length and subtract Y.
%Xl)      //  Modulate the result by X.length.
XsV=      //  Set V to the result of this, and slice off the first V chars of X.
+X¯V      //  Concatenate this with the first V chars of X.
y;        // Transpose the result again.
          // Implicit: output *last* expression

I really didn't envision this being that simple... When I was thinking about how to do this I was writing in groovy, not a golfing language.

@JAtkin Yep, I didn't realize it at first, but the best way to go about this seems to be make flipping the +/- the only difference between the algorithms, then align the programs so that this will happen. This might not work in languages like Groovy though, because of the manual output.

Haskell, 235 bytes
main=interact$unlines.g.lines;g l@("":_)=l; g l|t<-tail<$>l,n<-length t=zipWith(:)(head<$>l)$ g$take n$drop(n-1)$t++t
maim=interact$unlines.h.lines;h l@("":_)=l; h l|t<-tail<$>l,n<-length t=zipWith(:)(head<$>l)$ h$take n$drop(2-1)$t++t

and twisted by itself:
maim=interact$unlines.g.lines;g l@("":_)=l; g l|t<-tail<$>l,n<-length t=zipWith(:)(head<$>l)$ g$take n$drop(n-1)$t++t
main=interact$unlines.h.lines;h l@("":_)=l; h l|t<-tail<$>l,n<-length t=zipWith(:)(head<$>l)$ h$take n$drop(2-1)$t++t

This is a full program. Both lines are mostly the same so that they are not messed up. The differences are:
normal  twisted
=================================
main=   maim=     -- after twisting the second lines defines the main function
maim=   main=     -- the other defines an unused function maim

g       g         -- As I cannot define a function (say f) multiple times,
h       h         -- I need different names for the function in both lines

n-1     n-1       -- this is for the different functionalities (twisting up /
2-1     2-1       -- twisting down). When calling g/h recursively I go with the
                  -- rest of each input line. To twist down, I drop (length n) -1
                  -- chars of two copies of the line. To twist up, I drop 2-1 chars
                  -- Then cut to the original length.
                  --
                  -- e.g.  2222    two     2222    twist   4444    twist   3333
                           3333    copies  3333    down    2222    up      4444
                           4444            4444    ->      3333    ->      2222
                                           2222    drop 2          drop 1
                                           3333
                                           4444


text:
Say What You See
The "Look and say" or "Say what you see" sequence is a series of numbers where each describes the last.
1
11 (one one)
21 (two ones)
1211 (one two, one one)
111221 (one one, one two, two ones)
312211 (three ones, two twos, one one)

and on and on...
https://oeis.org/A005150
Anyway, this is a regular code golf challenge (least byte count wins) to make a program that takes two arguments, an initial number and the amount of iterations. For example if you plugged in "1" and "2" the result would be "21". If you plugged in "2" and "4" the result would be "132112". Have fun!

Can we receive/return a list of digits?

I'd close the older questions as dupes if necessary; this doesn't have the restrictions.

I don't see this as a duplicate. Both the previous look and say challenges were very restrictive (one with no numbers in the source code, the other with no named variables, named functions or named arguments). Very few languages will allow answers to the previous challenges that are also competitive here.

Are we allowed to output as a list of numbers?

Discussion on meta about duplicates without restrictions

Are the inputs meant to be strings or ints?

Three ones, two twos, and two ones??? The last line might be wrong.

Pyth, 10 8 bytes
-2 bytes by @FryAmTheEggman
ussrG8Qz

Explanation:
            Implicit: z=first line as string, Q=second line
u         the result of reducing lambda G:
  s s rG8   flattened run-length-encoded G
  Q       Q times
  z     starting with z

Try it here.

But at least I don't output brackets and commas; only spaces between the numbers :-P

In Soviet Russia, ussrG8Qz

CJam, 8 bytes
q~{se`}*

Input format is the initial number first, iterations second, separated by some whitespace.
Test it here.
Explanation
q~   e# Read and evaluate input, dumping both numbers on the stack.
{    e# Run this block once for each iteration...
  s  e#   Convert to string... in the first iteration this just stringifies the input
     e#   number again. In subsequent iterations it flattens and then stringifies the
     e#   array we get from the run-length encoding.
  e` e#   Run-length encode.
}*

The array is also flattened before being printed so the result is just the required number.

JavaScript, 57 bytes
F=(a,b)=>b?F(a.replace(/(.)\1*/g,c=>c.length+c[0]),b-1):a

Recursion works well for this problem. The first parameter is the initial number as a string, and the second is the number of iterations.

You can save three bytes with a weird recursive curry: b=>F=a=>b--?F(a.replace(/(.)\1*/g,c=>c.length+c[0])):a Found that while golfing my answer before I realized it was pretty much identical to yours ;)

R, 87 bytes
function(a,n){for(i in 1:n){r=rle(el(strsplit(a,"")));a=paste0(r$l,r$v,collapse="")};a}

Ungolfed & explained
f=function(a,n){
    for(i in 1:n){                      # For 1...n
        r=rle(el(strsplit(a,"")))       # Run length encoding
        a=paste0(r$l,r$v,collapse="")   # concatenate length vector and values vector and collapse
    };
    a                                   # print final result
}

MATL, 9 bytes
:"Y'wvX:!

Inputs are: number of iterations, initial number.
Try it online!
:      % implicit input: number of iterations. Create vector with that size
"      % for loop
  Y'   %   RLE. Pushes two arrays: elements and numbers of repetitions.
       %   First time implicitly asks for input: initial number
  w    %   swap
  v    %   concatenate vertically
  X:   %   linearize to column array
  !    %   transpose to row array
       % implicitly end loop
       % implicitly display

If you can output as an array then Pyth has 8.

@ThomasKwa Good point. I assumed it was possible

Ruby, 63 bytes
A full program, since the question seems to ask for that. Takes input as command line arguments.
i,n=$*
n.to_i.times{i=i.gsub(/(.)\1*/){"#{$&.size}#$1"}}
puts i

No, gsub! can't be used, since the strings in $* are frozen :/

Could you perhaps use the -p flag to save bytes? If you use it, gsub operates on a line of STDIN as if it were $_.gsub!. Then the command line argument is the iterations, so n,=$*, and the other input is read from STDIN.

R, 61 57 bytes
-4 thanks to @JayCe, just when I was sure it couldn't be done any simpler!
f=function(a,n)`if`(n,f(t(sapply(rle(c(a)),c)),n-1),c(a))

Try it online!

Slightly golfed: TIO

That t(sapply(z,c)) call is clever.

Perl 6, 63 bytes
say (@*ARGS[0],*.trans(/(.)$0*/=>{$/.chars~$0})…*)[@*ARGS[1]]

This is as short as I could get it for now, there might be some tricky flags that could reduce it, I'm not sure

Retina, 46 45 27 bytes
Martin did lots to help golf this.
+`(\d)(\1?)*(?=.*_)_?
$#2$1

Try it online
Takes input in the format:
<start><count>

<start> is the initial number.
<count> is in unary, all underscores, and is how many iterations are performed.
Single iteration, 20 16 bytes:
(\d)(\1?)*
$#2$1

Haskell, 62 bytes
import Data.List
0%y=y
x%y=do x<-group$(x-1)%y;[length x,x!!0]

Try it online!

JavaScript ES6, 71 bytes
(m,n)=>[...Array(n)].map(_=>m=m.replace(/(.)\1*/g,x=>x.length+x[0]))&&m

Takes input as a string and a number.

Perl 5, 50 bytes
$_=pop;for$i(1..pop){s/(.)\1*/length($&).$1/ge}say

The arguments are in reverse order (number of iterations then seed). Example:
> perl -E'$_=pop;for$i(1..pop){s/(.)\1*/length($&).$1/ge}say' 4 2
132112
> perl -E'$_=pop;for$i(1..pop){s/(.)\1*/length($&).$1/ge}say' 0 2
2
> perl -E'$_=pop;for$i(1..pop){s/(.)\1*/length($&).$1/ge}say' 2 0
1110
> perl -E'$_=pop;for$i(1..pop){s/(.)\1*/length($&).$1/ge}say' 1 10
1110
> perl -E'$_=pop;for$i(1..pop){s/(.)\1*/length($&).$1/ge}say' 11 1
3113112221232112111312211312113211

As a subroutine, I can shave a byte by ending it with $_ instead of say, I suppose, but I haven't tested it. The current solution is a program.

Jelly, 6 bytes
ŒrUFµ¡

Try it online!
           Implicit input: first argument.
     µ¡    Do this to it <second argument> times:
Œr            Run-length encode into [value, times] pairs
  U           Flip them
   F          Flatten list

Python 3.6, 100 98 93 bytes
import re
f=lambda s,n:n and eval("f'"+re.sub(r'((.)\2*)',r'{len("\1")}\2',f(s,n-1))+"'")or s

Try it online!
Note this creates a lambda that takes a string and an integer, and returns a string. Example: f('1', 5) == '312211'
Finds all repeated characters (((.)\2*) regex), makes a f-string out of their length and the character itself (r'{len("\1")}\2'), then evaluates it. Uses recursion on the counter (n and ...f(s,n-1)... or s) to avoid having to define a proper function and a loop.

Mathematica, 81 73 bytes
FromDigits@Nest[Flatten[(Tally/@Split@#)~Reverse~3]&,IntegerDigits@#,#2]&

Prepend your code with four spaces to get it show up as code :)

Perl, 38 + 2 bytes
for$i(1..<>){s/(.)\1*/(length$&).$1/ge}

Requires the -p flag:
$ perl -pe'for$i(1..<>){s/(.)\1*/(length$&).$1/ge}' <<< $'1\n5'
312211

Input is a multi line string:
input number
numbers of iterations

If all the steps are required as well then we can change it to the following, which is 44 + 2 bytes:
$ perl -nE'for$i(1..<>){s/(.)\1*/(length$&).$1/ge,print}' <<< $'1\n5'
11
21
1211
111221
312211

This is miscounted.  There are 39 bytes of code here.  It can get down to 38 by using $&=~y///c instead of (length$&).

05AB1E, 9 bytes (Non-competing)
Corrected due to Emigna's comments, see below/edits.
F.¡vygyÙJ

Try it online!

I think you missed the part about taking 2 arguments (initial number and number of iterations). Luckily you can just add F at the beginning and take the arguments as iterations,initialNo

And the byte lost by that could be regained by replacing Dgs with gy.

@Emigna what's y do in that context?

Same as the first y, push the current value in the loop. So instead of duplicating y and swapping it to the top, you just push it again when you need it.

@Emigna it should seem I still have a lot to learn haha.

Stax, 10 bytes
Çα▲ì4↔┌j█♀

Run and debug online!
Spent too many bytes on proper IO format ...
Explanation
Uses the unpacked version to explain.
DE|R{rm:f$e
D              Do `2nd parameter` times
 E             Convert number to digits
                   Starting from the `1st parmeter`
  |R           Convert to [element, count] pairs for each run
    {rm        Revert each pair
       :f      Flatten the array
         $     Convert array to string of digits
          e    Convert string of digits to integer

The essential part is D|R{rm:f(8 bytes).
If the first input can be taken as an array of digits, the whole program can be written in 9 bytes: Run and debug online!

-1 if you use $ instead of :f

K (ngn/k), 30 bytes
{y{,/{(#x;*x)}'(&~=':x)_x}/,x}

Try it online!

J, 26 bytes
2&([:;](#<@,{.);.1~1,~:/\)

Try it online!

05AB1E, 6 bytes
FÅγøí˜

Try it online!
FÅγøí˜  # full program
F       # for N in [0, 1, ...,
        # ..., implicit input...
F       # ... minus 1]...
     ˜  # flatten...
   ø    # zipped...
 Åγ     # list of chars used in runs of the same char in...
        # implicit input...
 Åγ     # or top of stack if not first iteration...
   ø    # with...
 Åγ     # list of lengths of runs of the same char in...
        # implicit input...
 Åγ     # or top of stack if not first iteration...
    í   # with each element of the list reversed
        # (implicit) exit loop
        # implicit output

øí can also be sø with no change in functionality. Try it online!

Husk, 11 bytes
!¡(dṁ§eL←gd

Try it online!
!              # get the arg2-th element of
 ¡             # the infinite list by repeatedly applying
               # (starting with arg1):
  (d           # get the digits of
    ṁ          # applying to each of
         gd    # the groups of identical neighbouring digits:
     §eL←      # combine length + first element

Go, 175 bytes
import."fmt"
func g(n int,s string)string{for N:=0;N<n;N++{c,o,f,k:=1,"",rune(s[0]),s[1:]+"_"
for _,r:=range k{if r==f{c++}else{o+=Sprintf("%d%c",c,f);f,c=r,1}}
s=o}
return s}

Attempt This Online!
A non-recursive port of Ogaday's answer.

J-uby, 41 bytes
Takes curried arguments with number of iterations first.
:**&(~(:gsub+:+%[:+@|S,~:[]&0])&/(.)\1*/)

Attempt This Online!
Non-regex solution, 47 bytes
:**&(A|:slice_when+:!=|:*&-[:+@,~:[]&0]|~:*&"")

Attempt This Online!

Vyxal, 31 bitsv2, 3.875 bytes
(øeRf

Try it Online!
Bitstring:
0011010110011001011100101001100

inputs are reversed

Japt -h, 14 bytes
ÆV=ìÈòÎcÈâ iXÊ

Try it

YASEPL, 132 bytes
=p'=n'(+`2£s©1`1=q)""=x=l®"p"`3=t$x!h¥t,"p"`4!x+}1,l,5!y¥x,"p"}3,h,4`5!f$x-tſ""!q+f+h!x}2,l,3!n-!p$q<!o$p(!s©o!pſ""!n}!s<!i+}2,n,2

prompts you twice. enter starting number and amount of iterations

Python 3, 138 bytes
I used a recursive approach.
def g(a,b):
 if b<1:return a
 else:
  c,n=1,'';f,*a=str(a)+'_'
  for i in a:
   if i==f:c+=1
   else:n+=str(c)+f;f,c=i,1
  return g(n,b-1)

The function accepts two ints, a and b as described.
I'm amazed at how terse the entries here are! Maybe someone will come along with a better Python method too.

Pylons, 11
i:At,{n,A}j

How it works:
i      # Get input from command line.
:A     # Initialize A
  t    # Set A to the top of the stack.
,      # Pop the top of the stack.
{      # Start a for loop.
 n     # Run length encode the stack.
  ,    # Seperate command and iteration
   A   # Repeat A times.
    }  # End for loop.
j      # Join the stack with '' and print it and then exit.

SmileBASIC, 100 98 bytes
DEF S N,T?N
WHILE""<N
C=C+1C$=SHIFT(N)IF C$!=(N+@L)[0]THEN O$=O$+STR$(C)+C$C=0
WEND
S O$,T-T/T
END

Prints out all the steps.
T/T is there to end the program when T is 0.

APL (Dyalog Classic), 22 bytes
{∊(≢,⊃)¨⍵⊂⍨1,2≠/⍵}⍣⎕,⎕

Try it online!

Retina, 27 bytes
~(`^
K`
$
+`(.)\1$*¶$$.&$$1

Try it online!

05AB1E, 7 bytes
FÅγs.ιJ

Try it online!

GolfScript, 32 bytes
~{-1%1/(1@{.3$={;)}1if}/]{\+}*}*

Try it online!
Input with first arg as string, +2 bytes for first arg as num:
~{`-1%1/(1@{.3$={;)}1if}/]{\+}*~}*


text:
Code Golf Pro Golfer Least Swings Calculator
Your Challenge:
For a golf Course Of Inputted 'n' length to hole where:
'n' is a whole number and a multiple of 5 between 150 and 500
and
1 integer in code = 1 metre

You must calculate the least amount of swings it can be completed in using a combination of clubs and ranges.
Here is a visual representation of what this calculator will be working out (in colours):

Disregarding nature and swing paths, you are to find the fewest number of swings.
Firstly, you must have a 'Men Or Women' Option as shown in the pseudocode below:
INPUT <- "Men Or Women"

Each club option has Two Values. These are the ranges of the distance in which the club's shot may fall. This calculator assumes the player is a pro and can choose how far the shot goes in the range.
~It can only be in multiples of 5~
Higher towards the range of one club overrules Lower towards the range of another.
Club       Men     Women
Driver  200-260   150-200
3-wood  180-235   125-180
5-wood  170-210   105-170
2-iron  170-210   105-170
3-iron  160-200   100-160
4-iron  150-185    90-150
5-iron  140-170    80-140
6-iron  130-160    70-130
7-iron  120-150    65-120
8-iron  110-140    60-110
9-iron   95-130    55-95
PW       80-120    50-80
SW       60-100    40-60
putter   10-30     10-20

The input must ask for course length and gender separately, and then calculate and then display the output, which must start with displaying gender, and then look like a list (in order of the clubs to be used and the distance hit.
The final Value Must Be A Putter Distance implying it has
EG:
(Gender):

(n)m Course

Driver (x)m
4-iron (x)m
3-iron (x)m
putter (x)m

Please Be Aware This is just an example as it could include any combination of clubs.
Finally:
If there is more than one answer, then all must be displayed with a title above exclaiming the answer like so:
(Gender):

(n)m Course

Run 1:

Driver (x)m
4-iron (x)m
3-iron (x)m
putter (x)m

Run 2:

Driver (x)m
4-iron (x)m
3-iron (x)m
putter (x)m

and so on...

Please be aware, except at weekends, I am unable to check comments between 0800 and 1600 GMT. If you leave one, I will get back to you as soon as I can


text:
Do you need a cup holder?
You're going to replicate the 90's cup holder joke software.
Here's what's it did, and you have to do:

Display the message Do you need a cup holder?
If the user confirms, enter an infinite loop that keeps opening the CDROM drive.
If the user doesn't confirm, silently exit.

You may display the message using either a console message (confirmation is y, decline is n), or display a message window with the two options "Yes" and "No". You can assume the default (or most common) CDROM drive (D: on Windows, /cdrom on linux etc.). Standard loopholes (except built-ins) are forbidden. No additional input nor output may be involved. If your PC has no physical drive, or another "style" of tray, make sure the program is valid.
code-golf, so shortest program in bytes wins.
Trivia: The loop is there to prevent anyone from closing the drive. On desktop drives, the re-open command will be sent while the drive is closing, therefore staying open and not "spilling the coffee".

Minus the necessary CD eject system call, I think this is strikingly similar to http://codegolf.stackexchange.com/questions/62732/implement-a-truth-machine

I think the requirement to interact with the hardware makes this sufficiently distinct from Implement a Truth Machine.

FYI http://meta.codegolf.stackexchange.com/a/8214/8478 (specifically "having long fixed output strings that benefit from compression.").

Bash, 115 69 68 66 bytes
This was written on Mac OS X but it should work on other BSD-based systems as well.
echo Do you need a cup holder?;sed 1q|grep y&&yes drutil\ eject|sh

We echo the prompt, get input with set 1q, and determine whether the user confirmed with grep y. If the user said y, we pipe the infinite output of yes with the string drutil eject to the shell, which will continuously eject the disk tray.
Saved 50 bytes thanks to Digital Trauma!

@DigitalTrauma You are the bash master!

Can you save bytes by replacing the sed and grep with read?

Shouldn't it be drutil tray eject?

@VoteToClose drutil eject is a synonym for drutil tray open. It works as expected. ;)

@CousinCocaine I was using read in a previous revision, but then I'd need an equality check, which makes it longer overall. You can take a look at the revision history to see what I mean.

Vitsy + Mac OSX bash, 55 bytes
'?redloh puc a deen uoy oD'ZWb2^/([1m]
<,'drutil eject'
Expects input as y or n. If it is n, it will execute line 2 (infinite loop with the shell command), otherwise, it will halt.

Python (3.5) 84 bytes
import os
i=input("Do you need a cup holder?")
while i=='y':os.system("eject cdrom")

On linux
edit: fix bytes count ;)

FYI: I noticed this because I'm using this script, which (among other things) adds a byte/char counter above blocks of code on PPCG.

AutoIt, 85 bytes
If MsgBox(4,0,"Do you need a cup holder?")=7 Then Exit
Do
CDTray("D:","open")
Until 0

No one will ever answer anything in AutoIt anyway :)

Python 3.5 on Windows 7, 135 Bytes
import ctypes
r=input('Do you need a cup holder?')
while r=='y':ctypes.windll.WINMM.mciSendStringW('set cdaudio door open',None,0,None)