text:
The sea in your terminal
Background
Summer is well over in the Northern Hemisphere, and a lot of us miss the sun, the beaches, the waves of the ocean... This challenge aims at cheering them up by reminding them of the sea.
The challenge
Here is the sea :
             **              **              **              **              **
         ****            ****            ****            ****            ****
      *****           *****           *****           *****           *****
    **   **         **   **         **   **         **   **         **   **
  **      **      **      **      **      **      **      **      **      **
**          ******          ******          ******          ******          ****

The sea is made of 5 times this wave pattern :
            **
        ****
     *****
   **   **
 **      **
*          *****

Note that the pattern is 16 characters long, and the sea is 5 times this pattern = 80 characters long.
Which you can print into a terminal using this command-line :
perl -e 'print "            **  \n        ****    \n     *****      \n   **   **      \n **      **     \n*          *****\n"'

Or this one :
perl -e 'print " "x12, "*"x2, " "x2, "\n", " "x8, "*"x4, " "x4, "\n", " "x5, "*"x5, " "x6, "\n", " "x3, "*"x2, " "x3, "*"x2, " "x6, "\n", " "x1, "*"x2, " "x6, "*"x2, " "x5, "\n", "*"x1, " "x10, "*"x5, "\n"'

(The second one should make it easier for you to get the exact pattern)
Your task is to display the sea in a terminal, and make look like the waves are moving toward the right : it needs to shift to the right at a speed of 1 character each 100ms (= 10 times each seconds). No character should be printed after the 80th column, but as the rightmost wave disappears, a new one appears on the left.
Here is an example of output :
time = 0.0s
             **              **              **              **              **
         ****            ****            ****            ****            ****
      *****           *****           *****           *****           *****
    **   **         **   **         **   **         **   **         **   **
  **      **      **      **      **      **      **      **      **      **
**          ******          ******          ******          ******          ****

time = 0.1s
              **              **              **              **              **
          ****            ****            ****            ****            ****
       *****           *****           *****           *****           *****
     **   **         **   **         **   **         **   **         **   **
   **      **      **      **      **      **      **      **      **      **
***          ******          ******          ******          ******          ***

time = 0.2s
*              **              **              **              **              *
           ****            ****            ****            ****            ****
        *****           *****           *****           *****           *****
      **   **         **   **         **   **         **   **         **   **
    **      **      **      **      **      **      **      **      **      **
****          ******          ******          ******          ******          **

time = 0.3s
**              **              **              **              **
            ****            ****            ****            ****            ****
         *****           *****           *****           *****           *****
       **   **         **   **         **   **         **   **         **   **
     **      **      **      **      **      **      **      **      **      **
*****          ******          ******          ******          ******          *

time = 0.4s
 **              **              **              **              **
*            ****            ****            ****            ****            ***
          *****           *****           *****           *****           *****
        **   **         **   **         **   **         **   **         **   **
      **      **      **      **      **      **      **      **      **      **
******          ******          ******          ******          ******

Of course, each output should replace the previous one.
You can run this code into a unix terminal to see how it should look with the animation:
perl -M5.010 -MTime::HiRes=sleep -E '@arr=([($")x12,($n="*")x2,($")x3],[($")x8,($n)x4,($")x4],[($")x5,($n)x5,($")x6],[($")x3,($n)x2,($")x3,($n)x2,($")x6],[($")x1,($n)x2,($")x6,($n)x2,($")x5],[($n)x1,($")x10,($n)x5]);while(++$j){for$i(0..5){for$k(0..15) {$out[$i][16*$_+$k]=$arr[$i][($k-$j)%16]for 0..4}}say"\e[H",$/,join$/,map{join"",@$_}@out;sleep 0.1}'

(Note that this code isn't very well golfed: I just made it compact enough to be convenient to run in a terminal.)
Winning criterion
This is codegolf, so shortest code in byte wins.

Can we start the animation at any frame?

http://05ab1e.tryitonline.net/#code=4oCiOCfigJNtZ2PDhMK1wqvDkuKCrMOkL-KAomJSMTbDtHZ5NcOX4oCeMDHigJ4gKuKAoX3Cuw too bad 05AB1E can't animate, that would've been short.

@Arnauld Yes, you can.

Is it me or those waves rather look like lambdas?

@LuisMendo I see what you mean, but lambdas point in the opposite direction, ie a reflection of the wave on the y-axis

Oh, you're right! These are true lambdas

"Summer is well over" that's very Northern Hemisphere of you.

Is this a repost? I swear this same question was posted a while back.

@haykam Not a repost but it went through the sandbox, so I'm guessing you saw it over there.

MATL, 41 40 bytes
`'3SJp/B@Tc`@+ara'F'* 'Za6el&Xx80:@-Z)DT

Example run:

Or try it at MATL Online! (the actual speed may depend on server load).
How it works
`                    % Do...while
  '3SJp/B@Tc`@+ara'  %   Compressed string (actually it's just a change of base)
  F                  %   Push false. Indicates base-95 input alphabet for decompression
  '* '               %   Push this string, which defines output alphabet
  Za                 %   Base conversion. This decompresses the string
  6e                 %   Reshape as a 6-row char array. This gives the basic pattern
  l&Xx               %   Pause 0.1 seconds and clear screen
  80:                %   Push array [1 2 ... 80]
  @-                 %   Subtract iteration index to each element of that array. This
                     %    will produce the rotation via modular indexing
  Z)                 %   Use as column index. Indexing is modular, so this repeats
                     %   (and rotates) the pattern
  D                  %   Display
  T                  %   True. Loop condition for infinite loop
                     % Implicit end

JavaScript (ES6) + HTML, 151 143 + 10 = 161 153 bytes

a=[48,15,57347,6147,1542,504];setInterval("a=a.map(n=>{for(x=-1;++x<80;)s+=' *'[n>>x%16&1];s+=`\n`;return n>>>15|n<<1},s='');O.innerHTML=s",99)

What is the function of the variable a?

@KritixiLithos a holds the binary-encoded wave pattern and is rotated on each frame. So, it can't be hardcoded: it needs to be stored in a variable.

HTML + CSS, 70 + 181 175 = 245 bytes
Makes use of text-shadow, rtl text and CSS keyframe animations.

a{display:flex;overflow:hidden;width:80ch}pre{text-shadow:16ch 0,32ch 0,48ch 0,64ch 0,80ch 0;direction:rtl;animation:w steps(16)1.6s infinite}@keyframes w{0%{margin-left:-16ch

**
  ****
    *****
    **   **
   **      **
***          ***

C# 450 444 425 417 Bytes
399 without using System.Linq; but I'm sure that would be cheating...
Edit: Saved 25 Bytes thanks to @Cyoce
Golfed:
void S(){Func<string,string>r=a=>string.Concat(Enumerable.Repeat(a,5));Func<string,int,string>s=(b,i)=>(b.Substring(16-i)+b).Substring(0,80);int p=0;for(;;){Console.Clear();Console.WriteLine(string.Join("\r\n",new string[]{s(r("            **  "),p),s(r("        ****    "),p),s(r("     *****      "),p),s(r(" **      **     "),p),s(r("*          *****"),p),}));Thread.Sleep(100);p++;if(p==16)p=0;}}

Ungolfed:
public void S()
{
  Func<string, string> r = a => string.Concat(Enumerable.Repeat(a, 5));
  Func<string, int, string> s = (b, i) => (b.Substring(16 - i) + b).Substring(0, 80);

  int p = 0;
  for(;;)
  {
    Console.Clear();
    Console.WriteLine(
      string.Join("\r\n", new string[]
    {
      s(r("            **  "), p),
      s(r("        ****    "), p),
      s(r("     *****      "), p),
      s(r(" **      **     "), p),
      s(r("*          *****"), p),})
      );
    Thread.Sleep(100);
    p++;

    if (p == 16)
      p = 0;
  }
}

I think you can remove the parentheses in (a)=>. And while(true) can be for(;;)

For the s lambda I think you can remove the {} and return

Worked on both, giving me a 25 Byte saving in total, thanks! :)

You can make your entire function a lambda. I think you can also remove the \r from the string.Join (at least on Windows it works, didn't test it with Mono though)
You can also save 1 byte by putting p++ into the for loop like this for(;;p++)

To remove the boundary check at the bottom (if (p==16)...) you can also put it into the for loop header like this for(;;p=++p%16). Save 1 more byte by declaring p in the loop (for(int p=0;;p=++p%16))

What software did you use to create capture and create gif file? Mine did not work properly.

@rnso I used "Snipping Tool" in Windows and stepped through the output at each stage, capturing 16 images in total. I then used GIMP photo-editing software to layer the images and create the GIF... Not the most efficient way, but hey, it works! :)

Change your r function to: new string('+',5).Replace("+",a); for a further 4 byte saving.

You may also save a few bytes if you use a bitmask to represent the wave. See https://dotnetfiddle.net/XHWvzs and the b function that takes an int converts it to a bit mask and replaces the binary result with the spaces and *. I did not extrapolate it for all your string params to r but it may save a byte or 2 in the long run.

You can improve it further: new string[] can be replaced by new []. if(p == 16) p = 0 can be replaced with p%=16;

V, 98 97 73 bytes
Thanks to @nmjcman101 for saving 24 bytes!
i¹ ³ **
¸ ´*´
µ µ*¶
³ **³ **¶
 **¶ **µ
*± µ*<ESC>{<C-v>}y4pò:sl100m
$<C-v>}x|Pò

This contains a lot of unprintables, so here's an xxd hexdump:
0000000: 69c2 b920 c2b3 202a 2a20 200a c2b8 20c2  i.. .. **  ... .
0000010: b42a c2b4 200a c2b5 20c2 b52a c2b6 200a  .*.. ... ..*.. .
0000020: c2b3 202a 2ac2 b320 2a2a c2b6 200a 202a  .. **.. **.. . *
0000030: 2ac2 b620 2a2a c2b5 200a 2ac2 b120 c2b5  *.. **.. .*.. ..
0000040: 2a1b 7b16 7d79 3470 c3b2 3a73 6c31 3030  *.{.}y4p..:sl100
0000050: 6d0a 2416 7d78 7c50 c3b2 0a              m.$.}x|P...

Edit

Used y$ instead of <C-v>$y
A lot of changes

Instead of copying each line and pasting them 4 times, I first generate the wave and then copy the whole thing and paste it 4 times
Used { and } to save few bytes
Used ò instead of registers to create the infinite loop (for some reason I have to include a ò at the end for it to work)
fixed the static * at the bottom

Mini-Explanation
I'm using <alt-n> to create copies of strings. For example, <alt-5>* (this looks like µ5) makes 5 copies of * in insert mode. This I found to be shorter than copying the string and using a regex to do the necessary replacements. After creating one wave, I paste it to create the other waves. Finally, I loop recursively using ò to create the infinite loop (with a delay of 100ms).
Gif
Most of the code is dedicated towards creating the wave, so I'm still trying to golf this. Note that this code will not work on TIO since TIO only outputs the output after the code has finished execution. So here's a gif (sorry for the low quality, I had to use a website to convert a .mov to a .gif, also the >_ that keeps popping up in the right is the Terminal icon on my mac's dock):

I have very little idea about how your funky repeating numbers work, but if you make one wave, and then block copy/paste it, you can save characters (instead of copy pasting each line 4 times) Link to TryItOnline

Less helpfully, I think your 5j (in the context of $<C-V>5j) could just be }, and the p after the | should be a P which will fix the static * in the bottom left.

Finally (sorry for comment spam, apparently they're editable for 5 minutes) you can replace the qm[CODE]@mq@m at the end with just ò[CODE].  Code between ò will loop until breaking (similarly to your macro), and at the end of a program an ò is implicitly closed.

@nmjcman101 Thanks for all you help! (it is not comment spam if you are helping me golf a few bytes :)

Batch, 424 bytes
@echo off
set f=
set a=%f%%f%  **
set b=%f%   ****
set c=%f%***** %f%
set d=   **   ** %f%
set e= **%f% **%f%
set f=*%f%%f%*****
set a=%a%%a%%a%%a%%a%%b%%b%%b%%b%%b%%c%%c%%c%%c%%c%%d%%d%%d%%d%%d%%e%%e%%e%%e%%e%%f%%f%%f%%f%%f%
:l
cls
echo %a%
set a=%a:~79,1%%a:~0,79%%a:~159,1%%a:~80,79%%a:~249,1%%a:~160,79%%a:~319,1%%a:~240,79%%a:~399,1%%a:~320,79%%a:~-1%%a:~-80,79%
ping>nul 1.1 -n 1 -w 100
goto l

Some lines have trailing spaces. Requires a standard 80-column terminal. The timing isn't very accurate, but it's the best you can do in Batch.

Racket 395 374 373 367 364 351 bytes
Uses an external library for screen clearing
Edit: Saved 21 bytes by not defining w and inlining the function.
Edit2: Saved 1 byte by removing a space.
Edit3: Saved 6 bytes by renaming loop to p, thanks @rnso!
Edit4: Putting substring in the let saving 3 bytes.
Edit5: Remove #lang racket, which isn't needed in the interpreter.
Golfed: 351 bytes
[require[planet neil/charterm:3:0]][let p([n 1])[with-charterm[void[charterm-clear-screen]]][for([i'["            **  ""        ****    ""     *****      ""   **   **      "" **      **     ""*          *****"]])[let([g substring][x[string-join[make-list 5 i]""]])[displayln[string-append[g x[- 16 n]][g x 0[- 16 n]]]]]][sleep .1][p[modulo[+ n 1]16]]]

Scrolling (no clear): 272 bytes
[let p([n 1])[for([i'["            **  ""        ****    ""     *****      ""   **   **      "" **      **     ""*          *****"]])[let([g substring][x[string-join[make-list 5 i]""]])[displayln[string-append[g x[- 16 n]][g x 0[- 16 n]]]]]][sleep .1][p[modulo[+ n 1]16]]]

Ungolfed:
#lang racket
[require [planet neil/charterm:3:0]]
[define w
'[
"            **  "
"        ****    "
"     *****      "
"   **   **      "
" **      **     "
"*          *****"]]
[define (rotmul count)
  [for ([i w])
    [let ([x [string-join [make-list 5 i] ""]])
      [displayln [string-append [substring x count]
                                [substring x 0 count]]]]]]

[let loop ([n 1])
  [with-charterm
   [void [charterm-clear-screen]]]
  [rotmul [- 16 n]]
  [sleep .1]
  [loop [modulo [+ n 1] 16]]]

Renaming names to shorter ones (like p instead of loop) can be done to reduce bytes. What software did you use to capture video to gif file?

@rnso: Oh you're right! Didn't think of that one. I used simplescreenrecorder with avconv to convert mp4 to gif.

You can put (g substring) in let so that you can use g in place of 2 substring keywords later in code. That should save you another 5 bytes. Also what is 'lst' doing in your ungolfed version?

@rnso: Removed it, was a remnant of when rotmul actually took in w as a parameter.

You can also remove "#lang racket" from golfed version. Most Racket code on this site is not including it while counting bytes.

PowerShell 3.0, 183 182 173 bytes
Requires PS 3.0 for binary shift operators. Slimmed to 173 bytes with  AdmBorkBork's help!
$w=12,240,1984,6336,24672,32799
for(){0..5|%{'{0:D16}'-f+[Convert]::ToString(([uint16]$o=$w[$_]),2)*5-replace0,' '-replace1,'*'
$w[$_]=$o-shr1-bor$o-shl15}
sleep -m 100
cls}

Nice answer! Some golfs -- using the decimal format specifier instead of .PadLeft, move the $o declaration into the [convert] call, and eliminate the quotes around the numbers in the -replace ops. Gets you down to 175 -- for(){0..5|%{("{0:D16}"-f+[Convert]::ToString(([uint16]$o=$w[$_]),2))*5-replace0,' '-replace1,'*'

@AdmBorkBork Thanks! Sorry that it took me quite a time to update the answer. Could you explain + in the "{0:D16}"-f+[Convert]? It doesn't work without it, but I can't grok what it does.

The [convert]::ToString() returns a string. The + forces a cast to an [int] so that -f picks up the correct parameter type for the D16 to work.

@AdmBorkBork You mean that PS treats +'1' like a valid arithmetical operation without first summand, casts string to int and returns result? Great Scott!

Bash+coreutils, 172 148 bytes
24 bytes saved thanks to @zeppelin, many thanks

while :
do clear
cut -c$[i=i%16+1]-$[79+i] <(base64 -d<<<4AJFACddABVgf2dnw+CvmeyOkhIoUJOPLK6oKkljh0+Peqi5BfrbbnDyuVkr+AA==|xz -qdFraw)
sleep .1
done

The first line decompresses the following pattern made of 6 consecutive waves:
**              **              **              **              **              **
            ****            ****            ****            ****            ****            ****
         *****           *****           *****           *****           *****           *****
       **   **         **   **         **   **         **   **         **   **         **   **
     **      **      **      **      **      **      **      **      **      **      **      **
*****          ******          ******          ******          ******          ******          *

Then, the loop slides an 80-bytes-wide window through that pattern.

Coreutils base64 utility does not support -D flag (should be -d, lowercase instead).

You can save ~10 bytes by using raw LZMA (xz), instead of gzip (compress with lzma -Fraw, decompress with xz -qdFraw).

You can also use an older arithmetic expansion syntax $[], instead of $(()), to save 4 more bytes

A leading zero can be omitted in sleep command, i.e. sleep .1 should work just fine

You can also get rid of explicit i=0 declaration

No need for a space between cut -c and the argument value (i.e. you can do cut -cX-Y)

And you can also save a newline, by using a process substitution, instead of a temporary file, like that: _cat -cX-Y <()

*><>, 251 250 251 bytes (non-competing)
" **             "e1C0["   ****         "e1C0["     *****      "e1C0["     **   **    "e1C0["    **      **  "e1C0["****          **"e1C0[06.
52Cl2,[52C52C]R
<v0&:l
$>:@=?v1+{:}&l1-[:&$@
?!v]1->:
~R>
vDDDDDD"H;0["ooooo
>l?u1S06.O{52Cl2,[a}48C]I
ol?!R

Note: "H;0[" is supposed to have ascii 27 after [.
Try it here! (set delay to 0ms)
I can't believe I ended up sucessfully making this. This uses the I and D instructions, which increments or decrements the selected stack. This is demonstrates that it's probably possible to do this in pure ><> (minus the sleep) or a competetive *><> answer, though probably a lot harder to do.
The online interpreter version is different simply to clear the output using a carriage return.
This is non-competing because the I, D, C, and R instructions are younger than the challenge. This is probably possible to do without those instructions, but it'd be very hard/long.
Edit: I actually managed to remove a byte, but I also noticed I measured the size wrong, so I actually gained a byte.

I'll do my best to break down the steps and explain what's happening here...
Explanation
" **             "e2C0["   ****         "e2C0["     *****      "e2C0["     **   **    "e2C0["    **      **  "e2C0["****          **"e2C0[09.
# Copy current stack 4 times
54Cl2,[54C54C]R
# Copy stack
<v0&:l
$>:@=?v1+{:}&l1-[:&$@
?!v]1->:
~R>
# Main loop
vDDDDDD"H;0["ooooo
>l?u1S09.O{54Cl2,[a}4cC]I
# Output stack
ol?!R

Table of Contents
Line 1 - Initialization
e2C    - Call "copy current stack 4 times"
54C    - Call "copy stack"
09.    - Jump to "main loop"
4cC    - Call "output stack" (not explained, is very simple)

Initialization
Here we build the 6 lines which construct the waves. We need to repeat each string 5 times to be the correct length.
We start with 6 of these, one for each line of the wave:
 " **             "       push " **             " to the stack
                   e2C    call "copy current stack 4 times"
                      0[  create a new stack

And we enter the main loop after initialization through 09..
Copy Current Stack 4 Times
This is a simple function which simply takes the current stack, and copies it 4 times. So "a" would become "aaaaa".
54C              call "copy stack"
   l2,[          copy half the current stack to a new stack
       54C54C    call "copy stack" twice
             ]   close the current stack, moving values to the one below
              R  return from the function

Copy Stack
This copies the current stack, appending the copy to the current stack.
Setup
Going to skip the initial < and invert the first line to become l:&0v as that's the order it gets executed in after the < changes the IP's direction.
l      push the stack length to the stack
 :&    copy the length to the register
   0   push 0 to the stack
    v  move the IP downwards, entering the loop

From here on out the length will be referred to as n and the 0 as i.
Loop
>                        move the IP to the right
 :                       copy i
  @=?v                   pop i from the stack, if n == i, proceed to cleanup
      1+                 add 1 to i
        {:}              copy the first value of the stack to the end of the stack
           &             place n on the stack
            l1-[         open a new stack moving all values but index 0 to the new one
                :&       copy n and place it on the register
                  $@     swap i with the value on its right
                     $   swap i with n

Cleanup
>                        move the IP to the right
 :?!v                    if i == 0 then ...
  ~R>                      remove i from the stack and return
     ]                   close the stack, appending all values to the stack below
      1-                 subtract 1 from i

Main Loop
Here is where the code runs forever, constantly redrawing the waves in-between 100ms sleeps.
Setup
DDDDDD                 select the 6th stack down
      "H;0[x"ooooo     move the cursor to the top-left of the term (x == ascii 27)
                  v    move the IP downwards, entering the loop

Loop
>                          move the IP to the right
 l?u     O                 if the stack is empty ...
    1S                       sleep for 100ms
      09.                    jump to main loop initialisation
          {                shift the stack left
           54Cl2,[         copy the current stack to a new stack
                  a        append a newline to the stack
                   }       shift the stack to the right
                    4cC    call "output stack"
                       ]   close the stack
                        I  select one stack higher

Javascript (ES6), 152 147 145 bytes
x=0,c=console;setInterval(a=>{for(c.clear();f="",i=128,++x,a--;c.log(f))for(;i--;)f+=" *"[[32799,24672,6336,1984,240,12][a]>>(i+x)%16&1]},100,6);

You can also save 2 bytes with setInterval(a=>{...},100,6), and 4 more with f+=" *"[[...][a]&1<<(i+x)%16].

Thanks for the suggestions! But are you certain you can get your second suggestion to work? You'll still have to coerce that value to a boolean to retrieve array index 0-1.
I was thinking of further bitmapping the wave ascii into a single hex value:
0x801F606018C007C000F0000C
but Javascript can only bitwise shift a maximum of 31 bits in either direction! You learn something every day!

Perl 6, 140 138 137 123 120 bytes
for ^Inf ->\i{print "\e[H";for 12,240,1984,6336,24672,32799 ->\j{say [~] map {j+>((i-$_)%16)%2??'*'!!' '},^80};sleep .1}

Old solutions:
for ^Inf ->\i {print "\e[H";for 12,240,1984,6336,24672,32799 ->\j {say [~] map {j+>((i-$_)%16)%2??'*'!!' '},^80};sleep .1;}
my @a=12,240,1984,6336,24672,32799;for ^Inf ->\i {print "\e[H";for @a ->\j {for ^80 {print j+>((i-$_)%16)%2??'*'!!' '};say ""};sleep .1;}
my @a=12,240,1984,6336,24672,32799;for ^Inf {print "\e[H";for @a ->\j {for ^80 ->\k {print j+>(($_- k)%16)%2??'*'!!' '};say ""};sleep .1;}
my @a=12,240,1984,6336,24672,32799;for ^Inf {print "\e[H";for @a ->\j {for ^80 ->\k {print j+>(($_+15*k)%16)%2??'*'!!' '};say ""};sleep .1;}

PHP, 128 bytes
for($a=[3,60,496,1584,6168,57351];;usleep(1e5))foreach($a as&$x)for($x=$x/2|$x%2<<15,$i=80;$i--;)echo" *"[$x>>$i%16&1],"\n"[$i];

Cannot animate more than one line, but it scrolls.
Add ,0 to the array for an empty line between iterations. Run with -r.

Ruby 269 217 189 185 Bytes
-28 Bytes thanks to @manatwork
-5 Bytes thanks to @ropata
Normal

p=0
loop do
  system 'clear'
  [' '*12+'**  ', ' '*8+'****    ','     *****      ','   **   **      ',' **      **     ','*          *****'].each {|i| puts ((i*5)[16-p..-1]+i)[0..79]}
  p=-~p%16
  sleep 0.1
end

Golfed
p=0
b=' '
loop{system'clear'
[b*12+'**  ',b*8+'****    ',b*5+'*****'+b*6,'   **   **'+b*6,' **      **     ',"*#{b*10}*****"].map{|i|puts ((i*5)[16-p..-1]+i)[0,79]}
p=-~p%16
sleep 0.1}

Although your code works fine please note that according to site rules it is not a valid solution yet: “All solutions to challenges should: (…) Be a serious contender for the winning criteria in use. For example, an entry to a code golf contest needs to be golfed, (…)” – [help/on-topic] See Tips for golfing in Ruby for some tips.

Anyway, a brief list: remove indentation; do … end → { … } and remove the newlines after { and before }; remove the space between system and its parameter; remove the , after array literal's last element; .each → .map and remove the space between it and its code block; remove the space in front of puts; 0..80 → 0,80 (this is also a bug as you expression results 81 characters long string); p=p+1==16?0: p+1 → p=-~p%16.

Yepp, manatwork's dumb explanation strikes again. Even changing do … end → { … }, there is still need for the loop keyword. This is the shortest I get: http://pastebin.com/cg3gxnm4

Can save 5 or 6 bytes by setting b='     ' (5 blank spaces) at the top then changing the output expression to ' '*12+'**  ', ' '*8+'****    ',b+'***** '+b,'   **   ** '+b,' **      **'+b,'*'+b+b+'*****' ... (but SE isn't showing repeated spaces properly in this comment!)

Mathematica, 213 bytes
i=0;RunScheduledTask[i++,0.1];Dynamic[RotateRight[#,i]&/@Characters/@(StringRepeat[#,5]&)/@{"            **  ","        ****    ","     *****      ","   **   **      "," **      **     ","*          *****"}//Grid]

I don't see any way of golfing the wave pattern in Mathematica other than just starting with a list of strings for each line. I initialize i to be 0 and schedule a task to increment it every 0.1 seconds. I Dynamically display the result of the following:

StringRepeat each line 5 times.
Convert each line into a list of its Characters.
RotateRight each list of characters by i.
Display the resulting array of characters as a Grid.

What software did you use to create capture and create gif file?

I used ScreenToGif.

C (unix), 231 191 bytes
This will only work on unix environments. Also, please excuse the fact that sleep accepts only integers... so it actually delays 1second between frames.
Ungolfed version:
#include <stdio.h>
int main() {
    int x=0,l,i,a[6]={32799,24672,6336,1984,240,12};
    while(l=6,++x) {
        printf("\033[2J");
        while(i=128,l--) {
            while(i--) putchar(a[l]&1<<(i+x)%16 ? 42 :32);
            puts("");
        }
        sleep(1);
    }
}

Golfed version:
#include <stdio.h>
int main(){int x=0,l,i,a[6]={32799,24672,6336,1984,240,12};while(l=6,++x){printf("\033[2J");while(i=128,l--){while(i--)putchar(a[l]&1<<(i+x)%16?42:32);puts("");}sleep(1);}}

That's the C in your terminal.

Mathematica 171 Bytes
The wave itself is data, so I'm storing a compressed version of the whole wave in my code.  I can store a single wave much more compactly as \fð߀ᣀ恠耟 using it's binary representation, but the character count overhead of uncompressing is too high*.
Here is the code:
w=Uncompress@"1:eJxTTMoPSmNjYGAoZgESPpnFJcEBQIYCEtDSUlCglI9iqJYWqhJy+QhDtdCUUMCHGQrmIymiiA8xFMajEg02FMkXWmi+IosPAJNuSHg=";
Dynamic[Pause[.1];Column[w=StringRotateRight/@w]]

Here is the code I used to create the compressed version of the wave data:
s={"            **  ","        ****    ","     *****      ","   **   **      "," **      **     ","*          *****"};
s//TableForm
StringRepeat[#,5]&/@s
Compress[%]

Here is the code I would have preferred to use to store compressed repeating binary data like this wave:
StringJoin /@ (PadLeft[(IntegerDigits[#1, 2] & ) /@ ToCharacterCode["\fð߀ᣀ恠耟"]] /. {0 -> " ", 1 -> "*"})

As you can see, the overhead to turn the compressed data back into a string is too expensive for this particular problem, although a single wave can be stored this way with 7 UTF characters and 15 bytes.
Here was the code to determine the UTF character sequence to store a single wave (s as above).
StringReplace[#,{" "->"0","*"->"1"}]&/@s
ToExpression/@%
IntegerDigits/@%
FromDigits[#,2]&/@%
FromCharacterCode/@%
StringJoin@%

Python 3, 240 239 230 bytes
-1 byte thanks to @redstarcoder
-9 bytes thanks to @PascalvKooten
import time
def p():print("\x1b[0;H")
i=0;p();s=[' '*13+'**',' '*9+'****  ','      *****    ','    **   **    ','  **      **   ','**          ***']
while True:
 for x in s:x*=5;c=i%80;print(x[-c:]+x[:-c])
 i+=1;p();time.sleep(.1)

print("\x1b[0;H") also works for me for -1 byte.

You can replace '             **' with ' '*13+'**' and you can have 1 character indents in the while, no need for it to be 4 characters.

@PascalvKooten thanks. The indents were transformed into spaces from tab characters during pasting. I will make sure to watch out for that.

Racket 295 bytes
(let*((g string-append)(h substring)(d displayln)(j(λ(l)(map(λ(x)(g(h x 1)(h x 0 1)))l))))(let p((l(map(λ(x)(apply g(for/list((i 5))x)))'("            **  ""         ****   ""      *****     ""    **   **     ""  **      **    ""*          *****"))))(for((i l))(d i))(d"")(sleep .1)(p(j l))))

Ungolfed:
(define(f)
 (define (lf l)
    (map (λ (x) (string-append (substring x 1) (substring x 0 1)))
         l))
  (let loop ((l (map (λ (x) (apply string-append (for/list ((i 5)) x)) )
                     (list
                      "            **  "
                      "         ****   "
                      "      *****     "
                      "    **   **     "
                      "  **      **    "
                      "*          *****"))))
    (for ((i l))
      (displayln i))
    (displayln "")
    (sleep 0.1)
    (loop (lf l))))

Testing:
(f)

Output:

(This gif file display is slower than actual output).

Python 2, 207 202 bytes
Usually I'm a C# developer, so this might not be completely golfed yet...
import time;i=0
while 5:
    print"\033[;H"
    for l in[" "*12+"**  "," "*8+"*"*4+" "*4," "*5+"*"*5+" "*6,"   **   **"+" "*6," **     "*2,"*"+" "*10+"*"*5]:print(l[16-i:]+l*5)[:80]
    time.sleep(.1);i=(i+1)%16

C#, 327 bytes
More or less a ported version of my solution in Python...
_=>{Func<string,int,string>t=(s,j)=>(s.Substring(16-j)+string.Concat(Enumerable.Repeat(s,5))).Substring(0,80);for(var i=0;;i=++i%16){Console.Clear();foreach(var q in "            **  ,        ****    ,     *****      ,   **   **      , **      **     ,*          *****".Split(','))Console.WriteLine(t(q,i));Thread.Sleep(100);}}

Perl, 110 bytes
Requires -E at no extra cost. This contains unprintable characters.
$_=unpack"B*","x?`00?";s!.{16}!$&x5 .$/!ge;y/01/ */;{say"\ec$_";select!s/(.+)(.)$/$2$1/mg,$a,$a,.1;redo}"

Create the above data using the below reversible hexdump. Run xxd -d > sea.pl in a linux or compatible terminal, paste the below and press Ctrl+d, then run perl -E "$(cat sea.pl)".
0000000: 245f 3d75 6e70 6163 6b22 422a 222c 2200  $_=unpack"B*",".
0000010: 0600 7803 e00c 6030 30c0 0f22 3b73 212e  ..x...`00..";s!.
0000020: 7b31 367d 2124 2678 3520 2e24 2f21 6765  {16}!$&x5 .$/!ge
0000030: 3b79 2f30 312f 202a 2f3b 7b73 6179 225c  ;y/01/ */;{say"\
0000040: 6563 245f 223b 7365 6c65 6374 2173 2f28  ec$_";select!s/(
0000050: 2e2b 2928 2e29 242f 2432 2431 2f6d 672c  .+)(.)$/$2$1/mg,
0000060: 2461 2c24 612c 2e31 3b72 6564 6f7d       $a,$a,.1;redo}

Usage
For easy copy/pasting, please use the below:
perl -E '$_=unpack"B*","\x00\x06\x00\x78\x03\xe0\x0c\x60\x30\x30\xc0\x0f";s!.{16}!$&x5 .$/!ge;y/01/ */;{say"\ec$_";select!s/(.+)(.)$/$2$1/mg,$a,$a,.1;redo}'

Explanation
A fairly straightforward solution that stores the wave as a string at the beginning, which is unpacked to binary, each section is quintuplicated, 0s are converted to spaces and 1s are converted to *s. Now we have the whole string so we enter a redo loop which prints out the whole string, then we wait for .1 seconds and for each line in the string, we move the last character to the beginning of the string.

Stax, 38 bytes
ç²kτ,e7rà♠Çƒ╜?║í▬u╬wπ■&Jµⁿj↨▄!=╢╡═+ZWu

Run and debug it
Took some shuffling around and :B to beat the MATL score.
Explanation
. *9*"!1$'YKaK968"%13|E:B16/WcM|)Ms{|,}6*|:m5*
. *                                            " *"
   9*                                          repeat 9 times
     "!1$'YKaK968"%13|E                        compressed run lengths of wave
                       :B                      run length decode using the two arrays
                         16/                   split in groups of 16
                            W                  loop forever
                             c                 copy the wave
                              M|)M             shift right
                                  s            swap
                                   {|,}6*      wait 6 frames(0.1s at 60fps)
                                         m5*   pop, repeat each line 5 times and display

HTML + JS + jQuery, 10 + 233 = 243 bytes

b="            **  q        ****    q     *****      q   **   **      q **      **     q*          *****".split`q`.map(x=>x.repeat(5).split``)
setInterval(a=>$("#a").text(b.map(f=>f.join``).join`\n`)+b.map(e=>e.unshift(e.pop())),100)

The JavaScript just shifts each row by 1 and changes the text every 100 ms.


text:
Variable-Prices income!
Introduction and credit
Assume you're a bartender. You have many happy people in your bar at most times, but many only ever drink the very same drink and too few for your taste and you want to change that. So you introduce a system where the price of a drink is variable, depending on how many have already been sold, but never more or less expensive than certain thresholds. For some odd reason you always forget to keep proper track of all sold drinks and prices and thus you need to think of a short (= memorable!) piece of code that does the math for you given the amount of drinks consumed.
This challenge has already appeared in the mid-term exam in 2012 at the functional programming course at my uni and I've got my professor's ok to post it here. We have been provided an example solution in the exam's language.
Input
Your input will be a list of strings which don't contain spaces - these are the names of the drinks sold. Take the input using your preferred, generally accepted input method.
Output
Your output will be a single number - this is the income you have generated this evening. Give the output using your preferred, generally accepted output method.
What to do?
This applies for each drink individually:

The starting price is 10.
Each time the drink is bought, it's price is bumped up by 1 for the next buyer.
The maximal price is 50. If the drink has been bought for 50 the new price will be 10 again.

Your task is to find the overall income, generated by the input list of drinks given the above rules.

In case you're wondering: "50 bucks is really damn expensive for a drink!", this is 50-deci Bucks, so 50 * 0.1 * Unit, but I've opted to go for 10-50 to not exclude languages without floating point arithmetic.
Who wins?
This is code-golf, so the shortest code in bytes wins! Standard rules apply.
Potential Corner Cases
If the input list is empty, the output shall be 0.
The input list icannot be assumed to be sorted by drink.
Examples
[] -> 0
["A"] -> 10
["A","B"] -> 20
["A","A","B"] -> 31
["A","B","A"] -> 31
["A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A"] -> 1240
["A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","B","B","B","C","C","D"] -> 1304
["D","A","A","C","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","B","B","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","B","C"] -> 1304
["A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","B","B","B","C","C","D","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A"] -> 1304

Props on asking your professor before posting, quite the O.G. move.

Python 2, 79 74 54 48 Bytes
Massive byte count increase by rethinking the problem. I would like to get rid of the int cast but my brain isn't working. Making use of l.pop() to avoid trimming the list twice and some good old lambda recursion :)
f=lambda l:l and l.count(l.pop())%41+10+f(l)or 0

thanks to Jonathan Allan for saving 6 bytes :)
My old 54-byte version I was quite proud of :)
f=lambda l:int(l>[])and~-l.count(l[0])%41+10+f(l[1:])

...l>[]and 1*~... to save those 3 bytes you knew you could.

In fact 1 less with: f=lambda l:l and~-l.count(l[0])%41+10+f(l[1:])or 0

Oooh and another two with: f=lambda l:l and l.count(l.pop())%41+10+f(l)or 0

@JonathanAllan thanks for the tips! I'll update my post soon :)

JavaScript (ES6), 50 bytes
a=>a.map(x=>t+=d[x]=d[x]<50?d[x]+1:10,t=0,d={})&&t

Where do you init d[x] to 10?

@Titus If d[x] has not been set, it's undefined; this makes d[x]<50 return false, so d[x]=d[x]<50?d[x]+1:10 sets d[x] to 10.

I keeü forgetting that JS has undefined. :)

05AB1E, 16 15 bytes
Thanks to Emigna for saving a byte!
ÎÙv¹y¢L<41%T+OO

Uses the CP-1252 encoding. Try it online!

ÎÙv¹y¢L<41%T+OO should work for 1 byte saved

@Emigna That's nice! Thanks :)

Pyth, 15 bytes
ssm<*lQ}T50/Qd{

A program that takes input of a list and prints the result.
Test suite (First line to allow multiple input)
How it works
ssm<*lQ}T50/Qd{   Program. Input: Q
ssm<*lQ}T50/Qd{Q  Implicit input fill
              {Q  Deduplicate Q
  m               Map over that with variable d:
       }T50        Yield [10, 11, 12, ..., 48, 49, 50]
    *lQ            Repeat len(Q) times
   <       /Qd     First Q.count(d) elements of that
 s                Flatten
s                 Sum
                  Implicitly print

Jelly, 14 11 10 bytes
50⁵rṁÐ€ĠSS

TryItOnline!
How?
50⁵rṁÐ€ĠSS - Main link: list of drink names                e.g. ['d', 'a', 'b', 'a', 'c']
       Ġ   - group indices by values                       e.g. [[2, 4], [3], [5], [1]]
  ⁵        - 10
50         - 50
   r       - inclusive range, i.e. [10, 11, 12, ..., 48, 49, 50]
    ṁÐ€    - mould left (the range) like €ach of right(Ð)  e.g. [[10, 11], [10], [10], [10]]
                 note: moulding wraps, so 42 items becomes [10, 11, 12, ..., 48, 49, 50, 10]
        S  - sum (vectorises)                              e.g. [40, 11]
         S - sum                                           e.g. 51

05AB1E, 13 bytes
{.¡€gL<41%T+O

Explanation
["A","B","A"] used as example.
{               # sort input
                # STACK: ["A","A","B"]
 .¡             # split on different
                # STACK: [["A","A"],["B"]]
   €g           # length of each sublist
                # STACK: [2,1]
     L          # range [1 ... x] (vectorized)
                # STACK: [1,2,1]
      <         # decrease by 1
                # STACK: [0,1,0]
       41%      # mod 41
                # STACK: [0,1,0]
          T+    # add 10
                # STACK: [10,11,10]
            O   # sum
                # OUTPUT: 31

C++14, 105 bytes
As generic unnamed lambda returning via reference parameter. Requires input to be a container of string that has push_back, like vector<string>.
Using the %41+10 trick from Kade's Python answer.
[](auto X,int&r){r=0;decltype(X)P;for(auto x:X){int d=0;for(auto p:P)d+=x==p;r+=d%41+10;P.push_back(x);}}

Creates an empty container P as memory what has been served already. The price is calculated by counting the x in P.
Ungolfed and usage:
#include<iostream>
#include<vector>
#include<string>

using namespace std;

auto f=
[](auto X, int& r){
  r = 0;
  decltype(X) P;
  for (auto x:X){
    int d = 0;
    for (auto p:P)
      d += x==p;
    r += d % 41 + 10;
    P.push_back(x);
  }
}
;

int main(){
 int r;
 vector<string> V;
 f(V,r);cout << r << endl;
 V={"A"};
 f(V,r);cout << r << endl;
 V={"A","B"};
 f(V,r);cout << r << endl;
 V={"A","B","C"};
 f(V,r);cout << r << endl;
 V={"A","A"};
 f(V,r);cout << r << endl;
 V={"A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A"};
 f(V,r);cout << r << endl;
 V={"A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","B","B","B","C","C","D"};
 f(V,r);cout << r << endl;
 V={"A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","B","C"};
 f(V,r);cout << r << endl;
}

Perl 41 Bytes
Includes +1 for -p
$\+=$H{$_}+=$H{$_}?$H{$_}>49?-40:1:10;}{

Takes input on newlines.
Increments a hash value by: 10  if it's undef, -40 if it's > 49 i.e. 50, or 1 otherwise. This is then added to $\, the output separator, which the -p prints.
Example:
$ echo -e 'A\nB\nA' | perl -pe '$\+=$H{$_}+=$H{$_}?$H{$_}>49?-40:1:10;}{'
31

k, 22 bytes
The argument can be any list - strings, numerics etc.
{+/,/10+(#:'=x)#\:!41}

The q translation is easier to read:
{sum raze 10+(count each group x)#\:til 41}

Mathematica, 64 bytes
Feels like it should be shorter.
Tr[(19+#)#/2&/@(Length/@Gather@#//.z_/;z>41:>Sequence[41,z-41])]&

Length/@Gather@# counts the repetitions of each drink. //.z_/;z>41:>Sequence[41,z-41] splits any integer z exceeding 41 in this into 41 and z-41, to reflect the price drop. Then each of the counts is plugged into the formula (19+#)#/2, which is the total cost of # drinks as long as # is at most 41. Finally, Tr sums up those costs.

C#, 193 bytes + 33
An extra 33 bytes for using System.Collections.Generic;
void m(string[]a){int t=0;Dictionary<string,int>v=new Dictionary<string,int>();foreach(string s in a){if(v.ContainsKey(s)){v[s]=v[s]==50?10:v[s]+1;}else{v.Add(s,10);}t+=v[s];}Console.WriteLine(t);}

I'm sure this can be golfed to oblivion, Dictionaries are definitely not the best way to do this and I could probably work a ternary into my if. Aside from that I think it's okay!
Examples:
a = {"A", "A", "A", "B", "B", "C"};
//output = 64

a = {"A", "A" ,"A", "A" ,"A", "A" ,"A", "A" ,"A", "A" ,"A", "A" ,"A", "A" ,"A", "A" ,"A", "A" ,"A", "A" ,"A", "A" ,"A", "A" ,"A", "A" ,"A", "A" ,"A", "A" ,"A", "A" ,"A", "A" ,"A", "A" ,"A", "A" ,"A", "A" ,"A", "A" ,"A", "A" ,"A", "A" ,"A", "A" ,"A", "A" ,"A", "A" ,"A",, "A" ,"A", "A" ,"A", "A" ,"A", "A" ,"A", "A" ,"A", "A" ,"A", "A" ,"A", "A" ,"A", "A" ,"A", "A" ,"A", "A" ,"A", "A" ,"A", "A" ,"A", "A" ,"A" "A" ,"A", "A" ,"A", "B", "B", "C"};
//output 727

Ungolfed
void m(string[] a)
{
    int t=0;
    Dictionary<string,int> v = new Dictionary<string,int>();
    foreach(string s in a)
    {
        if(v.ContainsKey(s))
        {
            v[s]=v[s]==50?10:v[s]+1;
        }
        else
        {
            v.Add(s,10);
        }
        t+=v[s];
    }
    Console.Write(t);
}

Clojure, 79 bytes
#(apply +(mapcat(fn[l](for[i(range l)](+(mod i 41)10)))(vals(frequencies %)))))

Counts frequencies of drinks, then calculates the base price as 10 + (i % 41). mapcat concatenates them and apply + calculates the sum.

PHP, 47 bytes
while($k=$argv[++$i])$s+=10+$p[$k]++%41;echo$s;

takes input from command line arguments; run with -r.

source: Stack Exchange

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

sort: votes


text:
Kuznetsov's Sequence
Kuznetsov's Sequence
(I made the name up, don't bother with Wikipedia or Google)

Given any number n > 0, let r represent the reverse of the number n. Iterate until the final result is zero, passing the result of each iteration back into the function using recursion or a methodology of your choice by performing the below operation:

If r > n for that iteration the result is r % n.
If n > r for that iteration the result is n % r.
If n % r = 0 or r % n = 0, you terminate iteration.

Take the intermediate result of each execution and store them in an array for the final answer. The initial number n is not part of the sequence, nor is 0; the examples should make everything a little more obvious.
Lets walk through an example where n=32452345.
54325423 % 32452345 = 21873078 # r > n, uses r % n
87037812 % 21873078 = 21418578 # r > n, uses r % n
87581412 % 21418578 = 1907100  # r > n, uses r % n
1907100 % 17091 = 9999         # n > r, uses n % r
9999 % 9999 = 0                # r % n = n % r = 0, terminated

Result: [21873078, 21418578, 1907100, 9999]

Another example n=12345678:
87654321 % 12345678 = 1234575 # r > n, uses r % n
5754321 % 1234575 = 816021    # r > n, uses r % n
816021 % 120618 = 92313       # n > r, uses n % r
92313 % 31329 = 29655         # n > r, uses n % r
55692 % 29655 = 26037         # r > n, uses r % n
73062 % 26037 = 20988         # r > n, uses r % n
88902 % 20988 = 4950          # r > n, uses r % n
4950 % 594 = 198              # n > r, uses n % r
891 % 198 = 99                # r > n, uses r % n
99 % 99 = 0                   # r % n = n % r = 0, terminated

Result: [1234575, 816021, 92313, 29655, 26037, 20988, 4950, 198, 99]

A final example n=11000:
11000 % 11 = 0 # n % r = 0, terminated

Result: []

This is code-golf lowest byte-count wins.

Can the results be printed as the calculations happen or must it construct an array?

I'd assume the default output rules apply, so you can choose output formart (array, displayed numbers separated by spaces, ...)

@Flp.Tkc I will not restrict output, as long as the numbers required are displayed.

Is the initial number allowed to be displayed?

@Flp.Tkc "neither n nor 0 may appear in the output" has been there since I made it .

So... this is basically the Euclidean algorithm on n and reversed(n)?

Just a note that the 'reverse' of a number is only meaningful with respect to a particular base.

@Sp3000 sort of; except that you need to take the reverse every iteration. You only thread one number through the calculation, not two, and take the second to always be the reverse of the first.

Is it okay if the program terminates w/ an exception?

@SocraticPhoenix what is the reasoning behind the exception? Gonna default to no, but if there's a valid reason... Maybe...

I've got a loop that terminates when attempting to take the mod w/ 0...

05AB1E, 11 bytes
[Â‚{R`%Ð>#,

Uses the CP-1252 encoding. Try it online!

PowerShell v2+, 89 bytes
param($n)for(){$r=-join"$n"["$n".length..0];if(!($n=(($r%$n),($n%$r))[$n-gt$r])){exit}$n}

Iterative solution. Lengthy because there's no easy way to reverse an array, so we stringify it and index on it backwards to store into $r. Then a pseudo-ternary to pull out the appropriate modulo and re-store into $n for the next round. However, if the result is zero, that means the !($n...) will be $true, so we exit instead of $n. The numbers are left on the pipeline and (implicitly) returned as an array, but without an encapsulating pipeline or saving the results into a variable, the default Write-Output sticks a newline between.
Try it online! (Yes, dead serious.)
PowerShell is now on TIO! You gotta give it a second or two, because PowerShell is a beast to startup, but now you, yes you, can verify PowerShell code right in your browser!

Gah, beat me to it and with the same approach. Nice!

Perl, 43 38 + 1 = 39 bytes
Run with the -n flag
say while$_=($;=reverse)>$_?$;%$_:$_%$

Try it online!  Includes the two non-empty examples.
Explanation chart
-n: Wraps the entire program in while(<>){ ... ;}.  This turns the above code into the following line: while(<>){say while$_=($;=reverse)>$_?$;%$_:$_%$;}.  Notice, a semicolon has been added to the trailing $, so it now becomes an instance of the variable $;.  In the condition of a while loop, <> automatically reads one line of input and saves it in the $_ variable.  So now let's look at what the interpreter reads inside the outer while loop:
say while$_=($;=reverse)>$_?$;%$_:$_%$;
[op][mod][         condition          ]     #While is acting as a statement modifier.
                                            #It evaluates the operation as long as the condition is truthy.
            ($;=reverse)>$_?$;%$_:$_%$;     #The meat of the program: a ternary operation
            ($;=reverse)                    #The reverse function takes $_ as a parameter by default, and reverses the value.
                                            #The value returned by reverse is stored in the variable $;
                        >$_                 #A condition asking if $% is greater than $_.  Condition of the ternary operation
                           ?$;%$_           #If true, then return $; modulo $_
                                 :$_%$;     #If false, return $_ modulo $;
         $_=                                #Assign the result of the ternary operation back into $_
                                            #If $_ is non-zero, then the condition is true, and while will evaluate the operation
say                                         #Implicitly takes the $_ variable as parameter, and outputs its contents

Original code, saved for posterity: 43 + 1 = 44 bytes
say$_=$%>$_?$%%$_:$_%$%while$_-($%=reverse)

$%>$_?$%%$_:$_%$% Did you choose the $% variable on purpose just for this line?

Almost - I also save 1 byte by using a non-alphanumeric character for the last character before the while statement, so I don't need a whitespace.  Other than that - pretty much, yeah

Pyth, 13 12 bytes
t.u|%F_S,s_`

Thanks to @TheBikingViking.
Try it online: Demonstration
My old code:
W
W=Q%F_S,s_`

Try it online: Demonstration
Explanation:
t.u|%F_S,s_`NNNQ  implicit Ns and Q at the end
               Q  start with N = Q (Q = input number)
        ,         create a pair with the numbers
         s_`N        convert N to string -> reverse-> convert to int
             N       and N
       S          sort
      _           reverse
    %F            fold by modulo
   |          N   or N (if the result is zero use N instead to stop)
 .u               apply this ^ procedure until a value repeats
                  print all intermediate values
 t                except the first one (the original number)

12 bytes: t.u|%F_S,s_<backtick>. Test

@TheBikingViking Thanks, that is really clever.

Jelly, 15 14 13 bytes
,ṚḌṢṚ%/
ÇÇÐ¿Ḋ

TryItOnline
How?
,ṚḌṢṚ%/ - Link 1, iterative procedure: n
,       - pair n with
 Ṛ      - reverse n
  Ḍ     - undecimal (int of digit list)
   Ṣ    - sort
    Ṛ   - reverse
     %/ - reduce with mod

ÇÇÐ¿Ḋ - Main link: n
  Ð¿  - collect while
 Ç    - last link as a monad is truthy
Ç     -     last link as a monad
    Ḋ - dequeue (remove the input from the head of the resulting list)

Jelly, 13 12 bytes
,ṚḌṢṚ%/Ṅß$Ṡ¡

This is a monadic link/function that prints to STDOUT.
Try it online!
How it works
,ṚḌṢṚ%/Ṅß$Ṡ¡  Monadic link. Argument: n

,Ṛ            Pair n and its reversed digit list.
  Ḍ           Convert the digit list into an integer.
   ṢṚ         Sort and reverse.
     %/       Reduce by modulo. Result: m
          Ṡ¡  Do sign(m) times:
       Ṅß$    Print with a newline and call the link recursively.

What's the footer for? If removed the code seems to output a trailing 0

That's correct. The 0 is the return value of the function, which the interpreter prints if it isn't discarded. As per this meta discussion, that's allowed.

Python 2, 92 87 81 73 61 bytes
Recursive solution:
def f(n):
    r=int(`n`[::-1]);x=min(r%n,n%r)
    if x:print x;f(x)

Try it online
Iterative solution: (also 61 bytes)
n=input()
while n:r=int(`n`[::-1]);n=min(r%n,n%r);print n/n*n

Try it online

The iterative solution that i gave you is actually 59 bytes, but I'm not sure if it's valid because it prints the input. If it is, then you can golf of 2 bytes by just doing while n:. Otherwise, you can do it with 61 bytes.

MATL, 16 bytes
`tVPUhSPZ}\tt]xx

Try it online!
Explanation
`         % Do...while
  t       %   Duplicate. Takes input implicitly in the first iteration
  VPU     %   Transform the number at the top of the stack by reversing its digits
  hSPZ}   %   Concatenate the two numbers into an array, sort, reverse, split the
          %   array: this moves the smaller number to the top
  \       %   Modulo
  t       %   Duplicate. The original copy is left on the stack for displaying,
          %   and the duplicate will be used for computing the next number
  t       %   Duplicate. This copy will be used as loop condition: exit if 0
]         % End
xx        % Delete the two zeros at the top. Implicitly display rest of the stack

PHP, 78 bytes
function a($n){while(($r=strrev($n))&&($n=$r>$n?$r%$n:$n%$r)!=0){echo$n.' ';}}

Batch, 140 bytes
@echo off
set/pn=
:l
set/am=n,l=0
:r
set/al=l*10+m%%10,m/=10
if %m% gtr 0 goto r
set/an=l%%n%%l+n%%l%%n
if %n% gtr 0 echo %n%&goto l

Takes input on STDIN and outputs the sequence on separate lines. Batch has conditional statements (which are somewhat verbose) but no conditional expressions so it's easier (despite having to quote the %s) to compute r%n%r (which is equal to r%n if n<r or zero if n>r) and n%r%n (which is equal to n%r if n>r or zero if n<r) and add them together.

Mathematica, 68 bytes
Thanks to Greg Martin for suggesting I use FixedPointList rather than NestWhileList:
FixedPointList[Mod[(r=IntegerReverse@#)~Max~#,r~Min~#]&,#][[2;;-4]]&

The shortest I could get my original solution with FixedPointList was 73 bytes:
NestWhileList[Mod[(r=IntegerReverse@#)~Max~#,r~Min~#]&,#,#!=0&][[2;;-2]]&

Note that you don't have quite the right terminating condition (try the example input 11000). You might get around this by switching to the technique described in your last paragraph. But I don't see how to get rid of Rest or Most in this way. On the other hand, FixedPointList[    Mod[(r = IntegerReverse@#)~Max~#, r~Min~#] &, #][[2 ;; -4]] & is only 68 bytes once the spaces are removed (throws a couple of errors, nbd).

I had somehow convinced myself that spans like {a,b,c,d}[[2;;-4]] would give an error rather than the empty list (I probably used a comma rather than ;;). Learned something.

You can get rid of that whole min/max business with a Sort: FixedPointList[-Mod@@Sort@-{#,IntegerReverse@#}&,#][[2;;-4]]&

R, 126 117 bytes
x=scan();while(x){y=sort(c(x,as.double(paste(rev(el(strsplit(c(x,""),""))),collapse=""))));if(x<-y[2]%%y[1])print(x)}

Sadly, reversing a number (as.double(paste(rev(el(strsplit(c(x,""),""))),collapse="")))) is pretty wordy. Rest is pretty easy. Uses sort to indirectly check which is higher.
The rest is straightforward, it keeps looping until x=0, and prints all steps.

C, 87 bytes
t;r;f(n){while(t=n){r=0;while(t)r=10*r+t%10,t/=10;n=r>n?r%n:n%r;if(n)printf("%d ",n);}}

t is temporary for reversing. The inner loop shifts r 1 digit to the left and adds the last digit of t until it is exhausted. Output is after the first iteration and only if it is non-zero to prevent the first and last item to be displayed.
Ungolfed and usage:
t;r;
f(n){
  while (t = n){
    r = 0;
    while (t)
      r = 10*r + t%10,
      t /= 10;
    n = r>n ? r%n : n%r;
    if(n)
      printf("%d ",n);
  }
}

JavaScript, 72 70 bytes

f=(s,...o)=>(u=s>(z=[...s+''].reverse().join``)?s%z:z%s)?f(u,...o,u):o

console.log(...[32452345, 12345678, 11000].map(x=>f(x)))
.as-console-wrapper{max-height:100%!important}

Edited:
-2 bytes: Spread operator waits string concatenation.

Racket 180 bytes
(let p((n n)(ol'()))(let*((v reverse)(o modulo)
(r(string->number(list->string(v(string->list(number->string n))))))
(m(if(> n r)(o n r)(o r n))))(if(= m 0)(v ol)(p m(cons m ol)))))

Ungolfed:
(define (f n)
  (let loop ((n n)
             (ol '()))
    (let* ((r (string->number
               (list->string
                (reverse
                 (string->list
                  (number->string n))))))
           (m (if (> n r)
                  (modulo n r)
                  (modulo r n))))
      (if (= m 0)
          (reverse ol)
          (loop m (cons m ol))))))

Testing:
(f 32452345)
(f 12345678)

Ouput:
'(21873078 21418578 1907100 9999)
'(1234575 816021 92313 29655 26037 20988 4950 198 99)

Mathematica, 64 bytes
NestWhileList[#2~If[#<=#2,Mod,#0]~#&[IntegerReverse@#,#]&,#,#>0&]&

The above code represents a pure function which takes a single input, and returns the kuznetsovs sequence. The really beautiful thing about mathematica is that you can put layer upon layer of pure functions... Allow me to explain the code ;)
Each term in the sequence itself is calculated with the below function, which takes one input and returns the next term.
#2~If[#<=#2,Mod,#0]~#&[IntegerReverse@#,#]&

The code IntegerReverse@# just generates r, the reversed value. The code #2~If[#<=#2,Mod,#0]~#& is a function that takes two inputs and either does the mod operation, or reverses the inputs and calls itself again. Another way of writing it is If[#<=#2, Mod, #0][#2, #]&, or it could be written as a regular function like this: k[a_, b_] := If[a <= b, Mod, k][b, a]

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


text:
Output the HTML colors
The 16-color CGA palette (also known as the HTML colors) is a set of 16 colors used by early graphics adapters. The goal of this challenge is to output all 16 of them, in hex format (RRGGBB), in ascending order by hex value, separated by newlines. Thus, the output should be exactly this:
000000
000080
0000FF
008000
008080
00FF00
00FFFF
800000
800080
808000
808080
C0C0C0
FF0000
FF00FF
FFFF00
FFFFFF

A single trailing newline is allowed, but not required.

Jelly, 31 29 27 bytes
“×Ɗ¡‘ŒP»Ṫ¦209ṗ€3Fd⁴ịØHs3ṢQY

Try it online!
How it works
“×Ɗ¡‘ yield the code points of the characters between the quotes in Jelly's SBCS, which are 0x11 = 17, 0x91 = 145, and 0x00 = 0.
ŒP constructs the powerset of the array of code points, yielding
[[], [17], [145], [0], [17, 145], [17, 0], [145, 0], [17, 145, 0]]

The last two entries correspond to combinations that contain both 80 and FF, so we have to discard them.
»Ṫ¦209 consists of three parts:

Ṫ (tail) removes the last array of code points, i.e., [17, 145, 0].
»209 takes the maximum of each integer in the remainder of the powerset and 0xD1 = 209, replacing all of them with 209.
¦ (sparse) iterates over the elements of the remainder of the powerset. If the corresponding index is found in [17, 145, 0], the element is replaced with all 209's. If not, it is left untouched.
¦ isn't modular, so this modifies only the last array (index 0) in the remainder of the powerset. The indices 17 and 145 are too large and have no effect.

The result is as follows.
[[], [17], [145], [0], [17, 145], [17, 0], [209, 209]]

ṗ€3 computes the third Cartesian power of each array, i.e., the array of all 3-tuples of elements of each array.
Fd⁴ flattens the result and computes quotient and remainder of each integer divided by 16.
ịØH indexes (1-based) into "0123456789ABCDEF, so 0x11, 0x91, 0x00, and 0xD1 get mapped to "00", "80", "FF", and "C0" (resp.).
s3ṢQ splits the character pairs into 3-tuples, sorts the tuples, and deduplicates.
Finally, Y joins the unique tuples, separating by linefeeds.

Bash + GNU Utilities, 67

2 bytes saved thanks to @manatwork
2 bytes saved thanks to @zeppelin

a={00,80,FF}
eval echo $a$a$a|fmt -w9|sed '16iC0C0C0
/F0*8\|80*F/d'

The brace expansion {00,80,FF}{00,80,FF}{00,80,FF} gives all need combinations in the right order (excluding C0C0C0), along some extras.  The extras are the ones that contain both F and 8 characters.
The result of the brace expansion is a single space-separated line.  fmt puts each entry on its own line
The 1st line of the sed expression inserts C0C0C0 in the appropriate line
The 2nd line of the sed expression filters out the "extras" described above.

Ideone.

Jelly, 38 31 bytes
“mạ9ṣṃwɠƁ,¡ẓw’b4µża1$ị“08CF”s3Y

TryItOnline!
Base 250 compression of a number  (“...’),
converted to base 4 (b4),
zipped (ż) with a copy of itself after a vectorised logical-and with 1 (a1$)*,
indexed (ị) into the four characters used (“08CF”),
split into chunks of length 3 (s3),
and joined with line feeds (Y).
* Thus pairing each zero digit with another zero and each of any other digits with a one. Along with the following indexed fetch this means 'F' becomes paired with another 'F' while '0','8', and 'C' each pair with a '0'.

Minor edit to fix this answer: “0FC8”, as we have 00, FF, C0, and 80.

Oh wow, I did not notice! Thank you.

Python 3, 134 129 125 108 91 90 bytes
I think there is still a lot of golfing to do here. Golfing suggestions welcome!
Edit: -9 bytes and many thanks to Mego for helping with the string formatting. -17 bytes from figuring out a better way to print the string in the first place. -17 bytes from figuring out a better way to write the for loop in the first place. -1 byte thanks to xnor's tip to use i%3//2*"\n" instead of "\n"*(i%3<2).
for i in range(48):print(end="F0C8F000"[0x10114abf7f75c147d745d55//4**i%4::4]+i%3//2*"\n")

Ungolfing
z = 0
a = [0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0, 2, 2, 2, 3, 3, 3, 1, 3, 3, 3, 1, 3, 1, 1, 3, 0, 0, 1, 1, 0, 1, 3, 3, 1, 1, 3, 1, 0, 1, 1, 3, 1, 1, 1, 1, 1]
for i in range(len(a)):
    z = (z + a[i]) * 4
z //= 4                   # we multiplied by 4 one too many times
for i in range(48):
    m = z // 4**j % 4
    s = "F0C8F000"[c::4]
    if i % 3 == 2:
        s += "\n"
    print(s, end="")

Try like this - you have to wrap the argument in parentheses (or square brackets) and splat it with *.

i%3//2*"\n" saves a byte.

This works with py 3 too

@Miguel No, that's an edit I didn't clean up. It doesn't work with Python 2.

PowerShell, 113 106 bytes
'777
7780
77FF
7807
78080
7FF7
7FFFF
8077
80780
80807
808080
C0C0C0
FF77
FF7FF
FFFF7
FFFFFF'-replace7,'00'

Yeah, I haven't found anything shorter than just printing the literal string... Thanks to @Martin Smith for shaving down 7 bytes using a simple replacement (which I completely overlooked). So, we're at least 7 bytes shorter than simply hardcoding it. Yay!
But that's boring!
So instead ...
PowerShell v4, 128 bytes
[consolecolor[]](0,7+9..15)+-split'Lime Maroon Navy Olive Purple Silver Teal'|%{-join"$([windows.media.colors]::$_)"[3..8]}|sort

The [system.consolecolor] namespace defines the console colors (natively) available to the PowerShell console. If we reference them via an integer array like this, the default value is the name (e.g., Black or White or the like). We combine that with a string that has been -split on spaces, so now we have an array of strings of color names.
We loop through those |%{...} and each iteration pull out the corresponding [system.windows.media.colors] value. The default stringification for those objects is the color in #AARRGGBB format as a hex value, so we leverage that by encapsulating that call in a string with a script block "$(...)". But, since we don't want the alpha values or the hash, we take the back end [3..8] of the string, and need to -join that resulting char-array back into a string. Then, a simple Sort-Object to put them in the right order.

There are 21 instances of 00 and .Replace(7,'00') is < 21 chars.

I don't know how to use PowerShell, but it might be worth it to also replace 80 and FF.

@nedla2004 Doing the -replace for 8 and 80 is the same byte count (saves 12 zeros, which is -replace8,80 length). Doing it for the FF is longer by two bytes because of the quotes needed around the "FF" in the -replace2,"FF" statement.

Ok, I was wondering if you could combine the replacements somehow.

JavaScript (ES6), 109 107 bytes
Saved 2 bytes, thanks to Neil
This is 7 9 bytes shorter than just returning the raw string in backticks.
_=>[...'1121173113106393'].map(v=>[4,2,0].map(x=>'08CF'[x=n>>x&3]+'000F'[x],n+=+v||21).join``,n=-1).join`
`

Test

let f =

_=>[...'1121173113106393'].map(v=>[4,2,0].map(x=>'08CF'[x=n>>x&3]+'000F'[x],n+=+v||21).join``,n=-1).join`
`

console.log(f())

Interestingly .replace(/./g) is the same length as .map().join, but .map(x=>'08CF'[x=n>>x&3]+'000F'[x],n+=+v||21) saves two bytes.

MATL, 39 bytes
'80FFC000'2e'3na:1Fswv1=`uIn'F4:ZaZ)6e!

Try it online!
'80FFC000'         % Push this string
2e                 % Reshape with 2 rows. So 1st column contains '80', 2nd 'FF' etc
'3na:1Fswv1=`uIn'  % Push this string
F4:Za              % Convert from base 95 to alphabet [1 2 3 4]
Z)                 % Use as column indices into the first string
6e!                % Reshape with 6 rows and transpose.
                   % Implicitly display

Pyth - 64 48 44 bytes
Super simple base compression.
jcs@L"FC80"jC"ÿÿûÿ¿û¿ðÿ¿»¿»·wðð\0ð\0"4 6

Try it online here.

05AB1E, 57 bytes
•P{Ætg7«r¨ëÅ,…}ù¢Ý%Vt®£8ãøÚ$0óDÛY²Zþ…ð7ê‘Ó{òìàYëØU¥•hR6ô»

Try it online!
What we need to output is basically (reversed and split):
FFFFFF00FFFFFF00FF0000FF0C0C0C080808000808080008000008FFFF0000FF00080800000800FF0000080000000000

Which, in decimal is:
39402003857025890357721060524755992261661062099432941475272448103296644696683709026793043150430945208910007869898752

Which in Base-214 is:
P{Ætg7«r¨ëÅ,…}ù¢Ý%Vt®£8ãøÚ$0óDÛY²Zþ…ð7ê‘Ó{òìàYëØU¥

This is the simplest solution I could come up with, because there's no way in hell I'm beating Dennis. Spent an hour trying and nothing beat his idea.

PHP, 92 Bytes
<?=strtr("000
001
002
010
011
020
022
100
101
110
111
333
200
202
220
222",["00",80,FF,CO]);

Try it online!
simply replacement from the digits as key in the array with the values strtr

Batch, 137 bytes
@for %%c in (000000 000080 0000FF 008000 008080 00FF00 00FFFF 800000 800080 808000 808080 C0C0C0 FF0000 FF00FF FFFF00 FFFFFF)do @echo %%c

Yes, it's that boring. Previous 148-byte attempt:
@if "%2"=="" (call %0 000000 80&call %0 C0C0C0 FF)|sort&exit/b
@echo %1
@for %%c in (0000%2 00%200 00%2%2 %20000 %200%2 %2%200 %2%2%2)do @echo %%c

Unfortunately you can't pipe the output of a for or a call: command, so I have to invoke myself recursively.

Pyke, 42 bytes
"80FF"2c8DF3"00"]F3+b2tRT`_R.:(s}"C0"3*+SJ

Try it here!

Befunge, 83 69 bytes
<v"UVTYZQPefij?EDA@"
v>>9\:4/:\4/>4%:3g,0`
<^_@#:,+55$_^#!-9:,g3
F08C

Try it online!
The colours are encoded in the string you see on the first line, two bits per colour component, with an additional high bit set to force each value into the ASCII range (except in the case of 63, which would be out of range as 127).
The list of colours on the stack is then processed as follows:
9\          9 is pushed behind the current colour to serve as a marker.
:4/:\4/     The colour is repeatedly divided by 4, splitting it into 3 component parts.

>           The inner loop deals with each of the 3 components.
 4%         Modulo 4 masks out the 2 bits of the colour component that we care about.
 :3g,       That is used as an index into the table on line 4 to get the character to output.
 0`3g,      For component values greater than 0 the second char is a '0', otherwise an 'F'.
 :9-!       Check if the next component is our end marker.
^           If not, repeat the inner loop.

55+,        Output a newline.
:_          Repeat the outer loop until there are no more colours on the stack.

C#, 195 bytes
void n(){string a="000000\r\n000080\r\n0000FF\r\n008000\r\n008080\r\m00FF00\r\n00FFFF\r\n800000\r\n800080\r\n808000\r\n808080\r\nC0C0C0\r\nFF0000\r\nFF00FF\r\nFFFF00\r\nFFFFFF";Console.Write(a);}

Sadly this beats, by a huge margin, the more interesting albeit incredibly convoluted (I had tons more fun writing it) C#, 270 bytes
void n(){string a,b,c,d;a="00";b="80";c="C0";d="FF";for(int i=0;i<16;i++){Console.WriteLine((i<7?a:i<11?b:i>11?d:c)+(i<3?a:i<5?b:i<7?d:i<9?a:i<11?b:i==11?c:i<14?a:d)+(i==0||i==3||i==5|i==7||i==9||i==12||i==14?a:i==1||i==4||i==8||i==10?b:i==2||i==6||i==13||i==15?d:c));}}

You could just directly return the string in your function - no need to store it in a variable and then print it. Also, a) you can use a lambda, and b) I'm certain there is a solution that beats simply dumping the string.

@Mego this is my first C# post in golf, not sure how I do a lambda function in all honesty!

I would suggest looking through this list to find some improvements to make.

@Alfie Goodacre: C# lambda that just returns a value: ()=>@"string_here" (this casts to Action<string>). I also suggest using a verbatim string (@) so that you can just put the new lines directly in the string without needing to escape them.

C (gcc), 99 bytes
f(i){for(i=48;i--;)printf("%.2s%s","FFC08000"+("#&/28MNQRSV]^_ab"[i/3]-35>>i%3*2&3)*2,"\n\0"+i%3);}

Try it online!
After having made an attempt involving creating a list of numbers and outputting them while sorting, I compared to the naïve solution, which was sobering:
f(){puts("000000\n000080\n0000FF\n008000\n008080\n00FF00\n00FFFF\n800000\n800080\n808000\n808080\nC0C0C0\nFF0000\nFF00FF\nFFFF00\nFFFFFF");}

That one clocks in at 140 bytes compared to my try at 200 and change.
The solution was to think of it as text like any other, albeit with a small alphabet. Each colour could be thought of as a triplet of 2-bit indices into the alphabet {0xff, 0xc0, 0x80, 00}. The process of colour -> triplet -> number -> character (with offset +35 to make them all printable and avoid any need for escapes) can be illustrated as such:
000000  333     63  b
000080  332     62  a
0000FF  330     60  _
008000  323     59  ^
008080  322     58  ]
00FF00  303     51  V
00FFFF  300     48  S
800000  233     47  R
800080  232     46  Q
808000  223     43  N
808080  222     42  M
C0C0C0  111     21  8
FF0000  033     15  2
FF00FF  030     12  /
FFFF00  003     3   &
FFFFFF  000     0   #

Then it's just a matter of iterating over the resulting string and cutting out the appropriate parts of the alphabet string.


text:
Optimize ASCII test-tubes
You are given a bunch of ASCII test-tubes, your task is to reduce number of test-tubes used.
Each test tube looks like this:
|  |
|  |
|  |
|~~|
|  |
|  |
|  |
|  |
|__|

Obviously, ~~ is the water level. Test-tube can be also empty, in which case there are no ~~ characters inside. Single tube can contain up to 8 water level units.
You are given finite number of test tubes with different water levels inside. You have to pour the water in least amount of test-tubes possible, and output the result.
|  | |  | |  | |  |         |~~| |  |
|  | |  | |  | |  |         |  | |  |
|  | |~~| |  | |  |         |  | |  |
|~~| |  | |  | |  |         |  | |~~|
|  | |  | |  | |  | ------> |  | |  |
|  | |  | |  | |  |         |  | |  |
|  | |  | |~~| |  |         |  | |  |
|  | |  | |  | |  |         |  | |  |
|__| |__| |__| |__|         |__| |__|

 05 + 06 + 02 + 00  ------>  08 + 05

As you can see, test-tubes are separated with single space. Empty tubes should not be shown in output.
This is code golf, so code with least number of bytes wins.
Test cases: http://pastebin.com/BC0C0uii
Happy golfing!

Can we also redistribute the water? E.g. would 7+6 be a valid output for your example?

@MartinEnder You should use least amount of tubes possible. I think that's acceptable in this case.

@StewieGriffin I haven't seen anything similar here yet, so If that's a kinda duplicate I'm sorry

Is trailing whitespace allowed?

Better title - "Optimizer ASCII test tube babies"

@Pietu1998 I think it is

What should the output look like for only empty tubes in the input? Three times - as guessed from the examples?

@nimi No, no, there should be not output at all. Sorry for misleading you

Pyth, 48 45 44 bytes
jCssm+_B,*9\|_X+\_*8;ld\~*9;cUs*L/%2w\~_S8 8

Try it online.
Prints a single trailing space on every line.

JavaScript (ES6), 159 148 bytes
s=>s.replace(/~~|\n/g,c=>1/c?i++:n+=7-i,n=i=-1)&&`012345678`.replace(/./g,i=>`|${g(+i)}| `.repeat(n>>3)+`|${g(~n&7^i)}|
`,g=i=>i?i>7?`__`:`  `:`~~`)

Outputs a trailing linefeed. Edit: Saved 11 bytes with some help from @Arnauld.

s.replace(/~~/g,(_,i)=>n+=9-i/s.indexOf\\n`|0,n=0)should save 4 bytes. You may want to initialize n to -1 instead and usen>>3and~n&7^i` to save one more byte.

@Arnauld Thanks for the -1 idea but I was able to improve on the replace idea.

Nice! I never realized 1/"\n" was truthy.

@Arnauld Well, it was only an extra byte of icing on the cake...

Perl, 150 bytes
149 bytes of code + -n flag.
$l+=9-$.for/~~/g}if($l){$%=($v=$l/8)+($r=$l!=8);say"|~~| "x$v.($@="|  | ")x$r;say$:=$@x$%for$l%8..6;say$@x$v."|~~|"x$r;say$:for 2..$l%8;say"|__| "x$%

I won't explain all the code, just a few things:
$l+=9-$.for/~~/g counts how much water the is in the input.
The second part of the code prints the output. The idea is to put as many fully filled tubes as possible, and a last one which contains the water that is left (if any). So the algorithm is in 4 parts: prints the first line of water (the top of tubes): say"|~~| "x$v.($@="|  | ")x$r. Then, print empty parts of tubes until we reach the level of water of the last tube: say$:=$@x$%for$l%8..6. Then print the level where the last tube water is: say$@x$v."|~~|"x$r. Then, print all the remaining "empty" levels: say$:for 2..$l%8;. And finally, print the bottom line: say"|__| "x$%.
The variable names make it hard to read ($%, $@, $:) but allows for keywords like x and for to be written after the variable without a space.
To run it:
perl -nE '$l+=9-$.for/~~/g}if($l){$%=($v=$l/8)+($r=$l!=8);say"|~~| "x$v.($@="|  | ")x$r;say$:=$@x$%for$l%8..6;say$@x$v."|~~|"x$r;say$:for 2..$l%8;say"|__| "x$%' <<< "|  | |  | |  | |  |
|  | |  | |  | |  |
|  | |~~| |  | |  |
|~~| |  | |  | |  |
|  | |  | |  | |  |
|  | |  | |  | |  |
|  | |  | |~~| |  |
|  | |  | |  | |  |
|__| |__| |__| |__| "

I'm not very satisfied with how long this answer is. I tried to make the best out of my algorithm, but a different approach could probably be shorter. I'll try to work on it soon.

@JamesHolderness I tried all of the test cases (and re-tried now because you had me doubting) and it seems fine to me. "The last one" is the one with 3 tubes: 2 with water level at 4, and 1 with water at level 2, right? If so, then I tried it and it gives the same output as the one on pastbin

@JamesHolderness Oh right, it explains a lot! Thanks :)

Befunge, 144 138 bytes
9>1-00p>~$~2/2%00gv
 |:g00_^#%4~$~$~+*<
$< v01!-g01+*8!!\*!\g00::-1</8+7:<p01-1<9p00+1%8-1:_@#:
_ ~>g!-1+3g:"|",,," |",,:>#^_$55+,10g:#^_@

Try it online!
The first two lines process the input, basically ignoring everything except the first character in each tube that might be a level marker. We take the ASCII value of that character, divide by 2 and mod 2 (giving us 1 or 0 depending on whether we're on a level marker or not), multiply that by the row number (counting down from 8, thus giving us the level value for that tube), and add it to a running total.
The output is handled on the second two lines, essentially starting on the far right of the third line. We first calculate the number of tubes by taking the total water level plus 7 divided by 8. Then when iterating over the rows of all the tubes, we calculate the character to display inside a specific tube (t, counting down to 0) for a given row (r, counting down from 8 to 0) as follows:
last_level = (total_water - 1)%8 + 1
level      = last_level*!t + 8*!!t
char_type  = !(level - r) - !r

The calculated char_type is -1 for the bottommost row (the base of the tube), 0 for a any other area that isn't a water level, and 1 for the water level. It can thus be used as simple table lookup for the appropriate character to output (you can see this table at the start of line 4).

Haskell, 186 bytes
import Data.Lists
z=[8,7..0]
f x|s<-sum[i*length j-i|(i,j)<-zip z$splitOn"~~"<$>lines x],s>0=unlines$(\i->(#i)=<<(min 8<$>[s,s-8..1]))<$>z|1<2=""
l#i|i==l="|~~| "|i<1="|__| "|1<2="|  | "

Usage example:
*Main> putStr $ f "|  | |  | |  | |  |\n|  | |  | |  | |  |\n|  | |~~| |  | |  |\n|~~| |  | |  | |  |\n|  | |  | |  | |  |\n|  | |  | |  | |  |\n|  | |  | |~~| |  |\n|  | |  | |  | |  |\n|__| |__| |__| |__|"
|~~| |  |
|  | |  |
|  | |  |
|  | |~~|
|  | |  |
|  | |  |
|  | |  |
|  | |  |
|__| |__|

Puts a trailing space on every line. How it works:
              lines x      -- split the input string at newlines
      splitOn"~~"<$>       -- split every line on "~~"
    zip z                  -- pair every line with its water level, i.e.
                           -- first line = 8, 2nd = 7 etc.
   [i*length j-i|(i,j)   ] -- for each such pair take the number of "~~" found
                           -- times the level
 s<-sum                    -- and let s be the sum, i.e. the total amount of water

  s>0                      -- if there's any water at all

          [s,s-8..1]       -- make a list water levels starting with s
                           -- down to 1 in steps of 8
       min 8<$>            -- and set each level to 8 if its greater than 8
                           -- now we have the list of water levels for the output
  \i->(#i)=<<(  )<$>z      -- for each number i from 8,7..0 map (#i) to the
                           -- list of output water levels and join the results
unlines                    -- join output lines into a single string (with newlines)

l#i                        -- pick a piece of tube:
                           --  |__|  if l==0
                           --  |~~|  if l==i
                           --  |  |  else

  |1<2=""                  -- if there's no water in the input, return the
                           -- empty string

The main pain was the lack of a function that counts how often a substring occurs in a string. There's count in Data.Text, but importing it leads to a bunch of name conflicts that are way too expensive to resolve.

Ruby, 139 bytes
(138 bytes of code plus one byte for the -n)
n||=0;b=gsub(/~~/){n=n+9-$.}[0,5];END{8.times{|i|puts (b*(n/8)).tr(?_,i>0??\ :?~)+(n%8>0?b.tr(?_,(8-i==n%8)??~:?\ ):"")};puts b*((n+7)/8)}

Try it online!
A few explanations:

This program requires the -n switch.
n – water counter.
b – Template for constructing tubes; equals "|__| "
i – Current line index during tube construction.
gsub(/~~/){…} – This abuses gsub to simply count the water level. gsub actually expands to Kernel.gsub, which is equivalent to $_.gsub!. This unnecessarily manipulates the current line ($_); however, it allows for a more concise assignment of b=…[0,5] instead of b=$_[0,5].
n=n+9-$. – To measure the water level, the expression uses the pre-defined variable $., which carries the current input line number. This allowed me to lose the explicit loop variable.
b=gsub(/~~/){…}[0,5] – caches the bottom of the leftmost tube as a template. (Feels a little bit like the “Elephant in Cairo” pattern to me because the bottom line wins.)
  Since the bottom of the tube never shows water, the gsub won’t replace anything when we’re there; therefore in the end, b always equals "|__| ".
END{…} – Gets called after the whole input stream has been processed. I use this phase to construct the target tubes.
i>0??\ :?~ – is simply short-hand for i > 0 ? " " : "~".

Update 1: Added details on variables, the gsub trickery and the END{…} phase.
Update 2: (±0 bytes overall)

Use n||=0 instead of n=n||0 (-1 byte)
Took malus for -n (+1 byte)

Python, 261 bytes
i=input().split('\n')
t=0
R=range(9)[::-1]
for n in R:t+=i[n].count('~')/2*(8-n)
m=t%8
e=t/8
o=t/8+1
T='|~~| '
b='|  | '
B='|__| '
n='\n'
if m:
 print T*e+b
 for n in R:
    if n==m:print b*e+T
    else:print b*o
 print B*o
elif t<1:1
else:print T*e+(n+b*e)*7+(n+B)*e

I feel like there is something I am missing. Also, if a bunch of newlines are accptable for the blank output, I could lose some bytes. Takes input like '|  | |  | |  |\n|  | |  | |  |\n|  | |  | |  |\n|  | |  | |  |\n|  | |  | |  |\n|  | |  | |  |\n|  | |  | |  |\n|  | |  | |  |\n|__| |__| |__|'.

Python 3, 404 bytes
This program creates the full intended output with the water levels both in ASCII and number formats.
w,x,y=[],[],[];a,b,s=" ------> ","~","";y=input().split("\n")
for i in [i for i in zip(*y) if "_" in i][::2]:w+=[8-i.index(b)] if b in i else [0]
u=sum(w)
while u:x+=[[8],[u]][u<8];u-=x[-1]
for i,k in enumerate(y):
    s+=k+"%s"%[a," "*9][i!=4]
    for j,l in enumerate(x):
        c=["  ","__"][i==8];s+="|%s| "%(c,b*2)[l==8-i]
    s+="\n"
s+="\n"
for i in w:s+=" %02d  "%i
s+="\b"+a
for i in x:s+=" %02d  "%i
print(s)


text:
Golfed decimal fractions
Your goal is to write some code that will output the shortest unique decimal sequence for the input fraction. No two fractions with the same denominator may have the same output, although it's possible for fractions with different denominators to have the same representation.
Take 2 integers as input, the first is the numerator, the second is the denominator.
E.g.:
n  d   output
-----  ------
0 13:  0.00
1 13:  0.07
2 13:  0.1
3 13:  0.2
4 13:  0.30
5 13:  0.38

etc.
3/13 is the only fraction with a denominator of 13 that starts with 0.2, so no further digits are required. 4/13 and 5/13 both start with 0.3, so another digit is required to distinguish between them.
You may output numbers greater than -1 and less than 1 either with or without a zero before the decimal point, as long as the output is consistent, i.e. 0.5 and .5 are the same number and are both valid. No other leading zeros are allowed. Trailing zeros must be shown if they are necessary to distinguish the output from another value.
You may not round any numbers away from zero; they must be truncated. There must be no leading or trailing spaces. There may optionally be a single trailing newline.
More test values:
   n    d   output
----------  ------
   0    1:   0 (this 0 may not be removed because there's no decimal point)
   5    1:   5
   0    3:   0.0 (or .0)
   4    3:   1.3
   5    3:   1.6
  10    8:   1.2
  11    8:   1.3
  12    8:   1.5
-496  -38:  13.05
 458  -73:  -6.27
  70  106:   0.660 (or .660)
 255  123:   2.07
 256 -123:  -2.081
-257 -123:   2.089
-258  123:  -2.09
 258 -152:  -1.697
-259  152:  -1.70
 260  152:   1.710
 272  195:   1.39
 380  247:   1.538
 455 -455:  -1.000
 -44  891:  -0.049 (or -.049)
 123 1234:   0.099 (or .099)

In each case, the output and the denominator are sufficient to uniquely work out the numerator.

Perl, 77 bytes
#!perl -p
$%++while/ /<grep{!index$_/$',$\=$`/$'.($`%$'?0:n).0 x$%&'?'x$%}$`-2..$`+2}{

Counting the shebang as one, input is taken from stdin.
Sample Usage
$ echo 0 3 | perl golf-decimals.pl
0.0

$ echo 4 3 | perl golf-decimals.pl
1.3

$ echo 11 8 | perl golf-decimals.pl
1.3

$ echo -496 -38 | perl golf-decimals.pl
13.05

$ echo 458 -73 | perl golf-decimals.pl
-6.27

$ echo -44 891 | perl golf-decimals.pl
-0.049

JavaScript (ES7), 118 93 90 bytes
f=(a,b,i=0)=>(v=(p=n=>((n/b*10**i|0)/10**i).toFixed(i))(a))==p(a+1)|v==p(a-1)?f(a,b,i+1):v

I saved 25 bytes, thanks to @Neil.
Saved additional 3 bytes by using recursion.

You always pass /b and i to p so you might as well code them inside p itself and just take a single parameter. Also the answer is just n so you don't have to calculate it again. I have a recursive ES6 version loosely based on this at a mere 86 bytes...

Pyth, 37 bytes
AQJ+`cGHK*20\0<Jf!}<JTm<+`dKTcRH,tGhG

A program that takes input in the form numerator,denominator and prints the result.
Test suite
[Explanation coming later]