text:
Overflow-Proof Buffer
Background
Programmers these days can't seem to keep their buffers straight! A common source of error is trying to use an array index that is too large for the buffer. Your task is to implement a buffer where large indices are reduced to a size that the buffer can handle. Because I decide exactly what's best for everyone, you will implement this buffer to my precise specifications.
Overview
You have a insert-only buffer that grows in size as elements are added to it. The buffer is zero-indexed, and also indexed modulo its current size. The special rule for this challenge is this:

To insert an item at index i means to compute j, j = i % buffer.length() and insert the new item after the jth item in the list.

The only special case is if the buffer is empty, as arithmetic modulo zero doesn't work. Thus, if the buffer is currently empty, the new item will be index 0.
If the buffer has only one item, then you are always inserting after the 0th item. This is just one instance of the general case.
If the buffer contains 6 items: [4, 9, 14, 8, 5, 2] and you are told to insert a new item 10 at index 15, you find that 15 % 6 == 3, and then insert the new 10 after the 8 at index 3 which gives a resulting buffer of  [4, 9, 14, 8, 10, 5, 2]
Problem
Write a function or program that takes in an ordered list of positive integers, and positive integer indices at which to insert them.
Start with an empty buffer, and add the specified integers to the buffer at the corresponding indices.
Output the ordered list of integers that are in the buffer after all the specified insertions have been made.
This is a code-golf challenge, so shortest code wins.
Input guidelines
You may take the input lists however you see fit. Examples:

List of pairs: [ [1,1], [2,4], [3,9], [4,16], [5,25]...]
Item list and index list: [1, 2, 3, 4, 5...], [1, 4, 9, 16, 25]
Flattened: [1, 1, 2, 4, 3, 9, 4, 16, 5, 25 ...]
etc.

You may assume the input always contains at least one item and corresponding index.
Test cases
Squares case from above:
[(1, 1), (2, 4), (3, 9), (4, 16), (5, 25), (6, 36), (7, 49), (8, 64)] -> [1, 2, 8, 7, 6, 5, 4, 3]

I generated these randomly:
[(11, 9), (13, 14)] -> [11, 13]
[(1, 18), (11, 7), (3, 35), (16, 22)] -> [1, 11, 16, 3]
[(3, 16), (16, 37), (0, 28), (18, 24)] -> [3, 18, 0, 16]
[(7, 26), (8, 20), (11, 39), (1, 23), (17, 27)] -> [7, 8, 11, 1, 17]
[(15, 35), (17, 7), (16, 15), (1, 13), (2, 6), (11, 34)] -> [15, 17, 1, 2, 16, 11]
[(2, 13), (1, 20), (16, 25), (8, 21), (5, 2), (16, 37), (3, 0)] -> [2, 3, 8, 1, 16, 5, 16]
[(6, 20), (15, 15), (12, 26), (10, 27), (17, 13), (7, 18), (4, 16)] -> [6, 10, 17, 12, 7, 4, 15]
[(18, 9), (5, 34), (15, 4), (12, 29), (2, 5), (7, 0), (7, 10), (16, 38)] -> [18, 7, 15, 2, 16, 5, 7, 12]
[(0, 12), (12, 0), (4, 16), (15, 12), (6, 28), (8, 10), (11, 24), (0, 25)] -> [0, 11, 8, 6, 15, 0, 4, 12]
[(6, 12), (14, 13), (10, 33), (11, 35), (1, 3), (0, 28), (15, 27), (8, 10), (1, 2)] -> [6, 14, 10, 1, 11, 8, 15, 0, 1]
[(2, 29), (19, 30), (18, 17), (13, 3), (0, 21), (19, 19), (11, 13), (12, 31), (3, 25)] -> [2, 13, 3, 11, 0, 12, 19, 18, 19]

Python3 reference implementation
def f(inputs):
    # `inputs` is a list of pairs
    buff = []
    for item, index in inputs:
        if len(buff) == 0:
            buff.insert(0, item)
        else:
            insert_after = index % len(buff)
            buff.insert(insert_after+1, item)
    return buff

Can the input be taken in reverse?

Yeah I think the input can be more-or-less as flexible as you want.

MATL, 24 22 bytes
"N?@2)yn\Q:&)@1)wv}@1)

Input is a matrix (with ; as row separator) containing the values in the first row and the indices in the second.
Output is a column array, displayed as numbers separated by newlines.
Try it online! Or verify all test cases, with each result displayed on a single line.
Explanation
"          % Input matrix (implicit). For each column
  N        %   Number of elements in the stack
  ?        %   If nonzero (true for all iterations but the first)
    @2)    %     Push second element of current column: new index
    yn     %     Duplicate current buffer; push its number of elements
    \      %     Modulo
    Q      %     Add 1
    :&)    %     Split buffer at that point. This gives two pieces, one
           %     of which may be empty
    @1)    %     Push first element of current column: new value
    wv     %     Swap; concatenate all stack. This places the new value
           %     between the two pieces of the buffer
  }        %   Else (this is executed only in the first iteration)
    @1)    %     Push first element of current column: new value
           %   End (implicit)
           % End (implicit)
           % Display (implicit)

Perl, 37 bytes
35 bytes of code + 2 bytes for -lp flags.
splice@F,1+<>%(@F||1),0,$_}{$_="@F"

Try it online!
The implementation is quite straight forward, splice inserts in array @F at index 1+<>%(@F||1) (note that @F||1 handles the case of the array being empty).
Just a few words about the (seemingly) unmatched braces }{ (because I had a comment about it, and I think it's quite weird for people who don't know Perl), and it's a quite common trick in Perl golfings:
-p flag surrounds the code with (roughly) while(<>){ CODE } continue { print }, (the continue is executed after each iteration). So with those unmatched }{, I change my code to while(<>) { CODE}{ } continue { print }. So it creates an empty block right after my code (but that's not a problem), and the continue is executed only once, after the while (ie. when the all the input has been read).

That }{ is driving me nuts...

@ETHproductions I'm used to it but I love to show it to other people, they always think something is wrong! :) (the downside is that is messes with my emacs indentation..)

That }{ reminds me of this illusion

Yes, I did. :-)

ES6 (Javascript), 58,57,53, 50 bytes
Golfed
a=>a.map((e,i)=>b.splice(1+e[1]%i,0,e[0]),b=[])&&b

Takes an array of index-value pairs, as input.
EDITS

Use && to return value, -1 byte
Removed |0 (as splice apparently can handle NaN just well), -2 bytes
Made b=[] a second "argument" to map(), -2 bytes (Thx @ETHproductions !)
Replaced b.length with map() index (i), -3 bytes (Thx @Patrick Roberts !)

Test
F=a=>a.map((e,i)=>b.splice(1+e[1]%i,0,e[0]),b=[])&&b

F([[11, 9], [13, 14]])
[ 11, 13 ]

F([[2, 29], [19, 30], [18, 17], [13, 3], [0, 21], [19, 19], [11, 13], [12, 31], [3, 25]])
[ 2, 13, 3, 11, 0, 12, 19, 18, 19 ]

Nice, I should've tried non-recursive approaches. I think you can do a=>a.map(e=>...,b=[])&&b

You can subtract 3 bytes by changing e=> to (e,i)=> and using i instead of b.length

@PatrickRoberts That's a nice idea ! Thank you !

Haskell, 70 69 bytes
b!(x,i)|b==[]=[x]|j<-1+i`mod`length b=take j b++x:drop j b
foldl(!)[]

Try it online! Usage: foldl(!)[] [(1,5),(2,4),(3,7)]. Saved one byte thanks to @nimi!
Explanation:
b!(x,i)                         -- b!(x,i) inserts x into list b at position i+1
 | b==[] = [x]                  -- if b is empty return the list with element x
 | j <- 1 + i `mod` length b    -- otherwise compute the overflow-save insertion index j
     = take j b ++ x : drop j b -- and return the first j elements of b + x + the rest of b
foldl(!)[]                      -- given a list [(1,2),(3,5),...], insert each element with function ! into the initially empty buffer

Solution without computing the modulus: (90 bytes)
f h t(x,-1)=h++x:t
f h[]p=f[]h p
f h(c:t)(x,i)=f(h++[c])t(x,i-1)
g((x,_):r)=foldl(f[])[x]r

Try it online!

j<-1+i`mod`length b saves a byte.

Python 2, 62 60 bytes
Takes input as a list of pairs, prints the result. Edit: Outgolfed by Dennis
b=[]
for x,y in input():b.insert(1+y%(len(b)or 1),x)
print b

Try it online!
This is quite simple - loop through the input, inserting the items into the correct place, and then print the result. Deciding which index to insert into is done with 1+y%(len(b)or 1). This is the standard way to do modular indexing, with the or 1 to handle the edge case of an empty list.

Python 2, 64 62 58 56 bytes
x=[]
for n,i in input():x[i%(len(x)or 1)+1:0]=n,
print x

Thanks to @xnor for golfing off 2 bytes!
Try it online!

Can you do (len(x)or 1) instead of initializing the length?

Looking for a shorter way. Both len(x or[0]) and -~len(x[1:]) tie.

JavaScript (ES6), 60 bytes
f=([[q,r],...a],z=[])=>z.splice(r%z.length+1,0,q)+a?f(a,z):z

Test snippet

f=([[q,r],...a],z=[])=>z.splice(r%z.length+1,0,q)+a?f(a,z):z

I.textContent = I.textContent.replace(/(.+) -> (.+)/g, (_,a,b) => _ + " (" + (f(eval(a.replace(/\(/g, "[").replace(/\)/g, "]"))) + "" == eval(b) + "") + ")")

[(11, 9), (13, 14)] -> [11, 13]
[(1, 18), (11, 7), (3, 35), (16, 22)] -> [1, 11, 16, 3]
[(3, 16), (16, 37), (0, 28), (18, 24)] -> [3, 18, 0, 16]
[(7, 26), (8, 20), (11, 39), (1, 23), (17, 27)] -> [7, 8, 11, 1, 17]
[(15, 35), (17, 7), (16, 15), (1, 13), (2, 6), (11, 34)] -> [15, 17, 1, 2, 16, 11]
[(2, 13), (1, 20), (16, 25), (8, 21), (5, 2), (16, 37), (3, 0)] -> [2, 3, 8, 1, 16, 5, 16]
[(6, 20), (15, 15), (12, 26), (10, 27), (17, 13), (7, 18), (4, 16)] -> [6, 10, 17, 12, 7, 4, 15]
[(18, 9), (5, 34), (15, 4), (12, 29), (2, 5), (7, 0), (7, 10), (16, 38)] -> [18, 7, 15, 2, 16, 5, 7, 12]
[(0, 12), (12, 0), (4, 16), (15, 12), (6, 28), (8, 10), (11, 24), (0, 25)] -> [0, 11, 8, 6, 15, 0, 4, 12]
[(6, 12), (14, 13), (10, 33), (11, 35), (1, 3), (0, 28), (15, 27), (8, 10), (1, 2)] -> [6, 14, 10, 1, 11, 8, 15, 0, 1]
[(2, 29), (19, 30), (18, 17), (13, 3), (0, 21), (19, 19), (11, 13), (12, 31), (3, 25)] -> [2, 13, 3, 11, 0, 12, 19, 18, 19]

V, 38 40 35 bytes
This answer bends the definition of list, and isn't normally a language you'd use for list manipulation, but I wanted to use [count]/{regex} which I recently added to V.  The input is taken like [index] [num] [index] [num] ... and returned like [num] [num] [num].
Í ¨ä«© ½/¯ÜdÜ+òhea ±^
Hdd2xdG@"
X

Try it online!
Hexdump for 2 hidden characters:
00000000: cd20 a8e4 aba9 20bd 2faf dc64 dc2b f268  . .... ./..d.+.h
00000010: 6561 20b1 161b 5e0a 4864 6432 7864 4740  ea ...^.Hdd2xdG@
00000020: 220a 58                                  ".X

Explanation
The code up to dG@" formats all \d+ \d+ pairs so that a list 1 2 3 4 5 6 would end up like
a 2^[^3/\d\+
hea 4^[^5/\d\+
hea 6^[^

and then the dG@" executes all of that as V code like the following:
a 2^[                 | insert " 2" and return to command mode
     ^                | LOOP: go to the first number
      3/\d\+          | find the 3rd number (0 indexed)
h                     | move one character left
 e                    | go to the end of the next word
  a 4^[               | append " 4" and return to command mode
       ^5/\d\+        | basically the same as LOOP on, just with different numbers

PHP, 72 92 bytes
for($b=[];++$i<$argc;)array_splice($b,$b?$argv[$i]%count($b)+1:0,0,$argv[++$i]);print_r($b);

takes input flattened from command line arguments. Run with -nr.

I'm fairly certain this answer is invalid: I got a Fatal error: Uncaught DivisionByZeroError: Modulo by zero, fixed that, then tried 1 1 1 2 1 3 and got [1=>null] as output instead of [1,3,2]

It still overwrites j+1 rather than inserting after j, no? 18 1 7 11 35 3 22 16 => [1,11,16] rather than [1,11,16,3]

@user59178: Oh I had missed the insert keyword. Thanks; fixed.

Java 7, 125 124 bytes
import java.util.*;List z(int[]a){List r=new Stack();for(int i=0,q=a.length/2;i<q;)r.add(i<1?0:a[i+q]%i+1,a[i++]);return r;}

Accepts a flat list of values followed by indexes. For the squares test case the input would be new int[] {1, 2, 3, 4, 5, 6, 7, 8, 1, 4, 9, 16, 25, 36, 49, 64}
Try it online!

Mathematica, 62 bytes
Fold[Insert[#,#2[[1]],Mod[Last@#2,Tr[1^#]]+2/.0/0->-1]&,{},#]&

Pure function with first argument # expected to be a list of pairs. Starting with the empty list {}, left Fold the input list # with the following function:
Insert[                                            Insert
       #,                                          into the first argument
         #2[[1]],                                  the first element of the second argument
                 Mod[                              at the position given by the modulus of
                     Last@#2,                      the second element of the second argument
                             Tr[1^#]               with respect to the length of the first argument
                                    ]+2            plus 2 (plus 1 to account for 1-indexing, plus 1 because we are inserting after that position)
                                       /.          then replace
                                         0/0       Indeterminate
                                            ->     with
                                              -1   negative 1
                                                ]& End of function

Perl 6, 51 bytes
{my @a;.map:{splice @a,(@a??$^b%@a+1!!0),0,$^a};@a}

Takes the flattened input.

Clojure, 87 bytes
#(reduce(fn[r[v i]](let[[b e](split-at(+(mod i(max(count r)1))1)r)](concat b[v]e)))[]%)


text:
Print a word clock
Since I saw the first one a few years ago, I always was subjugated by this kind of word clock where the time is actually spelled out by words being lit up or not into a meaningful sentence.

The text displayed on that clock is the following.
IT IS HALF TEN
QUARTER TWENTY
FIVE MINUTES TO
PAST TWO THREE
ONE FOUR FIVE
SIX SEVEN EIGHT
NINE TEN ELEVEN
TWELVE O'CLOCK

Your task is to write such a working clock. Words are lit up if and only if they're relevant to printing the current time. Otherwise, they're lit down. Words are "lit up" by being printed and are "lit down" by being replaced by a number of spaces being the length of the word.
Example: if the current time is 17:23, the printed text must be exactly the following:
IT IS
        TWENTY
FIVE MINUTES
PAST
         FIVE

Rules

The time printed is the 12h variant, but without AM/PM.
The rounding is done on the base of minutes only (seconds are totally irrelevant). The rounding is done to the closest multiple of 5. So, for example, even though 17:52:38 really is closest to 17:55, but since the seconds are irrelevant, 17:52 is actually rounded down to 17:50, and the text printed is "IT IS TEN MINUTES TO SIX" (with relevant spacing). So if XX is a multiple of five, XX will be used from HH:(XX-2):00 until HH:(XX+2):59. The word MINUTES must appear if FIVE, TEN or TWENTY are lit up in the minutes section (before "TO" or "PAST").
All irrelevant words are replaced by as many spaces as needed to keep the text where it is located in the template above. Trailing spaces may be trimmed. Spaces relevant to keeping the text at the expected position must be kept.
Trailing lines may be trimmed as well. Relevant empty lines are still required to appear. Example:
IT IS      TEN

     MINUTES
PAST TWO

Do not light up TEN on the first line or FIVE on the third line when these values refer to the hours.
You may accept an input. If you accept an input, the input will be the time to print in any valid format you want (string, list of integers, native time type your language support, ...), but no parameters are allowed if they're not related to the time to print. If you support no input, then you must use the current time. If you support both, that's better but there's no bonus ;)
Your code may be a program, a function, a lambda but not snippet.
If your language supports printing in any way, it must print the result (in a file, on the standard output, I don't mind). If your language doesn't support printing in any way, it is allowed to simply "return" the expected text. The result may be either all uppercase or all lowercase, not a mix of both.
Standard loopholes apply.
This is code-golf so the shortest code wins!
In the measure of possible, please provide a link to an online interpreter of your language.

Test cases
Input:  <no input> (the current local time is 19:20)
Output:
IT IS
        TWENTY
     MINUTES
PAST

    SEVEN

Input: 13:15
Output: (empty line is being printed)
IT IS
QUARTER

PAST
ONE

Input: 13:58
Output: (rounding)
IT IS

     TWO

       O'CLOCK

Input: 14:30
Output: (half is always a edge-case)
IT IS HALF

PAST TWO

Input: 15:35
Output: (light up "TO")
IT IS
        TWENTY
FIVE MINUTES TO

    FOUR

Input: 10:00
Output: (do not use the TEN or FIVE on the first line when referring to the hours)
IT IS

    TEN
      O'CLOCK

Input: 12:00
Output: (O'CLOCK and a lot of empty lines)
IT IS

TWELVE O'CLOCK

Great challenge, I really like it!

I'm impressed at how many different algorithms appeared in the answers - that's the sign of a great question.  (I'm glad the clock didn't combine NinEighTen or TwOnEleven to save space - that would have made the challenge extra hard!)

Thanks! I love returning to this question from time to time and revisit the answers. In retrospection I should have allowed returning a string, but that's too late now.

PHP, 387 384 353 352 342 323 310 306 298 293 291 bytes
Thanks @Christoph for golfing along with his excellent findings!
At least 45 bytes are on his account; 16 or more inspired by him.
A Marvel Team Up!
IT IS <?foreach([HALF,TEN,QUARTER,TWENTY,FIVE,MINUTES,TO,PAST,TWO,THREE,ONE,FOUR,FIVE,SIX,SEVEN,EIGHT,NINE,TEN,ELEVEN,TWELVE,"O'CLOCK"]as$w)echo strstr([w,ghj,dhj,ej,fhj,fghj,cj,fghi,fhi,ei,dhi,ghi][$m=date(i)/5+.5].mklnopqrstuvm[date(h)-($m<7)],99+$i)?$w:$w^$w^"       ","
  "[$i++%3^$i<3];

loops through the data and checks if the current index is in a generated string that contains the indexes of the words to light up (mapped to letters); appends linebreak or space depending on the index.
May yield notices if you dont´t use the default value for error_reporting (22519).
Test it online.
breakdown
IT IS <?
foreach([HALF,TEN,QUARTER,TWENTY,FIVE,MINUTES,TO,PAST,  // loop through words
TWO,THREE,ONE,FOUR,FIVE,SIX,SEVEN,EIGHT,NINE,TEN,ELEVEN,TWELVE,"O'CLOCK"]as$w)
    echo strstr(                    // search word index in ...
        [w,ghj,dhj,ej,fhj,fghj,cj,fghi,fhi,ei,dhi,ghi][$m=date(i)/5+.5] // minutes & co
        .mklnopqrstuvm[date(h)-($m<7)]                          // hours (-1 if minutes<33)
    ,99+$i                          // (map 0..20 to c..w)
    )?$w:$w^$w^"       ",           // if found, print string, else print spaces
    "\n  "[$i++%3^$i<3];            // if $i in [3,5,8,...], print newline, else space

Golfs:

$x/5+.5|0 is two bytes shorter than round($x/5).
Two calls of date(h) are one byte shorter than assigning the date result to a variable.
Using a single assigment golfed away the variable that the light-up indexes were stored in.
A string for the light-up indexes instead of an array saved around 30 bytes.
$w<A is three bytes shorter than $w=="\n" - make sure that no space is after a delimiter!
abs saved 8 bytes on the minutes word.
Thanks @Christoph: Moving from numbers to letters for the map rendered the separators obsolete and allowed one more string instead of array; saved 23+8 bytes.
Using underscore as the first index allowed to include it into the "it is" alternatives; and it rendered the quotation for the hours obsolete.
Duplicating the 1 value in the hours map rendered the modulo obsolete and that with additional golfing saved 10 bytes. Inspired by @Christoph.
Calculating the linebreaks and spaces instead of hardcoding them shaved off 19 bytes.
Bit logic on strings saves 7 bytes: str_pad("",strlen($w)) -> $w^$w^"       ". (Christoph)
If strtr´s second parameter is no string, it will be interpreted as an ascii code. saves 5 bytes.

This is very nice! I tried this implementation in Java when making sure the question was solvable, but it ended up being so complicated I gave up and used a longer, but more straightforward approach! So congrats on succeeding where I failed ;)

Beating of the rest: $i++%3^($i<3) to $i++%3^$i<3. I'm officially completly wasted now. I'll take a break until someone matches us. It was really fun. Thank you Titus for your teamwork!

@Christoph You are ... GREAT seems to small a word. \o/

TI-Basic, 335 334 bytes
Pretty much perfect, since the TI-84 calcs have 8x16 letter displays, and this is 8x15. Date is taken as input in order to support calcs earlier than TI-84, which do not have internal clocks. With no arguments, Input gets input by default into X and Y, similar to Prompt X,Y. So make X be hours (anything >=0 will work correctly) and have Y be minutes.
Input
ClrHome
int(Y/5-5.6
Output(1,1,"IT IS
If Ans=~6
Output(8,8,"O'CLOCK
If 2=abs(3-abs(Ans
Output(3,1,"FIVE
If 4=abs(Ans
Output(1,12,"TEN
If 3=abs(Ans
Output(2,1,"QUARTER
If 2=abs(Ans
Output(2,8,"TWENTY
If sum(abs(Ans)={1,2,4,5
Output(3,5,"MINUTES
If not(Ans
Output(1,7,"HALF
If Ans<1 and Ans+6
Output(4,1,"PAST
If Ans>0
Output(3,14,"TO
12fPart(12(^~1)(X+(Y>32->A
If not(Ans
12->A
{21,6,10,25,30,41,45,51,61,66,70,81
.05Ans(A
Output(int(4+Ans),20fPart(Ans),sub("ONE   TWO   THREE FOUR  FIVE  SIX   SEVEN EIGHT NINE  TEN   ELEVENTWELVE",6A-5,6

Note 1: For TI-84+ you can replace Input with something like getTime:Ans(1->X:getTime:Ans(2->Y. Also, int(Y/5-5.6 is equivalent to round(Y/5,0)-6. And no, in this case int( could not be interchanged with iPart(.
Note 2: This prints the input just fine, but for asethetic reasons you probably want Pause at the end of the program to avoid the Done message upon program termination.
Edit: Byte count lowered because tokenized (see note on previous revision), also a bug is fixed thanks to @Neil. Third, fixed a bug I found myself which would have costed 2 bytes but the optimization actually saved 1 byte overall, and I also realized that I am getting input so I don't need to call getTime (duh?). Last, for anyone who wants to confirm this byte count, the only two byte token is sub(.

It seems to me that after outputting O'CLOCK the code will go on to output PAST too...

Thanks for the catch there @Neil -- you're right. That's fixed now, thanks!

It's impressive to see a TI-Basic answer leading the scoreboard, congrats !

Thanks @Aaron, I guess it's because of the low byte count. Maybe I'll add a complete explanation to explain the golfs.

The only thing I don't understand here is the line 12fPart(12.... It's clearly linked to the TO word by being close to and by checking against the 32 value, but that line is just chinese to me ;)

I count 545 bytes could you please enlighten me?

@Christoph Found the related meta post: http://meta.codegolf.stackexchange.com/a/4764/29637

@OlivierGrégoire Actually it's not related to that previous line at all. What it's doing is converting 24-hour to 12-hour time and also to the nearest hour (e.g. rounding with minutes accounted for). Basically, in a normal language it would look something like x+(y>32) mod 12 if the comparison yields 1 or 0 like in TI-Basic.

So @Christoph it seems like you answered your own question with that link, do you still want me to explain? If you want to see where I did the switch from ASCII scoring to tokenized, check revision #4.

JavaScript (ES6), 291 303 295 bytes
Takes input as two integers with currying syntax (h)(m)
h=>m=>console.log(`IT IS HALF TEN
QUARTER TWENTY
FIVE MINUTES TO
PAST TWO THREE
ONE FOUR FIVE
SIX SEVEN EIGHT
NINE TEN ELEVEN
TWELVE O'CLOCK`.replace(/\S+/g,w=>(k/=2)&1?w:w.replace(/./g,' '),k=[x=1<<19,88,81,66,84,92,64.5,60,52,34,49,56,x,h=(m<33?h+11:h)%12][m/5+.4|0]*16|6|2048<<(h?h-(h<3):2)))

How it works
The whole clock can be seen as 23 LEDs that are either ON or OFF. So, the clock state is a 23-bit integer.
Bit | Word        Bit | Word
----+--------     ----+--------
00  | IT          12  | ONE
01  | IS          13  | FOUR
02  | HALF        14  | FIVE
03  | TEN         15  | SIX
04  | QUARTER     16  | SEVEN
05  | TWENTY      17  | EIGHT
06  | FIVE        18  | NINE
07  | MINUTES     19  | TEN
08  | TO          20  | ELEVEN
09  | PAST        21  | TWELVE
10  | TWO         22  | O'CLOCK
11  | THREE

The minutes logic that we need to implement to enable the right words is not as simple as one might think at first glance. A magic-golfing formula may exist but I went the easy way and decided to just hardcode each possible configuration:
Minutes | Words                    | Enabled bits | Value   | Value / 8
--------+--------------------------+--------------+---------+----------
  00    | O'CLOCK                  | 22           | 4194304 | 524288
  05    | FIVE MINUTES PAST        | 6, 7, 9      | 704     | 88
  10    | TEN MINUTES PAST         | 3, 7, 9      | 648     | 81
  15    | QUARTER PAST             | 4, 9         | 528     | 66
  20    | TWENTY MINUTES PAST      | 5, 7, 9      | 672     | 84
  25    | TWENTY FIVE MINUTES PAST | 5, 6, 7, 9   | 736     | 92
  30    | HALF PAST                | 2, 9         | 516     | 64.5
  35    | TWENTY FIVE MINUTES TO   | 5, 6, 7, 8   | 480     | 60
  40    | TWENTY MINUTES TO        | 5, 7, 8      | 416     | 52
  45    | QUARTER TO               | 4, 8         | 272     | 34
  50    | TEN MINUTES TO           | 3, 7, 8      | 392     | 49
  55    | FIVE MINUTES TO          | 6, 7, 8      | 448     | 56

Test cases

let f =

h=>m=>console.log(`IT IS HALF TEN
QUARTER TWENTY
FIVE MINUTES TO
PAST TWO THREE
ONE FOUR FIVE
SIX SEVEN EIGHT
NINE TEN ELEVEN
TWELVE O'CLOCK`.replace(/\S+/g,w=>(k/=2)&1?w:w.replace(/./g,' '),k=[x=1<<19,88,81,66,84,92,64.5,60,52,34,49,56,x,h=(m<33?h+11:h)%12][m/5+.4|0]*16|6|2048<<(h?h-(h<3):2)))
;

[[13,15],[13,58],[14,30],[15,35],[10,0],[12,0]].map(([h, m]) => {
  console.log('h = ' + h, 'm = ' + m);
  f(h)(m);
});

Very clever. I was trying to cut some more byte from mine, then I saw this and there's no hope to compete.

The task (rule 8) says that it must be printed, not just returned

@smls Oh, you're right. That's fixed.

Very cool. Except the time is wrong :-( Display: h = 13 m =15 Actual time: 14:43

@Strawberry Please see rule #6. This implementation is using input exclusively, not the local time.

Fair enough. :-)

Batch, 789 bytes
@echo off
if not "%1"=="" setlocal&set time=%1
set/a"h=%time:~0,2%,m=6%time:~3,2%%%60+2,h+=m/35,h%%=12,m=6-m/5%%12,n=m%%3,o=m%%2
set p=
set s=
call:c %m:-=% "IT IS HALF" 0 "IT IS      TEN" 4 "IT IS"
call:c %m:-=% QUARTER 3 "        TWENTY" 2 "        TWENTY" 1
if %m% lss 0 set s= TO
call:c 0 "            " %n% "     MINUTES" %o% "FIVE MINUTES"
set s=
set p=PAST
if %m%==6 set p=
if %m% lss 0 set p=
call:c %h% TWO 2 "    THREE" 3
set p=
call:c %h% ONE 1 "    FOUR" 4 "          FIVE" 5
call:c %h% SIX 6 "    SEVEN" 7 "          EIGHT" 8
call:c %h% NINE 9 "     TEN" 10 "         ELEVEN" 11
if %m%==6 set s= O'CLOCK
call:c %h% TWELVE 0 "      "
exit/b
:c
set t=%1
:l
if %t%==%3 echo(%p%%~2%s%&exit/b
shift
shift
if not "%3"=="" goto l
echo(%p%%~2%s%

Note: Trailing space after PAST and 5 trailing spaces on each of the following two lines.

I ran it and it does just fine (bar one missing space for the hour 3)! I just don't understand what's going on (with call:c for instance)! I should probably learn some batch :)

@OlivierGrégoire Sadly a space had gone missing but that's fixed now.

Python 2,  466,460,449,452,459 449 bytes
As it's allowed to be a function accepting h and m as integers we can save a few bytes. Try it online.
def t(h,m):

m=(2+m)//5
 h=h%12
 n=0
 if m>6:n,m=1,12-m;h+=1
 a="""IT IS _HALF _TEN_
 _QUARTER _TWENTY_
 _FIVE _MINUTES _TO_
 _PAST _TWO _THREE_
 _ONE _FOUR _FIVE_
 _SIX _SEVEN _EIGHT_
 _NINE _TEN _ELEVEN_
 _TWELVE _O'CLOCK""".split("_")
 b=[1,m==6,m==2,1,m==3,3<m<6,1,m in[1,5],m in[1,2,4],n*m,1,(1-n)*m,h==2,h==3,1,h==1,h==4,h==5,1,h==6,h==7,h==8,1,h==9,h==10,h==11,1,h==0,m==0]
 for i,c in enumerate(a):
  if b[i]:print c,
  else:print' '*len(c),

I had a couple of bugs (now fixed) with the logic for TO/PAST vs O'CLOCK.  Also saved a few bytes for enumerate, changing the import, and 19<m<26 instead of m in [20,25]. Saved another 8 for working in 5-minute chunks rater than minutes. Rod pointed out some more bugs costing me quite a bit, but I recovered a little with more efficient assignments and a bugfix that worked in my favour.

Takes a trick from @Titus' PHP answer.  I'm losing out to python's == as comparison and I reckon I can improve some of the h tests

you can just print c on the last line, c already holds a[i] due enumerate

The output format is broken, print add a newline after each print, you can suppress it adding a , after c. Also it should print blank spaces when a word isn't printed, you can fix with an else in the last if else:print' '*len(c),

The order of bytes is better if descending.

@Rod, thanks for the bug-spots, even though it makes it much longer

JavaScript (ES6) 360
A function with input parameters hour (0..23) and minute (0..59).
Using alert for output, as it's the standard output function in javascript even if it's inconvenient. (And it's short)
(k,n,m=(n+2)/5|0,h=(k+(m>6))%12,i=0)=>alert(`IT IS HALF TEN
QUARTER TWENTY
FIVE MINUTES TO
PAST TWO THREE
ONE FOUR FIVE
SIX SEVEN EIGHT
NINE TEN ELEVEN
TWELVE O'CLOCK`.replace(/\S+/g,w=>[,,m-6,m-2&&m-10,m-3&&m-9,m-4&&m-8&&m-5&&m-7,m-1&&m-11&&m-5&&m-7,!(m%3),m<7|m==12,!m|m>6,h-2,h-3,h-1,h-4,h-5,h-6,h-7,h-8,h-9,h-10,h-11,h%12,m%12][i++]?w.replace(/./g,' '):w))

Test Note: for your peace of mind, in the test snippet the alert output is redirected to the page text

F=
(k,n,m=(n+2)/5|0,h=(k+(m>6))%12,i=0)=>alert(`IT IS HALF TEN
QUARTER TWENTY
FIVE MINUTES TO
PAST TWO THREE
ONE FOUR FIVE
SIX SEVEN EIGHT
NINE TEN ELEVEN
TWELVE O'CLOCK`.replace(/\S+/g,w=>[,,m-6,m-2&&m-10,m-3&&m-9,m-4&&m-8&&m-5&&m-7,m-1&&m-11&&m-5&&m-7,!(m%3),m<7|m==12,!m|m>6,h-2,h-3,h-1,h-4,h-5,h-6,h-7,h-8,h-9,h-10,h-11,h%12,m%12][i++]?w.replace(/./g,' '):w))

function alert(x) { O.textContent=x }
function update() { F(+H.value,+M.value) }

update()
input { width:3em }
Hours<input id=H type=number min=0 max=23 value=17 oninput='update()'>
Minutes<input id=M type=number min=0 max=59 value=37 oninput='update()'>

I love your answer! I learned a bunch of stuff from it! However, what's going on with the arrow function that has square brackets? Also, what is the role of i? I can see you get all non-whitespace groups (the "LEDs") and you replace them with whitespace based on the conditions you wrote for each one of them. For example, h-2 it's false only when h == 2, so I presume you invert it somewhere? Can you explain a bit how this works? Perhaps as an edit to your answer? I'd be really thankful!

Update - I almost realized what you're doing. You have an array of zero and non-zero elements and you use i to refer to the right one by incrementing it after each regex match. If it's truthy, you replace the matched string with blank spaces, else you leave it as it is.
I don't understand one thing, though. replace() uses the return value of the specified function (arrow function in this case). Where do you return a value? I just see a ternary operator.

@HristiyanDodov an arrow function made of just an expression just returns the value of that expression. Example (a,b)=>{ return a+b } is the same as (a,b)=>a+b

JavaScript, 567 564 551 542 529 527 519 bytes

f=(h,m)=>{c={m6:"HALF ",m2:"TEN\n",m3:"QUARTER ",m4:"TWENTY\n",m1:"FIVE ",m:"MINUTES ",t:"TO\n",p:"PAST ",h2:"TWO ",h3:"THREE\n",h1:"ONE ",h4:"FOUR ",h5:"FIVE\n",h6:"SIX ",h7:"SEVEN ",h8:"EIGHT\n",h9:"NINE ",h10:"TEN ",h11:"ELEVEN\n",h0:"TWELVE ",m0:"O'CLOCK"};l=[];p="push";m=Math.round(m/5);if(m>11){m=0;h++}if(m>6){l[p]("t");m=12-m;h++}else if(m)l[p]("p");if(m%3)l[p]("m");if(m==5)l[p]("m4","m1");else l[p]("m"+m);l[p]("h"+h%12);s="IT IS ";for(k in c)s+=(l.indexOf(k)>=0)?c[k]:c[k].replace(/\S/g," ");console.log(s)}

f(19, 20);
f(13, 15);
f(13, 58);
f(14, 30);
f(15, 35);
f(10, 0);
f(12, 0);

I don't know if it's OK to take hours and minutes as arguments. You said "list of integers". Does it still count?
It's my first time golfing, by the way. What do you think?

Edit: Saved a few bytes by dividing minutes. Thanks, Olivier!

Yes, the idea behind that rule is that you can take arguments, but only if they relate to the input, which is the time to print.

Regarding the golfing, you can probably golf some bytes if you consider dividing your minutes by 5. Also, you might want to move c inside your function. You shouldn't lose any byte by doing so, I guess, but this makes it more like a snippet than a function (to me, at least, maybe JS gurus will say otherwise).

Perl 6, 308 296 293 bytes
->\h,\m{my \n=round(m/5)%12;say "IT IS HALF TEN
QUARTER TWENTY
FIVE MINUTES TO
PAST TWO THREE
ONE FOUR FIVE
SIX SEVEN EIGHT
NINE TEN ELEVEN
TWELVE O'CLOCK".subst: /\S+/,{++$==1|2|(0,7,4,5,6,(6|7),3)[min n,12-n]|8*?(n%3)|(23,10,9)[(n+5)/6]|(13,11,12,|(14..*))[(h+m/33-1)%12]??$_!!" "x.comb},:g}

Try it online!
Explanation
The basic structure is as follows:
-> \h, \m {                             # A lambda taking two args (hour and minute).
    my \n = round(m / 5) % 12;          # Index from 0 to 11, representing the minutes.
    say "...".subst: /\S+/, {           # Print the template with each word replaced:
        ++$ == ...|...|...|...          # If counter equals one of expected indices,
            ?? $_                       # then replace the word with itself,
            !! " " x .comb              # else replace it with spaces.
    }, :g                               # (Use global matching.)
}

The expression elided as ...|...|...|... above, is a Junction of integers representing 1-based word indices, and is made up as follows:
  1|2                                   # IT IS
| (0,7,4,5,6,(6|7),3)[min n,12-n]       # FIVE / TEN / QUARTER / TWENTY / TWENTY FIVE / HALF
| 8*?(n%3)                              # MINUTES
| (23,10,9)[(n+5)/6]                    # O'CLOCK / PAST / TO
| (13,11,12,|(14..*))[(h+m/33-1)%12]    # ONE / TWO / THREE / FOUR / FIVE / SIX / SEVEN / ...

Python3 , (569 bytes)
This answer requires time in format hh mm (space separated integers) .I managed to have '\n' printed, which is inspired by Chris's method.Thanks, Chris! Any help reducing code is appreciated.

H,M=input().split()
w="""HALF _TEN_
_QUARTER _TWENTY_
_FIVE _MINUTES _TO_
_PAST _TWO _THREE_
_ONE _FOUR _FIVE_
_SIX _SEVEN _EIGHT_
_NINE _TEN _ELEVEN_
_TWELVE _O'CLOCK""".split("_")
h,m=int(H),int(M)
if h>12:h-=12
m=(m//5+1)*5 if m%5>2.5 else m//5*5
if m>30:
    m=60-m
    h=(h+1)%12
X=[m==30,m==10,1,m==15,m in[20,25],1,m in[5,25],m not in[0,15,30],int(M)>30 and m!=0,1,m!=0 and int(M)<31,h==2,h==3,1,h==1,h==4,h==5,1,h==6,h==7,h==8,1,h==9,h==10,h==11,1,h in[0,12],m==0]
t="IT IS "
for i in range(0,28):
    if(X[i]):t+=w[i]
    else:t+=" "*len(w[i])
print(t.strip())

Try It Online

Can you combine w into a single string and then use .split(',')? Should save a few.

Also take your input as H,M=input() where the input is H,M. Two integer sequence  is allowed under the rules, Not sure if this works as intended under Python 3. I'm still a 2 guy :-)

Thanks @ElPedro .Saved 57 bytes.  H,M=input() didn't work as you doubted.

SimpleTemplate, 737 708 bytes
Yeah, verbosity and lack of "real" math hurt the bytecount badly.
{@seth argv.0}{@php$DATA[m]=ceil($DATA[argv][1]/5)*5%60|0}{@ifm}{@ifm is30}{@setA"HALF"}{@/}{@if"@[15]0$@"is matchesm}{@setB"TEN"}{@/}{@if"@[14]5$@"is matchesm}{@setC"QUARTER"}{@/}{@if"@[24]0$@"is matchesm}{@setD"TWENTY"}{@/}{@if"@^[25]?5$@"is matchesm}{@setE"FIVE"}{@/}{@if"@^([235]?5|[1245]0)$@" is matchesm}{@setF"MINUTES"}{@/}{@ifm is greater30}{@setG"TO"}{@else}{@setH"PAST"}{@/}{@else}{@setU"O\'CLOCK"}{@/}{@setZ"","ONE","TWO","THREE","FOUR","FIVE","SIX","SEVEN","EIGHT","NINE","TEN","ELEVEN","TWELVE"}{@setY"J"}{@incbyh Y}{@php$DATA[$DATA[Y]]=$DATA[Z][$DATA[h]]}{@print"IT IS%-6s%s\n%8s%s\n%-5s%-7s %s\n%4s %3s %s\n%3s %4s %s\n%3s %5s %s\n%4s %3s %s\n%6s %s",A,B,C,D,E,F,G,H,J,K,I,L,M,N,O,P,Q,R,S,T,U}

This expects the hour and minutes as the 1st and 2nd parameter on the class.

Ungolfed:
{@set hour argv.0}

{@//The bitwise is required for the `@if minutes is 30`}
{@//Otherwise, I would be forced to write `@if minutes is equal to 30`}
{@php $DATA['minutes'] = ((ceil($DATA['argv'][1] / 5) * 5) % 60) | 0}

{@if minutes}
    {@if minutes is 30}
        {@set A "HALF"}
    {@/}
    {@if "@[15]0$@" is matches minutes}
        {@set B "TEN"}
    {@/}
    {@if "@[14]5$@" is matches minutes}
        {@set C "QUARTER"}
    {@/}
    {@if "@[24]0$@" is matches minutes}
        {@set D "TWENTY"}
    {@/}
    {@if "@^[25]?5$@" is matches minutes}
        {@set E "FIVE"}
    {@/}
    {@if "@^([235]?5|[1245]0)$@" is matches minutes}
        {@set F "MINUTES"}
    {@/}
    {@if m is greater than 30}
        {@set G "TO"}
    {@else}
        {@set H "PAST"}
    {@/}
{@else}
    {@set U "O\'CLOCK"}
{@/}

{@set numbers "", "ONE", "TWO", "THREE", "FOUR", "FIVE", "SIX", "SEVEN", "EIGHT", "NINE", "TEN", "ELEVEN", "TWELVE"}
{@set key "J"}
{@inc by hour key}
{@php $DATA[$DATA['key']] = $DATA['numbers'][$DATA['hour']]}

{@print "IT IS%-6s%s\n%8s%s\n%-5s%-7s %s\n%4s %3s %s\n%3s %4s %s\n%3s %5s %s\n%4s %3s %s\n%6s %s", A, B, C, D, E, F, G, H, J, K, I, L, M, N, O, P, Q, R, S, T, U}

How to run:

Get the code from https://github.com/ismael-miguel/SimpleTemplate
Run the following code:
<?php
    include 'SimpleTemplate.php';

    $template = new SimpleTemplate('');

    $template->render($hour, $minutes);

    //system-time: $template->render(date('g'), date('i'));

Done!

Python 2, 443 440 bytes
R=range
w="HALF TEN QUARTER TWENTY FIVE MINUTES TO PAST TWO THREE ONE FOUR FIVE SIX SEVEN EIGHT NINE TEN ELEVEN TWELVE O'CLOCK".split(' ')
h=[10,8,9]+R(11,20)
c=['IT','IS']+[' '*len(x)for x in w]
i,j=input()
i=(i,i+1)[j>30]%13-1
j=int(round(j/5.0)*5.0)%60
for z in[[20],[4,5,7],[1,5,7],[2,7],[3,5,7],[3,4,5,7],[0,7],R(3,7),[3,5,6],[2,6],[1,5,6],R(4,7)][j/5]:c[z]=w[z]
c[h[i]]=w[h[i]]
x=0
for y in[4]+R(6,22,3)+[23]:print' '.join(c[x:y]);x=y

Try it online!
It could probably still benefit from some more golfing. Input is a list of integers e.g. 7,23 = 7:23

Java (OpenJDK 9), 437 bytes
(h,m)->{h=(h+m/35+11)%12+1;Object[]s="HALF TEN QUARTER TWENTY FIVE MINUTES TO PAST TWO THREE ONE FOUR FIVE SIX SEVEN EIGHT NINE TEN ELEVEN TWELVE O'CLOCK".split(" ");for(int i=s.length,M[]={1<<20,176,162,132,168,184,129,120,104,68,98,112};i-->0;)s[i]=(7<i&i<20?h==i-(h>3?7:h>1?6:9):(M[(m+2)/5%12]&(1<0)?s[i]:"";System.out.printf("IT IS %4s %3s%n%7s %6s%n%4s %7s %2s%n%4s %3s %5s%n%3s %4s %4s%n%3s %5s %5s%n%4s %3s %6s%n%6s %7s",s);}

Try it online!
I thought I'd finally give a shot at my challenge ;)

Suggest 1<<i instead of (1<30){s/to/TO/;$h++;$m=60-$m}elsif($m){s/past/PAST/}$h=$h%12||12;$m!=30?$m%15?s/m\w+/uc$&/e:$m?s/q\w+/uc$&/e:s/oc/O'CLOCK/:s/half/HALF/;$m%10&&!/Q/&&s/five/FIVE/;$m>15&&$m<30?s/tw/TWENTY/:$m==10&&s/ten/TEN/;s/\b$h\w+/uc$&/es;y/a-z0-9/ /;say

Try it online!

C, 447 bytes
A function c() which takes hours and minutes as arguments, and prints the result to standard output stream:
char*z="";c(h,m){h+=(m+=2,m/=5)>6;h%=12;m=1<<m;printf("IT IS%5s %s\n%7s %s\n%4s%8s %s\n%4s%4s %s\n%3s%5s %s\n%3s%6s %s\n%4s%4s %s\n%6s %s",m&64?"HALF":z,m&1028?"TEN":z,m&520?"QUARTER":z,m&432?"TWENTY":z,m&2210?"FIVE":z,m&3510?"MINUTES":z,m&3968?"TO":z,m&126?"PAST":z,h-2?z:"TWO",h-3?z:"THREE",h-1?z:"ONE",h-4?z:"FOUR",h-5?z:"FIVE",h-6?z:"SIX",h-7?z:"SEVEN",h-8?z:"EIGHT",h-9?z:"NINE",h-10?z:"TEN",h-11?z:"ELEVEN",h?z:"TWELVE",m&4097?"O'CLOCK":z);}

Explanation
The selection of the hour number should be obvious; for the other words, we make a 13-bit mask (0-12) of the minute hand's position, and use this to select which texts light up.
void clock(int hour, int min)
{
    min = (min + 2) / 5;
    if (m > 6) ++hour;
    hour = hour % 12;
    min = 1 << min;
    printf("IT IS%5s %s\n"
           "%7s %s\n"
           "%4s%8s %s\n"
           "%4s%4s %s\n"
           "%3s%5s %s\n"
           "%3s%6s %s\n"
           "%4s%4s %s\n"
           "%6s %s",
    min & (1 << 6) ? "HALF" : "",
    min & ((1 << 2) | (1 << 10)) ? "TEN" : "",
    min & ((1 << 3) | (1 << 9)) ? "QUARTER" : "",
    min & ((1 << 4) | (1 << 5) | (1 << 7)  | (1 << 8)) ? "TWENTY" : "",
    min & ((1 << 1) | (1 << 5) | (1 << 7) | (1 << 11)) ? "FIVE" : "",
    min & ((1 << 1) | (1 << 2) | (1 << 4) | (1 << 5) | (1 << 7) | (1 << 8) | (1 << 10) | (1 << 11)) ? "MINUTES" : "",
    min & ((1 << 7) | (1 << 8) | (1 << 9) | (1 << 10) | (1 << 11)) ? "TO" : "",
    min & ((1 << 1) | (1 << 2) | (1 << 3) | (1 << 4) | (1 << 5) | (1 << 6)) ? "PAST" : "",
    hour == 2 ? "TWO" : "",
    hour == 3 ? "THREE" : "",
    hour == 1 ? "ONE" : "",
    hour == 4 ? "FOUR" : "",
    hour == 5 ? "FIVE" : "",
    hour == 6 ? "SIX" : "",
    hour == 7 ? "SEVEN" : "",
    hour == 8 ? "EIGHT" : "",
    hour == 9 ? "NINE" : "",
    hour == 10 ? "TEN" : "",
    hour == 11 ? "ELEVEN" : "",
    hour == 0 ? "TWELVE" : "",
    min & ((1 << 0) | (1 << 12)) ? "O'CLOCK" : "");
}

Demo
This is also available on Try It Online.
#include <stdio.h>
int clock(int hour, int min)
{
    c(hour, min);
    printf("(%2d:%02d)\n---\n", hour, min);
}

int main(void)
{
    /* examples from the question */
    clock(19, 20);
    clock(13, 15);
    clock(13, 58);
    clock(14, 30);
    clock(15, 35);
    clock(10, 00);
    clock(12, 00);

    /* Test all the lights */
    int hour = 11;
    for (int min = 0;  min <= 60;  min += 5) {
        clock(++hour, min);
    }
}

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:
Play the sound of Pi
Yup, you read the title right. play the sound of pi.
More specifically, for every digit of pi in the first 1000, map it to a musical note and output the resulting melody to a file.
Basically, each digit turns to a note on the C Major scale (basically the normal scale). so 1 turns to Middle C, 2 turns to D4, 3 turns to E4, 9 turns to D5 and so on.
Rules

Each note should be exactly 0.5 seconds long.
The melody should contain the first 1000 digits of pi, including the starting 3.
1 to 7 represent Middle C to B4, 8 is C5, 9 is D5 and 0 is E5
All well supported file formats are allowed, as long as they were created before this challenge.
There may be no pauses anywhere in the file, including the start and end.
The instrument played does not matter. It could be a piano, sine wave, anything really, as long as the correct sound is easily hearable.
It must take no input and produce no output except for the file. Reading from other files is disallowed.
Standard loopholes are forbidden.

Example mathematica code:
(*please forgive me for this horrible, horrible mess of code*)
digits = RealDigits[Pi, 10, 1000][[1]] /. {0 -> 10};
weights = {0, 2, 4, 5, 7, 9, 11, 12, 14, 16};
melody = {};
For[i = 1, i < 1001, i++, melody = {melody , Sound[SoundNote[weights[[digits[[i]]]], 0.5]]}]
final = Sound[Flatten[melody]];
Export["C:\\Mathematica Shenanigans\\pi.wav", final];

Example melody showing first 100 digits: http://vocaroo.com/i/s0cfEILwYb8M
For your sanity, A table of pitches for each note and what note does each digit represent:
Digit 1: C: 261.63 Hz
Digit 2: D: 293.66 Hz
Digit 3: E: 329.63 Hz
Digit 4: F: 349.23 Hz
Digit 5: G: 392.00 Hz
Digit 6: A: 440.00 Hz
Digit 7: B: 493.88 Hz
Digit 8: C5: 523.25 Hz
Digit 9: D5: 587.33 Hz
Digit 0: E5: 659.25 Hz

9 turns to D5 You should clarify that the other notes are in the 4-th octave. Also, in your table does digit 0 come last (E5)?

@LuisMendo Yes it does. I'll make these too more clear.

Can we assume 'well supported formats' to mean anything openable by vlc?

@Pavel Pretty much

Can I output the note names (e.g. 3.14 --> ECF) if my language does not support sound or writing to sound files?

@Everyone someone post a TIO link already, I want to hear pi to the millionths place.

Can I play the notes instead of writing them to a file?

@BookOwl As long as it's the same as a file, sure!

@FinW You can write to a midi file, which doesn't need a lot of complicated code and libraries.

Mathematica, 107 87 bytes
Thanks to Martin Ender for saving 20 bytes!
"t.au"~Export~Sound[SoundNote[⌊12Mod[#,10,1]/7⌋-1,.5]&/@#&@@RealDigits[Pi,10,1000]]

#&@@RealDigits[Pi,10,1000] gives the list of the first 1000 digits of π. SoundNote[⌊12Mod[#,10,1]/7⌋-1 produces the correct pitch number (where 0 is middle C by default) from a digit. Then SoundNote[...,.5]&/@ turns that pitch name into a sound object of duration 1/2 second, which Sound gathers into an actual audio snippet. Finally "t.au"~Export~ exports to a Unix Audio Format file, mostly because the extension is the shortest supported one, but also because we get to make the filename a slap in the face to π!
Previous submission:
"t.au"~Export~Sound[StringSplit["E5 C D E F G A B C5 D5"][[#+1]]~SoundNote~.5&/@#&@@RealDigits[Pi,10,1000]]

Python 2, 182 bytes
x=p=6637
while~-p:x=p/2*x/p+2*10**999;p-=2
s="MThd\0\0\0\6\0\1\0\1\342\4MTrk\0\0\13\301\0\220"
for i in`x`:s+="JHGECA@><L\260"[~ord(i)%29]+'{<'
open('p.mid','w').write(s+"\0\377/\0")

`x` will produce 31415926...20198L. The trailing L is used to produce the final channel message byte, via the mapping ~ord(i)%29.
Outputs a single track Type 1 Midi file, named p.mid to the current working directory.
0000: 4d 54 68 64 00 00 00 06  MThd....  # Midi header, 6 bytes to follow
0008: 00 01 00 01              ....      # Type 1, 1 track
000c: e2 04                    â.        # (-)30 ticks per beat, 4 beats per second

000e: 4d 54 72 6b 00 00 0b c1  MTrk...Á  # Track header, 3009 bytes to follow
0016: 00 90 40 7b              ..@{      # Wait  0 ticks, play E4 (3), 97% volume
001a: 3c 3c 7b                 <<{       # Wait 60 ticks, play C4 (1), 97% volume
001d: 3c 41 7b                 <A{       # Wait 60 ticks, play F4 (4), 97% volume
0020: 3c 3c 7b                 <<{       # Wait 60 ticks, play C4 (1), 97% volume
0023: 3c 43 7b                 <C{       # Wait 60 ticks, play G4 (5), 97% volume
...
0bcf: 3c b0 7b 3c              <°{<      # Wait 60 ticks, all notes off
0bd3: 00 ff 2f 00              .ÿ/.      # End of track marker

Quite late, but if you are wondering what pi formula is used, it's a variation on Formula 25 at http://mathworld.wolfram.com/PiFormulas.html.

Scratch, 530 bytes
Inspired by BookOwl's answer.
Online Demonstration. Playback will begin immediately, press space to stop and reset. Click the cat to start again.
Edit: golfed down slightly. I found some golfing tips on the official wiki.
when gf clicked
set[c v]to[4e3
repeat(c
add[2e3]to[f v
end
repeat(250
set[b v]to(c
set[h v]to((d)mod(1e4
change[c v]by(-16
repeat(b
set[d v]to(((d)*(b))+((1e4)*(item(b)of[f v
set[g v]to(((2)*(b))-(1
replace item(b)of[f v]with((d)mod(g
set[d v]to(((d)-((d)mod(g)))/(g
change[b v]by(-1
end
change[h v]by(((d)-((d)mod(1e4)))/(1e4
repeat(4
add((h)mod(10))to[a v
set[h v]to(((h)-((h)mod(10)))/(10
end
repeat(4
say(item(last v)of[a v
play note((round((((item(last v)of[a v])-(1))mod(10))*(1.78)))+(60))for(0.5)beats
delete(last v)of[a v

Graphical:

Uses the Rabinowitz Wagon spigot to produce 4 digits at a time.

R, 450 bytes
N=261.63*(2^(1/12))^c(16,0,2,4,5,7,9,11,12,14);S=44100;s=unlist(sapply(el(strsplit(as(Rmpfr::Const("pi",1e5),"character"),""))[c(1,3:1001)],function(x)sin(0:(0.5*S-1)*pi*2*N[(x:1)[1]+1]/S)));c=32767*s/max(abs(s));a=file("p.wav","wb");v=writeChar;w=function(x,z)writeBin(as.integer(x),a,z,e="little");v("RIFF",a,4,NULL);w(36+S*10,4);v("WAVEfmt ",a,8,NULL);w(16,4);w(c(1,1),2);w(S*1:2,4);w(c(2,16),2);v("data",a,4,NULL);w(2*length(s),4);w(c,2);close(a)

Uses package Rmpfr to get the correct precision on pi digits. Outputs a .wav file.
Indented, with new lines and comments:
N=261.63*(2^(1/12))^c(16,0,2,4,5,7,9,11,12,14) # Frequency of each notes
S=44100 #Sampling rate
s=unlist(sapply(el(strsplit(
                   as(Rmpfr::Const("pi",1e5),"character"), #get pi correct digits as a character string
                   ""))[c(1,3:1001)], #Grabs first 1000 digits
                function(x)sin(0:(0.5*S-1)*pi*2*N[(x:1)[1]+1]/S))) #Wave function
c=32767*s/max(abs(s)) #Normalize to range [-32767;32767] as per wav 16-bit standard
a=file("p.wav","wb")
v=writeChar
w=function(x,z)writeBin(as.integer(x),a,z,e="little")
v("RIFF",a,4,NULL)     #ChunkID
w(36+S*10,4)           #Chunksize
v("WAVEfmt ",a,8,NULL) #Format, followed by SubChunk1ID
w(16,4)                #SubChunk1Size
w(c(1,1),2)            #AudioFormat & NumChannels
w(S*1:2,4)             #SampleRate & ByteRate
w(c(2,16),2)           #BlockAlign & BitsPerSample
v("data",a,4,NULL)     #SubChunk2ID
w(2*length(s),4)       #Subchunk2Size
w(c,2)                 #Actual data
close(a)

C (gcc) 572 bytes
p(float f){i;char b[10000];p=3.14;for(i= 0;i<5000;i++){b[i]=35*sin(f*(2*p*i)/10000);putchar(b[i]);}} f(){i;FILE *f;char p[1001];float n[10];n[0]= 261.63;for(i=1;i<=6;i++){if(i==3)n[i]=349.23;else n[i]=1.12231*n[i-1];}for(i=7;i<=9;i++)n[i]=2*n[i-7];f=popen("pi 1000","r");fgets(p,sizeof(p)-1,f);for(i=0;i<999;i++){switch(p[i]){case'1':p(n[0]);break;case'2':p(n[1]);break;case'3':p(n[2]);break;case'4':p(n[3]);break;case'5':p(n[4]);break;case'6':p(n[5]);break;case'7':p(n[6]);break;case'8':p(n[7]);break;case'9':p(n[8]);break;case'0':p(n[9]);break;default:p(n[0]);break;}}}

Ungolfed version:
void play(float freq)
{
    char buffer[10000];
    float pi=3.14;
    for(int i = 0; i<5000; i++)
    {
       buffer[i] = 35*sin(freq*(2*pi*i)/10000 );
       putchar(buffer[i]);
    }
}

void f()
{
    FILE *fp;
    char pi[1001];
    float note[10];
    note[0]= 261.63;

    for(int i=1;i<=6;i++)
    {
       if(i==3)
         note[i]=349.23;
       else
         note[i]=1.12231*note[i-1];
    }

    for(int i=7;i<=9;i++)
      note[i]=2*note[i-7];

   fp=popen("pi 1000","r" );
   fgets(pi, sizeof(pi)-1, fp);

   for(int i=0;i<1001;i++)
   {
    switch(pi[i])
    {
        case '1': play(note[0]);break;
        case '2': play(note[1]);break;
        case '3': play(note[2]);break;
        case '4': play(note[3]);break;
        case '5': play(note[4]);break;
        case '6': play(note[5]);break;
        case '7': play(note[6]);break;
        case '8': play(note[7]);break;
        case '9': play(note[8]);break;
        case '0': play(note[9]);break;
        default : play(note[0]);break;
    }

  }
}

Explanation:

play(float freq) routine takes in the frequency as a parameter of the note (hardcoded) you want to play and stores a sine wave in a buffer.
In the function f(), i stored the frequencies corresponding to notes ranging from C4 to E5  in a notes array.
Store the pi value followed by 1000 digits in a buffer.In order to do this, I installed the pi package on my machine, and used popen to read the output of pi 1000 and store it in a char buffer.
Using a for loop and switch I called the play() function to produce notes that correspond to every single digit in the pi buffer. ,

Usage: ./binary_name.o | aplay on modern Linux distributions, on older distributions you would redirect it to /dev/audio

Suggest replacing the entire switch(foo){...} with something like play(note[(foo-'1')%10]). Also, read tips for golfing in C

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


text:
Contiguous Block Count
Count the number of contiguous blocks within a given 3D input.
Input
The input will consist of one or more rectangles of characters separated by blank lines. Each rectangle represents a cross section of the 3D space. The characters used will be 0, representing empty space, and 1 representing a solid block.
Example
00000
01110
01110
01110

00000
01110
01110
01110

00000
01110
01110
01110

In the above example we have a 3x3 cube - the bottom layer first, then the middle and then the top.
Output
The output should be a single integer giving the number of contiguous blocks within the input.
What's considered contiguous?
If any two 1s are adjacent to each other to the front, back, left, right, top or bottom, they are considered to be part of the same contiguous block. If they are not adjacent or they are only adjacent diagonally, they are not considered to be part of the same block.
Examples
00
11

Contiguous.
10
10

Contiguous.
10
01

Not contiguous.
01
00

01
00

Contiguous.
01
00

00
01

Not contiguous.
01
00

00
10

Not contiguous.
01
00

10
00

Not contiguous.
Test inputs
11101110111
10000011100

00111000000
00000000000

Result: 1

111
111
111

000
010
000

111
111
111

Result: 1

111
111
111

100
000
000

101
011
111

Result: 2

11011011011
00100100100

11011011011
00100100100

00100100100
11011011011

00100100100
11011011011

Result: 14

11011011011
01100100110

11011011011
00100100100

00100100100
11011011011

00100100100
11011011011

Result: 12

11011011011
00100100100

11011011011
01100100110

00100100100
11011011011

00100100100
11011011011

Result: 10

11111
10001
10001
10001
11111

Result: 1

11111
10001
10101
10001
11111

Result: 2

11111
11111
11111
11111
11111

11111
10001
10001
10001
11111

11111
10001
10001
10001
11111

11111
10001
10001
10001
11111

11111
11111
11111
11111
11111

Result: 1

11111
11111
11111
11111
11111

11111
10001
10001
10001
11111

11111
10001
10101
10001
11111

11111
10001
10001
10001
11111

11111
11111
11111
11111
11111

Result: 2

11111
11111
11111
11111
11111

11111
10001
10001
10001
11111

11111
10001
10101
10001
11111

11111
10001
10101
10001
11111

11111
11111
11111
11111
11111

Result: 1

Input format
I'm happy to be slightly flexible on the input format, so if you want to take a list of strings as input instead of one continuous string that's okay, and if you want to take a list of lists of characters (or integers if that helps) that's okay too.
Your answer can be a full program reading input or a function taking the input as a parameter. If your anonymous function needs a name in order for me to call it, then the characters for assigning the function to a name need to be counted too.
This is code golf so shortest code in bytes will win the big green tick, but any answer that meets the spec, passes the tests and has obviously been golfed will get my upvote.

Can we take the input as 3dimensional array?

@flawr Yes you can.

Thanks for providing so many test cases! I suggest you put most of them in a snippet/gist/pastebin in order to declutter the challenge a little bit.

@flawr I've put them all into one code block to force the scroll bar to appear.

Octave, 30 bytes
bwlabeln(...,6) determines the 6-connected components of an n-dimensional array and outputs the number of components found as a second argument.
@(m){[~,N]=bwlabeln(m,6),N}{2}

Try it online!

Apologies. I've just noticed ( over 2 years late :-\ ) that I never accepted your answer even though you won.

@Gareth Thanks! Actually many people don't accept any code-golf answers in the first place as the challenges usually do not have any deadline. So it might always be the case that someone can find an even shorter answer. See for example the discussion here.

Yes, I've read that. I prefer to accept after a few answers have come in - I can always change the accepted answer if someone comes along with a shorter answer. :-)

APL, 83 bytes
{0=⍴o←(,G)/Z←,⍳⍴G←⍵:0⋄1+∇G⊣{G[⊂⍵]←0⋄0=⍴A←G[A]/A←(A∊Z)/A←⍵∘+¨(+,-)↓∘.=⍨⍳3:⍬⋄∇¨A}⊃o}

Unlike some other languages, APL does not have a built-in for this (that I know of).
This function takes a 3-dimensional array of bits. It uses a 3-dimensional flood fill to remove blocks one by one, and counts how many blocks it can remove before the input is empty.
Non-golfed version with comments here.

Why the read function when input may be rank 3?

@Adám: so I could enter the test data easier. That read function reads the input as written in the question using ⍞ and returns a rank-3 array. That way I didn't have to convert it into X Y Z ⍴ ... by hand. Since I wrote it anyway, I thought I might as well include it in the non-golfed version.

Mathematica, 53 bytes
Max@MorphologicalComponents[#,CornerNeighbors->False]&

Unnamed function taking a 3D-array of integers. MorphologicalComponents is the builtin being exploited here: treating 0 as empty space, it separates the other integers into contiguous blocks, and assigns each block a number (starting from 1, 2, ...) and replaces all of its component entries by that number. So the number of blocks is just the maximum of all entries thus produced. Unfortunately, by default MorphologicalComponents counts diagonal neighbors as connected, so we need to add the option CornerNeighbors->False to fit the spec. (Side note: MorphologicalComponents is really built to operate on 2D and 3D images; but it handles arrays of integers as a side benefit.)


text:
Exit Code Golfing
Inspired by this default for IO.
The Task
Write a program that, given an input integer x between 0 and 255, crashes with exit code x.
Restrictions

You may not call anything which is intended directly for exit code output (System.exit(x), returning from main, etc.). Instead, your program must cause an error or crash which will cause, with a probability of 1, the program to exit with the input integer.

In this case, the words "error" and "crash" means that the program caused some fatal unintended exception, wherein a method, operation or otherwise was used incorrectly that caused an irreversible failure.
You may not directly cause the error by throwing it directly. You must cause it by using a method, function, or otherwise whose purpose serves a different function (i.e. attempting to execute a file write to a read-only directory).

You must have at least two exit codes accounted for in your program.
Termination of the process with the use of signals is banned. (Reasoning may be found in this discussion)

Scoring
Your program's score is determined by the number of supported exit codes, where code concision is tiebreaker. The greatest number of supported exit codes wins!

Just to clarify, if I raise an error, that is illegal yes?

@AnthonyPham If you directly raise it (throw new Exception() style), that is illegal. If it is the byproduct of misuse of an existing function, then that's fine.

@VoteToClose I guess I wasn't clear enough. I agree with you, but was suggesting, say square, instead of factorial. But whatever, it doesn't really matter, was just a suggestion

Sushi has an exit code for every possible error. Too bad I haven't published the interpreter yet.

@Pavel You can always make a non-competing answer, if you want.

Is accepting input as spelt-out English digits (e.g. one zero zero for 100) acceptable? I have an idea for this challenge, but the language has some fairly unusual ideas about I/O, and this is the most natural input format.

@VoteToClose: Does scheduling an alarm and failing to set up a signal handler count?

@ais523 I don't see an issue with that - it has the same "meaning", if you will.

Is an exit code triggered by version mismatch in the JVM, or any other of these, a valid submission? http://journal.thobe.org/2013/02/jvms-and-kill-signals.html

@carusocomputing Sure - if you can trigger them input-specifically.

I would consider Exit Code Golfing a clickbait title, altho it is accurate. <(°_°<)

Can we read a byte from STDIN that represents the 8-bit input integer?

@Dennis Sorry for the late response. However you accept your input is fine, as long as it is consistent. I will not restrict how you accept input.

Unix Shell (+ncurses +BSD utilities), 36, 26 bytes, 256 exit codes
Golfed
jot -bu0 $[252+$1]|tput -S

If the -S option is used, tput checks for errors from each line, and if any errors are found, will set the exit code to 4 plus the number of lines with errors.  If no errors  are  found,  the exit  code  is  0.  No indication of which line failed can be given so exit code 1 will never appear.  Exit codes 2, 3, and 4 retain their usual interpretation.

Once the tput exit code goes over 255, it just overflows, so 253 (errors on input) will result in the exit code of 1 e.t.c., thus yielding the desired exit status for the whole range of inputs.
Note: whether tput will fail on not, when setting/getting a particular capability, depends on the terminal type, I've used: xterm with 256 colors
jot is a BSD utility, which
prints sequential or random data, and (AFAIK) is also available out of the box on OSX systems.
If your system does not have jot available, you can use a slightly longer (29 bytes) version:
yes u0|sed $[252+$1]q|tput -S

Try It Online ! (the 29 bytes version)

Wow, that's pretty good. +1

Bash 4.2 + extras, 24 exit codes
grep \#$1$ $0|sed 's:#.*::;s:T:tcc -run -<<<main=:;s:C:curl -L x.org/! :'|sh;exit
man#1
C-#2
C/#3
sed#4
C-x/#5
C_#6
C0#7
man /#16
C-f#22
C-o/#23
C-L3#35
C--capath /#60
C--max-filesize 1#63
C--cacert /#77
timeout 1e-9 w#124
/#126
-#127
T6\;#132
T204\;#133
$[2**63%-1]#136
{0..1000000000}#137
T0\;#139
exit _#255

Thanks to @KenY-N for 3 exit codes. Thanks to @el.pescado for 1 exit code.
Verification
All tests have been performed on openSUSE 13.2.
$ for n in {0..255}; do bash exit.sh $n; (($? == $n)) && echo $n >&0; done &> /dev/null
0
1
2
3
4
6
7
16
22
23
35
60
63
77
124
126
127
132
133
136
137
139
255

Exit code 5: http_proxy=fafa curl http://example.org

@el.pescado It took me over a year, but I finally implemented your suggestion. Thank you!

INTERCAL (C-INTERCAL), 15 codes, 313 + 2 = 315 bytes
        PLEASE WRITE IN .1
(8)     PLEASE CREATE .1 A
        PLEASE A
        PLEASE COME FROM #2$!1/#1'

        DO X
(123)   DO (123) NEXT
        DO COME FROM (222)
(222)   DO STASH .2
(240)   DO ,1 <- #0
(241)   DO ,1 SUB #0 <- #1
(19)    DO .2 <- #256 $ #0
(21)    DO .1 <- #2
(148)   DO GO BACK
(180)   DO RETRIEVE .2
        DO COME FROM (50)
(50)    DO WRITE IN .2
(109)   DO RESUME #0
(120)   DO RESUME #9
        MAYBE COME FROM (223)
(223)   DO COME FROM (223)
(121)   PLEASE NOT X

Try it online!
All whitespace here is irrelevant. (The original program contained tabs, but I converted them to spaces so that it'd line up correctly on SE; it's conventional to use a tab width of 8 for INTERCAL. I've tested a version of the program with all tabs, spaces, and newlines deleted, though, and it works fine.)
Compile with -abm (2 byte penalty, because -b is required for the compiler to be deterministic).
As usual for INTERCAL, this takes numeric input in the format, e.g., ONE TWO THREE for 123.
Explanation
When a C-INTERCAL program errors out, the exit status is the error code modulo 256. As a result, we can aim to write a program that's capable of producing as many runtime errors as possible. This program only omits two runtime errors that don't indicate internal compiler issues: ICL200I, because reproducing it requires the use of external libraries that are only compatible with a single-threaded program (and multithreaded programs have more errors available); and ICL533I, because 533 has the same value modulo 256 as 277 does, and the program's capable of producing ICL277I.
The program always starts the same way. First, we input (WRITE IN) a value for the variable .1. Then, we use a computed CREATE statement to create new syntax (here, A); but because it's computed, the definition of the syntax varies based on the value of .1. Finally, in most cases we run our new A statement, which has been defined to produce an error; the table of possible definitions we have contains a definition for each possible runtime error (other than the exceptions listed above).
First, there are two exceptions to this general scheme. (0) is not a valid line number, so if the user inputs ZERO, we jump from the second line (numbered (8)) to the fourth line by means of a computed COME FROM statement. This then falls through into a syntax error DO X, which produces error ICL000I. (In INTERCAL, syntax errors happen at runtime, due to the tendency of commands to be disabled, syntax to be redefined under you, etc.). The COME FROM statement also has a side effect, even if no actual COME FROM happens, creating an operand overload from .1 to #1 whenever a line with a line number is executed; this is used later on when producing output 21. (Random global side effects are fairly idiomatic in INTERCAL.)
The other exception is with input ONE TWO NINE. There's no line number (129) in the program, so we get an error for a missing line number, which is ICL129I. So I didn't have to write any code to cover that case at all.
Here are the other errors, and what causes them:

123 is a NEXT stack overflow (DO (123) NEXT). The NEXT statement needs other modifiers (FORGET or RESUME) in order to retroactively determine what sort of control statement it was. Not having those causes error ICL123I once there are 80 unresolved `NEXT statements.
222 is a stash overflow (DO STASH .2 in a COME FROM loop). The stashes are limited only by available memory, but that will run out eventually, causing error ICL222I.
240 is dimensions an array to size zero. That's exactly what DO ,1 <- #0 means, and it causes error ICL240I.
241 is caused by assigning outside the bounds of an array. In this case, ,1 hasn't been allocated (, is used for array-type variables in INTERCAL), so indexing it causes error ICL241I.
19 assigns 65536 (#256 $ #0) to a 16-bit variable .2. It doesn't fit, causing error ICL275I.
21 assigns #2 to .1. That might look like a simple enough assignment, but we overloaded .1 to mean #1 earlier, and attempting to change the value of 1 with no -v option on the command line causes error ICL277I.
148 attempts to return to the top entry of the choicepoint stack (GO BACK), which doesn't exist at this point in the program (we haven't run any commands to manipulate the choicepoint stack, so it's still empty). That causes error ICL404I.
180 attempts to RETRIEVE .2 from a nonexistent stash (because we didn't stash anything there in this branch of the program), causing error ICL436I.
50 requests input (WRITE IN) forever in a COME FROM loop. Eventually we'll end up reading past EOF, causing error ICL562I.
109 runs the statement DO RESUME #0, which is meaningless and specifically documented as causing an error (ICL621I).
120 runs the statement DO RESUME #9. We haven't run that many NEXT statements yet, and thus we get error ICL120I. (Intriguingly, this particular error is defined in the INTERCAL documentation as exiting the program normally and then causing the error, rather than exiting the program with an error. I don't believe these two cases are observably different, though.)
223 is basically a complex tangle of multithreading primitives that all point back to line 223, causing an infinite loop that blows up memory. Eventually, there's memory exhaustion in the multithreading subsystem, leading to error ICL991I.
121 is actually a valid statement (it's a comment), but it appears at the end of the program. As such, execution falls off the end of the program immediately after it executes, causing error ICL633I.

Verification
Some of the errors involve intentionally running the program out of memory, so I suggest setting fairly small memory limits. Here's the shell command I used to test the program (with newlines added for readability; delete them if you run it yourself):
for x in "ZERO" "ONE NINE" "TWO ONE" "FIVE ZERO" "ONE ZERO NINE"
         "ONE TWO ZERO" "ONE TWO ONE" "ONE TWO THREE" "ONE TWO NINE"
         "ONE FOUR EIGHT" "ONE EIGHT ZERO" "TWO TWO TWO"
         "TWO TWO THREE" "TWO FOUR ZERO" "TWO FOUR ONE";
do  echo;
    echo $x;
    echo $x | (ulimit -Sd 40000; ulimit -Sv 40000; ulimit -Ss 40000;
               ./errors; echo $?);
done

And here's the output (with the line numbers and "PLEASE CORRECT SOURCE" messages deleted to save space), which I added partly to demonstrate the program working but mostly to show off INTERCAL's silly error messages:
ZERO
ICL000I PLEASEWRITEIN.1(8)PLEASECREATE.1APLEASEAPLEASECOMEFROM#2$!1/#1'DOX(123)DO(123)NEXTDOCOMEFROM(222)(222)DOSTASH.2(240)DO,1<-#0(241)DO,1SUB#0<-#1(19)DO.2<-#256$#0(21)DO.1<-#2(148)DOGOBACK(180)DORETRIEVE.2DOCOMEFROM(50)(50)DOWRITEIN.2(109)DORESUME#0(120)DORESUME#9MAYBECOMEFROM(223)(223)DOCOMEFROM(223)(121)PLEASENOTX
0

ONE NINE
ICL275I DON'T BYTE OFF MORE THAN YOU CAN CHEW
19

TWO ONE
ICL277I YOU CAN ONLY DISTORT THE LAWS OF MATHEMATICS SO FAR
21

FIVE ZERO
ICL562I I DO NOT COMPUTE
50

ONE ZERO NINE
ICL621I ERROR TYPE 621 ENCOUNTERED
109

ONE TWO ZERO
ICL632I THE NEXT STACK RUPTURES.  ALL DIE.  OH, THE EMBARRASSMENT!
120

ONE TWO ONE
ICL633I PROGRAM FELL OFF THE EDGE
121

ONE TWO THREE
ICL123I PROGRAM HAS DISAPPEARED INTO THE BLACK LAGOON
123

ONE TWO NINE
ICL129I PROGRAM HAS GOTTEN LOST
129

ONE FOUR EIGHT
ICL404I I'M ALL OUT OF CHOICES!
148

ONE EIGHT ZERO
ICL436I THROW STICK BEFORE RETRIEVING!
180

TWO TWO TWO
ICL222I BUMMER, DUDE!
222

TWO TWO THREE
ICL991I YOU HAVE TOO MUCH ROPE TO HANG YOURSELF
223

TWO FOUR ZERO
ICL240I ERROR HANDLER PRINTED SNIDE REMARK
240

TWO FOUR ONE
ICL241I VARIABLES MAY NOT BE STORED IN WEST HYPERSPACE
241

This is possibly the greatest INTERCAL program I have ever seen.

C90 (gcc), 256 exit codes, 28 27 18 bytes
main(){getchar();}

I'm not sure if this is clever or cheaty, but I don't think it violates the rules as written: it technically doesn't use exit, return, or any error throwing mechanism, but simply relies on undefined behavior and the fact that gcc does something rather convenient as far as this challenge goes.
Try it online!
How it works
This simply uses getchar to read one byte from STDIN. By itself, this does nothing.
However, a compliant C90 program must end with a return statement or something equivalent; everything else is undefined behavior. gcc ends the generated assembly with a ret anyway, so whatever value was casually in the register EAX will get returned by the program. Luckily, glibc's getchar stores the byte it reads from STDIN in EAX, so the value of that byte is the exit code of our program.

It would be interesting to see if this can be modified to break through the 8 bit barrier, using the shell like  jsh, which supports set -o fullexitcode.

That's clever. But the program doesn't actually crash, then. It returns normally, whether the spec is to "cause a fatal exception/irreversible failure/crash"

Either way, this is awesome.

@dim I guess that depends on your definition of crash. Not ending main with return or exit is an error as far as the C90 standard goes, and it results in an exit code that indicates failure. That's all a crash does at heart.

A crash is a program stopping to function properly. Your program does all that you told it to do properly, it reads one character from the input and then stops. So even though the exit code indicates an error it didn't crash.

Perl, 108 bytes, 256 exit codes
This program (ab)uses Test::More module. It tries to open file named "" n times where n is given as command line argument. It fails every time, and each invocation is treated as a test. Test::More return number of failed tests as exit code. plan tests => $ARGV[0]%255 is needed to get exit code 255.
#!/usr/bin/perl
use Test::More;
plan tests => $ARGV[0]%255 if($ARGV[0]>0);
ok(open(F,"")) for (1..$ARGV[0])

Golfed: perl -MTest::More -e'plan tests,$%%255if$%=<>;ok 0for 1..$%', 51 bytes (38 bytes + 13 bytes for -MTest::More<space>). Takes input on stdin.

C (gcc) under bash shell on x86, 230 bytes, 8 exit codes
Newlines added to aid readability.  Comments ignored in score.
main(int c, char **v){
int p[2];
switch(atoi(v[1])-128){
case 2:__asm("UD2");        /* SIGILL: x86 undefined instruction */
case 5:__asm("int $3");     /* SIGTRAP: x86 breakpoint instruction */
case 6:abort();             /* SIGABRT: raise() is called under the covers */
case 8:c/=c-2;              /* SIGFPE: divide by 0 (c-2) */
case 11:c=*(int *)c;        /* SIGSEGV: dereference of invalid pointer */
                            /* SIGPIPE: write() to a pipe closed at the other end */
case 13:socketpair(1,1,0,p);close(p[1]);write(p[0],v,1);
case 14:alarm(1);sleep(2);  /* SIGALRM: kernel will send alarm signal after 1 sec */
}
}

A feature of the bash shell:

When a command terminates on a fatal signal N, bash uses the value of 128+N as the exit status.

So all we need to do is trigger various signals from within a c program.  At this point, I assume simply doing kill(n-128); is banned.  So instead we execute code that triggers various signals, which causes the corresponding error codes to be made available at the calling shell.
The exit codes are 0, 130, 133, 134, 136, 139, 141, 142.
Try it online.  Expand the "Debug" section to see the return code.
This can certainly be golfed deeper.  But I'd be more interested in adding more signals.

Would I be correct to assume that the signals are caused outside your code by pre-existing functions or operations?

@VoteToClose yes, that's right.  For example, __asm("UD2") runs the x86 "undefined instruction" which will cause a CPU exception which will be relayed by the kernel to the program in the form of a SIGILL signal.  For the socketpair example, SIGPIPE will be sent by the kernel or glibc as we are trying to write() to a pipe that was close()d at the other end.

Then I have no issue with it. :P

I have altered the rules so that answers, provided that at least two error codes are covered, are valid. You're not the only answer with this issue.

You can golf out 1) two characters if you use int3 and not int $3 and 2) one character if you declare v as int**, given that you do not fundamentally rely on the char-ness of the datatype in your pointer arithmetic, plus 3) two characters if you use *p instead of p[0], or 4) six characters, if you're willing rely on the predictable fd numbers returned by all syscalls that create them, and replace p[0] and p[1] by their near-certain values. Lastly, pipe(fd) is much shorter than socketpair(...) and generates the same error when closing fd[0] and writing to.fd[1].

For SIGIO on Linux: case 29:fcntl(1,8,getpid());fcntl(1,4,8192);puts(" ");. That is fcntl(STDOUT_FILENO, F_SETOWN, getpid()); fcntl(STDOUT_FILENO, F_SETFL, O_ASYNC);.

SIGILL should be 4.

A few additional golfing suggestions: 1) Use &63 instead of -128. 2) Replace sleep(2) with for(;;). 3) Replace c=*(int*)c with atoi(0). 4) Replace c/=c-2 with c/=0.

PHP, 15 bytes, 2 exit codes
Without die/exit, PHP cannot return anything but 0 or 255 (afaik; probably ~1), so ...
!$argv[1]?:p();

If command line argument is falsy, it evaluates to 1 and exits with 0. If not, it tries to call a function and exits with <b>Fatal error</b>:  Uncaught Error: Call to undefined function p().
Run with -r.

That's not true. exit() sets an exit status... which you can't use for this challenge, granted. But your code is also invalid. It sets the exit status to 255

@aross: Hmm I always assumed error would exit with 1. I searched for a list of exit codes, but couldn´t find one.

Python 2, 13 Bytes, 2 exit codes
1/(input()-1)

If you enter 0, it tries to print 1/-1 which is -1 which is perfectly fine thus exit code 0. If you enter 1, you get 1/0 which raises a ZeroDivisionError in which there is an exit code of 1. With my IDE, there is only 0 and 1 for the exit codes...
Outputs:

Excel VBA, 414 514 533 + 3 Bytes, 14 exit codes

Takes input as a Conditional Compilation Argument, n=[input value] and produces that number's associated error code.
Sub e()
Dim a As Application, b As Byte, s As String, v(), x
Set a=Application
#If n=3 Then
Return
#ElseIf n=5 Then
b=a.CommandBars("")
#ElseIf n=6 Then
b=2^8
#ElseIf n=7 Then
ReDim v(9^9)
#ElseIf n=9 Then
v=Sheets("")
#ElseIf n=10 Then
v=Array(1)
For Each x In v
ReDim v(9)
Next
#ElseIf n=11 Then
b=1/0
#ElseIf n=13 Then
Debug.?Int("X")
#ElseIf n=14 Then
Debug.?String(9E8,1)
#ElseIf n=20 Then
Resume
#ElseIf n=28 Then
f 256
#ElseIf n=35 Then
Call c
#ElseIf n=92 Then
For Each x In v
ReDim v(9)
Next
#ElseIf n=94 Then
b=Null
#End If
End Sub

Sub f(n):DoEvents:f n-1:End Sub

+3 for n=[Value] conditional compilation call
Handles Inputs where n=
3
5
6
7
9
10
11
13
14
20
28
35
92
94

Note: VBA does not have exit codes 0 or 1. I have included the solutions for 3 and 5, which are the two lowest numbered exit codes available to VBA in their place

I won't disallow this answer, because it's synonymous for me disallowing due to language capability for output types.

What does the # do here?

The #if and #ElseIf are conditional compilation statements meaning that the statements that follow it are only compiled if the condition is true

So, if they're not true, the statements aren't compiled...that's different than not using #, where they'd be compiled whether or not the statements are true? I know how If statements work, but I'm new to getting down to what actually compiles, so sorry for such a simple question.

@BruceWayne, yes, that is exactly the case. Because these lines are designed to throw specific errors, it is necessary to have only the lines that produce the desired error code be compiled at a give time. To do this #if is used in place of If or Select Case as only truthy conditional statements are actually compiled. In this case specifically, this keeps the program from exiting with error code 3, Return without GoSub on every execution, but rather only exiting with this code when n=3

Turtlèd, 4 bytes, 2 exit codes
I don't know if there are any ways to get more exit codes... are there even any more ways in the interpreter language
I found a few four length answers
' ?;

Try it online!
!.(0

Try it online!
?;(*

Try it online!
How these work:
' ?;

in my interpreter, there is a bug feature that causes errors when the grid in memory has more than one line, and has no non-space characters on it. this program erases the * on the origin cell '[space], takes non-negative integer input ? (0 or 1 really), and moves down that many ;, if it is zero, the grid will only have one line and not error, otherwise it will move down and the error will occur
!.(0

parentheses and stuff don't get parsed, they just get executed at run time to mean: "skip to the matching paren, if the cell symbol isn't right". in this program, inputting (!) one causes the program to write it to the cell (.), execute the paren, which checks if the cell symbol is 0, try to skip to the matching paren, but instead throw an error as there is none. if it is zero, it writes it down, checks the parentheses, finds itself on a 0, and then ignores it, and the program finishes
?;(*

has elements of the previous answer, and the first. it takes non-negative integer input, moves down that many, and checks whether the cell is '*', searching for a non existing extra paren if it is not. if the input is 1, it will move off the starting space, and find the cell is a space, and error, if it is zero, it will stay on the start space and ignore the paren.

Javascript (node), 19 bytes, 2 exit codes
Full program:
+process.argv[2]&&a

Function:
f=i=>i&&f(i)

process.argv is an array that contains the path to the node executable, the path to the javascript file executed and the command line arguments. In this case, this will be either "1" or "0". The string is converted to a number with the unary + operator. If the number is zero the lazy && operator won't evaluate the right hand side, if the number is truthy (not zero), the right hand side of && is evaluated and an error is thrown because it's referencing an undefined variable, and the program exists with exit code 1.
The function expects the input as a number. If the input is truthy, the function calls itself, and crashes the node runtime with a stack overflow. If the input is 0, the lazy && operator returns 0 without evaluating the right hand side.

@VoteToClose Changed it to an undefined variable

That works. :P

The full program can be shortened to +process.argv[2]&&a.

@user2428118 You're right

Just out of curiosity, would ReferenceError.prototype.name=process.argv[2]?a:0 be valid?

Perl 6, 57 bytes, 256 exit codes
use Test;plan $_=@*ARGS[0];ok try {open ""} for ^($_%255)

Try it
This is a translation of the Perl 5 example.
Expanded
use Test;  # bring in ｢plan｣ and ｢ok｣

plan $_ = @*ARGS[0]; # plan on having the input number of tests
                     # only actually needed for the 255 case
                     # if the plan is greater than the number of tests
                     # it fails with exitcode 255

  ok                 # increment the failure counter if the following is False
    try {            # don't let this kill the whole program
      open ""        # fails to open a file
    }

for                  # repeatedly do that

  ^(                 # upto Range
    $_ % 255         # either the input number of times, or 0 times for 255
  )

Python 3, 15 bytes, 2 exit codes
Obviously, this is longer than the Python 2 solution, because in Python 3 we can't take a literal input without calling eval. However, we can use string
comparison techniques interestingly...
1/(input()<'1')

Input will be either the string 0 or 1 - if it's 1, the condition evaluates to 0 (false), resulting in an attempt to compute 1 / 0 which obviously crashes (exit code 1). Otherwise, nothing happens, and Python exits with the regular exit code 0.
As far as I'm aware, Python is incapable of crashing with other exit codes.

Scala, 19 bytes, 2 exit codes
if(args(0)=="1")1/0
1/(args(0).toInt-1)
The JVM supports only 1 and 0 as exit codes if you don't call System.exit.
The first program tries to calculate 1/0 if the first argument is 1, which will crash the JVM with an exit code of 1. If the argument is 0, it wil exit succesfully.
The second program to converts the argument to integer, subtracts one and tries to divide 1 by that number. If the argument if 1, it calculates 1/0, so the JVM will crash; if the argument is 0, it calculates 1/-1 and exits.

Java, 71 66 bytes, 2 exit codes
4 bytes saved thanks to Holger
Full program:
interface I{static void main(String[]a){a[a[0].charAt(0)-48]="";}}

Function taking an int as an argument:
i->1/(i-1)

The program takes the first char of the first argumant (either '0' or '1' and subtracts 48 (ascii value of '0') to get an integer (0 or 1). It then tries to set the argument at the position of that integer to the empty string. If the input is 1, the program crashes with an ArrayIndexOutOfBoundsException, beacuse the argument array only has one element at position 0 (zero-indexed).

You can assign the value or use it in any other way, e.g. as array index a[a[0].equals("1")?1/0:1]="";, which is on par with int x=a[0].equals("1")?1/0:1;. But changing the program further to provoke an ArrayIndexOutOfBoundsException instead of ArithmeticException saves a few bytes: interface I{static void main(String[]a){a[a[0].charAt(0)-'0']="";}}

Python 2, 11 bytes, 2 exit codes
1>>-input()
1/~-input()
0<input()<x

Three different 11-byte solutions for three different errors! (Just for fun, this doesn't give points.) By default, Python only has exit codes 0 for successful exit and 1 for error. The successful runs don't output anything.
 1>>-input()

On input 1, gives "ValueError: negative shift count". On input 0, a zero shift count succeeds and gives 1.
1/~-input()

On input 1, gives "ZeroDivisionError: integer division or modulo by zero" due to ~-input(), aka input()-1 being 0. In input 1, 1/-1 gives -1. 0**-input() would also work.
0<input()<x

On input 1, gives "NameError: name 'x' is not defined". On input 0, these first inequality 0<0 is evaluated to False, so the rest is not evaluated and the result is just False.

SmileBASIC, 640 bytes, 39 exit codes (out of 52)
SPSET.,0INPUT C$GOTO"@"+C$@0
STOP@3
A
@4
CLS.@5@A
GOSUB@A@7?1/A@8
X$=3@9
A%=POW(2,31)@10
BEEP-1@11
DIM B[#ZL*#R]@13
READ A
@15
V"OPTION STRICT?X
@16
CALL@D@17
V@A*2
@18
V"VAR A,A
@19
V"DEF A:END:DEF A
@20
V"FOR I=0TO
@21
V"NEXT
@22
V"REPEAT
@23
V"UNTIL
@24
V"WHILE.
@25
V"WEND
@26
V"IF.THEN
@27
V"IF.THEN"+CHR$(10)+"ELSE
@28
V"ENDIF
@29
V"DEF X
@30
RETURN@31
DIM E[-1]@32
V"DEF A:DEF
@34
GOTO"|
@36
XOFF MIC
MICSTOP
@37
XOFF MOTION
GYROSYNC
@38
PRGDEL
@39
DIM F[66]SPANIM.,1,F
@40
DIM G[2]SPANIM.,1,G
@42
MPSTART 2,@A@L
MPSEND"A"GOTO@L@44
PROJECT
@46
USE"PRG1:A
@47
BGMPLAY"`
@48
X=
@51
DLCOPEN"
DEF V C
PRGEDIT 1PRGDEL-1PRGSET C
EXEC 1
END

This could definitely be made shorter.
SB only has error codes from 0 to 51, and some are impossible to trigger.

Node.js (ES6), 77 bytes, 2 exit codes
require('readline').createInterface({input:process.stdin}).prompt("",i=>i&&x)

Jelly, 4 exit codes, 18 bytes
ß€
2*
Ṁ¹Ŀ
RÇĿỌḊ?R

Supports exit codes 0, 1, 137 (killed), and 139 (segmentation fault).
Try it online!
How it works
RÇĿỌḊ?R  Main link. Argument: n (integer)

R        Range; yield [1, ..., n] if n > 1 or [] if n = 0.
    Ḋ?   If the dequeued range, i.e., [2, ..., n] is non-empty:
 Ç         Call the third helper link.
  Ŀ        Execute the k-th helper link, where k is the the integer returned by Ç.
         Else, i.e., if n is 0 or 1:
   Ọ       Unordinal; yield [] for n = 0 and "\x01" for n = 1.
      R  Range. This maps [] to [] and causes and error (exit code 1) for "\x01".

Ṁ¹Ŀ      Third helper link. Argument: r (range)

Ṁ        Maximum; retrieve n from r = [1, ..., n].
 ¹Ŀ      Call the n-th helper link (modular).
         When n = 139, since 139 % 3 = 1, this calls the first helper link.
         When n = 137, since 137 % 3 = 2, this calls the second helper link.

2*       Second helper link. Argument: k

2*       Return 2**k.
         Since 2**137 % 3 = 174224571863520493293247799005065324265472 % 3 = 2,
         ÇĿ in the main link will once again call the second helper link.
         Trying to compute 2**2**137, a 174224571863520493293247799005065324265472-
         bit number, will get the program killed for excessive memory usage.

ß€       First helper link. Argument: k

ß€       Recursively map the first helper link over [1, ..., k].
         This creates infinite recursion. Due to Jelly's high recursion limit,
         a segmentation fault will be triggered.

ZX81 BASIC >255 exit codes - 52 bytes (listing)
1 INPUT N
2 GOTO 1+(2*(N>0 AND N <=255))
3 PRINT "EXIT CODE ";N
4 RAND USR N

Technically, N could be any 24 bit floating point number within the range, but we'll assume integers here. Line 2 is equivalent to IF N>0 AND N <=255 THEN GOTO 3: ELSE GOTO 1 if ZX81 BASIC had IF/ELSE in its symbolic instructions.

How does this satisfy the program caused some fatal unintended exception? This just prints out some text and finishes execution.

You are right - I need to be more awake in the mornings.

RAND USR N will cause unintended effects as calling part of the ROM from an unexpected place is not a good idea, therefore RAND USR 0 has been excluded as that is too graceful.

Can you elaborate a bit more on how that actually causes the program to crash? I'm not intimately familiar with ZX81 BASIC.

The ROM resides from 0x0000 - 0x1fff; calling ROM routines will work if you start at the right place. Starting one or more bytes into any machine code routine in Z80 will cause unexpected effects. If you have a simple LD BC, 0000 RST 10 RET at 0x1000 but called RAND USR 4097 then you'll miss out the LD operand and the machine code will therefore be skewed. I don't remember all ROM calls but I'll work out all legal/graceful ends and exclude them later.

Another issue when entering ZX81 BASIC is that the interpreter will error check as you enter your listing, and therefore if it looks like you are entering something erroneous then it will not allow you to add the line to your program until you have fixed the issue it has highlighted.


text:
The Eratosthenes Shuffle
Challenge
Write a function or program that accepts a line of input, performs a very specific and oddly familiar shuffle on its characters, and outputs the result.
The required shuffling can be described using the following algorithm:

Label each character in the input with a 1 based index.
Write character number 1 as output.
Starting with character number 2, write every other character to the output in order, excluding character 2 itself.  In other words, write characters 4, 6, 8, 10, and so on as output.
Starting with the next character number n not yet written as output, write every nth character to the output, excluding character n itself, and excluding any other character (by numeric label) you may have already written to the output.
Repeat step 4 as long it continues to add new characters to the output.
Write the remaining characters to output, in order.

Example

Label the characters.

  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
  O  L  D     D  O  C     Y  A  K  '  S     B  E  A  U  T  Y     C  O  R  N  E  R

2. Write the first character to output:
  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
  O  L  D     D  O  C     Y  A  K  '  S     B  E  A  U  T  Y     C  O  R  N  E  R
O

3. Write every other character starting with 2, excluding 2.
  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
  O  L  D     D  O  C     Y  A  K  '  S     B  E  A  U  T  Y     C  O  R  N  E  R
O O A' EUYCRE
4. The next character not yet written is character number 3; write every 3rd character starting with 3, but excluding character 3 itself, and any character already written.
  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
  O  L  D     D  O  C     Y  A  K  '  S     B  E  A  U  T  Y     C  O  R  N  E  R
O O A' EUYCREYB R
5. Repeat step 4 using the next character, character 5.
4. The next character not yet written is character number 5; write every 5th character starting with 5, but excluding character 5 itself, and any character already written.  (This amounts to just character 25).
  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
  O  L  D     D  O  C     Y  A  K  '  S     B  E  A  U  T  Y     C  O  R  N  E  R
O O A' EUYCREYB RN
5. The next character is 7; but 14, 21 have already been written, so no more characters would be output if we repeat step 4.  Thus, we're done with 5.
6. Write the remaining characters out in order.
  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
  O  L  D     D  O  C     Y  A  K  '  S     B  E  A  U  T  Y     C  O  R  N  E  R
O O A' EUYCREYB RNLDDCKSATO
Rules
Input and output may be via standard input/standard output, strings, or arrays of characters.
If reading in as standard input you may at your convenience assume there's a trailing newline, or that the entire input contains the line.  Newline characters do not participate in the shuffle.
Likewise, at your convenience, your output may either have a trailing newline or not.
Standard loopholes are disallowed.
This is a code golf competition.  Smallest code in bytes wins.
Test Cases
123456789ABCDEF -> 1468ACE9F2357BD

OLD DOC YAK'S BEAUTY CORNER -> O O A' EUYCREYB RNLDDCKSATO

Blue boxes use a 2600hz tone to convince telephone switches that use in-band signalling that the caller is actually a telephone operator.
->
Bebxsuea20h oet ovnetlpoesice htuei-adsgaln httecle satal  eehn prtre 0ncce ha nng aiuapootnt ihyon atallu o s 6z oi ehwstsnbilt lr clee.

Now I see why this is so oddly familiar... It's a prime sieve...

I was really puzzled by the 4 in your code blocks. Crossed out 4 is still regular 4...

@MamaFunRoll Yeah, but everything is spaced out quite a bit to show the numeric labels.  Taking advantage of this, I extended the strikeouts.  Now 4 actually looks crossed out... better?

Yeah, it was partly an old PPCG meme :P Thanks though, appreciate the clarity!

Jelly, 10 bytes
JÆfṂ$ÞÆPÞị

TryItOnline
How?
JÆfṂ$ÞÆPÞị - Main link: theString
J          - range(length), the 1-based indexes of theString
     Þ     - sort these by
    $      -     last two links as a monad
 Æf        -         prime factorization array (e.g. 20 -> [2,2,5])
   Ṃ       -         minimum
        Þ  - sort these by
      ÆP   - isPrime, i.e. move all the primes to the right
         ị - index into theString

Mathematica, 61 bytes
#[[SortBy[Range@Length@#,FactorInteger[#][[1,1]]PrimeQ@#&]]]&

Unnamed function taking a list of characters as input and returning a list of characters.
FactorInteger[#][[1,1]] yields the smallest prime factor of # (and returns 1 if # equals 1). Therefore FactorInteger[#][[1,1]]PrimeQ@# yields a strange expression: [#'s smallest prime factor] False if # is not prime, and # True if # is prime (these are unevaluated products of a number and a boolean).
Range@Length@# yields a list of the numbers up to the length of the input. Then SortBy sorts those numbers by the funny function described above. Mathematica is really type-sensitive in many ways, but cheerfully mixes them in other ways: expressions of the form [number] False are alphabetically sorted before expressions of the form [number] True, while ties are broken by sorting the numbers numerically. That produces exactly the permutation we want here, and #[[...]] permutes the characters of the input accordingly.

C, 164 bytes
This takes input as the first command parameter and prints back to stdout.  As we process each character, we clear it, allowing the final pass.
#define p putchar
main(c,s,i,j,t)char**s,*t;{c=strlen(t=s[1]);p(*t);for(;j++<c;)if(t[j])for(i=2*j+1;i<=c;i+=j+1)!t[i]?:p(t[i]),t[i]=0;for(j=0;j++<c;)!*++t?:p(*t);}