text:
Convert any number (up to 1e3000) to text
Given an input, calculate the correct suffix and output the number in a readable format in short scale (where 1 billion is 10^9). The suffixes must go to at least 10^3000, in which the rules for calculating them can be found here, or a list can be found here.
There is no need to output the exact numbers, this is focused on getting a huge number into a readable format.
For example:
10000 = 10.0 thousand
135933445 = 135.93 million
-2 = -2.0
-2.36734603 = -2.37
'1'+'9'*3000 = 2.0 nongennovemnonagintillion

 // out of range examples
'1'+'9'*3010 = 20000000000.0 nongennovemnonagintillion
'-1'+'9'*5000 = -inf nongennovemnonagintillion

I am aware it is similar to this question, though with 10x as many numbers and not having to read the names, there's potentially a lot more room for golfing. For the record, my result is 578 characters in Python.
Rules:

No getting things from external resources - it must all be calculated within the code.
External modules are fine, just don't break the above rule.
The code should work when input is either a string, integer or float (eg. you may wish to input the super large numbers as strings).
The output must always contain a decimal place.
The output must be rounded if above 2 decimal places. Using the inbuilt round function is fine, I am aware there are some floating point errors, so if the occasional '.045' doesn't round up to '.05' for example, don't worry about it.
Leaving multiple zeroes at the end is optional, as long as it doesn't go above 2 decimals (1.00 or 1.0 are both fine) and is consistent for all inputs (an input of 1 and 1.0 should output the same result).
An input too large shouldn't cause an error, inf is a valid value since it's part of float.

Scoring:

Score is the length of the code, including indents.
Lowest score wins.
Output can be either printed or returned.
Setting the input number does not count towards length.

As a starting point, here is an ungolfed version of some code in Python to generate the list of suffixes. Feel free to build upon this or start from scratch.
a = ['', 'un','duo','tre','quattor','quin','sex','septen','octo','novem']
c = ['tillion', 'decillion', 'vigintillion', 'trigintillion', 'quadragintillion', 'quinquagintillion', 'sexagintillion', 'septuagintillion', 'octogintillion', 'nonagintillion']
d = ['', 'cen', 'duocen', 'trecen', 'quadringen', 'quingen', 'sescen', 'septingen', 'octingen', 'nongen']

num_dict = ['']
num_dict.append('thousand')
num_dict.append('million')
num_dict.append('billion')
num_dict.append('trillion')
num_dict.append('quadrillion')
num_dict.append('quintillion')
num_dict.append('sextillion')
num_dict.append('septillion')
num_dict.append('octillion')
num_dict.append('nonillion')

for prefix_hundreds in d:

    #tillion can't be used first time round
    if not prefix_hundreds:
        b = c[1:]
    else:
        b = c

    for prefix_tens in b:
        for prefix in a:
            num_dict.append(prefix_hundreds+prefix+prefix_tens)

Short scale? Long scale? Myriad system?

Sorry, short scale since most people seem to use it :)

1e3000? I don't think most languages will even be able to handle numbers that high. Which arithmatic functions do we need to support?

Possible duplicate http://codegolf.stackexchange.com/questions/12766/converting-integers-to-english-words

Another possible duplicate http://codegolf.stackexchange.com/questions/16217/cardinal-numbers-in-standard-american-english

I guessed the generic 'convert number to text' would have been done so I avoided going down the same route. Those two questions are about fully printing the entire number representation up to a small small amount (first is 1e4, second is 1e6), I'm wanting to correctly output the number with a suffix, calculated up to 1e3000 (eg. '2.5 thousand', or '105.0 quingenquinsexagintillion', words such as 'one' and 'two' are not needed). And vihan, that's why I said accept strings too, you may do anything to calculate the output as long as it doesn't go against the rules :)

So, I added a bit of extra information, does it clear it up a little? Also, to try get this started off, should I add my shortened code to the question or as an answer?

@vihan: Based on what I know about the backing implementation, I'd assume that Java's BigIntegers can handle up to 16 gigabits.

Are BigInt libraries allowed for languages that don't' natively support such large numbers without penalty?

Would that be similar to Python's decimal module? Yes it's allowed, bear in mind though, it's also possible to calculate without ever having to process large numbers :)

To get the ball rolling then, this is my version. Only the final number is converted to a float so there is no problem with large numbers if they're within range.
In terms of speed, it takes about 0.85 seconds to calculate 1000 random integers between -1e3000 and 1e3000.
Python 2 (574)
N=str(X).split('.');K=len;E=min(1000,(K(str(abs(int(N[0]))))-1)/3);P=N[0][:(-E*3if E else K(N[0]))];L=K(P);B=''.join(N);O='%.2f'%float((P+'.'+((B[L:L+3])or'0')));m,n,o,p,q,r,s,t,u,v,w,x,y,z='illion quadr quin sex sept oct non ing ag g tre duo c t'.split();a=[''];l=a+['thousand']+[i+m for i in['m','b','tr',n,o+z,p+z,q,r,s]]+[i+j+k for i in a+[i+'en'for i in[y,x+y,w+y,n+t,o+v,'sesc',q+t,r+t,s+v]]for k in[C+m for C in[z,'dec']+[B+'int'for B in['vig','trig',n+u,o+'quag',p+u,q+'uag',r+'og',s+u]]][not i:]for j in a+['un',x,w,'quattor',o,p,q+'en',r+'o','novem']];print O,l[E]

Then with some test cases:
>>> X = 100
100.0
>>> X = '100.0'
100.0
>>> X = '1037093920'
1.04 billion
>>> X = '-1540420004036040042.400642'
-1.54 quintillion
>>> X = '1540420' + '0'*153
1.54 duoquinquagintillion
>>> X = '1540496' + '0'*1553
154.05 quingenoctodecillion

Past the limit (just to show it doesn't throw an error and still handles negative value):
>>> X = '-10935' + '6'*3005
-1093566666.67 nongennovemnonagintillion
>>> X = '10935' + '6'*3250
1.09356666667e+254 nongennovemnonagintillion
>>> X = '10935' + '6'*3500
inf nongennovemnonagintillion


text:
Name a number using the Myriad System!
The Myriad System is an alternative system for naming large numbers proposed by Donald Knuth in 1981.
In this system, numbers up to 999 are named as they are normally, but 1000 is not given a special name and is instead named as "ten hundred"; the next benchmark number being 10000, or "one myriad" (which, of course, comes from an ancient greek word meaning 10000).
From here one myllion is defined as one myriad * one myriad, one byllion as one myllion * one myllion, one tryllion as one byllion * one byllion, and so forth.
The challenge here is to take a base-10 integer from the input and determine its name in this system.
Your input is guaranteed to be nonnegative and less than 10212=104096 (one decyllion)
Either a full program (in which case input can be taken from either stdin or a command line argument, and output must be sent to stdout) or a function (which takes the input as an argument and returns the output) is permissible.
The returned string should be formatted as per this Java program:
import java.math.*;

public class Myriadizer{
    static BigInteger b=new java.util.Scanner(System.in).nextBigInteger(),c=b,TEN=BigInteger.TEN,d=TEN.pow(4),f=TEN.pow(2),e=BigInteger.ZERO;
    static String[]strings={"six","seven","eight","nine","four","thir","fif"};
    static String output="";
    static void t(){
        int i=0;
        while(b.compareTo(d)>=0){
            b=b.divide(d);
            i++;
        }
        int k=b.intValue();
        char[]binary=Integer.toString(i,2).toCharArray();
        int q=48,bits=binary.length;
        String r="yllion ";
        s(k);
        if(bits>0&&binary[bits-1]!=q)output+="myriad ";
        if(bits>1&&binary[bits-2]!=q)output+="m"+r;
        if(bits>2&&binary[bits-3]!=q)output+="b"+r;
        if(bits>3&&binary[bits-4]!=q)output+="tr"+r;
        if(bits>4&&binary[bits-5]!=q)output+="quadr"+r;
        if(bits>5&&binary[bits-6]!=q)output+="quint"+r;
        if(bits>6&&binary[bits-7]!=q)output+="sext"+r;
        if(bits>7&&binary[bits-8]!=q)output+="sept"+r;
        if(bits>8&&binary[bits-9]!=q)output+="oct"+r;
        if(bits>9&&binary[bits-10]!=q)output+="non"+r;
        if(bits>10&&binary[bits-11]!=q)output+="dec"+r;
        b=c=c.subtract(d.pow(i).multiply(b));
        if(b.compareTo(f)>=0)output+=",";
        output+=" ";
        if(b.compareTo(e)>0&&b.compareTo(f)<0)output+="and ";
    }
    static void s(int t){
        if(t>99){
            s(t/100);
            output+="hundred ";
            if(t%100>0)output+="and ";
            s(t%100);
            return ;
        }
        if(t==0)return;
        if(t<13){
            output+=(new String[]{
                    "one","two","three",
                    strings[4],"five",strings[0],strings[1],strings[2],strings[3],
                    "ten","eleven","twelve"
            })[t-1]+" ";
            return ;
        }
        if(t<20){
            output+=(new String[]{
                    strings[5],strings[4],strings[6],strings[0],strings[1],strings[2],strings[3]
            })[t-13]+"teen ";
            return ;
        }
        output+=new String[]{"twen",strings[5],"for",strings[6],strings[0],strings[1],strings[2],strings[3]}[t/10-2]+"ty";
        if(t%10>0){
            output+="-";
            s(t%10);
            return;
        }
        output+=" ";
    }
    public static void main(String[]a){if(b.equals(e)){System.out.println("zero");return;}while(c.compareTo(e)>0)t();System.out.println(output.replaceAll("\\s+$","").replaceAll("\\s\\s+"," ").replaceAll("\\s,",","));}
}

Some details of this that should be noted:

The terms in the main sum should be arranged in descending order
The terms in any given product should be arranged in ascending order, and exactly one term in any given product should be under one myriad
The terms in the main sum should be comma-separated, unless the last is under one hundred in which case the last two should be separated by the conjunction "and"

This is code golf, so the shortest program wins.
Some test cases:
0                                 = zero
100                               = one hundred
1000                              = ten hundred
10014                             = one myriad and fourteen
19300                             = one myriad, ninety-three hundred
100000                            = ten myriad
1000000                           = one hundred myriad
1041115                           = one hundred and four myriad, eleven hundred and fifteen
100000000                         = one myllion
1000000501801                     = one myriad myllion, fifty myriad, eighteen hundred and one
94400000123012                    = ninety-four myriad myllion, forty hundred myllion, twelve myriad, thirty hundred and twelve
10000000200000003000000040000000  = ten hundred myriad myllion byllion, twenty hundred myriad byllion, thirty hundred myriad myllion, forty hundred myriad
100000002000000030000000400000000 = one tryllion, two myllion byllion, three byllion, four myllion

The fine details aren't the same as http://codegolf.stackexchange.com/q/16217/194 , but it's essentially the same question.

It seems rather distinct from that question to me.

At first it seemed laughable that Knuth invented something special with the Myriad System: the word myriad is ancient and the Chinese always use myriads rather than thousands. But once I understood I realised I underestimated the great man. According to the definition 10000000 20000000 30000000 40000000 is 1 byllion 2 myllion tryllion, 3 byllion 4 myllion. It implies a recursive algorithm where the number is split in half and each half is named separately. This is unlike other number systems. @PeterTaylor I'm open voting, but not upvoting because it's close to the latest question asked.

I think you should make it clearer that 1 tryllion is 1 byllion * 1 byllion and 1 quadryllion is 1 tryllion * 1 tryllion. The fact that 1byllion * = 1 myllion * 1 myllion is as far as your text goes, and does not demonstrate any departure from the normal long scale system.

@steveverill Using the standard established in the specs, 1,0000,0002,0000,0003,0000,0004,0000,0000 (which I am assuming was what you meant) would be one tryllion, two myllion byllion, three byllion, four myllion

@Yeah I screwed up the math but i did at least read the link and work out what the question was about. Have an upvote ;-)

so the word byllion has to be repeated, even though it is understandable without? what about one hundred one myriad one hundred million? where do repeated words have to be used, and where do commas and ands have to be used? The spec should be in English, not Java. This has always been a rule here, reference implementations do not constitute a spec. Please clarify in the question.

@steveverrill but if you meant 1000,0000,2000,0000,3000,0000,4000,0000 (which is also possible) that would be ten hundred myriad myllion byllion, twenty hundred myriad byllion, thirty hundred myriad myllion, forty hundred myriad

C, 698 bytes
Recursive approach, don't mind the memory leaks :) Explanation to come later.
#include <stdlib.h>
#define c char*
n;c r(c v){c p,*z,*o[]={"","one","two","three","four","five","six","seven","eight","nine","ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen","twen","thir","for","fif","six","seven","eigh","nine","hundred","myriad","m","b","tr","quadr","quint","sext","sept","oct","non","dec"};int s,l;long t;v+=strspn(v,"0");l=strlen(v);if(l<3)n=atoi(v),n<20?p=o[n],0:asprintf(&p,n%10?"%sty-%s":"%sty",o[n/10+18],o[n%10]);else s=(int)(log(l-1)/log(2))-1,z=v+l-(2<<s),t=strtol(z,0,10),p=r(z),*z=0,asprintf(&p,*p?"%s %s%s%s %s":"%s %s%s",r(v),o[s+28],s>1?"yllion":"",*p?t<100?" and":",":"",p);return p;}main(_,v)c*v;{puts(r(v[1]));}

Examples
$ ./a.out 0
zero
$ ./a.out 100
one hundred
$ ./a.out 1000
ten hundred
$ ./a.out 10014
one myriad and fourteen
$ ./a.out 19300
one myriad, ninety-three hundred
$ ./a.out 100000
ten myriad
$ ./a.out 1000000
one hundred myriad
$ ./a.out 1041115
one hundred and four myriad, eleven hundred and fifteen
$ ./a.out 100000000
one myllion
$ ./a.out 1000000501801
one myriad myllion, fifty myriad, eighteen hundred and one
$ ./a.out 94400000123012
ninety-four myriad, forty hundred myllion, twelve myriad, thirty hundred and twelve
$ ./a.out 10000000200000003000000040000000
ten hundred myriad myllion, twenty hundred myriad byllion, thirty hundred myriad myllion, forty hundred myriad
$ ./a.out 100000002000000030000000400000000
one tryllion, two myllion and three byllion, four myllion

Java, 1477 1459 bytes
import java.math.*;class M{static BigInteger b=new java.util.Scanner(System.in).nextBigInteger(),c=b,k=BigInteger.TEN,d=k.pow(4),f=k.pow(2),e=BigInteger.ZERO;static String o="",s[]={"six","seven","eight","nine","four","thir","fif"},p=" ";static void s(int t){if(t>99){s(t/100);o+="hundred ";if(t%100>0)o+="and ";s(t%100);return;}if(t==0)return;if(t<13){o+=new String[]{"one","two","three",s[4],"five",s[0],s[1],s[2],s[3],"ten","eleven","twelve"}[t-1]+p;return;}if(t<20){o+=new String[]{s[5],s[4],s[6],s[0],s[1],s[2],s[3]}[t-13]+"teen ";return;}o+=new String[]{"twen",s[5],"for",s[6],s[0],s[1],s[2],s[3]}[t/10-2]+"ty";if(t%10>0){o+="-";s(t%10);return;}o+=p;}public static void main(String[]a){if(b.equals(e)){System.out.println("zero");return;}while(c.compareTo(e)>0){int i=0;while(b.compareTo(d)>=0){b=b.divide(d);i++;}char[]z=Integer.toString(i,2).toCharArray();int q=48,l=z.length;String r="yllion ";s(b.intValue());if(l>0&&z[l-1]!=q)o+="myriad ";if(l>1&&z[l-2]!=q)o+="m"+r;if(l>2&&z[l-3]!=q)o+="b"+r;if(l>3&&z[l-4]!=q)o+="tr"+r;if(l>4&&z[l-5]!=q)o+="quadr"+r;if(l>5&&z[l-6]!=q)o+="quint"+r;if(l>6&&z[l-7]!=q)o+="sext"+r;if(l>7&&z[l-8]!=q)o+="sept"+r;if(l>8&&z[l-9]!=q)o+="oct"+r;if(l>9&&z[l-10]!=q)o+="non"+r;if(l>10&&z[l-11]!=q)o+="dec"+r;b=c=c.subtract(d.pow(i).multiply(b));if(b.compareTo(f)>=0)o+=",";o+=p;if(b.compareTo(e)>0&&b.compareTo(f)<0)o+="and ";};System.out.println(o.replaceAll("\\s+$","").replaceAll("\\s\\s+"," ").replaceAll("\\s,",","));}}

This is way too soon to post your own answer. I know it's horribly long, but it may still put people off.

I don't see anything wrong with posting a reference answer.

@BetaDecay It's only a quickly-golfed version of the Java program in the question.

source: Stack Exchange

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

sort: votes


text:
World Big Dosa
You are a talented young chef who has just been offered the position of sous chef at the world's most prestigious Indian restaurant. You have little experience with preparing Indian cuisine, but you're determined, so you set out to prove yourself. You decide to become the leading dosa expert. To do this, you must not only master the creation of dosas, but you must be able to scale them to be arbitrarily large.
You find a promising recipe for dosa batter:

1 cup rice
1 cup ukda chawal
1/2 cup urad dal
1/4 cup poha
1/4 tsp methi seeds
Salt to taste
Water as needed

This will make a dosa approximately 1/2 meter in length.
Challenge
Write a program or function that will tell the restaurant staff exactly what's needed to make a single dosa out of an integer multiple of the given recipe. Space is tight in the kitchen, so you want your code to be as short as possible. The shortest code wins, with ties going to the earlier post.
Measuring spoons and cups come in the following standard sizes: 1/4, 1/3, 1/2, 2/3, 3/4, and 1. To avoid angering the kitchen staff, measurements must be reported in the largest unit in which the number can be written as mixed numbers using standard sizes only.
Measurements propagate to larger sizes per the following convention:

3 tsp == 1 tbsp
4 tbsp == 1/4 cup

So for a multiple of 12, 1/4 tsp methi seeds becomes 1 tbsp. However, for a multiple of 13, it becomes 3 1/4 tsp. Otherwise it wouldn't be represented in standard sizes.
The wait staff must be able to carry the dosa to the tables. To ensure that the dosa does not break in transit, you instruct them to carry the dosa in teams. Each person can carry at most one meter of dosa. So for a single or double recipe, only one person is needed to carry it. The wait staff is less effective if they're cut into fractional pieces, so an integer number of waiters is always required.
Input
Take a positive integer via STDIN (or closest alternative), command line argument, or function argument. This number dictates the scaling factor for the recipe and can be as small as 1 but no larger than 232-1. It can be any integer in that range.
Output
Print to STDOUT (or closest alternative) the list of ingredients scaled according to the input as well as the number of waiters required to carry the dosa. The ingredients must be listed in the order given above and in the format given below.
Examples
Input:
2

Output:
2 cups rice
2 cups ukda chawal
1 cup urad dal
1/2 cup poha
1/2 tsp methi seeds
Salt to taste
Water as needed
1 waiter

Note that "cup" changes to "cups" when the value is greater than 1. "tsp" does not change. "waiter," like "cup," becomes plural.
Input:
5

Output:
5 cups rice
5 cups ukda chawal
2 1/2 cups urad dal
1 1/4 cups poha
1 1/4 tsp methi seeds
Salt to taste
Water as needed
3 waiters

Non-integer values greater than 1 are represented as mixed numbers, i.e. an integer followed by a reduced fraction.
Note: The title comes from a relevant video.

Now we need someone to do a Chef answer:)

"The wait staff is less effective if they're cut into fractional pieces, so an integer number of waiters is always required." ...How much less effective, exactly?

@LivingInformation Well, have you ever seen just a pair of legs carry food to your table?

@AlexA. Have you not?

I would greatly appreciate it if the downvoter would be willing to leave a comment so I know what I can do to improve the challenge.

I think downvoters only leave comments right after they downvoted. If they didn't leave a comment then, then they never will

@MickyT: I tried, but I seem to have run into some bugs in the Chef interpreter from CPAN. (a) Output values are separated by spaces, except when they aren't. (b) Something about my Mixed Number Chutney sub-recipe (or is it the Comparison Minted Yoghurt?) is causing the interpreter to die with an obscure error message.

To clarify: a 4x recipe should report the methi seeds as 1/3 tbsp, not 1 tsp?

So I worked around the crash error (but not the spacing error), and now have working Chef code to turn an improper fraction into a mixed number. At this rate, I might have the whole challenge finished by January... https://gist.github.com/perey/d77af1e8518ff43df0c1 (5 KB, commented and ungolfed)

@DLosc Correct.

@TimPederick do you happen to still have your Chef code, in golfed format? I'm working on this challenge myself, but it would nice to have a good place to work from.

@Riker Sorry, that gist is as far as I ever got.

CJam, 214 bytes
ri[48_24C.25]{[48ZX]f{:DW$@*\md_D{_@\%}h;:M/iDM/}3/_{W=5<}#:I=[(\'/*]{S+_0e=!*}/["cup"2$2a>'s*+"tbsp"_'b-]I=S}%4/"rice
ukda chawal
urad dal
poha
methi seeds
Salt to taste
Water as needed"N/.+N*N@)2/" waiter"1$1>'s*

Try it online in the CJam interpreter.

Not really golfed yet, but it's late and I wanted to post the first answer.

Since no Chef answer has been posted and yours is the shortest valid answer at the end of the bounty period, you win the bounty. Thanks for participating in my first challenge. :)

Javascript (ES6), 443 chars
This was very fun to golf, but the result is considerably longer than what I was expecting.
d=n=>(y=s=>n<s?' cup':' cups',z=s=>n/s|0,A=' 1/4',B=' 1/2',C=' 3/4',n+y(2)+` rice
${n+y(2)} ukda chawal
${(n%2<1?n/2:z(2)+B)+y(3)} urad dal
${((e=n%4)<1?n/4:z(4)+(e<2?A:e<3?B:C))+y(5)} poha
${(n%48<1?z(192)+((c=n/48%4)>2?C:c>1?B:c>0?A:'')+y(193):n%3<1?z(12)+((f=n/3%4)>2?C:f>1?B:f>0?A:'')+' tbsp':(z(4)+(e>2?C:e>1?B:e>0?A:''))+' tsp')} methi seeds
Salt to taste
Water as needed
${(b=Math.ceil(n/2))} waiter`+(b<2?'':'s')).replace(/\n0 /g,'\n')

Try it out:

d=n=>(y=s=>n<s?' cup':' cups',z=s=>n/s|0,A=' 1/4',B=' 1/2',C=' 3/4',n+y(2)+` rice
${n+y(2)} ukda chawal
${(n%2<1?n/2:z(2)+B)+y(3)} urad dal
${((e=n%4)<1?n/4:z(4)+(e<2?A:e<3?B:C))+y(5)} poha
${n%48<1?z(192)+((c=n/48%4)>2?C:c>1?B:c>0?A:'')+y(193):n%3<1?z(12)+((f=n/3%4)>2?C:f>1?B:f>0?A:'')+' tbsp':(z(4)+(e>2?C:e>1?B:e>0?A:'')+' tsp')} methi seeds
Salt to taste
Water as needed
${(b=Math.ceil(n/2))} waiter`+(b<2?'':'s')).replace(/\n0 /g,'\n')

W=function(){setTimeout(function(){
    (Q=document.getElementById("num").value)&&(document.getElementById("a").innerHTML =d(+Q).replace(/\n/g,'
'));
  }, 10);};
document.getElementById("num").addEventListener("keypress", function(){W();});
document.getElementById("num").addEventListener("click", function(){W();});
<form>How many recipes of dosa batter would you like?
  <input type="number" name="num" id="num" value="1" />
</form>

1 cup rice

1 cup ukda chawal

1/2 cup urad dal

1/4 cup poha

1/4 tsp methi seeds

Salt to taste

Water as needed

1 waiter

It accepts values up to and even including 2^32, or 4294967296. After that, the 'urad dal' overflows on odd numbers and becomes negative.
Basically, it calculates the correct amounts as it goes. Luckily, only the methi seeds need to have tsp/tbsp/cup measures; otherwise, this would have been a whole lot longer. (The methi seed line alone is 155 chars!)
This also would have been at least 500 chars long in ES5. I ❤ ES6.
As always, suggestions are greatly appreciated!
Edit 1: Just realized that according to the rules, 1 tsp should be replaced with 1/3 tbsp, same with 2 tsp and 2/3 tbsp, as well as 16 tsp and 1/3 cup....

Math.ceil can be shortened to -~ so, b=-~t/2  is much shorter, You can also exclude the parenthesis

@vihan Thanks for the tip, but this only works on non-integers. -~1 results in 2, which is not the intended result. The best alternative I could find, b=-~((n-1e-9)/2), is just as long, so I'll keep it the way it is for now.

R, 602 603 526 bytes
Still lots of room to golf this I suspect, but I have run out of time and I really wanted to do an answer for this one.
function(i){S=gsub
M=i/c(1,5,60)
A=list(c(2,1),c(4,3),c(64,48))[[I<-max(which(M>=1))]]
B=c(4,12,192)[I]
V=c(' tsp',' tbsp',' cup')[I]
C=i%/%B
C=C+max((i%%B)%/%A*c(.3,.25))
cat(S('([ ]*)0 ','\\1',S('\\.3',' 1/3',S('\\.6',' 2/3',S('\\.5',' 1/2',S('\\.25',' 1/4',S('\\.75',' 3/4',paste0(i,' cup',if(i>1)'s',' rice
',i,' cup',if(i>1)'s',' ukda chawal
',i*.5,' cup',if(i>2)'s',' urad dal
',i*.25,' cup',if(i>4)'s',' poha
',C,V,if(C>1&I>2)'s',' methi seeds
Salt to taste
Water as needed
',ceiling(i*.5),' waiter',if(i>2)'s'))))))))}

For an input of 5 this has 1/3 tbsp 1/4 tsp methi seeds but it should should be represented in a single common unit. So it should be 1 1/4 tsp methi seeds (if my mental math is correct).

@AlexA. That's good too know.  I'll fix it up soonish.  I assume that it's the same with cups and tbsp.

Yep, same rule for all the units. +1 in the meantime though, on good faith that it'll be correct soon. Thanks for participating in my first challenge. :)

Common Lisp, 435
(lambda(n)(labels((k(y)(some(lambda(x)(integerp(* y x)))'(1 4/3 3/2 2 3 4)))(h(s m)(multiple-value-bind(q r)(floor m)(format()"~[~:;~:*~A ~]~[~:;~:*~A ~]~@? " q r s m)))(g(o &aux(h(/ o 3))(c(/ h 4)))(cond((k c)(h"cup~P"c))((k h)(h"tbsp"h))(t(h"tsp"o)))))(format t"~&~A rice
~Aukda chawal
~Aurad dal
~Apoha
~Amethi seeds
Salt to taste
Water as needed
~A waiter~:P
"(g(* n 12))(g(* n 12))(g(* n 6))(g(* n 3))(g(/ n 4))(ceiling(/ n 2)))))

Slightly ungolfed
(lambda (n)
  (labels ((k (y)
             (some (lambda (x) (integerp (* y x))) '(1 4/3 3/2 2 3 4)))
           (h (s m)
             (multiple-value-bind (q r)
                 (floor m)
               (format nil "~[~:;~:*~A ~]~[~:;~:*~A ~]~@?" q r s m)))
           (g (o &aux (h (/ o 3)) (c (/ h 4)))
             (cond ((k c) (h "cup~P" c)) ((k h) (h "tbsp" h)) (t (h "tsp" o)))))
    (format t "~&~A rice
~A ukda chawal
~A urad dal
~A poha
~A methi seeds
Salt to taste
Water as needed
~A waiter~:P
"
            (g (* n 12)) (g (* n 12)) (g (* n 6)) (g (* n 3)) (g (/ n 4))
            (ceiling (/ n 2)))))

All measures are expressed in tsp. Based on the k function, g decides which units to use for printing and call the formatting function h with the appropriate arguments.

k returns true when the argument can be expressed as a multiple of 1, 1/4, 1/3, 2/3, 4/3 units
g converts the input as a number of tbsp and the number of tbsp as a number of cups (as given in the question). We try to print by units of cups first, or units of tbsp, or else in tps.
h use a conditional formatting directives to print either x, x y/z or y/z followed by the formatting of s with argument m: for cups, s is "cup~P" which plurializes the word according to m.

Exemple (n = 17)
17 cups rice
17 cups ukda chawal
8 1/2 cups urad dal
4 1/4 cups poha
4 1/4 tsp methi seeds
Salt to taste
Water as needed
9 waiters

This is neat. Nice work.

JavaScript (Node.js), 419 bytes
a=>(y=g=>a<g?" cup":" cups",z=g=>a/g|0,a+y(2)+` rice
${a+y(2)} ukda chawal
${(1>a%2?a/2:z(2)+(B=" 1/2"))+y(3)} urad dal
${(1>(e=a%4)?a/4:z(4)+(2>e?A=" 1/4":3>e?B:C=" 3/4"))+y(5)} poha
${1>a%48?z(192)+(2<(c=a/48%4)?C:1<c?B:0<c?A:"")+y(193):1>a%3?z(12)+(2<(f=a/3)?C:1<f?B:0<f?A:"")+" tbsp":z(4)+(2<e?C:1<e?B:0<e?A:"")+" tsp"} methi seeds
Salt to taste
Water as needed
${b=-~a/2|0} waiter`+(2>b?"":"s")).replace(`
0 `,`
`)

Try it online!

Stax, 122 120 117 bytes
Öàu≈9o∞3┴&•ªâ6üòf±Σ§LXâ¢vò╣*/T≥C└ôZüæR-^╦ìóσ∩A←··■☼⌂▌2åH╨bgrp╬3L♫-◙•►]╘═º♀ú♣É±╧○+╧┴Qî¼▼◄I"a≤ΩzH♦╩k╖FΦúZa═q|▬◄┼W╥ßöo29

Run and debug it
It was a bit infuriating to start over after closing this program's tab, but now it works, and it's shorter!
-5 bytes from recursive.
Explanation (Unpacked)
3:B244E{um+{x*uuB\"cup"sch1>{s's+}{s}?]+{fJm"rice,ukda chawal,urad dal,poha,methi seeds"',/\{JmN"cup""tsp"R]+{PF"Salt to taste"P"Water as needed"P2:_ecp" waiter"p1>{'sp}*

3:B244E{um+ array [1,1,1/2,1/4,1/4]
{...m map to:
 x*uu product with input,  converted to fraction

 B\                        push fractional part and whole part, and pair them

 "cup"sch1>{s's+}{s}?]+    if whole part <1, append "cup", else cups

 {fJ                       remove zeroes, and join with spaces

"rice,ukda chawal,urad dal,poha,methi seeds"',/ array of ingredients
\{Jm zip with the amounts, and jin with spaces
N remove last element and push separately(methi seeds)
"cup""tsp"R]+ replace "cup" with "tsp", add it back in
{PF print each ingredient
"Salt to taste"P"Water as needed"P print the constant instructions
2:_ecp divide input by 2, ceil, duplicate, and print
" waiter"p print "waiter"
1>{'sp} if number of waiters > 1, print an s

all_licenses: 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/


text:
Code me a cookie
Challenge
Code an ASCII cookie of a kind according to the input.
Input

The cookie kind. This is one of the three strings: "Plain", "Chocolate", or "Nuts". May be function arguments, stdin (or closest equivalent), or file arguments.

Output

An ASCII cookie. See below.

Must be
     ___
    /   \
    |   |
    \___/

for Plain input,
     ___
    /. .\
    | . |
    \___/

for Chocolate input, and finally
     ___
    /^  \
    |^ ^|
    \___/

for Nut input.
Other information

This is my first challenge, it's as simple as can be. Constructive feedback is greatly appreciated.
Use any means to do so.
Trailing spaces are fine.
This is a code golf challenge, so shortest entry at the end of 9 days (Wednesday, the 12th of August 2015) wins.

Thank you!
The winner is Jakube using Pyth with 41 bytes. Thank you to all who participated. I will now task myself with coming up with more complicated challenges.

This is nice, but rather simple as it is. It could be massively improved by requiring user input for the diameter or quantity of cookies of each type. Do the chocolate chips and and nuts have to be in the location per the examples? (with variable diameter, they could perhaps be random.) That said, it's bad form to change the challenge after posting. I suggest you either 1. leave it as it is, or 2. delete it, think a bit more about it and/or post it in http://meta.codegolf.stackexchange.com/q/2140/15599 then repost later.

@steveverrill Alright, thank you for the feedback.

Allowing multiple toppings could have been another way to make this more interesting. Then again, simple looking challenges often get a lot of participation. BTW, two of the cookies have leading white space in the sample output. That's probably not intentional?

I made a minor edit to cancel the indent, so all the cookies have the same leading whitespace. I assume the four leading spaces are a formatting issue and are not required? You should specify whether leading/trailing newlines are allowed. I would suggest disallowing unnecessary whitespace, with the exception of allowing an optional trailing newline.

Will functions be permitted?

@SpeedyNinja Yes, "Use any means to do so."

After @steveverrill opened my eyes, this seems to be just a simplified version of Do you want to code a snowman?. Some further requirements, like the mentioned variable diameter, would really improve it.

Can the chips/nuts be positioned anywhere inside the cookie? Or only in the positions you put in the example

@BetaDecay Sorry for a late reply, the chips and nuts should be in the same positions they are in the examples.

@BassetHound Ah okay, thanks :)

Pyth, 42 41 bytes
X" ___
/d a\\
|cac|
\___/"G.>"^X .  .^"Cz

Try it online: Regular Input / Test Suite
Explanation:
 "..."                      template string
X     G                     replace "a..z" in ^ with:
                   Cz         convert z to an integer (base 256 of ord(char))
       .>"^X .  .^"           rotate "^X .  .^"
                              ["Plain"     -> " .  .^^X",
                               "Chocolate" -> ".  .^^X ",
                               "Nuts"      -> " .^^X . "]

Ruby, 73
->s{' ___
/'+['^  \
|^ ^','. .\
| . ','   \
|   '][s[0].ord%3]+'|
\___/'}

This is an anonymous lambda function. Here it is in a test program:
g=->s{' ___
/'+['^  \
|^ ^','. .\
| . ','   \
|   '][s[0].ord%3]+'|
\___/'}

puts g.call(gets)

It just uses the first letter of the cookie type (in uppercase) and takes it modulo 3 to get an index in the range 0..2. Then it returns the string representing the cookie, with the appropriate strings embedded in the right places.

What do you think the ord method can do if you call it for a whole string? My first idea was formatting: ->s{" ___\n/%1$s  \\\n|%1$s %1$s|\n\\___/"%'^. '[s.ord%3]}

Forget it. Once again tr proves to be shorter: ->s{' ___↵/%  \↵|% %|↵\___/'.tr ?%,'^. '[s.ord%3]}

@manatwork thank you for your suggestions. I missed s[0] --> s, it never occurred to me to try it. Your code doesn't seem to give the right answer for the chocolate case, as the chocolate chips are in different places than the nuts. Nevertheless there's some useful ideas there, I will look at them later. I haven't used tr or % before.

Oops. You are right. That was a quick try BC (before coffee). Too early to notice the chips placement difference. :( (BTW, the “%” has nothing to do with tr's syntax. Is just a character not involved in the cookie art that I used as placeholder.)

Python 2.7.6, 99 bytes
def c(t):n=hash(t)%3;return" ___\n/"+" ^."[n]+" "+"  ."[n]+"\\\n|"+[" ","^ ^"," . "][n]+"|\n\\___/"

This algorithm relies on the fact that hash(cookie)%3 gives 0 when cookie = "Plain", 1 when cookie = "Nut and 2 when cookie = "Chocolate.
If anyone knows a way to make this code shorter, please let me know in the comments.

Optional arguments are most certainly allowed

"Use any means to do so." Yes, optional arguments are allowed.

Okay, but I think I'll still stick with the first one and leave the second one as it is.

@BetaDecay I just don't think that optional arguments really are in the spirit of code-golf. I don't really know why, I just think that it shouldn't be allowed. Now that they are both the same length, I removed the optional-arguments version.

@Loovjo Using strange and unusual methods are the whole spirit of code golf :)

@BetaDecay Okay, but I think I'll still use the original version.

You can join "\\\n"+"|" into "\\\n|".  Doing so will bring it down around 9 chars.

You can condense the " ^ "[n]+"  ."[n]+" ^ "[n] part into a single ["   ","^ ^"," . "][n]. That kills around 4 bytes more :)

Which Python version is this? hash behaviour changes between versions

@Sp3000 2.7.6. I didn't know that. Silly me.

BrainFuck, 481 447 436 bytes
Why not BrainFuck?, the program can probably be golfed more, but I think it's pretty neat.
,>++++++[-<---------->]<-------[----------->>>-<<+<[-->->+<<]]>>>+>>++.<+++++++++[->>>>>>>++++++++++<+++++<++++++++++++++<++++++++++<+++++<++++++++++<+++<]++++++++++>+++.>+++++...>++>++>-->+>++++<<<<<<<.<<<[->>>>>>.>>>.<<<<<.>>>>>.<<.<<<<.>>>>>.<<<<.>>>>>.<<<<<.>>>>.<<<<<.>>>>.<<...>.<<<<<<]>[->>>>>.<<...>>>.<<<<.>>>>>.<<<<...>>>>.<<<<<.>>>>.<<...>.<<<<<]>[->>>>.>>>>.<<<<<<..>>>.<<<<.>>>>>.>>.<<<<<<.>>>>>>.<<.<<<<<.>>>>.<<...>.<<<<]

C#
With indentation and line break
using System;
class Cookie
{
    static void Main()
    {
      String E="",N="",C=Console.ReadLine();
      if(C=="P"){E="   ";N="   ";}
      if(C=="C"){E=". .";N=" . ";}
      if(C=="N"){E="^  ";N="^ ^";}
      Console.Write(" ___ \n/" + E + "\\ \n|" + N + "|\n\\___/");
    }
}

Golfed (225 Characters)
using System;class X{static void Main(){String E="",N="",C=Console.ReadLine();if(C=="P"){E="   ";N="   ";}if(C=="C"){E=". .";N=" . ";}if(C=="N"){E="^  ";N="^ ^";}Console.Write(" ___ \n/" + E + "\\ \n|" + N + "|\n\\___/");}}[![enter image description here][1]][1]

Why not String C= Console.ReadLine(),E= ...etc?

Hey @rpax, Your comment helped me trim 2 characters. Thanks.

C: 122
q(char *p){char *t,*m;int i=*p%3;t=i?i%2?". .":"   ":"^  ";m=i?i%2?" . ":"   ":"^ ^";printf(" ___\n/%s\\ \n|%s|\n\\___/",t,m);}

Explanation after i finish golfing.
Example of use:
 int main(void){
 q("Plain");
 printf("\n");
 q("Nut");
 printf("\n");
 q("Chocolate");
 }

105 bytes

CJam, 49 48 bytes
" ___
/""^  ^ ^. . ."S7*+6/rci=3/"\
|"*"|
\___/"

Try it online in the CJam interpreter.
How it works
" ___
/"

e# Push that string.

"^  ^ ^. . ."S7*+6/

e# Push that string, append 7 spaces and split into chunks of length 6.
e# This pushes ["^  ^ ^" ". . . " "      "].

rci

e# Read from STDIN, cast to character, then to integer.
e# "Plain", "Chocolate", "Nuts" -> 'P', 'C', 'N' -> 80, 67, 78

=

e# Select the corresponding element from the array.
e# Arrays wrap around in CJam, so for an array A of length 3,
e# A80= is A2=, A67= is A1= and A78= is A0=.

3/

e# Split into chunks of length 3.

"\
|"*

e# Join those chunks, using that string as separator.

"|
\___/"

e# Push that string.

At the end, CJam automatically prints all elements on the stack.

Javascript (ES6), 90
s=>" ___\n/"+(s.length-4?s.length-5?". .\\\n| . ":"   \\\n|   ":"^  \\\n|^ ^")+"|\n\\___/"

This is an anonymous arrow function. It uses the length of the input to determine which cookie to draw.
Explanation:
s=>
 " ___\n/" +               //build the first part of the cookie

 (s.length - 4 ?           //if the length is 4, this condition will evaluate to 0, which coerces to false. Otherwise it is true

      s.length - 5 ?            //if the length is 5, this evaluates to false; otherwise true

           ". .\\\n| . " :      //build the unique part of the Chocolate cookie, if length was not 5
           "   \\\n|   "        //build the unique part of the Plain cookie, if length was 5

      : "^  \\\n|^ ^"      //build the unique part of the Nuts cookie, if length was 4
 )

 + "|\n\\___/"             //build the last part of the cookie, and implicitly return the built string

To test:
f=s=>" ___\n/"+(s.length-4?s.length-5?". .\\\n| . ":"   \\\n|   ":"^  \\\n|^ ^")+"|\n\\___/"

console.log(f("Nuts"))
console.log(f("Plain"))
console.log(f("Chocolate"))

Commodore 64 BASIC, 181 bytes
10 INPUT A$
20 IF A$="PLAIN" THEN B$="/   \":C$="|   |"
30 IF A$="CHOCOLATE" THEN B$="/. .\":C$="| . |"
40 IF A$="NUTS" THEN C$="/^  \":C$="|^ ^|"
50 PRINT" ___":PRINT B$:PRINT C$:PRINT"\___/"

Notes:
Instead of backslashes \ the SHIFT-M characters have been used, for slashes / - SHIFT-N and for pipes | - SHIFT-T. SHIFT-Z (card diamond sign) was used for ^. In fact characters do not matter as they all occupy one byte each.
Because on C64 each command (PRINT, INPUT, THEN, etc.) takes 2 bytes in memory (or some even one, IIRC), the BASIC language was worth trying (however, it took more bytes than I expected).
The program size was calculated by measuring free memory before typing the program (38909 bytes) and after (38728 bytes), using PRINT FRE(0)+65536 command, giving 181 bytes of difference.
Code tested and screenshots prepared with this tool: http://codeazur.com.br/stuff/fc64_final/ (GPL).
Screenshots:

Lua 5.3, 113 Bytes 112 Bytes
c=io.read()print(' ___\n/'..(c=='plain'and'   \\\n|   'or c=='nut'and'^  \\\n|^ ^'or'. .\\\n| . ')..'|\n\\___/')

It uses a lot of the ternary operator and string concatenation, and I squeezed out all whitespace that isn't part of the output itself.

Pyth, 58 54 53 52 50 bytes
+d*\_3p+\/j"\\
|"c@["^  ^ ^"*". "3*d6)Chz3\|"\___/

I don't think this can be golfed more. I was really trying to squeze this in under 50 bytes

A quick and easy one is ". . . " -> *". "3

If your interested, I found a nice method to do this in 42 bytes.

C# 6, 105 bytes
So very nearly got this sub-100 bytes, no idea where to squeeze the last few bytes from though :C
string C(string t)=>$" ___\n/{(t[0]=='C'?". .\\\n| . ":t[0]=='N'?"^  \\\n|^ ^":"   \\\n|   ")}|\n\\___/";

JavaScript (ES6), 72 bytes
About as simple as it gets… new lines are counted as 1 byte each.
f=s=>` ___
/${s[4]?s[5]?`. .\\
| . `:`   \\
|   `:`^  \\
|^ ^`}|
\\___/`

Demo
As it is ES6, this demo only works in Firefox and Safari for now.

f=s=>` ___
/${s[4]?s[5]?`. .\\
| . `:`   \\
|   `:`^  \\
|^ ^`}|
\\___/`

// Snippet stuff

A.innerHTML = f("Nuts");
B.innerHTML = f("Plain");
C.innerHTML = f("Chocolate");

Nuts

Plain

Chocolate

Java 258 217 characters/bytes

Golfed
class C{public static void main(String[] a){p(" ___");if(a[0].equals("Chocolate")) {p("/. .\\");p("| . |");}if(a[0].equals("Nut")){p("/^  \\");p("|^ ^|");}p("\\___/");}static void p(String s) {System.out.println(s);}}

Original
class C {
    public static void main(String[] a) {
        p(" ___");
        if(a[0].equals("Chocolate")) {
            p("/. .\\");
            p("| . |");
        }
        if(a[0].equals("Nut")){
            p("/^  \\");
            p("|^ ^|");
        }
        p("\\___/");
    }
    static void p(String s) {
        System.out.println(s);
    }
}

LUA 270 characters 270 bytes
    c = io.read()
    if c == "plain" then
    print" ___"
    print"/   \\"
    print"|   |"
    print"\\___/"
    io.read()
    elseif c == "chocolate" then
    print" ___"
    print"/. .\\"
    print"| . |"
    print"\\___/"
    io.read()
    elseif c == "nut" then
    print" ___"
    print"/^  \\"
    print"|^ ^|"
    print"\\___/"
    end

this is my second answer to any challenges

The "What type of cookie do you want" can be taken out, it isn't needed. That takes out 39 bytes right there.

This is a code-golf challenge. Try to shorten your code a little. E.g. You don't need the initial print, shorten cookie to c, remove whitespace during ifs, remove those unnecessary io.read()s, the first and last line of a cookie is always the same, ....

@BassetHound removed the print statement

@Jakube shortened cookie to c

How about this. Only 173 bytes using exactly the same approach.

Or even this for 143 by using a trick of the Tips for golfing in lua-page.

LOLCODE 265 characters
HAI
I HAS A T
GIMMEH T
VISIBLE " ___"
BOTH SAEM T AN "Chocolate", O RLY?
YA RLY
VISIBLE "/. .\"
VISIBLE "| . |"
OIC
BOTH SAEM T AN "Nut", O RLY?
YA RLY
VISIBLE "/^ ^\"
VISIBLE "|^  |"
OIC
BOTH SAEM T AN "Plain", O RLY?
YA RLY
VISIBLE "/   \"
VISIBLE "|   |"
OIC
VISIBLE "\___/"
KTHXBYE

Run


text:
Golfing Delayed Expansion Variables in Batch
Enabling delayed expansion variables in Batch chews up a lot of bytes. The shortest I have managed to make it is:
@!! 2>nul||cmd/q/v/c%0&&exit/b

Saving 11 bytes over @echo off&setLocal enableDelayedExpansion. The method is explained here - Tips for Golfing in Batch. Basically, it runs a command (!!) which fails initially (due to no delayed expansion) causing the script to be called again with delayed expansion variables enabled and echo turned off. The command (which is expanded now to 'nothing') then executes successfully, causing the rest of your script to be run. The initial instance of the script then exits.
Can this be made any shorter / better? If so, how?
One way which I have thought to make it smaller is piping the error output to a file with a one character name, instead of to null (2>null becomes 2>f). However, you then run the risk of overwriting an existing file, as well as generating unwanted output in the form of a file containing the error: '!!' is not recognized as an internal or external command, operable program or batch file.. Which I suppose is fine if the challenge doesn't specify output requirements (in which case you can probably drop the redirect all together along with @ and /q)..
Suppressing no output you can save a further 9 bytes: !!||cmd/v/c%0&&exit/b. And in fact, you could drop the exit and just have the code run again without delayed expansion variables enabled (it won't run correctly the second time, but it will have already run). So if output doesn't matter, you could do something like the following:
!!||cmd/v/c%0
set a=test
echo !a!

Which would output:
h:\>test.bat

h:\>!! || cmd/v/ctest.bat
'!!' is not recognized as an internal or external command,
operable program or batch file.

h:\>!! || cmd/v/ctest.bat

h:\>set a=test

h:\>echo !a!
test

h:\>set a=test

h:\>echo !a!
!a!

(Inspired by Golfing with Python Import)

Good, not only will this help people with their golfing, but it will stop people from Stack Overflow getting annoyed with us :)

Questions about golfing specific code snippets are on topic.

for some reason, using this in some scripts tend to execute the script twice...


text:
X Marks the Spot
X Marks the spot
Your goal is to add a cross-hair around the capital X:
Example Input / Output
Input:
                mdhyyyyyyyhhhddmmm
            mdyyssoo  oooosyyyhhhdmm
          hsso     oossoooooyyhhdhhdmmm
        yoooooo     oo ssysssyhhdyyyhmmmm
      myso oso  o  oyo    hhhdhhyhyhhm mm m
     mhsyhhys  oss      yyyhhhsosyhhmmmmdmmm
    mhyhhhy y         ssyhoho o shhdmmmmdmmmm
    hhyyyh   s   oo syysyyhhdysso oyhdhhhmmmmm
   dhysyys      sdysoXoyyyyhhso     syshm  mmm
   hhyhyo       o      osss y   shhyyhd mmmmmm
   yyhyyyss           o  oyyyydmmdmmmmmmmmm mm
   ysyhyhhho   s     osy  sdm m  mddmmddhydmmm
   h  oshhhyyyddhoo  ooyysshdmdohdmmdmddsshmmm
    y   oyhhhdhhsyhsssshdddsss    hdddyyyhddm
    dyyshyyhssyyhyyyyddhhmmdmmmdy syssoosyhdm
     hsyyhhhhsoo sooyyhhdoohdhhyhyysoo  osdm
      doyhhhyyyyhhhysyyy oossyyssso   osydm
        soyhyyhhhhhhyhyyyooos       ohdddm
         msoyyyyyyyhyyyyo ooo       syyd
            ho oyyysooo    osso   osyd
               dhyyysssyyyyyysoosdm
                    mmdddddmmm

Output:
                mdhyyyyyyyhhhddmmm
            mdyyssoo  oooosyyyhhhdmm
          hsso     oossoooooyyhhdhhdmmm
        yoooooo     oo ssysssyhhdyyyhmmmm
      myso oso  o  oyo    hhhdhhyhyhhm mm m
     mhsyhhys  oss   |  yyyhhhsosyhhmmmmdmmm
    mhyhhhy y        |ssyhoho o shhdmmmmdmmmm
    hhyyyh   s   oo s|ysyyhhdysso oyhdhhhmmmmm
   dhysyys      -----X-----hhso     syshm  mmm
   hhyhyo       o    | osss y   shhyyhd mmmmmm
   yyhyyyss          |o  oyyyydmmdmmmmmmmmm mm
   ysyhyhhho   s     |sy  sdm m  mddmmddhydmmm
   h  oshhhyyyddhoo  ooyysshdmdohdmmdmddsshmmm
    y   oyhhhdhhsyhsssshdddsss    hdddyyyhddm
    dyyshyyhssyyhyyyyddhhmmdmmmdy syssoosyhdm
     hsyyhhhhsoo sooyyhhdoohdhhyhyysoo  osdm
      doyhhhyyyyhhhysyyy oossyyssso   osydm
        soyhyyhhhhhhyhyyyooos       ohdddm
         msoyyyyyyyhyyyyo ooo       syyd
            ho oyyysooo    osso   osyd
               dhyyysssyyyyyysoosdm
                    mmdddddmmm

Input:
000000000000
000000000000
0000X0000000
0000000X0000
000000000000
000000000000
000000000000
000000000000
000000000000
000000000000
000000000000
000000000000

Output:
     |
 0000|00|0000
 0000|00|0000
-----X--+--00
 00--+--X-----
 0000|00|0000
 0000|00|0000
 0000000|0000
 000000000000
 000000000000
 000000000000
 000000000000
 000000000000

Input:
00000000000000000
00000000000000000
00000000000000000
00000X000X0000000
00000000000000000
00000000000000000
00000000000000000
00000000000000000
00000000000000000
00000000000000000
00000000000000000
00000000000000000

Output:
00000|000|0000000
00000|000|0000000
00000|000|0000000
----+#+++#+----00
00000|000|0000000
00000|000|0000000
00000|000|0000000
00000000000000000
00000000000000000
00000000000000000
00000000000000000
00000000000000000

Crosshair
Your cross-hair should be a 3-tall and 5-wide:
     |
     |
     |
-----X-----
     |
     |
     |

Input
Input will be at least 12x12 characters in size and will consist of only ASCII characters. It can be taken in through STDIN or function argument. The input will not always contain an X. Input will be in any shape and have an arbitrary amount of whitespace. The input will not contain any of: +, -, #,  and |
Output
Output can be through STDOUT or a function's return value. Output should be the input image with the cross-hair drawn. If there is not enough space to draw the crosshair, you must add lines / spaces to draw it. Overlapping spots should be replaced with a +. If the | or - of the crosshairs overlaps an X, instead of a +, an # should appear.
Trailing whitespace is not allowed except for a single newline at the very end.

This is code-golf so shortest code in bytes wins!

if the input is an argument, does it have to be a string with lines separated by newlines, or can it be an array of strings? 2. is it acceptable to add whitespace around the design even if not necessary (i.e always add 3 rows above / below and 5 columns to the left / right)? 3. The input is missing for the 3rd test case.

@steveverrill 1. It will be a newline separated string, not an array of strings 2. No, that is not allowed. You can use that in your code but it shouldn't appear in the output

Does the + for overlapping - and | apply only when those characters are part of crosshairs, or does it affect literal - and | found in the input as well?

Can we assume a rectangular input i.e. all lines (including whitespace) will be the same length?

@steveverrill I think not: The input will not always contain an X. Input will be in any shape and have an arbitrary amount of whitespace., but I agree that it would make things a lot easier.

@DLosc those will not be in the input. I've updated the question

What if a literal # in the input is encountered by a crosshair? Will it be overwritten?

@Andrew no, #  won't be  in the inout

Will all lines of the input always be equal length?

@GeorgeReith no the input's lines may be different lengths

Damn... I'll need to make another change to my answer then!

Are ASCII nonprintable characters (such as '\t' or '\r') allowed in input?

@edc65 nope, they aren't

CoffeeScript, 345 336  327 bytes
Z=(s,c)->s in'X#'&&'#'||s in'-|+'&&'+'||c
X=(s)->l=u=0;o=(r.split ''for r in s.split '\n');c in'X#'&&(i-x&&(o[y][i]=Z o[y][i],'-';i<l&&l=i)for i in[x-5..x+5];i-y&&((o[i]?=[])[x]=Z o[i][x],'|';i<u&&u=i)for i in[y-3..y+3])for c,x in r for r,y in o;((o[y][x]||' 'for x in[l...o[y].length]).join ''for y in[u...o.length]).join '\n'

X is the function to call.
Explained:
# get new char. s - old char. c - '|' or '-'
Z=(s,c)->s in'X#'&&'#'||s in'-|+'&&'+'||c

X=(s)->

  # leftmost and upmost positions
  l=u=0

  # split input into 2D array
  o=(r.split ''for r in s.split '\n')

  # for every 'X' or '#'
  c in'X#'&&(

    # for positions to left and right
    i-x&&(

        # draw horisontal line
      o[y][i]=Z o[y][i],'-'

      # update leftmost position
      i<l&&l=i

    )for i in[x-5..x+5]

    # for positions above and below
    i-y&&(

      # add row if necessary and draw vertical line
      (o[i]?=[])[x]=Z o[i][x],'|'

      # update upmost position
      i<u&&u=i

    )for i in[y-3..y+3]

  )for c,x in r for r,y in o

  # concatenate into string, replacing empty chars with spaces
  ((o[y][x]||' 'for x in[l...o[y].length]).join ''for y in[u...o.length]).join '\n'

Executable:

<script src="http://coffeescript.org/extras/coffee-script.js"></script>
<script type="text/coffeescript">

Z=(s,c)->s in'X#'&&'#'||s in'-|+'&&'+'||c
X=(s)->l=u=0;o=(r.split ''for r in s.split '\n');c in'X#'&&(i-x&&(o[y][i]=Z o[y][i],'-';i<l&&l=i)for i in[x-5..x+5];i-y&&((o[i]?=[])[x]=Z o[i][x],'|';i<u&&u=i)for i in[y-3..y+3])for c,x in r for r,y in o;((o[y][x]||' 'for x in[l...o[y].length]).join ''for y in[u...o.length]).join '\n'

################################################################################
# tests follow
s = ['''
                mdhyyyyyyyhhhddmmm
            mdyyssoo  oooosyyyhhhdmm
          hsso     oossoooooyyhhdhhdmmm
        yoooooo     oo ssysssyhhdyyyhmmmm
      myso oso  o  oyo    hhhdhhyhyhhm mm m
     mhsyhhys  oss      yyyhhhsosyhhmmmmdmmm
    mhyhhhy y         ssyhoho o shhdmmmmdmmmm
    hhyyyh   s   oo syysyyhhdysso oyhdhhhmmmmm
   dhysyys      sdysoXoyyyyhhso     syshm  mmm
   hhyhyo       o      osss y   shhyyhd mmmmmm
   yyhyyyss           o  oyyyydmmdmmmmmmmmm mm
   ysyhyhhho   s     osy  sdm m  mddmmddhydmmm
   h  oshhhyyyddhoo  ooyysshdmdohdmmdmddsshmmm
    y   oyhhhdhhsyhsssshdddsss    hdddyyyhddm
    dyyshyyhssyyhyyyyddhhmmdmmmdy syssoosyhdm
     hsyyhhhhsoo sooyyhhdoohdhhyhyysoo  osdm
      doyhhhyyyyhhhysyyy oossyyssso   osydm
        soyhyyhhhhhhyhyyyooos       ohdddm
         msoyyyyyyyhyyyyo ooo       syyd
            ho oyyysooo    osso   osyd
               dhyyysssyyyyyysoosdm
                    mmdddddmmm
'''
'''
000000000000
000000000000
0000X0000000
0000000X0000
000000000000
000000000000
000000000000
000000000000
000000000000
000000000000
000000000000
000000000000
'''
'''
00000000000000000
00000000000000000
00000000000000000
00000X000X0000000
00000000000000000
00000000000000000
00000000000000000
00000000000000000
00000000000000000
00000000000000000
00000000000000000
00000000000000000
'''
'X'
'XX\nXX'
]
document.write '<pre>'
document.write '\n\n',X x for x in s
</script>

345 is too good! I'm trying to get close, but you're way ahead so far! I don't know if I can do much more without changing my approach entirely... Hmm :)

Until somebody comes with CJam/Pyth/GolfScript and makes sub-100. But thank you.

Hah.. Too true... I'm wondering if this should be the encouragement I need to learn Pyth...

Python 3, 577 519 515 490 475 467 454 bytes
def c(g,d):
 R,L,V,e,b=range,list,len,'-|+','#';t,g=(lambda g,d:sum([[(i,j)for j in R(V(L(g.split('\n')[i])))if g.split('\n')[i][j]==d]for i in R(V(g.split('\n')))],[]))(g,d),[L(i)for i in g.split('\n')]
 for a,r in t:
  for j in R(a-3,a+4):
   if V(g)>j>-1:n=g[j][r];g[j][r]='+'if n in e else'#'if n in(d,b)else'|'
  for j in R(r-5,r+6):
   if V(g[a])>j>-1:n=g[a][j];g[a][j]='+'if n in e else'#'if n in(d,b)else'-'
 return'\n'.join(''.join(l)for l in g)

I'm not sure how much farther I can golf this.
Usage:
c(g, d)

Where g is the input grid and d is the crosshair-marking character.

Perl, 370 bytes
sub r{$h=pop;($=[$n=pop].=$"x(1+"@_"-length$=[$n]))=~s!(.{@_})(.)!"$1".($2=~/[-|+]/?'+':$2=~/[X#]/?'#':$h)!e}map{chop;push@c,[$-,pos]while/X/g;$-++}@==<>;($x,$y)=@$_,3-$x>$a?$a=3-$x:0,$x+5-@=>$b?$b=$x+5-@=:0,6-$y>$c?$c=6-$y:0 for@c;@==($",@=)for 1..$a;$_=$"x$c.$_ for@=;map{($x,$y)=@$_;$_&&r$y+$c+$_-1,$x+$a,'-'for-5..5;$_&&r$y+$c-1,$x+$_+$a,'|'for-3..3}@c;print@=,$,=$/

Usage, save above as xmarks.pl:
perl xmarks.pl <<< 'X'
I'm not sure how much smaller I can make this, but I'm sure I'll come back to it later! I might post an explanation if anyone is interested too.
Handles input of X and non-square inputs as well now.

Python 2, 755 706 699 694 678 626 Bytes
Expects input on stdin, with a trailing newline. The end of input is triggered with cmd+d.
import sys;a=sys.stdin.readlines();b=max;c=len;d=enumerate;e=c(b(a,key=lambda x:c(x)))-1;a=[list(line.replace('\n','').ljust(e))for line in a];R=range;f=lambda:[[i for i,x in d(h)if x=='X']for h in a+[[]]*4];q=lambda y,z:'#'if z=='X'else'+'if z in'|-+'else y;g=f();h=j=k=l=0
for m,n in d(g):
 if n:h=b(3-m,h);l=b(abs(n[0]-5),l);j=b(m-c(a)+4,j);k=b(n[-1]-e+6,k)
o=[' ']*(l+k+e);a=[o for _ in R(h)]+[[' ']*l+p+[' ']*k for p in a]+[o for _ in R(j)];g=f()
for m,x in d(a):
 for i in[3,2,1,-1,-2,-3]:
    for r in g[m+i]:x[r]=q('|',x[r])
 for r in g[m]:
    for i in R(5,0,-1)+R(-1,-6,-1):x[r+i]=q('-',x[r+i])
for s in a:print''.join(s)

Full program:
import sys

lines = sys.stdin.readlines()

# pad all lines with spaces on the right
maxLength = len(max(lines, key=lambda x:len(x))) - 1 # Subtract the newline
lines = [list(line.replace('\n', '').ljust(maxLength)) for line in lines]

def findX():
    global xs
    xs = [[i for i, ltr in enumerate(line) if ltr == 'X'] for line in lines+[[]]*4]

# add sufficient padding to the edges to prevent wrap
findX()
top,bottom,right,left=0,0,0,0
for ind, item in enumerate(xs):
    if item:
        top = max(3-ind, top)
        left = max(abs(item[0]-5), left)
        bottom = max(ind-len(lines)+4, bottom)
        right = max(item[-1]-maxLength+6, right)
clear = [' '] * (left+right+maxLength)
lines = [clear for _ in range(top)] + [[' ']*left + line + [' ']*right for line in lines] + [clear for _ in range(bottom)]

findX()
def chooseChar(expected, curr):
    return '#' if curr == 'X' else ('+' if curr in '|-+' else expected)

for ind, x in enumerate(lines):
    # try:
        for i in [3, 2, 1, -1, -2, -3]:
            for elem in xs[ind+i]:
                x[elem] = chooseChar('|', x[elem])
        for elem in xs[ind]:
            for i in [5, 4, 3, 2, 1, -1, -2, -3, -4, -5]:
                x[elem+i] = chooseChar('-', x[elem+i])
    # except:f

for line in lines: print(''.join(line))

I'm sure that a lot more golfing could be done on this (since I'm still learning python), so any help is appreciated.
Edits

Shaved about 50 bytes from findX by using for comprehensions
Saved 7 bytes thanks to @mbomb007's suggestion about using range instead of a literal array
Removed 5 bytes by changing findX to a lambda
Saved 15 bytes by extending xs by 4 and eliminating the try-except block
Shaved 2 more by using tabs instead of spaces
Removed 5 bytes by using h=i=j=k=l=0 instead of h,j,k,l=0,0,0,0
Thanks to @mbomb007, I removed about 40 more bytes from chooseChar

You should define R=range to shorten ranges. Then you can also change for i in[5,4,3,2,1,-1,-2,-3,-4,-5]: to for i in R(5,0,-1)+R(-1,-6,-1):

Thanks! I had thought about doing that but it seemed that it would be longer.

Good work on trimming down! I'm not sure if you've seen the tip threads, but there might be a few shorteners you can get from here: http://codegolf.stackexchange.com/questions/54/tips-for-golfing-in-python

I did a few days ago, but I forgot about some things.

Also, your q lambda seems very inefficient to me. Can that be shortened at all? At the very least, I don't think the parentheses are necessary, but I think the boolean logic and string comparisons can be shortened, too.

Big thanks, after looking at it for a while I discovered that if I flipped it around it could be much shorter and clearer.

@JAtkin, apologies, I didn't mean to come off as rude, I specifically noticed the input() section for STDIN and didn't know if that would work here too? Unsure because the examples there were focussed on numbers!

You didn't come off as rude at all. In fact your reminder was useful because I had forgotten a couple of tricks, although in this case I couldn't use them (http://codegolf.stackexchange.com/a/18983/42736).

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


text:
The Untouchables
Untouchable Numbersα
An untouchable number is a positive integer that cannot be expressed as the sum of all the proper divisors of any positive integer (including the untouchable number itself).
For example, the number 4 is not untouchable as it is equal to the sum of the proper divisors of 9: 1 + 3 = 4. The number 5 is untouchable as it is not the sum of the proper divisors of any positive integer. 5 = 1 + 4 is the only way to write 5 as the sum of distinct positive integers including 1, but if 4 divides a number, 2 does also, so 1 + 4 cannot be the sum of all of any number's proper divisors (since the list of factors would have to contain both 4 and 2).
The number 5 is believed to be the only odd untouchable number, but this has not been proven: it would follow from a slightly stronger version of the Goldbach conjecture. β
There are infinitely many untouchable numbers, a fact that was proven by Paul Erdős.
A few properties of untouchables:

No untouchable is 1 greater than a prime
No untouchable is 3 greater than a prime, except 5
No untouchable is a perfect number
Up to now, all untouchables aside from 2 and 5 are composite.

Objective
Create a program or function that takes a natural number n via standard input or function parameters and prints the first n untouchable numbers.
The output must have separation between the numbers, but this can be anything (i.e. newlines, commas, spaces, etc).
This should be able to work at least 1 <= n <= 8153. This is based on the fact that the b-file provided for the OEIS entryγ goes up to n = 8153.
Standard loopholes are disallowed, as per usual.
Example I/O
1    -> 2
2    -> 2, 5
4    -> 2, 5, 52, 88
10   -> 2, 5, 52, 88, 96, 120, 124, 146, 162, 188
8153 -> 2, 5, 52, 88, 96, 120, ..., ..., ..., 59996

This is code-golf, so least number of bytes wins.

α - Wikipedia,
β - MathWorld,
γ - OEIS

For some reason this was marked as a duplicate to the 'finding semiperfect numbers' question, however the tasks are completely different. In this case, you must check to make sure that no sum of perfect divisors of any natural number can equal a certain number.

This is purely speculative, since I haven't really thought about how I would solve this yet: Would it be cheating if I assumed an upper limit on the resulting numbers? Say, if I wrote code that only finds untouchable numbers up to 60,000? That would be enough to cover the input range. But of course I only know that based on the partial results you provided.

I guess it would be okay. It's not technically hardcoding the results, doesn't violate standard loopholes as far as I know. As long as it fits the rest of the spec that will be fine.

@vihan Definitely not.

Pyth, 21 bytes
.f!fqZsf!%TYStTSh^Z2Q

Warning: Incredibly slow. Test run and timing below.
$ time pyth -c '.f!fqZsf!%TYStTSh^Z2Q' <<< 3
[2, 5, 52]

real    2m46.463s
user    2m46.579s
sys 0m0.004s

It's basically as brute force as possible, tests factorizations up to the potential lonely number squared plus one.

C, 104 bytes
j,i,z,w;u(y){for(z=2;y;z++)for(w=0;(++w<z*z||0&printf("%i ",z)+y--)&&j^z;)for(i=j=0;++i<w;j+=i*!(w%i));}

It will take a few minutes for y > 20, but whatever.

Java, 310 Bytes
class U{int[] p;U(int e){p=new int[(int)4e9];for(int i=1,c=0;c<e;i++)if(u(i)>0){System.out.println(i);c++;}}int p(int n){if(p[n]!=0)return p[n];int i,s=1;for(i=2;i<=n-1;i++)s+=n%i==0?i+(n/i!=i?n/i:0):0;return(p[n]=s);}int u(int n){if(n==1)return 0;for(int i=2;i<=(n-1)*(n-1);i++)if(p(i)==n)return 0;return 1;}}

Golfed as well as I could but, I was more interested in making sure it ran in reasonable time. The unglofed version is probably more interesting
public class Untouchable {
    int[] properDivisorSumMap;

    public Untouchable(int estimatedMaxium){
        properDivisorSumMap = new int[(estimatedMaxium-1)*(estimatedMaxium-1)];
    }

    public int properDivisorSum(int n){
        if(properDivisorSumMap[n] != 0){
            return properDivisorSumMap[n];
        }

        int sum = 1;
        for(int i=2;i<=(int)Math.sqrt(n);i++){
            if(n%i==0){
                sum+=i;
                if(n/i != i){
                    sum+=n/i;
                }
            }
        }
        properDivisorSumMap[n] = sum;
        return sum;
    }

    public boolean untouchable(int n){
        if(n==1){
            return false;
        }
        for(int i=2;i<=(n-1)*(n-1);i++){
            if(properDivisorSum(i) == n){
                return false;
            }
        }
        return true;
    }

    public static void main(String[] args){
        Untouchable test = new Untouchable(8480);

        int elements = Integer.parseInt(args[0]);

        for(int i=1,count=0;count < elements;i++){
            if(test.untouchable(i)){
                System.out.printf("%4d: %4d%n",count,i);
                count++;
            }
        }
    }
}

Go, 396 bytes
Not really golfed, but it can do all of the required range.  Runs in about ~20min and needs ~7GB (independent of n).  Makes a giant array to compute the sum of divisors for all numbers up to 59997 squared.
func untouchable(n int) {
    const C = 59997
    const N = C * C
    s := make([]uint16, N)
    for d := 1; d < N; d++ {
        for i := 2 * d; i < N; i += d {
            v := int(s[i]) + d
            if v > C {
                v = C + 1 // saturate at C+1
            }
            s[i] = uint16(v)
        }
    }
    var m [C]bool
    for i := 2; i < N; i++ {
        if s[i] < C {
            m[s[i]] = true
        }
    }
    for i := 2; n > 0; i++ {
        if !m[i] {
            println(i)
            n--
        }
    }
}

I'm over 8 years late, but you forgot to post the golfed version!

Jelly, 10 9 bytes
2²Æṣ€ḟƑƊ#

Try it online!
Times out on TIO for \$n > 3\$, but works in theory for all \$n\$. Relies on the assumption that for a given \$x \ge 2\$, \$x\$ is untouchable if none of the proper divisor sums between \$1\$ and \$x^2\$ equals \$x\$. Takes \$n\$ on STDIN.
How it works
2²Æṣ€ḟƑƊ# - Main link. Takes no arguments
       Ɗ  - Group the previous 3 links together into a monad f(k):
 ²        -   k²
    €     -   Over each 1, 2, ..., k²:
  Æṣ      -     Proper divisor sum
      Ƒ   -   Is the list of proper divisor sums unchanged after:
     ḟ    -     removing k from it?
2       # - Count up k = 2, 3, ... until n such k's return true under f(k)

R, 122 bytes
function(n)while(n){T=T+1
m=T^2
t=0
while(m<-m-1){i=s=0;while((i=i+1)<m)if(!m%%i)s=s+i;t=t+(T==s)}
if(!t){print(T);n=n-1}}

Try it online!
Anyone familiar with R programming will certainly wince when they look at this.  Loops in general are horribly inefficient in R, and the fast and idiomatic way to tackle this kind of question would normally be to use vectorized functions.
Unfortunately, the maximum size of a vector in R is 2^31-1 elements, which is smaller than the square of 59996, the highest number that we need to test for untouchability, so we can't easily find divisors by checking a large vector.
So here we use a set of nested while loops to avoid making the big vectors that we really want.  If you aren't used to R, this will probably seem quite unremarkable, and you'll probably also be surprised at just how slowly it runs (n=4 times-out on TIO!).
If only R used un-signed integers to index vectors, and so could manage vectors with 2^32 elements, the code would be only 80 bytes:
Imaginary R with 2^32-sized vectors, 80 bytes
function(n,m=1:4e9,a=!m){for(y in m)a[sum(which(!y%%(2:y-1)))]=T
which(!a)[1:n]}

Try it online! (but it won't work for large n)


text:
ASCII Maya Numbers
Write a program or function which, given a positive integer as input, outputs the representation of that integer in Maya numerals.
Maya numerals
Maya numerals is a vigesimal system (base 20) using only 3 symbols :

<  > for Zero (The correct symbol is some sort of shell that can't easily be represented using ASCII).
. for One
---- for Five

Numbers are written vertically in powers of 20, and numbers between 0 and 19 are written as stacks of fives and ones. You shall refer to the Wikipedia article for more details.
As an example, here are the numbers between 0 and 25, separated by commas:
                                                                                .    ..  ...  ....
                                                        .    ..  ...  .... ---- ---- ---- ---- ----  .    .    .    .    .    .
                               .    ..  ...  .... ---- ---- ---- ---- ---- ---- ---- ---- ---- ----
<  >, .  , .. ,... ,....,----,----,----,----,----,----,----,----,----,----,----,----,----,----,----,<  >, .  , .. ,... ,....,----

Inputs

Inputs always are positive integers between 0 and 2147483647 (2^31 - 1).
You may take the input from STDIN, as a command line argument, function parameter or anything similar.

Outputs

Each line is at most 4 characters long. <  > and ---- should always be printed as given here (4 characters long each).
Ones(.) must be centered on the line. If there are 1 or 3 ., since perfect horizontal alignment is impossible, it does not matter whether they are one column to the left or one column to the right or the center.
There must be exactly one empty line between different powers of 20, regardless of the height of the stacks in the power of 20s. For example, the correct output for 25 and 30 are :
        .
 .
       ----
----   ----

No leading or trailing lines allowed.
Outputs must be printed exactly like they are in the examples given.

Test cases

Each individual number between 0 and 25 given as example above.
Input: 42

Output:
 ..

 ..

Input: 8000

Output:
 .

<  >

<  >

<  >

Input: 8080

Output:
 .

<  >

....

<  >

input: 123456789

Output:
 .

...
----
----
----

 .
----
----

 ..
----
----

 .

....
----
----
----

....
----

Input: 31415

Output:
...

...
----
----
----

----
----

----
----
----

Input: 2147483647

Output:
 .

...
----
----

 .
----
----

 .

----
----
----

....
----

 ..

 ..
----

Scoring
This is code-golf, so the shortest code in bytes wins.

15 and 20 appear to be identical.

@isaacg Thanks, I actually had 15 appearing both at the right spot and also between 19 and 20. Fixed.

@Fatalize Does the output need to be printed (i.e. STDOUT) or can my function just return the output?

@rink.attendant.6 Must be printed exactly like they are in the post.

Is it ok if 1 is one column to the right, but 3 is one column to the left?

@aragaer yes it's fine

And another one - is it ok to have a trailing newline? Basically we're operating lines here, so it would make sense if the last line was actually a line.

@aragaer The "No trailing or leading lines" rule has been included since the beginning of the challenge, so to be fair to other participants I can't remove it. So no

For "digits" that are multiples of 5, I'm assuming that an extra blank line isn't acceptable: That is, for the number 35, there must be exactly one blank line between the line with the single dot, and the first of the three lines of dashes. Correct?

@MtnViewMark correct

Is it possible to return a 2D list of lines? (Jelly solution)

Pyth, 41 bytes
j+bbm|jb_m.[\ 4kc:*d\.*5\.*4\-4"<  >"jQ20

Try it online: Demonstration
Explanation:
                                     jQ20   convert input to base 20
    m                                       map each value d to:
                  *d\.                         string of d points
                 :    *5\.*4\-                 replace 5 points by 4 -s
                c             4                split into groups of 4
         m.[\ 4k                               center each group
        _                                      invert order
      jb                                       join by newlines
     |                         "<  >"          or if 0 use "<  >"
j+bb                                        join by double newlines

Perl, 125 117 bytes
$-=<>;{$_=($-%20?(""," .
"," ..
","...
","....
")[$-%5]."----
"x($-/5&3):"<  >
").$_;($-/=20)&&($_=$/.$_,redo)}print

Thanks to Dom Hastings for helping me save 8 bytes.

Hey samgak, a couple more byte saving changes, rather than redo,if(int($i/=20)) you can use ~~($i/=20)&&redo. ~~ converts to int - you could also use 0| at the beginning (or |0 at the end). Also replacing substr(".... ...   ..   .   ",20-$i%5*5,5) with (' .', ' ..','...','.'x4)[$i%5-1].$/ seems to work ok, but I haven't tested all the test cases... If those work, you're down to 114... If I think of anything else to share I'll let you know!

Thinking about it, if you only ever want to have an integer and ignore the remainder, you can use the magic variable $- which will always truncate to an int... might save a few more!

@DomHastings thanks, the int conversion trick saves a couple of bytes, and getting rid of substr saves another 4. The newlines need to go inside the string constants because there has to be no newline in the case where there are no dots.

@DomHastings indeed it does, thanks again! I guess that means I have to get rid of my end of the world joke

Mathematica 185 182 171 153
With 18 bytes saved thanks to Arcinde's suggestion to use anonymous functions,
c=Column;c[If[#>0,{q,r}=#~QuotientRemainder~5;c@{{""," ."," .."," ...","...."}[[r+1]],c@{{""},{d="----"},{d,d},{d,d,d}}[[q+1]]},"< >"]&/@#~IntegerDigits~20]&

Example
c[If[# > 0, {q, r} = #~QuotientRemainder~5; c@{{"", " .", " ..", " ...", "...."}[[r + 1]], c@{{""}, {d = "----"}, {d, d}, {d, d, d}}[[q + 1]]}, "< >"] & /@ #~IntegerDigits~20] &[31415]

Checking
The decimal number, 31415, expressed in base 20.
Mathematica employs lower case for this.
BaseForm[31415, 20]

The decimal digits corresponding to the above base 20 number.
IntegerDigits[31415,20]

{3, 18, 10, 15}

Another example
IntegerDigits[2147483607, 20]

{1, 13, 11, 1, 15, 9, 0, 7}

c[If[# > 0, {q, r} = #~QuotientRemainder~5;c@{{"", " .", " ..", " ...","...."}[[r + 1]], c@{{""}, {d = "----"}, {d, d}, {d, d, d}}[[q + 1]]},"< >"] & /@ #~IntegerDigits~20] &[2147483607]

c=Column;c[If[#>0,{q,r}=#~QuotientRemainder~5;c@{{""," ."," .."," ...","...."}[[r+1]],c@{{""},{d="----"},{d,d},{d,d,d}}[[q+1]]},"<  >"]&/@#~IntegerDigits~20]& using anonymous functions.

@Arcinde, Thanks.  Good old anonymous functions.

JavaScript ES6, 143 bytes
Loads of bytes added because need to console.log, could save another 23 bytes without it.
n=>console.log((d=(x,s='',l=1,j=x/l|0)=>s+(j>19?d(x,s,l*20)+`

`:'')+((j=j%20)?(' '+`.`.repeat(j%5)).slice(-4)+`
----`.repeat(j/5):'<  >'))(n))

JavaScript (ES6), 157 bytes
The newlines are significant and are counted as 1 byte each. Since printing to STDOUT is required, console.log cost me a few bytes there.
f=i=>console.log([...i.toString(20)].map(j=>(!(j=parseInt(j,20))||j%5?[`<  >`,` .`,` ..`,`...`,`....`][j%5]+`
`:'')+`----
`.repeat(j/5)).join`
`.slice(0,-1))

Demo
For demonstration purposes I'll write an ES5 version so it works in all browsers:

// Snippet stuff
console.log = function(x) {
  O.innerHTML = x;
}
document.getElementById('I').addEventListener('change', function() {
  f(this.valueAsNumber);
}, false);

// Actual function
f = function(i) {
  console.log(i.toString(20).split('').map(function(j) {
    return (! (j = parseInt(j, 20)) || j % 5 ? ['<  >', ' .', ' ..', '...', '....'][j % 5] + '\n' : '') + '----\n'.repeat(j / 5);
  }).join('\n').slice(0,-1));
}
<input type=number min=0 max=2147483647 value=0 id=I>

<output id=O></output>

Does the last .join need parenthesis?

137 bytes: http://pastebin.com/3Zgg4qtX

@vihan That doesn't output anything, it just returns.

didn't know that was a requirement as input can be through a function. http://pastebin.com/0pS0XtJa is 3 bytes shorter

CJam, 82 76 bytes
li{_K%[""" .
"" ..
""...
""....
"]1$5%='-4*N+2$5/3&*+"<  >
"?N+L+:L;K/}h;L);

My first CJam program, basically just a transliteration of my Perl answer to CJam.
Try online
Multi-line with comments:
li            # read input
{             # start of do-while loop
  _K%         # check if this base-20 digit is a zero
    [""" .
    "" ..
    ""...
    ""....
    "]1$5%=   # push dots for 1s onto stack
    '-4*N+2$5/3&*+    # push lines for 5s onto stack

    "<  >
    "         # push zero on stack
  ?           # ternary if test (for digit equals zero)
  N+L+:L;     # pre-concatenate string with output plus newline
  K/          # divide by 20
}h            # end of do while loop
;L);          # push output string on stack, chop off trailing newline

Python 2.x, 142 bytes:
def m(n):
 h=[[""," "*(2-n%5/2)+"."*(n%5)+"\n"][n%5!=0]+"----\n"*(n%20/5),"<  >\n"][n%20==0]
 n/=20
 if n>0:
  h=m(n)+"\n\n"+h
 return h[:-1]

Example:
>>> print m(2012)
----

<  >

 ..
----
----
>>>

Edit: trailing line...

I have a few improvements to suggest. First, change [n%20==0] to [n%20<1]. Second, change [[""," "*(2-n%5/2)+"."*(n%5)+"\n"][n%5!=0] to h=[(" "*(2-a/2)+"."*a+"\n")*(a>0)+"----\n"*(n%20/5),"< >\n"][n%20<1] with a=n%5, which moves all the n%5s out, and changes the conditional to *(a>0) which returns an empty string at a==0 for the same effect.

Finally, put a, h, and n on one line, like so: a=n%5;h=[(" "*(2-a/2)+"."*a+"\n")*(a>0)+"----\n"*(n%20/5),"< >\n"][n%20<1];n/=20. All this should leave you with 131 bytes.

PHP, 220 bytes
Same approach as my JavaScript answer. PHP has built-in functions for everything.
Takes 1 input from the command line (i.e. STDIN), as seen with $argv[1]:
<?=rtrim(implode("\n",array_map(function($j){return(!($j=base_convert($j,20,10))||$j%5?['<  >', ' .', ' ..', '...', '....'][$j%5]."\n":'').str_repeat("----\n",$j/5);},str_split(base_convert($argv[1],10,20)))));

C - 149
f(v){v/20&&(f(v/20),puts("\n"));if(v%=20)for(v%5&&printf("%3s%s","...."+4-v%5,v/5?"\n":""),v/=5;v--;v&&puts(""))printf("----");else printf("<  >");}

Uses recursion to print most significant numbers first. Then either prints zero or prints all dots with one clever printf and all fives in a loop. I am not sure if I can avoid using if-else here.
The downside of clever printf is that 1 and 3 are not aligned to each other:
Result for 23 is:
  .

...

119 incorrect solution - trailing newline
f(v){v/20&&(f(v/20),puts(""));if(v%=20)for(v%5&&printf("%3s\n","...."+4-v%5),v/=5;v--;)puts("----");else puts("<  >");}

146 bytes.

building on @JonathanFrech 140 bytes

PHP, 202 192 bytes
function m($n){return(($c=($n-($r=$n%20))/20)?m($c)."\n":"").
($r?(($q=$r%5)?substr(" .   .. ... ....",$q*4-4,4)."\n":"").
str_repeat("----\n",($r-$q)/5):"<  >\n");}
echo rtrim(m($argv[1]),"\n");

It gets the input from the first command line argument.
The complete source code, with comments and tests, is available on github.

\n is two characters - but a newline in the middle of a string is only one.

Python 2, 114 bytes
This answer is based on Jakube's Pyth answer and Locoluis's Python 2 answer.
def f(n):d,m=divmod(n%20,5);h=[" "*(2-m/2)+"."*m+"\n----"*d,"<  >"][n%20<1];n/=20;return(f(n)+"\n\n"if n else"")+h

Jelly, 50 49 47 bytes
b5µṪ”.x⁶;$L<3Ɗ¡ṭ⁾--;UW¤ẋ$Ẏ$L¡Ṛø“<  >”WµẸ?
b20Ç€

Try it online!
... is now left aligned thanks to user202729's point.
When you trick yourself into thinking <  > is a palindrome...

Why do you right-align ......

@user202729 For . and .. there needs to be a space so I put one for ... too. Is there a shorter way?

I think that according to the challenge spec ... should not be right-aligned. Just change <4 to <3?

@user202729 You’re right, I think I misread the spec. I don’t think it specifies for ... but I can change it to <2


text:
We love our weird puzzles, us Brits
In a few British newspapers there is a game known as Hidato. It is somewhat similar to Sudoku, albeit instead of having 1-9 in a line and block, it's about placing numbers such that they connect in order from 01 all the way up to the highest one, so they are all touching horizontally, diagonally or vertically.
Inputs will contain multiple lines separated by \n, containing blocks separated by a space, which you can assume to be two characters wide. Each block will be a number, a blank space to be filled (indicated by --), or a wall that cannot have numbers in (XX).
Your output should match the provided one albeit with empty blocks provided with numbers. Note that there may not be a unique, or even the existence of, a solution – some may yield multiple due to their ambiguity, much like Sudoku, and some may be literally unsolvable, in which case you should give a falsey output, but you can assume inputs are formatted as below.
Use a standard header Language: XX bytes. Happy golfing!
Examples
Inputs 01 XX 03, 01 -- 04, 01 --, etc should all return something falsey.
Input:
01 -- --
-- XX 05

Output:
01 03 04
02 XX 05

Input:
-- 33 35 -- -- XX XX XX
-- -- 24 22 -- XX XX XX
-- -- -- 21 -- -- XX XX
-- 26 -- 13 40 11 XX XX
27 -- -- -- 09 -- 01 XX
XX XX -- -- 18 -- -- XX
XX XX XX XX -- 07 -- --
XX XX XX XX XX XX 05 --

Output:
32 33 35 36 37 XX XX XX
31 34 24 22 38 XX XX XX
30 25 23 21 12 39 XX XX
29 26 20 13 40 11 XX XX
27 28 14 19 09 10 01 XX
XX XX 15 16 18 08 02 XX
XX XX XX XX 17 07 06 03
XX XX XX XX XX XX 05 04

Input:
XX XX XX XX -- 53 XX XX XX XX
XX XX XX XX -- -- XX XX XX XX
XX XX 56 -- -- -- 30 -- XX XX
XX XX -- -- -- -- -- -- XX XX
XX -- -- 20 22 -- -- -- -- XX
XX 13 -- 23 47 -- 41 -- 34 XX
-- -- 11 18 -- -- -- 42 35 37
-- -- -- -- 05 03 01 -- -- --
XX XX XX XX -- -- XX XX XX XX
XX XX XX XX 07 -- XX XX XX XX

Output:
XX XX XX XX 52 53 XX XX XX XX
XX XX XX XX 54 51 XX XX XX XX
XX XX 56 55 28 50 30 31 XX XX
XX XX 26 27 21 29 49 32 XX XX
XX 25 24 20 22 48 45 44 33 XX
XX 13 19 23 47 46 41 43 34 XX
14 12 11 18 04 02 40 42 35 37
15 16 17 10 05 03 01 39 38 36
XX XX XX XX 09 06 XX XX XX XX
XX XX XX XX 07 08 XX XX XX XX

Making sure I understand: Given a grid with some non-walkable cells, find a Hamiltonian path that fits the prefilled cells?

@AmiRuse Wow. That looks tricky. (Of course, this is coming from a person who hates photo editing.) It's kind of nice to know of someone else here who has a VG character as their logo. :O

Can we see a solution for the example? More examples are going to be helpful as well.

Brilliant :). You could also have a generator challenge later

@Geobits The cells must be in a path in which 01 is adjacent to 02, 02 to 03… so on to the maximum number, in a Hamiltonian path, yes.

@Vioz- I… uh… don't actually have the answer, as the newspaper (yes, it's from a newspaper) said it would have the answer tomorrow, by which I'll (hopefully remember to) edit it in. Solving it may show a few tricks – and problems you'll have to overcome – that may help, though.

@AmiRuse I figured out the solution on my own :) If you can maybe go through some past puzzles, that could help to add extra examples.

Here's the solution to the example given, so it can be added to the post: http://pastebin.com/SAAUVLvz

@Vioz- Thanks! I've added another with a solution.

I've made such improvements as I could (and removed the bit about a three-day deadline, which is quite against the philosophy of this site), but there are a couple of things which I wasn't sure about. 1. You talk about testing it, but there's nothing in the spec which requires answers to finish in the next 100 years. You probably need to add a flexible but reasonable  time limit. 2. You don't state whether answers can assume that the solution, if it exists, is unique. This could possibly help some lines of logic and provide a significant speed-up if you're willing to guarantee it.

If our solution solves all solvable puzzles in a minute, but doesn't exit after the first minute on the unsolvables, can this be considered valid?

@PeterTaylor I was editing as you improved it, so sadly my SE client didn't want to show me your edit as I pushed mine. I've made a few things clearer, but please edit it as you want.

@Vioz- Ah, that's the challenge (I only just edited this in, mind, per request). If you don't determine it's unsolvable in the time, it won't work – timeout, and hope it's not a complex one, or any other method, but it must be in the time limit, elsewise brute force programs could have a field day on the challenge (and my CPU).

I added the link to its Wikipedia page, since I think the explanation and graphics there are helpful.

Also, could you post an example or two that are more diverse (unsolvable or multiple solutions)?

This website has some very consise solutions to this problem in multiple languages... http://rosettacode.org/wiki/Hidato

Will there always be a 1 and whatever the last number is, revealed in the input?

@Whothehellisthat Yes. You can assume the highest number you see is the amount of cells.

Some simpler examples would be nice for early testing: gist

Did you say if the lines are separated by \n or not?

I kind of think maybe the input walls could be left as "XX". Makes it a lot easier to parse, and I would guess the parsing isn't really the point of this challenge.

Okay @Whothehellisthat, I've added a few more examples and clarifications :)

Could the input method be simplified? Maybe use a 2D array of integers, and have -1 be a wall, and 0 be a blank? That'd make it easier to focus on the real challenge of the puzzle, and then there's no complexity of padding numbers with zeros or parsing strings.

Placeholder: https://jsfiddle.net/rtgdm9bb/

JavaScript (Node.js), 482 bytes
This is a brute-force solution, it starts at 01 and checks every neighbouring cell checking for empty cells (--) or the desired number and following the path to completion or impossibility. If the desired number exists and isn't a neighbour it shortcuts this solution. Takes a few seconds for the largest grid.
This probably isn't particularly interesting, but I thought I'd try my hand at making a solution before looking at the answers linked on Rosetta Code and I enjoyed tackling a slightly more difficult challenge!
Finds all solutions when many exist. The body is a function that accepts a two dimensional array and the footer processes the input to the desired format, and returns the result to the desired format too. Happy to provide more information (and a less golfed implementation if there's interest).
f=a=>{F=(D,n,j)=>[Z=[].concat(...D),z=Z.indexOf(j),z>-1&&[x=z%w,y=z/w|0],z>-1&&[[x-1,y-1],[x,y-1],[x+1,y-1],[x-1,y],[x+1,y],[x-1,y+1],[x,y+1],[x+1,y+1]]][n];C=q=>q.map(Q=>Q.slice());w=a[0][L='length'];l=F(a,0).filter(c=>c!='XX')[L];R=[];r=(s,d)=>{let n=`0${+s+1}`.slice(-2);N=F(d,2,n);n>l?R.push(C(d)):~F(d,1,s)?(p=F(d,3,s),p.filter(P=>P==N+'')[L]?r(n,C(d)):!~F(d,1,n)?p.map(I=>{[x,y]=I,(x<0||x>w-1||y<0||y>d[L]-1)||d[y][x]=='--'&&(D=C(d),r(D[y][x]=n,D))}):0):0};r('01',a);return R}

Try it online!

Python3, 860 bytes:
R=range
S=lambda x,y:[(X,Y)for X in R(x)for Y in R(y)]
def O(b,x,y,X,Y):
 for A,B in[(0,1),(0,-1),(1,0),(-1,0),(1,1),(1,-1),(-1,1),(-1,-1)]:
  if-1<(j:=x+A)<X and-1<(k:=y+B)<Y and b[j][k]!='XX':yield(j,k,b[j][k])
def f(b):
 b=[[int(j)if j.isdigit()else j for j in i.split()]for i in b.split('\n')]
 k=S(*(I:=(len(b),len(b[0]))))
 if len(d:=[(x,y)for x,y in k if type(b[x][y])==int])==1:return
 s,e=min(d,key=(_:=lambda x:b[x[0]][x[1]])),max(d,key=_)
 q,a=[(s,{(x,y)for x,y in k if b[x][y]=='--'},b)],[]
 D=[b[x][y]for x,y in d]
 while q:
  (X,Y),W,B=q.pop(0)
  if(X,Y)==e and W==set():return'\n'.join(' '.join(str(j).zfill(2)for j in i)for i in B)
  T=[]
  for x,y,C in O(B,X,Y,*I):
   if C==B[X][Y]+1:q+=[((x,y),W,B)];T=[];break
   if'--'==C and B[X][Y]+1 not in D:
    U=eval(str(B));U[x][y]=B[X][Y]+1
    if U not in a:T+=[((x,y),W-{(x,y)},U)];a+=[U]
  q+=T

Try it online!


text:
Sort the Textbooks
Sort the Textbooks
School is starting soon (if it hasn't already) and so it's time to get our textbooks in order. You need to sort your books in alphabetical order but that takes too long so you decide to write a program to do it.
Examples
Input:
 _
| |  _
|F| | |
|o|_|P|
|o|B|P|
| |a|C|
| |r|G|
|_|_|_|

Output:
   _
  | |_
  |F| |
 _|o|P|
|B|o|P|
|a| |C|
|r| |G|
|_|_|_|

Input
The input will be a set of books which need to rearranged alphabetically. It will contain only: |, _, , and A-Za-z. The titles of the books are read vertically, top-bottom.
You may choose to assume the input is padded with whitespace to fit a rectangle. If you choose to have your input padded with whitespace, please specify this in your answer.
The very maximum book height your program will need to handle is 5,120 lines tall without failing.
The books will always be 1-thick and their will always be at least one book in the input
Output
The output will need to be the same set of books organized in alphabetical order. The height of the books must stay the same and the title must have the same spacing from the top when re-arranged.
Books should be sorted alphabetically. If your language sports a sort function you can use that. Otherwise you can use alphabetical sorting as described here.
Book Title Examples
 _
| |
| |
|F|
|o|
|o|
| |
| |
|B|
|a|
|r|
| |
| |
|_|

This books title is:
"Foo  Bar"

Book titles will only contain letters and spaces.
Trailing whitespace is allowed

Winning
This is code-golf so shortest code in bytes wins.

Is there a limit to the "height" of the books?

@BassetHound No, there currently isn't but don't need to worry about supporting books 2^64-1 tall. I'll put a maximum at 5,120 "tall" is what your program needs to handle without failing

Alright, great.

@ETHproductions Yes, book titles will only contain letters and spaces

You've changed the rules on sorting quite a few times, so just to make sure - does "If your language sports a sort function you can use that." mean that alphabetical sorting is optional and we can use our language's own sort function (which typically compares ASCII codes and puts capital letters before lowercase and spaces before both), or is alphabetical sorting mandatory (and if so what happens with spaces?).

What about the thickness of books? Always 1 column?

Minimum number of books? 1? 2?

Is there a difference between (assume _ is a space character) "Foo_Bar" and "Foo__Bar" (one versus two spaces between words)? Your example has two spaces, and I just wonder if it's significant.

@BrianJ Yes spaces are significant

@MartinBüttner Their will always be atleast 1 book.

@coredump yes, all books will be one column

@Sp3000 yes, you may use your language's sort function even if it doesn't sort alphabetically

CJam, 60 bytes
qN/:Kz1>2%{_{" _"-}#>}$_{_'_#>,}%2,\*2ew{:e>('|*K,Se[}%.\zN*

I tried porting my Python answer, which is also similar to @RetoKoradi's approach.
Try it online. The input should be padded with spaces to form a rectangle.

Python 3, 231 bytes
def f(s):
 *M,L=sorted(["".join(c).strip()for c in zip(*s.split("\n"))][1::2],key=lambda x:x[1:-1].strip()),;l=m=0
 for r in L+[""]:n=len(r);M+="|"*~-max(n,l),r;m=max(n,m);l=n
 for r in zip(*[x.rjust(m)for x in M]):print(*r,sep="")

Just a quick hack. Zip the books, sort, rezip, taking care of the columns of | while we're at it.
Input a multiline string, padded with trailing spaces to a rectangle. The output has one more trailing space on each line than necessary.
Ungolfed
def f(s):
  new_cols = []

  # Zip columns, removing the spaces above each book
  # [1::2] is to skip columns of |s, keeping only the books
  books = ["".join(c).strip() for c in zip(*s.split("\n"))][1::2]

  # Sort based on title, [1:-1] to remove the top and bottom _s
  books.sort(key=lambda x:x[1:-1].strip())

  last = 0
  max_height = 0

  for book in (books + [""]):
    height = len(book)

    # Append |s as necessary for the left edge of the current book
    # The +[""] above is for the right edge of the last book
    new_cols.extend(["|"*(max(height, last) - 1), book])

    max_height = max(height, max_height)
    last = height

  # Rezip columns, add back spaces as necessary and print
  for col in zip(*[x.rjust(max_height) for x in new_cols]):
      print("".join(col))

I would love to see an ungolfed version,  if it's possible, please.

@Pureferret Added an ungolfed version with a few comments

Ruby (209 204 200 198 bytes)
a=n.tr(?|,' ').split$/
i=!p;t=a.map(&:chars).transpose.map(&:join).select{i^=a}.sort_by{|s|s[/[A-Z]/][0]}
x=0;t.map{|t|y=0;u=p;t.chars{|c|u&&a[y][x,3]=?|*3;a[y][x+1]=c;y+=1;u|=c=='_'};x+=2}
a.join$/

The transpose function in this solution requires that all lines are the same length, hence the input needs to be padded with whitespace.
Explanation
def sort_books(n)
  a = n.tr(?|,' ')  # pre-emptively remove all the '|'.
    .split $/         # and split into an array of lines
                      # ($/ is the INPUT_RECORD_SEPARATOR, typically "\n")
                      # we're going to write our answer into `a` later

  i = !p # i = true; we'll use this as a flip-flop variable
         # Kernel#p returns nil with no args

  # we're now going to get a sorted array of book titles (t)
  t = a.map(&:chars)  # break array into nested array of every character
       .transpose     # and transpose the entire array
       .map(&:join)   # this gives us an array of "horizontal" book titles with dividers

       .select { i ^= a } # select every second line
                          # (i.e. just titles without dividers)
                          # `i` starts off true
                          # `a` is truish (it's our original array)
                          # `^=` is the bitwise xor assignment,
                          #      it will alternate true/false on each execution

       .sort_by { |s| s[/[A-Z]/][0] } # sort by the first alphabetical char

  # use counters for less chars than `each_with_index`
  # x and y are cartesian coordinates in the final array

  x = 0 # start in the left-hand column

  # go through each title
  t.map { |t|
    y = 0 # each book title starts on the top row

    u = p # `u` is "have we reached the book's spine yet?" (or are we above it?)
          # `u` starts off false and we'll set it true when we see the first '_'
          # after which we'll start writing the book's edges

    # go through each character of each title, including leading spaces and '_'s
    # this will "descend" down the array writing each letter of the title
    # along with the "edges"
    t.chars { |c|

      u &&                  # if we're on the spine
        a[y][x,3] = ?|*3;   # write ||| in the next 3 columns
                            # the middle | will be overwriten by the title char

      a[y][x+1] = c; # write the current title char into the second (x+1) column

      y+=1; # descend to the next row

      u |= c == '_' # Since '_' is the top and bottom of the book,
                    # this toggles whether we're on the spine
    }
    x += 2 # jump to the right 2 columns and start on the next title
  }
  a.join $/ # hopefully this is obvious
end

Which ruby version is required? With 2.1.2 for the sample input from the question I get “`transpose': element size differs (6 should be 2) (IndexError)”.

@manatwork sorry, I should've specified that the function requires a rectangle padded by whitespace. I'll update the answer.

Oh. Indeed. Sorry, not analyzed it exhaustively. Neither today, so I only mention gsub(?|,' ') → tr(?|,' ').

Python 2 - 399 bytes
Expects the input to not have a trailing newline.
import sys;a=str.strip;L=list(sys.stdin);b=len(L[-1])/2;s=['']*b
for l in L:
    i=0
    for c in l[1:-1:2]:s[i]+=c;i+=1
s=sorted([a(a(x),'_')for x in s],key=a);y=map(len,s);m=[y[0]]+[max(y[i],y[i+1])for i in range(b-1)]
for i in range(max(y)+1):
    h=max(y)-i;l='';j=0
    for x in s:l+='|'if h<m[j]else' ';l+='_' if h==len(x)else' 'if h>len(x)else x[-h-1];j+=1
    print l+('|'if h<y[-1]else' ')
print'|_'*b+'|'

CJam, 75 66 65 bytes
qN/z(;2%{_{" _"#W=}#>}$es:P;_W>+{_'_#_Pe<)S*2$,'|*.e<@@:P;}%);zN*

This expects input padded with spaces to form a rectangle.
Try it online
Thanks to @Sp3000 and @Dennis for suggestions on string trimming on chat, as well as clueing me in that the $ operator can take a block as an argument.
I'm still not entirely happy with the second loop. But after trying a few other options without better success, I'm getting tired.
Explanation:
qN/     Read input and split at newlines.
z       Transpose to turn columns into lines.
(;      Drop first line...
2%      ... and every second line after that, to keep only lines with titles.
{       Start block that maps lines for sort.
  _       Copy.
  {       Start block for matching first title letter.
    " _"#   Search for character in " _".
    W=      True if not found.
  }#      End match block. This gets position of first character not in " _".
  >       Trim leading spaces and '_.
}$      End of sort block. Lines are now sorted alphabetically by title.
es:P;   Store large number in P. P holds previous position of '_ in following loop.
_W>+    Repeat last title line, so that final separator line is generated.
{       Loop over title lines.
  _'_#    Find position of '_.
  _       Copy position. Will store it in P after the minimum has been determined.
  P       Get position of '_ in previous line.
  e<)     Take the smaller of the two '_ positions, and decrement.
  S*      Generate leading spaces from the count.
  2$,     Get length of title line.
  '|*     Generate full line length sequence of '|.
  .e<     Overlap spaces with '| to give the final separator.
  @@      Get '_ position to top, and stack in order for next loop iteration.
  :P;     Store '_ position in P.
}%      End of loop over lines.
);      Remove last line, which was a repeat.
z       Transpose to turn lines into columns again.
N*      Join with newline characters.

Scala 359 341 bytes
expects all lines to be of the same length (i.e. padded with spaces)
(s:String)=>{def f(s:String)=(" "/:s)((r,c)=>if(r.last=='|'||c=='_')r+"|"else r+" ").init;val h=s.lines.toSeq.transpose.collect{case s if s.exists(_.isLetter)=>s.mkString}.sortBy(_.filter(!_.isWhitespace));((Seq(f(h(0)))/:h.sliding(2))((s,l)=>s:+l(0):+f(l.minBy(_.indexOf('_')))):+h.last:+f(h.last)).transpose.map(_.mkString).mkString("\n")}

ungolfed & commented:
//anonymous method that takes the books ascii-art string
(s: String) => {

  //method to convert the middle to a border
  def f(s: String) =
    //fold (starting from non empty string since we use `.last`)
    (" "/:s)((r,c) =>
      if(r.last=='|'||c=='_')r+"|"
      else r+" "
    ).init.tail

  //h is a sequence of strings of the middle of the books
  val h =
    //transpose lines of input string, and take only the lines the contains letters (middle of the books)
    s.lines.toSeq.transpose.collect{
      case s if s.exists(_.isLetter) =>
        s.mkString
    }.sortBy(_.filter(!_.isWhitespace)) //sort the books by title (actually by "_$title" since we filter out just whitspaces)

  //fold over pairs of books and add the last manually
  (
    (Seq(f(h(0)))/:h.sliding(2))((s,l) =>
      s :+ l(0) :+ f(l.minBy(_.indexOf('_'))) //convert higher book to border and append to folded accumulator
    ) :+ h.last :+ f(h.last) //add last book manually
  ).transpose.map(_.mkString).mkString("\n") //transpose back and construct the output string
}