text:
Write Buggy Code
Now is the time to show off your abilities to write bad code. I am trying out a new sort of programming puzzle, most similar, I think, to the underhanded C contest. The main difference is that this is not nearly as nefarious: it's just some good clean fun. The goal of the puzzle is to pack as many bugs as you can into a program. The winner of this contest is the one who writes the program with the most bugs per character.
To avoid a huge thread of comments asking for clarification, I should define right now what I consider to be qualifying bugs.
First, a bug is not an error. If it is a problem that can be detected by the interpreter as an error (e.g. mismatched delimeters, badly-formed syntax, acessing a property of a null object, etc.) or if it prevents the program from executing or continuing, it is not a bug. Otherwise, you could type in four characters and the interpreter could list eight syntax errors and you could claim a bug-character ratio of 2.
Second, the bug must not be obviously wrong and a bug is not an easter egg. This is certainly a subjective criterion, but I think essential to this sort of contest. This means that you cannot have conditional code that specifically mangles the code in obvious ways. (Read: use a turing pit language, because nobody will know the difference).
Third, the bug must be plausible. This is subjective, like the one above, but the bug must look like it could have been written by a less-than-meticulous or perhaps ignorant person, or someone who just made a mistake. This includes, for example, off-by-one errors or syntax that is valid and looks correct but causes undesired behavior (say, using square brackets instead of parentheses).
The bug can cause any sort of undesired behavior to the program, including, but certainly not limited to, undesired output for some exceptional cases, have different behavior based on something that is seemingly unrelated (e.g. output displays differently depending on whether the current time ends with an odd or even number of seconds), memory leaks, loss of data, and so on.
Example Problem:
Make a program that displays all of the ASCII characters in ascending order of their numerical value.
Example answer:
Brainf***, 5 chars, 1 bug, 0.2 bug-char ratio
+[+.]

Bug: does not display the ASCII character for 1. Could be fixed by changing to .+[.+].
Ok, I think you should mostly have gotten it by now, here is your puzzle:
Decode a Caesar Cipher and Sort the Words Alphabetically
A caesar cipher is created by taking a series of letters and shifting them n letters over in the alphabet. If it goes all the way to the beginning or end of the alphabet, A comes after Z, and Z comes before A. For example:
Mannequin
Nboofrvjo //Shifted over 1 or -25
Wkxxoaesx //Shifted over 10 -16
Ftggxjnbg //Shifted over -7 or 19

You will be given two inputs (you can get input however is most convenient for you, within reason). The first input is the words, and the second input is the value it is shifted over. Your task is to output the decoded words, and then output the decoded words after they have been sorted alphabetically.
Example (no offense to bad boys, it's just an example):

First input: gtdx wjbfwiji. ljy Gfi hfssty
Second input: 5
First output: boys rewarded. get Bad cannot
Second output: Bad boys cannot get rewarded.

Good luck!

Your example's second input is not -5 ?

@S.Mark: The input is 5 because the task is to decode the cipher.

Do we have to support both capital and lowercase letters?

@Joey, No, but you can try and put in a capitalization bug if you want.

@Peter: I've opened a new discussion on meta that concerns this question (among others). Perhaps you would like to comment.

Ruby, 136 characters, 7 bugs, ratio = 0.051
o=gets[/\d+/].to_i
$,='\s'
a=gets.split(/ /).map{|w|w.gsub(/[^.,:;?!]/){(97+($&.ord-97-o)%26).chr}}
print a.join,a.sort_by{|a|a[0]}.join

[/\d+/]: negative numbers have their sign removed (a seeming attempt at input validation)
'\s': backlash escapes are only interpreted within double-quoted strings, so this won't generate a space but rather a literal \s
split(/ /): unlike a plain split, this won't split on newlines (so the last word will keep the newline)
/[^.,:;?!]/: this regex excludes punctation, but not uppercase characters, digits or underscores, and, most critically, newlines
97: anything other than punctation or lowercase letters will get garbled
sort_by{|a|a[0]}: apparently the programmer didn't know about sort, and instead used this ridiculous method, which doesn't sort words starting with the same letter
print: unlike puts, doesn't print a newline between each argument (so the strings come out glued together)

I'm not going to accept my own answer, but I thought I would show you the ultimate buggy sorting decipherer. The great thing about it is I didn't even plan most of the bugs.
Brainf***: 483 chars, 11 bugs
,------------------------------------------------[>,---------]<[<]>[>[
->]<[<]>-]>[+++++++++.>]<[---------------------------<]>>[[>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>+<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<-]>]>[[>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>+<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
<<<<<<<<<<<<<<<<-]>]>[[>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>+<<<<<<<<<<<<<<<
<<<<<<<<<<<<<<<<-]>]>[[>>>>>>>>>>>+<<<<<<<<<<<-]>]++++++++++.>[[>>>>>>
>>>>>>>>>>+<<<<<<<<<<<<<<<<-]>]>[>+++++++++++++++++++++++++++.]

Input:
5 gtdx wjbfwiji. ljy Gfi hfssty

Output:
bo_sre]arded)getBadcannot
adbo_scannotgetre]arded)

List of bugs:
Input/Display bugs:

Nonpositive numbers or numbers that are more than one digit break the program.
The decipherer does not make Z come before A. It just subtracts the ASCII character value.
Spaces appear as the ASCII ESC (27) character.
If the input is not terminated by a tab, the program does not continue after the input instructions.
The program has to be manually terminated. It will continually display the ESC character until stopped.
The program will break if the input file is not ASCII encoded.
The program does not display the first character of the sorted output.

Sorting bugs:
I implemented the sorting extremely naively.

The program breaks when the number of words does not equal 5.
The program breaks if the number of bytes of input exceeds 60.
The program can only sort correctly if the alphabetical order is identical to the example input.
The program adds extra spaces if any of the words are smaller than the example input and overwrites characters if any of the words are longer.

I have a bug-char ratio of 0.0228. Admittedly, Joey beat me, but I take pride in the fact I only used 8 different characters in my program, and my bugs are much more critical.

re]arded? Sounds serious.

C - 224 characters, 2 bugs, 7 cases of undefined behavior
Edit: My assessment here is incorrect.  Overflowing an unsigned integer is, in fact, well-defined in C.  Moreover, comparison between signed and unsigned is well-defined too, but the compiler warns because the way it's defined may not be what you think.
m(char**a,char**b){return strcmp(*a,*b);}main(int c,char*v[]){unsigned i,j
,o;o=atoi(v[1])+19;for(i=2;i<c;i++)for(j=0;j<=strlen(v[i])-1;j++)v[i][j]=(
tolower(v[i][j])-o)%26+97;qsort(v,c,sizeof(v),m);for(i=2;i<c;puts(v[i++]));}

Usage:
$ ./a.out 5 gtdx wjbfwiji ljy Gfi hfssty
bad
boys
cannot
get
rewarded

Breakdown:
m(char**a,char**b){return strcmp(*a,*b);}
main(int c,char*v[])
{
    unsigned i,j,o;

    // Undefined behavior if o is assigned negative value.
    o=atoi(v[1])+19;

    // Comparison between signed and unsigned integer.
    for(i=2;i<c;i++)
        // * Bug: if strlen(v[i]) is zero, subtraction will overflow
        //        unsigned value, and loop will have extra iterations.
        // * strlen is implicitly declared.
        //   Undefined behavior if sizeof(void*) != sizeof(int)
        for(j=0;j<=strlen(v[i])-1;j++)
            // tolower expects either an unsigned char casted to an int, or EOF.
            // Thus, undefined behavior if v[i][j] is non-ASCII.
            v[i][j]=(tolower(v[i][j])-o)%26+97;

    // * Bug: Program name and offset are included in the sort.
    //        "./a.out" and "5" both happen to be less than lowercase strings.
    // * qsort is implicitly declared.
    //   Undefined behavior if sizeof(void*) != sizeof(int)
    qsort(v,c,sizeof(v),m);

    // Comparison between signed and unsigned integer.
    for(i=2;i<c;puts(v[i++]));
}

Good job for breaking the ice. I'll say you have a 0.0402 bug-char ratio.

@Peter Does that include comments and whitespace/CRLFs?

@muntoo No. It is 9/224.

But shouldn't it output the unsorted text as well?

JavaScript: 403 characters, 8 bugs, ratio = 0.0199
Although not as bad as C, JavaScript does have design flaws that can lead to bugs, at least when used by a novice (demo with all bugs unfixed).
function W(v){D.write("<input value="+v+">");return D.body.lastChild}function R(J){I=S.indexOf(C=i.value[J]);H=s.value;if(!I){o.value+=C}if(H>0){o.value+=S[I+H]}if(H<0){o.value+=S[I-26-H]}p.value=o.value.split(" ").sort().join(" ");setTimeout("R("+(J+1)+")",99)}D=document;S="ZYXWVUTSRQPONMLKJIHGFEDCBA";S+=S;S+=S.toLowerCase();i=W("input");s=W("shift");W("run type=button onclick=R(0)");o=W("");p=W("")

function W(v) {
    D.write('<input value=' + v + '>');
    return D.body.lastChild;
}

function R(J) {
    I = S.indexOf(C = i.value[J]);
    H = s.value;
    if(!I) o.value += C;
    if(H > 0) o.value += S[I + H];
    if(H < 0) o.value += S[I - 26 - H];
    p.value = o.value.split(' ').sort().join(' ');
    setTimeout('R(' + (J + 1) + ')', 99);
}

D = document;

S = 'ZYXWVUTSRQPONMLKJIHGFEDCBA';
S += S;
S += S.toLowerCase();

i = W('input');
s = W('shift');
W('run type=button onclick=R(0)');
o = W('');
p = W('');

I + H is string concatenation, not addition: undefinedundefinedundefined...
!I is not the correct way to check the return value of .indexOf(), which returns -1 for a non-match: boysVrewardedVV...
Missing else keywords: boys Vrewarded.V Vget...
Will not stop at end of input: ...cannotundefinedundefined...
Won't correctly handle zero shift (e.g. just trying to use the program to sort words)
Will it handle a negative shift? Not correctly.
Double-clicking the button causes a second timeout to start, leading to incorrect output (demo with most of the previous bugs fixed):boys rebwoayrsd erde.w agredte dB.a dg ecta nBnaodt  cannot.
Output text boxes must be empty when the button is clicked

Also note that this will not work on older versions of IE because it uses an extension to ECMAScript 3 that was only standardized in ES5.

Good call on not including lack of IE support in your list of bugs, I would have been quite tempted to add it, and I almost suggested it because it is a very common "bug" in web development, until I thought about whether or not lack of support for Netscape 4 (or any arbitrary browser) would really be a bug.

Well, lack of support for an obsolete browser certainly hurts no one, but lack of support for a current one would. Unless you're a hip and totally rad Web 2.0 company creating stuff at the bleeding edge of technology until it bleeds out I'd say it is a bug. (Re-read the answer; lack of support for older versions is likely no bug, then. XP is long out of mainstream support and all supported Windows versions have a decent version of IE to run which even comes through automatic updates).

Python3 184 characters, 4 bugs. Bug ratio 0,0217
import string
d=input()
y=int(input())
print("".join(sorted(d.translate(str.maketrans("".join([chr(x)for x in range(96,123)]),"".join([chr(96+(x+y)%26)for x in range(26)]))).split())))

degolfed:
data = input() #string to convert
y = int(input()) #value to shift
print("".join(
    sorted(
        data.translate(
            str.maketrans(
                "".join([chr(x) for x in range(96,123)]),
                "".join([chr(96+(x+y)%26) for x in range(26)]))
            ).split()
        )))

Example input: gtdx wjbfwiji. ljy Gfi hfssty
Example input: -5
Example output: Gcanxrbmmnsfdsqdv`qcdc.
Known bugs:

Does not convert upper-case characters
Includes ` and converts to/from it.
Does not convert non-ascii characters (åäö)
Does not print spaces.
Can handle, but ignores, punctuation -- I choose not to count this, but if I do my ratio goes to 0.027)

I'm not very good at coming up with bugs deliberately.


text:
Calculate an integer sequence derived from prime factors
Create a function, expression, or program which does the following:

Take the prime factors of any number and sum them. For example, the prime factors of 28 are 2 2 7, summed to 11.
Multiply the result by the number of prime factors for the given number. E.g, 28 has 3 prime factors which sum to 11. 11 * 3 is 33.
Repeat the process recursively, storing the resulting list (which starts with the original number), until you reach a number that is already included in the list. Halt without adding that final number, so that the list contains no duplicates. The progression for 28 is 28 33, because 33 results in 28 again.
Count the elements in the resulting list. In the case of 28, the answer is 2.

Here are the results for 0<n<=10, so you can check your algorithm.
2 1 1 10 1 11 1 9 5 10
(As balpha pointed out, the answer for higley(1) is 2, from the list 1 0. I originally had 1, due to a bug in my original algorithm written in J.)
Since I'm a conceited SOB and haven't found this on OEIS, let's call this the "Higley Sequence," at least for the duration of this round of code golf. As an added bonus, find the first two n having the lowest higley(n) where n is not prime and n>1. (I think there are only two, but I can't prove it.)
This is standard code golf, so as usual the fewest keystrokes win, but I ask that you please upvote clever answers in other languages, even if they are verbose.

Why is highley(1) == 1? One has no prime factors, so the resulting list in 4) is [1, 0], so highley(1) == 2 as I see it.

Can we assume that the input number and intermediate values will be no greater than 2^31-1 (i.e. fits in a signed 32-bit integer)?

@Peter Taylor Sure.

In case anyone finds it helpful, the OEIS sequences which are vaguely related and may provide some inspiration are A001414, A001222, and A002217.

since you haven't commented I assume you haven't noticed: I proved that there are only the two non-prime fixpoints and added it as an appendix to my post.

J, 47 45
#@((~.@,[:(+/@{:*+/@:*/)2 p:{:)^:_)`2:@.(=&1)

It's possible this would be much shorter without using ^:_, but my brain is sufficiently fried already.
Edit: (47->45) Double coupon day.
Usage:
   higley =: #@((~.@,(+/@{:*+/@:*/)@(2&p:)@{:)^:_)`2:@.(=&1)
   higley 1
2
   higley"0 (1 + i. 10)
2 1 1 10 1 11 1 9 5 10

Wow! A J solution that's shorter than a GolfScript solution. First one I've seen. (I'm a big fan of J.)

You can shorten this considerably by using a slightly different algorithm: #@((~.@,((+/*#)@:q:)@{:)^:_)\2:@.(=&1)`, which is 38 characters.

Wow, I tried to figure out how to do it with q: but was trying to manhandle it into my 2 p: solution so I didn't get it. Obvious in retrospect.

The fact that you can look at that explosion of characters and say it "obvious in retrospect" simply blows my mind. One of these days I should check out Golfscript or J.

@Casey I felt the same way at one time, but the more J you learn and use, the more it sort of "leaps out at you," though I still see things I have to puzzle out. One helpful thing to know about J is that if you add a . or : after a symbol, it creates a new symbol, e.g, {, {., and {: all mean different things, but {- (for example) is definitely a sequence of two things, { and -.

Golfscript, 68 67 62 61 chars
[.]({[.2@{1$1$%{)}{\1$/1$}if}*;;].,*0+{+}*.2$?@@.@+\@)!}do;,(

This is an expression: it takes n on the stack and leaves the result on the stack. To turn it into a program which takes n from stdin and prints the result to stdout, replace the leading [ with ~
The heart of it is [.2@{1$1$%{)}{\1$/1$}if}*;;] (28 chars) which takes the top number on the stack and (by an incredibly inefficient algorithm) generates a list of its prime factors. C-style pseudocode equivalent:
ps = [], p = 2;
for (int i = 0; i < n; i++) {
    if (n % p == 0) {
        ps += p;
        n /= p;
    }
    else p++;
}

The 0+ just before {+}* is to handle the special case n==1, because Golfscript doesn't like folding a binary operation over the empty list.
One of the non-prime fixpoints is 27; I found this without using the program by considering the mapping (pa -> a2p), which is a fixpoint if a == p(a-1)/2, and trying small a. (a==1 gives the fixpointedness of primes).
Searching with the program turns up a second fixpoint: 30 = (2+3+5)*3

Appendix: proof that there are only two non-prime fixpoints
Notation: sopfr(x) is the sum of prime factors of x, with repetition (A001414). Omega(x) is the number of prime factors of x (A001222). So the Higley successor function is h(x) = sopfr(x) Omega(x)
Suppose we have a fixpoint N = h(N) which is a product of n=Omega(N) primes.
N = p_0 ... p_{n-1} = h(N) = n (p_0 + ... + p_{n-1})
Basic number theory: n divides into p_0 ... p_{n-1}, so w=Omega(n) of those primes are the prime factors of n. Wlog we'll take them to be the last w. So we can divide both sides by n and get
p_0 ... p_{n-w-1} = p_0 + ... + p_{n-1}
or
p_0 ... p_{n-w-1} = p_0 + ... + p_{n-w-1} + sopfr(n)
Given that all of the primes p_0 to p_{n-w-1} are greater than 1, increasing any of them increases the LHS more than the RHS. So for a given n, we can enumerate all candidate solutions.
In particular, there can be no solutions if the LHS is greater than the RHS setting all the "free" primes to 2. I.e. there are no solutions if
2^{n-w} > 2 (n-w) + sopfr(n)
Since sopfr(n) <= n (with equality only for n=4 or n prime), we can make the weaker statement that there are no fixpoints if
2^{n-w} > 3 n - 2 w
Holding w fixed we can select different values of n satisfying w=Omega(n). The smallest such n is 2^w. Note that if 2^{n-w} is at least 3 (i.e. if n-w>1, which is true if n>2) then increasing n while holding w constant will increase the LHS more than the RHS. Note also that for w>2 and taking the smallest possible n the inequality is satisfied, and there are no fixpoints.
That leaves us with three cases: w = 0 and n = 1; w = 1 and n is prime; or w = 2 and n is semi-prime.
Case w = 0. n = 1, so N is any prime.
Case w = 1. If n = 2 then N = 2p and we require p = p + 2, which has no solutions. If n = 3 then we have pq = p + q + 3 and two solutions, (p=2, q=5) and (p=3, q=3). If n = 5 then 2^4 > 3 * 5 - 2 * 1, so there are no further solutions with w = 1.
Case w = 2. If n = 4 then N = 4pq and we require pq = p + q + 4. This has integer solution p=2, q=6, but no prime solutions. If n = 6 then 2^4 > 3 * 6 - 2 * 2, so there are no further solutions with w = 2.
All cases are exhausted, so the only non-prime fixpoints are 27 and 30.

Found those two same fixpoints using pencil-and-paper: 27 and 30.  I would agree with OP it seems those are the only two.

Next interesting question might be.  Are there infinitely many higley(x) = 2?  How about is there a way to generate arbitrary higley(x), such as higley(x) = 100?

Very nice! I'm a J guy but just might have to learn GolfScript.

@mellamokb I think there are a number of interesting questions with this sequence. For instance, if we consider the sequence of numbers generated for each n before it is counted, are there any non-prime n after 49 for which said sequence does not end in 28?

Another interesting question to ask is whether there is a simple function of n which bounds higley(n) above. (That would allow simplifying the loop considerably - just iterate f(n) times and then discard duplicates).

@Peter That's a fascinating deconstruction. I have never formally studied number theory — or math in general past high school — but I was able to follow your reasoning pretty well.

Ruby, 92 characters
f=->i{r=[i];(x=s=0;(2..i).map{|j|(s+=j;x+=1;i/=j)while i%j<1};r<<i=s*x)until r.uniq!;r.size}

This solution assumes higley(1) is actually 2, not 1 (see balpha's comment above):
(1..10).map &f
=> [2, 1, 1, 10, 1, 11, 1, 9, 5, 10]

Octave - 109 chars
l=[input('')];while size_equal(unique(l),l);n=factor(l(1));l=[sum(n)*length(n) l];endwhile;disp(length(l)-1);

Husk, 9 bytes
LU¡o§*LΣp

Try it online! or Verify first 10 tests
Explanation
LU¡o§*LΣp input → n
  ¡o      create an infinite list:
        p get the prime factors
      L   length
    §*    times
       Σ  sum
 U        longest unique prefix of the infinite list
L         length of the prefix

Jelly, 9 bytes
ÆfS×LƊ$ƬL

Try it online!
Explanation
ÆfS×LƊ$ƬL   Main monadic link
       Ƭ    Repeat and collect results until a duplicate occurs
      $     (
Æf            Prime factorization
     Ɗ        (
  S             Sum
   ×            Multiplied by
    L           Length
     Ɗ        )
      $     )
        L   Length

MATL, 19 bytes
i`vt0)Yftnws*yy-]xn

Try it online!

Pyth, 10 bytes
l.u*sJPNlJ

Try it online!

Explanation:
 .u       Q | N = input, then N =
    s       |  sum of
      PN    |   list of prime factors of N
     J      |   (call this list J)
   *        |  times
        lJ  |  length of J
 .u         | until a previous result is repeated. return the list of results
l           | print the length of the list

source: Stack Exchange

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

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

sort: votes


text:
Fake error message
Write a program that prints out the syntax error message of the compiler or interpreter. The error message should be misleading so that code maintainers will take days to find out that the error was faked, that means, you should obfuscate (and hide your intention). Also, the error must be as exact as possible, and should reference to the code correctly.
For complied languages, assume your code maintainer will do compile program.p && ./program on the command line to compile AND run the program, that means, he cannot distinguish if the output comes from the compiler or the program itself.
Also, assume your code maintainer will turn on syntax error messages.
For reference, here is an example I made: https://gist.github.com/359604
The DATA section encodes the string of error message, and the hash %abcdef is the decode table. The error printed references to the backslashes, which makes a code maintainer will try to count the backslashes.
Entries will be graded by:

Code has an deceptively obvious intention /6
Code reproduces error correctly /16
(your point starts with 16, and divide by the corresponding factors for each inaccuracies)

Correct capitalization: 4
Correct line number and column number: 4
Correct wording: 2 for each incorrect words

The line number referenced misleads the code maintainer /3

For example,
./pythontest1.py: line 7: syntax error near token `('
./pythontest1.py: line 7: `   x=input("Enter a number:") #Number input'

gets 8 (16 / 2) on correctness for missing "unexpected" before "token", a normal Python interpreter displays
./pythontest1.py: line 7: syntax error near unexpected token `('
./pythontest1.py: line 7: `   x=input("Enter a number:") #Number input'

If your "code reproduces error correctly" point is under 1, your entry disqualifies.
In case of a tie, I will put up additional grading factors.

Uh...I closed Sparky's recent obsfuscation question on account of not being objective, and now we've got Peter's underhanded thingy and this (which I admit makes a valiant effort to obtain objectivity). Rather than just sit on everything willy-nilly or chose based on my personal prejudice I'm going to open another topic on meta, or maybe resurrect an old one. Be aware that Jeff seems to think that "objective" is a requirement.

http://meta.codegolf.stackexchange.com/q/305/78

A solution can be the [tag:popularity-contest]. Well, an objective winning criteria.

Python
import sys,traceback
try:
  f=open(sys.argv[0])
  print eval(f.readline())
except Exception, e:
  traceback.print_exc(0)

This is a program that should take a filename on the command line, evaluate the first line in it, and print the result.  It has 2 bugs.  The major bug is that it should use sys.argv[1], not sys.argv[0], so it ends up evaluating the program itself, not the contents of the file named by the first argument.  The second bug is that the argument to print_exc makes it print only the deepest frame on the stack, hiding the fact that the error took place inside the eval.  As a result, you get an error like this:
$ python fake_error.py twelve
Traceback (most recent call last):
  File "<string>", line 1
     import sys,traceback
          ^
 SyntaxError: invalid syntax

This looks very much like the first line of the program has a syntax error.  It's not quite right as the file is <string>, not fake_error.py, but otherwise it is indistinguishable from the case where, for example, you spell import wrong.
Both errors are somewhat "underhanded" in that they could be accidental.

This is brilliant

Brilliant. This reminds me of another oddity of Python. Running raise in Python 2, but in IDLE, python's default IDE, causes an internal error printing gibberish about queues. Traceback (most recent call last): ** IDLE Internal Exception:    File "2.7/lib/python2.7/idlelib/run.py", line 325, in runcode     exec code in self.locals   File "2.7/lib/python2.7/idlelib/run.py", line 111, in main     seq, request = rpc.request_queue.get(block=True, timeout=0.05)   File "2.7/lib/python2.7/Queue.py", line 176, in get     raise Empty

Reminds me a practical joke.
$ ls -l
$ cat readme.txt
cat: readme.txt: No such file or directory
$ echo 'cat: readme.txt: No such file or directory' >readme.txt
$ ls -l
total 8
-rw-r--r--  1 florian  staff  43 Mar 16 09:52 readme.txt
$ cat readme.txt
cat: readme.txt: No such file or directory
$

BrainF***
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>++++++++++[<+++++++++++<++++++++++<++++++++++<+++++++++++<+++++++++++<+++<+++++++++<+++<++++++++++<+++++++++++<++++++++++<+++++++++++<++++++++++<+++++++++++<+++++++++++<+++<+++++++++++<+++++++++<+++<++++++++++<+++++++++++<+++++++++++<++++++++++<++++++++++<+++++++++<+++<++++++++++<++++++++++<+++++++++++<+++++++++<++++++++++<+++++++++++<+++++++++++<+++++++++<+++<+++++++++++<++++++++++<++++++++++<+++++++++++<+++++++++++<+++<+++++++++<+++<++++++++++<+++++++++++<++++++++++<+++++++++++<+++++++++++<++++++++++<+++++++++<+++<+++++<+++++++++++<+++++++++++<+++++++++++<+++++++++++<++++++++++<+++<++++++++++++<+++++++++<+++++++++++<+++++++++++<++++++++++++<++++++++<+++<+++<++++<++++<++++<+++++++>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>-]<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<.>++.>++.>++.>+++.>++.>+++.>+.>.>++++++.>+++++++.>.>++.>+.>++++.>++++.>+.>++++.>++++++++.>++.>+++++++++.>++++++++.>+.>+++++.>+++++.>.>+++.>++.>+++.>++.>++++++.>+.>+++++++.>+.>.>++.>+++++++.>++.>++.>+.>+++++++.>++++.>+.>.>++.>++++++++.>+.>++.>+.>++++.>+.>++.>+++++++.>.>++.>+.>++.>+.>.>+++++.>.>+++.>++.>+.>++.>++++++.>+.>+++++++.>+.>.>

I can't find the particular compiler I used before, but I assure you that that is the exact error message.

For those of you without BF compilers who are curious,  this prints, "F***! Syntax error: closing ] token appeared before an opening [ token"

It's nice to see you on CG, Minitech :)

Lol, revision history is amusing :P

Java
throw new Error();

I didn't know if you meant actually throwing an unhandled exception (as in that example), or simulating an error message. If that is the case, this should work:
C
printf("FATAL ERROR #0xBAD\nProgram execution stopped\n\nIn line 123, character 321, of file 'buggy.c'");

(this assumes that stdio.h is #included)

oops, just read your post in-depth about the obfuscation part. i would add an obfuscator to it, but i currently don't have access to any ides. [ :( ] when i get one, i will definetly post an obfuscated version (who knows, maybe in even another lang ;)

Game Maker Language
show_error("Error: Undefined variable a##Line 1, character 4, of event Create in obj_controller",0)

ACTIONSCRIPT 3
trace("TypeError: Error #1009: Cannot access a property or method of a null object reference.");

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


text:
Circle Through Three Points
Given the Cartesian coordinates of three points on a plane, find the equation of the circle through them all. The three points will not be on a straight line.
Each line of input to your program will contain the x and y coordinates of three points, in the order A(x),A(y),B(x),B(y),C(x),C(y). These coordinates will be real numbers less than 1,000,000 separated from each other by space.
The solution is to be printed as an equation of the form (x-h)^2 + (y-k)^2 = r^2. Values for h, k, r are to be printed with three digits after the decimal point. Plus and minus signs in the equations should be changed as needed to avoid multiple signs before a number.
Sample Inputs

7.0 -5.0 -1.0 1.0 0.0 -6.0
1.0 7.0 8.0 6.0 7.0 -2.0

Sample Outputs

(x - 3.000)^2 + (y + 2.000)^2 = 5.000^2
(x - 3.921)^2 + (y - 2.447)^2 = 5.409^2

Can we use polar or parametric equations instead?

@peter No. That way it will be difficult to compare with other answers.

What should be output in the case that there isn't a unique solution? What constraints are there on numerical robustness?

@peter-taylor It is given in the problem statement that 'The three points will not be on a straight line.'

@fR0DDY, I asked two questions...

@peter-taylor Sorry, I missed that. I will add that.

Does the output have to be exactly like your example (i.e. do we have to print all the whitespace)?

@ventero Do not worry about the spaces, but yes the rest of the format should be the same.

Granted, it is only a few characters so this isn't a rant that my solution could be a few shorter, just an honest question...but if whitespace is in the output spec, shouldn't it be mandatory?  Otherwise, in a code-golf, why would anyone meet the output spec?

Python, 176 189 chars
import sys,re
for s in sys.stdin:x,y,z=eval(re.sub(r'(\S+) (\S+)',r'\1+\2j,',s));w=z-x;w/=y-x;c=(x-y)*(w-abs(w)**2)/2j/w.imag-x;print'(x%+.3f)^2+(y%+.3f)^2=%.3f^2'%(c.real,c.imag,abs(c+x))

Does all its work in the complex plane.  I go the math from the bottom of this page.  -c is the center of the circle.

@Joey: yep, my bad.  Fixed.

Ruby, 192 characters
$<.map{|l|a,b,c,d,e,f=l.split.map &:to_f
n=(f-d)/(e-c)
puts"(x%+.3f)^2+(y%+.3f)^2=%.3f^2"%[x=-(n*(a+c)+(n*(b-f)-(c+e))*m=(d-b)/(c-a))/2/n-=m,y=-(x+(a+c)/2)/m-(b+d)/2,((a+x)**2+(b+y)**2)**0.5]}

Usage examples:
$ echo "7.0 -5.0 -1.0 1.0 0.0 -6.0
1.0 7.0 8.0 6.0 7.0 -2.0" | ruby circle.rb
(x-3.000)^2+(y+2.000)^2=5.000^2
(x-3.921)^2+(y-2.447)^2=5.409^2

Inlining the assignments to x, y and r in the call to % should help, if possible.

@Joey: Sorry, apparently missed that when reading the question. Fixed it now.

C# - 490
using System;class C{static void Main(){Func<string,double>p=s=>double.Parse(s);Func<double,string>t=s=>(s<0?"+ ":"- ")+Math.Abs(s).ToString("F3");foreach(var l in System.IO.File.ReadAllLines("i")){var v=l.Split();double a=p(v[0]),b=p(v[1]),c=p(v[2]),d=p(v[3]),e=p(v[4]),f=p(v[5]),m=(d-b)/(c-a),n=(f-d)/(e-c),x=(m*n*(b-f)+n*(a+c)-m*(c+e))/(2*(n-m)),y=-(x-(a+c)/2)/m+(b+d)/2,r=Math.Sqrt((x-a)*(x-a)+(y-b)*(y-b));Console.WriteLine("(x "+t(x)+")^2+(y "+t(y)+")^2 = "+r.ToString("F3")+"^2");}}}

This finds the 2 lines between AB and BC.  Then it finds where the bisects of those 2 lines intersect.  (Which I just noticed is what @PeterTaylor mentioned in his comment to @PeterOfTheCorn.)

Javascript (299)
The only way that I could think of solving this was algebraically solving three equations for three unknowns to find h, k, and r.
p=prompt().split(' ');a=p[0],b=p[1],c=p[2],d=p[3],e=p[4],f=p[5];h=((a*a+b*b)*(f-d)+(c*c+d*d)*(b-f)+(e*e+f*f)*(d-b))/(a*(f-d)+c*(b-f)+e*(d-b))/2;k=((a*a+b*b)*(e-c)+(c*c+d*d)*(a-e)+(e*e+f*f)*(c-a))/(b*(e-c)+d*(a-e)+f*(c-a))/2;r=Math.sqrt((a-h)*(a-h)+(b-k)*(b-k));alert("(x-"+h+")²+(y-"+k+")²="+r+"²");

Example I/O:
7.0 -5.0 -1.0 1.0 0.0 -6.0 --> (x-3)²+(y--2)²=5²
1.0 7.0 8.0 6.0 7.0 -2.0 --> (x-3.9210526315789473)²+(y-2.4473684210526314)² =5.409159155551175²
The only bug that I see is that if h or k is negative, it outputs -- instead of +.

It can be done with compass and straight edge. Take two points, draw the line which bisects them. Take a different pair of two points, ditto. Find the intersection. Whether that leads to shorter code, I have yet to investigate.

This handles only a single line of input, right?

@Joey, yes. Does the problem require multiple line handling?

Quoting from the task: »Each line of input to your program will contain the x and y coordinates of three points ...«


text:
Amicable number calculator
Write a program that calculates amicable numbers, starting from [0,0], intil the maximum value for an integer is reached in the language you chose to write it in.
Amicable numbers are two different numbers so related that the sum of the proper divisors of each is equal to the other number. (A proper divisor of a number is a positive integer divisor other than the number itself. For example, the proper divisors of 6 are 1, 2, and 3.) A pair of amicable numbers constitutes an aliquot sequence of period 2. A related concept is that of a perfect number, which is a number which equals the sum of its own proper divisors, in other words a number which forms an aliquot sequence of period 1. Numbers that are members of an aliquot sequence with period greater than 2 are known as sociable numbers.
For example, the smallest pair of amicable numbers is (220, 284); for the proper divisors of 220 are 1, 2, 4, 5, 10, 11, 20, 22, 44, 55 and 110, of which the sum is 284; and the proper divisors of 284 are 1, 2, 4, 71, and 142, of which the sum is 220.
If you want more information on amicable numbers, here's a link to Wikipedia's entry on the subject.
NOTE: It cannot use pre-determined tables of which are and which are not amicable numbers
EDIT: I suppose I should have said how I will determine the winner:
Your score will be calculated by this formula: Total_characters_of_code / Up_votes = Score
I will select an answer on Sunday, May 1.
The lowest score wins!

What do you mean "starting from 0,0"? I hope you're not suggesting that 0,0 is a pair of amicable numbers, because if so you're disagreeing with the reference you provided.

0, 0 are amicable numbers. 0 has no factors, so the sum of both of their factors are 0.

@minitech, by definition amicable numbers come in distinct pairs. You could argue that 0 is perfect, but perfect numbers are not amicable.

Okay, I missed that :P

Does this mean that, given sufficient time (and space), the program has to compute an unlimited number of amicable numbers (meaning those overflowing int)?

Also, you should define amicable numbers directly in your post, rather than make answerers (who are already taking the time to figure out a solution) have to follow a link.  See what I wrote in meta.

well, if i went through the whole definition of amicable numbers, the post would be really long, so i just provided a link. also, i missed something there about the integer. i will edit to clarify

@joey adams i see what you mean about clarity in your post. i have edited the question to add a definition (cut and paste is awesome ;)

Now to find a language where the maximum integer is very tiny....  ;)

What is a the maximum for languages like Python that switch to big-int automaticaly?

@Casey Brainfuck has a max of 255.

@Juan It's the biggest value you can put in a bignum... which in Ruby, at least, is several hundred KB in size.

In fact, thinking a bit more about 0, I think I have to argue that the aliquot number of 0 is undefined, because every positive integer divides into it without remainder.

Brainfuck has an undefined maximum, actually.

You'll select an answer Sunday, March 1? Seeing as it's already Saturday, April 30, I'm not sure if you really mean to wait that long ;)

@minitech sorry that was a typo. I meant May

-1 for selecting a winner based on upvotes.

Golfscript (51 50 chars)
2{.{:a,(\{.a\%!*+}/}:^~1$>{..^^={[..^](\p}*}*).}do

The core is the override of ^ as :a,(\{.a\%!*+}/ which finds the aliquot of the number on the top of the stack (call it n) by the grossly inefficient approach of considering every number from 1 to n-1 to see whether it's a factor.

Score for this post: 25.5

Now it's 10, just for the record.

C (gcc), 162, 158, 146, 138 chars
s(n){int x=1,i=2;for(;i<=sqrt(n);++i)if(n%i==0)x+=i+n/i;return x;}main(i,a){for(;;)a=s(i),((a>i)?s(a):0)==i++?printf("%d,%d\n",i-1,a):0;}

compile with gcc using gcc amic.c  -o amic -lm -include math.h
To shorten it any further I suspect the algorithm would have to change.
Edits:
162->158: Consolidated the variable b into the printf conditional.
158->146: Utilized main to declare a instead of using a global var, also using implicit int of the parameter and return type for the function s(n)
146->138: Add Lowjacker's suggestion of removing the cast to double. Thanks!

You can change (a>i)? to a>i? .  The operator precedence for ?: is a few rows down from the relational operators.

Score for this post: 46

I´m sorry to tell you but your algorithm for s(n) is incorrect.
Assume n is a square number, then you would add sqrt(n) to the sum of divisors twice.
It´s cool that tried to optimize it, but for golfing purposes, you´d better go for "i<n.... x*=i;
Also if you want optimized runtime, i*i<n is the faster choice.

Scala (120 chars):
def d(n:Int)=(1 to n-1).filter(n%_==0)
def i(x:Int,y:Int)=x!=y&&d(y).sum==x
(1 to Int.MaxValue).filter(x=>i(x,d(x).sum))

Ruby 1.9, 126 124
Not quite a serious answer, but it's theoretically correct. If you're really patient, and have lots of RAM, it should eventually print every pair of amicable numbers.
s=->n{eval (1...n).select{|i|n%i==0}*?+}
i=0
loop{Thread.new(i+=1){|j,k=j|loop{s[k+=1]==j&&s[j]==k&&printf("%d,%d\n",j,k)}}}

Score for this post: 124


text:
1P5: Nested boxes
This task is part of the First Periodic Premier Programming Puzzle Push.
You get a hierarchy of items in the following format:
2
Hat
1
Gloves

which need to be put in boxes, like so:
.------------.
| Hat        |
| .--------. |
| | Gloves | |
| '--------' |
'------------'

In the input format the numbers start a box with as many items as the number specifies. The first box has two items in it (the Hat and the box that contains the Gloves), the second one only contains a single item – the gloves.
As can be seen, boxes can live inside boxes, too. And they are always rounded ... sort of (pointy corners are a wound hazard and we wouldn't want that).
Below there are the nasty details for those that want to utilize every tiny bit of leeway the specification gives. Mind you, not reading the spec is no excuse for submitting wrong solutions. There is a test script and a few test cases at the very end.

Specification

Boxes are constructed from the following characters:

| (U+007C) is used to construct the vertical edges.
- (U+002D) is used to construct the horizontal edges.
' (U+0027) are the round lower corners.
. (U+002E) are the round upper corners.

A box therefore looks like this:
.--.
|  |
'--'

Note that while Unicode also has round corners and proper box-drawing characters, this task is in ASCII only. As much as I love Unicode I realize that there are languages and environments out there that didn't quite arrive in the second to last decade.
Boxes can contain a sequence of items that are either text or other items. Individual items in a box are rendered from top to bottom. The sequence A, B, C thus renders as follows:
.---.
| A |
| B |
| C |
'---'

This of course applies to nested boxes too, which are an item just like text. So the sequence A, B, Box(C, Box(D, E)), F would render as follows:
.-----------.
| A         |
| B         |
| .-------. |
| | C     | |
| | .---. | |
| | | D | | |
| | | E | | |
| | '---' | |
| '-------' |
| F         |
'-----------'

Boxes adjust their size to the content and nested boxes always extend to the size of their parent. There is always a space before and after the content, so that neither text nor nested boxes are too close to the outer box' edge. In short, the following is wrong:
.---.
|Box|
'---'

And the following is correct:
.-----.
| Box |
'-----'

Looks much nicer, too :-)
Text items (see Input below) have to be reproduced exactly.
There is always a single top-level box (cf. XML). However, one box can contain several other boxes.

Input

Input is given on standard input; for easier testing likely redirected from a file.
The input is given line-wise, with each line representing either a text item to put in the current box or opening a new box.
Every line is terminated by a line break.
Text items are marked by a line that does not consist of a number (see below). Text uses alphabetic characters, the space and punctuation (.,-'"?!()). Text will not start or end with a space and it will always have at least one character.
A box starts with a single line with a number in it. The number tells the size of the box, i.e. the number of following items that are put into it:
2
A
B

yields a box with two text items:
.---.
| A |
| B |
'---'

A box will always contain at least one item.
The end of boxes is not explicitly marked with a line; instead boxes are implicitly closed after the specified number of items are put into them.
A box is always just a single item, regardless how many items are in it. E.g.
3
A
4
a
b
c
d
B

will yield a box with three items, the second of which is another box with four items.
Nesting also does not affect the fact that a box is just a single item.

Limits

The maximum nesting level is five. I.e. there are at most five boxes inside of each other. This includes the outermost one.
There is a maximum of ten items per box.
Text items have a maximum length of 100 characters.

Output

Output is the rendered box including all containing and nested items according to the rules outlined above.
Output should be given on standard output and it has to match exactly. No leading or trailing whitespace is allowed.
Each line must be terminated with a line break, including the last.

Winning condition

Shortest code wins (i.e. gets the accepted answer).

Sample input 1
3
This is some text!
Oh, more text?
Just text for now, as this is a trivial example.

Sample output 1
.--------------------------------------------------.
| This is some text!                               |
| Oh, more text?                                   |
| Just text for now, as this is a trivial example. |
'--------------------------------------------------'

Sample input 2
4
Extreme
nesting
3
of
boxes
4
might
lead
to
2
interesting
1
visuals.
Indeed!

Sample output 2
.--------------------------.
| Extreme                  |
| nesting                  |
| .----------------------. |
| | of                   | |
| | boxes                | |
| | .------------------. | |
| | | might            | | |
| | | lead             | | |
| | | to               | | |
| | | .--------------. | | |
| | | | interesting  | | | |
| | | | .----------. | | | |
| | | | | visuals. | | | | |
| | | | '----------' | | | |
| | | '--------------' | | |
| | '------------------' | |
| '----------------------' |
| Indeed!                  |
'--------------------------'

Sample input 3
1
1
1
1
1
Extreme nesting Part Two

Sample output 3
.------------------------------------------.
| .--------------------------------------. |
| | .----------------------------------. | |
| | | .------------------------------. | | |
| | | | .--------------------------. | | | |
| | | | | Extreme nesting Part Two | | | | |
| | | | '--------------------------' | | | |
| | | '------------------------------' | | |
| | '----------------------------------' | |
| '--------------------------------------' |
'------------------------------------------'

Sample input 4
3
Foo
2
Bar
Baz
2
Gak
1
Another foo?

Sample output 4
.----------------------.
| Foo                  |
| .------------------. |
| | Bar              | |
| | Baz              | |
| '------------------' |
| .------------------. |
| | Gak              | |
| | .--------------. | |
| | | Another foo? | | |
| | '--------------' | |
| '------------------' |
'----------------------'

Test Script
Since getting details right can be difficult at times we (Ventero and me) have prepared a test script you can run your solution with to check whether it's correct. It's available as both a PowerShell script and a bash script. Invocation is: <test-script> <program invocation>.
UPDATE: The test scripts have been updated; there were a number of test cases that did not honor the limits I defined. The PowerShell test script did not use case-sensitive comparison for checking the result. I hope everything is fine now. The number of test cases was reduced to 156, although the last one now is quite ... large.
UPDATE 2: I uploaded my test-case generator. Written in C#, targeting the .NET 2 runtime. It runs on Mono. It may help people to test their implementation. As a definitive worst-case given the limits in the task you can try:
nb.exe 1 10 10 5 100 100 | my invocation

which will generate only boxes up to the innermost level and utilize both the maximum number of items per box and the maximum length of text items. I didn't include this test case into the test script, though, since it's quite large and the output even larger.
UPDATE 3: I updated the PowerShell test script which was prone to throw errors depending on how the line endings were in the script and what line endings the solution printed. Now it should be agnostic to both. Sorry again for the confusion.

You say boxes should adjust their size to their content. Yet in the last example, the first inner box adjusts it's size to the outer box. So, how do nested boxed get their size?

@Juan: Thanks for catching that. Amazing that slips like those still happen. Edited :-)

@Joey An oldy but a goody. Hopefully it can inspire some of our newer users to write good, well-specified questions. :-)

@Gareth, I should definitely try to find the time to write more of those again. But a well-specified question, test cases, reference implementation and stuff (things I consider essential for a competition, but that view isn't shared by many ;)) take time. It was much easier while in uni :D

GolfScript, 125 characters
n/):B;[(~{[B"."+"""-"]B"| "+:B;@@{(.10,`-{[B\" "]\}{~A}if}*B[2>:B"'"+"""-"]\}:A~;].{~;1$++,}%$-1=:§;{~§3$.+3$+,-*+1$-1%++}%n*

Using a similar approach as Keith's solution.

Python, 204 chars
def P(n):x=raw_input();return eval('[(n+".","","-")]'+'+P(n+"| ")'*int(x))+[(n+"'",'','-')]if'0'<x<':'else[(n,x,' ')]
r=P('')
for q,t,f in r:print q+t+f*(max(len(2*x+y)for x,y,a in r)-len(2*q+t))+q[::-1]

P returns a list of triples, each of which is a line prefix/suffix (the suffix being the reverse of the prefix), some line text, and a line fill character.  After calculating all the triples, they are printed using the right number of fill characters to make all the lines the same length.
Ungolfed version:
def get_lines(prefix):
  line=raw_input()
  result=[]
  if line.isdigit():
    result.append((prefix+'.', '', '-'))
    for i in xrange(int(line)):
      result += get_lines(prefix + '| ')
    result.append((prefix+"'", '', '-'))
  else:
    result.append((prefix, line, ' '))
  return result
lines=get_lines('')
width=max(2*len(prefix)+len(text) for prefix,text,fill in lines)
for prefix,text,fill in lines:
  print prefix+text+fill*(width-2*len(prefix)-len(text))+prefix[::-1]

Whoa, that was quick. And interesting idea with P there.

Wow, indeed. This is interesting, can you post the ungolfed version? I'd like to understand how the eval bit works. Heh, my ungolfed python solution is 1500+ chars :( Though I take a totally different (and inefficient) approach.

@Casey: eval is just a golfing shortcut for a loop, it isn't fundamental.  I'll post an ungolfed version in a sec...

Ruby 1.9, 174 characters
r=->l{$*<<(l*2+i=gets.chop).size;/\d/?eval('[l+?.,p=?-,p,'+'*r["| "+l],'*i.to_i+"l+?',p,p]"):[l,i,?\s]}
r[""].each_slice(3){|a,b,c|puts a+b+c*($*.max-(a*2+b).size)+a.reverse}

Somewhat similar to Keith's solution.

APL (78)
{∧/⎕D∊⍨I←⍞:{∆,('-'⍪⍵⍪'-'),∆←'.|'''/⍨1(⊃⍴⍵)1}⍕⍪/{⍵↑[2]⍨⌈/⊃∘⌽∘⍴¨∆}¨∆←∇¨⍳⍎I⋄⍉⍪I}⍬

whats this i dont even

I can't get this to run on tio.run to test the solution. Otherwise I'd switch the accepted answer as well.

Python - 355 314 259 chars
w=0
def p(n,l):
 global w;f=[(l-1,0)]
 for k in' '*n:
  i=raw_input()
  try:f+=p(int(i),l+1)
  except:f+=[(l,i)];w=max(w,4*l+len(i))
 return f+[(l-1,1)]
for l,s in p(input(),1):p=w-4*l-2;print'| '*l+(".'"[s]+'-'*p+".'"[s]if s<2 else s+' '*(p+2-len(s)))+' |'*l

almost a 100 char reduction, good job.

C, 390 366 363 characters
#define F(n)for(int i=n;i--;)
#define H(n,s,a...)F(n)printf(s);printf(a);
#define I(s)H(v,"| ",s)H(l-2,"-",s)J
#define J H(v," |","\n")
S[1<<17][26],N[1<<17],P,a;E(p){int l=strlen(gets(S[p]));if(sscanf(S[p],"%d",N+p))F(N[p])l<(a=E(++P))?l=a:l;return l+4;}R(p,v,l){if(N[p]){I(".")F(N[p])R(++P,v+1,l-4);I("'")}else{H(v,"| ","%-*s",l,S[p])J}}main(){R(P=0,0,E(0)-4);}

Compile with gcc -std=gnu99 -w file.c
Not even close to Keith's version, but hey, it's good ol' C

Passes only 159 of the 160 tests here.

Ouch. I think now it's OK. I was forgeting to allocate space for the \0 in the extreme case.

Looks still the same, Test #142 fails. By the way, the actual extreme case isn't even present as it has 10 MiB input and 78 MiB output. I didn't want the test script to be that large ;-)

weird, i'm getting 160/160 passed (I meant a string of 100 characters, which isn't present anyway)

Hm, weird. FreeBSD 8.2-RELEASE #5: Sun Feb 27 10:40:25 CET 2011 with gcc version 4.2.1 20070719  [FreeBSD] on x64 here. I'll take your word for the 160, then :-). And there should be a test case with 100 characters, actually (Tests 143–147).

Mh, this segfaults for me when trying the worst-case input (check Joey's 2nd update to the question). If you don't have/want Mono, I can either upload an example input for which your program fails or port the input generator to Python or something else.

I'm sorry.. the arrays were too small for extremely large inputs. Now it's fixed (the maximum number of lines is 111111 which, for some reason, I failed to see at first)

Ruby 1.9, 229 228 226 223 222
g=->n{(1..n).map{g[Integer l=gets.chop]rescue l}}
w=->b{b.bytesize rescue b.map{|e|w[e]}.max+4}
p=->b,c{r=c-2
[?.+?-*r+?.,*b.map{|i|p[i,c-4]}.flatten.map{|k|"| #{k} |"},?'+?-*r+?']rescue[b.ljust(c)]}
puts p[b=g[1][0],w[b]]

Haskell, 297 characters
f§(a,b)=(f a,b)
h c=(c,'-',c)
b l=h".":map(\(p,f,q)->("| "++p,f,q++" |"))l++[h"'"]
y[]s z=([(s,' ',"")],z)
y[(n,_)]_ z=b§foldr(\_(l,w)->(l++)§x w)([],z)[1..n]
x(a:z)=y(reads a)a z
m(p,_,q)=length$p++q
n®a@(p,c,q)=p++replicate(n-m a)c++q++"\n"
o(l,_)=l>>=(maximum(map m l)®)
main=interact$o.x.lines

While golf'd, the method is pretty straight forward. Only limits are available memory.

very functional python, 460 characters
r=range
s=lambda x:isinstance(x,str)
w=lambda x:reduce(max,[len(i)if s(i)else w(i)+4 for i in x])
z=lambda b,x:''.join(b for i in r(x))
def g(n=1):
 t=[]
 for i in r(n):
  x=raw_input('')
  try:t+=[g(int(x))]
  except:t+=[x]
 return t
o=list.append
def y(c,m):
 f='| ';h=' |';e=z('-',m+2);a='.'+e+'.';b="'"+e+"'";t=[a]
 for i in c:
  if s(i):o(t,f+i+z(' ',m-len(i))+h)
  else:[o(t,f+j+h)for j in y(i,m-4)]
 return t+[b]
x=g()[0];m=w(x);print '\n'.join(y(x,m))

Hm, this doesn't seem to work for me the | characters aren't spaced correctly. It is very similar to my python solution

Indeed, does not pass any of the test cases. eordano: We included those so that no one would submit answers that are plain wrong anymore.

I guess I pasted an old version of the code. Should work now. Sorry about being unprofessional.

Works for me! Nice solution, I like the functional approach.

Indeed, works now.

PHP, 403 388 306 chars
<?b((int)fgets(STDIN),'');foreach($t as $r)echo$r[0].str_pad($r[2],$w-2*strlen($r[0]),$r[1]).strrev($r[0])."\n";function b($c,$p){global$t,$w;$t[]=array($p.".","-");while($c--){if(($d=trim(fgets(STDIN)))>0)b($d,"| ".$p);else$t[]=array("| ".$p," ",$d);$w=max($w,strlen($d.$p.$p)+4);}$t[]=array($p."'","-");}

Ungolfed:
box((int)fgets(STDIN), '');

foreach($table as $row) {
    $prefix = $row[0];
    $pad = $row[1];
    $data = $row[2];
    echo $prefix . str_pad($data, ($width - 2*strlen($prefix)), $pad) . strrev($prefix)."\n";
}

function box($count,$prefix) {
    global $table, $width;
    $table[] = array($prefix.".","-");
    while($count--) {
        if(($data = trim(fgets(STDIN))) > 0) {
            box($data, "| ".$prefix);
        } else {
            $table[] = array("| ".$prefix, " ", $data);
        }
        $width = max($width,strlen($data.$prefix.$prefix)+4);
    }
    $table[] = array($prefix."'","-");
}
?>

I borrowed the prefix-idea from Keith (is that allowed at all?), otherwise this is pretty much as the original. Still couldn't get below 300. Stuck with this. Onwards.

Well, code is public here in every case, so borrowing ideas is allowed and perhaps even encouraged. I think that is also something that differentiates this site from other, similar ones. As gnibbler one noted we compete and collaborate at the same time.

C# -1005 859 852 782 characters
using c=System.Console;using System.Linq;class N{static void Main(){new N();}N(){var i=R();c.WriteLine(i.O(0,i.G().W));}I R(){var s=c.ReadLine();int l=0,i=0;if(int.TryParse(s,out l)){var b=new I(l);for(;i<l;){b.m[i++]=R();}return b;}else{return new I(0,s);}}class P{public int W;public int H;}class I{public I[]m;bool z;string t;public I(int l,string r=""){z=l!=0;m=new I[l];t=r;}public P G(){var s=new P();if(z){var d=m.Select(i=>i.G());s.W=d.Max(y=>y.W)+4;s.H=d.Sum(y=>y.H)+2;}else{s.W=t.Length;s.H=1;}return s;}public string O(int l,int w){if(z){string s=A(l,"."+"-".PadRight(w-2,'-')+"."),e=s.Replace(".","'");foreach(var i in m){s+="\n"+i.O(l+1,w-4);}s+="\n"+e;return s;}else{return A(l,t.PadRight(w));}}}static string A(int l,string o){while(l-->0){o= "| "+o+" |";}return o;}}

I need to take another look at this as I'm sure it can be improved, but this is my initial go third pass at it.
Ungolf'd:
using c=System.Console;
using System.Linq;

class NestedBoxes
{
    static void Main()
    {
        new NestedBoxes();
    }
    NestedBoxes()
    {
        var item = ReadItem();
        c.WriteLine(item.Print(0, item.GetSize().Width));
    }
    Item ReadItem()
    {
        var line = c.ReadLine();
        int count = 0, i = 0;
        if (int.TryParse(line, out count))
        {
            var box = new Item(count);
            for (; i < count;)
            {
                box.items[i++] = ReadItem();
            }
            return box;
        }
        else
        {

            return new Item(0,line);
        }
    }
    class Size
    {
        public int Width;
        public int Height;
    }
    class Item
    {
        public Item[] items;
        bool isBox;
        string text;
        public Item(int size,string word="")
        {
            isBox = size != 0; items = new Item[size]; text = word;
        }
        public Size GetSize()
        {
            var s = new Size();
            if (isBox)
            {
                var sizes = items.Select(i => i.GetSize());
                s.Width = sizes.Max(y => y.Width) + 4; s.Height = sizes.Sum(y => y.Height) + 2;
            }
            else
            {
                s.Width = text.Length;
                s.Height = 1;
            }
            return s;
        }
        public string Print(int level, int width)
        {
            if (isBox)
            {
                string output = AddLevels(level, "." + "-".PadRight(width - 2, '-') + "."),
                        bottomLine = output.Replace(".", "'");
                foreach (var item in items)
                {
                    output += "\n" + item.Print(level + 1, width - 4);
                }
                output += "\n" + bottomLine;
                return output;
            } else {return AddLevels(level, text.PadRight(width)); }
        }
    }
    static string AddLevels(int level, string output)
    {
        while(level-->0)
        {
            output = "| " + output + " |";
        }
        return output;
    }
}

@Joey, yeah, I definitely need to go through it all again.  Need to play with the logic to try and cut it down also.

I'm not familiar with C, but in JS, you can combine multiple var statements to one, like this: var a = 1, b = 2, c = 3;. Can't you do the same thing in C?

@Nyuszika7H, this is C#, not C.  You can't combine implicit var statements like that.  You can only combine if they have an explicit type like Joey mentioned using string b="",e="".

@RebeccaChernoff: I worked on the other guys answer, 689 now.

@NickLarsen, nice - but I'm not looking. q:  I still need some time to go through mine.  This was my initial go at logic, I'm sure there are places I can be smarter about the logic, just need time to give it attention.

You still have an unnecessary space at the very end of your code in o= "| "+o+" |";.

PHP, 806 769 721 653 619 chars
<?php function A($a,$b,$c,&$d){for($e=$b;$e>0;$e--){$f=fgets($a);if(false===$f){return;}$g=intval($f);if(0<$g){$h[]=A($a,$g,$c+1,$d);}else{$f=trim($f);$h[]=$f;$j=strlen($f)+4*$c;if($d<$j){$d=$j;}}}return $h;}$d=0;$h=A(STDIN,intval(fgets(STDIN)),1,&$d);function B($k,$c,$d){$f=str_pad('',$d-4*$c-2,'-',2);return C($k.$f.$k,$c,$d);}function C($f,$c,$d){$f=str_pad($f,$d-4*$c,' ');$f=str_pad($f,$d-2*$c,'| ',0);$f=str_pad($f,$d,' |');return $f;}function D($l,$c,$d){if(!is_array($l)){echo C($l,$c,$d)."\n";return;}echo B('.',$c,$d)."\n";foreach($l as $m){echo D($m,$c+1,$d);}echo B('\'',$c,$d)."\n";}D($h,0,$d);exit(0);?>

Ungolfed version:
<?php
function read_itemgroup($handle, $item_count, $depth, &$width) {

    //$items = array();

    for($i = $item_count; $i > 0; $i--) {
        $line = fgets( $handle );
        if(false === $line) {
            return;
        }

        $line_int = intval($line);
        if(0 < $line_int) {
            // nested group
            $items[] = read_itemgroup($handle, $line_int, $depth + 1, $width);
        }
        else {
            // standalone item
            $line = trim($line);
            $items[] = $line;

            // determine width of item at current depth
            $width_at_depth = strlen($line) + 4 * $depth;
            if($width < $width_at_depth) {
                $width = $width_at_depth;
            }
        }
    }

    return $items;
}
$width = 0;
$items = read_itemgroup(STDIN, intval(fgets( STDIN )), 1, &$width);

//var_dump($items, $width);

function render_line($corner, $depth, $width) {
    $line = str_pad('', $width - 4 * $depth - 2, '-', 2); // 2 = STR_PAD_BOTH
    return render_item($corner . $line . $corner, $depth, $width);
}

function render_item($line, $depth, $width) {
    $line = str_pad($line, $width - 4 * $depth, ' ');
    $line = str_pad($line, $width - 2 * $depth, '| ', 0); // 0 = STR_PAD_LEFT
    $line = str_pad($line, $width, ' |');
    return $line;
}

function render($item, $depth, $width) {
    if(!is_array($item)) {
        echo render_item($item, $depth, $width) . "\n";
        return;
    }
    echo render_line('.', $depth, $width) . "\n";
    foreach($item as $nested_item) {
        echo render($nested_item, $depth + 1, $width);
    }
    echo render_line('\'', $depth, $width) . "\n";
}

render($items, 0, $width);

exit(0);
?>

Why're you using two-letter function names instead of one-letter ones?

@Lowkacler: good catch, that's one thing that I still need to optimize. I didn't have any minifier at hand, so I did that manually. I also have several ideas on what to enhance (codewise, not minification), so I'll post a revised version later on.

First of all, this is missing a <? in the beginning to even run. Then you're apparently using the maximum length of all text items in a test case as the width for the innermost box. This code only passes 118 of the test cases (tested on Linux and FreeBSD). I have no idea what you did to the PowerShell script that it wouldn't run, though :-(. Invoking it as powershell -noprofile -file test.ps1 php boxes.php should work, actually. But I have no PHP on my Windows machine to test.

Tested this on my box using the latest bash script, got 118/156. I put the output on a gist

@Juan: thank you very much for that, kind sir! :-)

@Joey: thank you for pointing that out, I fixed the length detection and included the <? tags respectively. Your invocation example helped me to capture the output to a file, thank you for providing it. It seems that the tests fail due to different linebreaks. The test expects \r\n, but I cannot achieve that on Windows (CLI seems to override it). I uploaded output from the recent script to gist: https://gist.github.com/948083

MicE: I updated the PowerShell test script; it expected whatever line endings it was saved with, which was the problem you (and others) encountered. It should be fixed now and work with whatever line endings you throw at it.

@Joey: thank you, that did the trick! 156/156 passed :-)

Nice to hear :). That's what I get for writing a test script that was initially intended for single-line output ;-)

Java - 681 668 chars
import java.util.*;public class b{static int m,h,i;public static void main(String[]a)throws Throwable{for(Object o:z("")){a=(String[])o;String s=a[0]+a[1];i=a[0].length();for(h=0;h<m-i*2-a[1].length();h++){s+=a[2];}for(h=i;h>0;h--){s+=a[0].charAt(h-1);}System.out.println(s);}}static List z(String p)throws Throwable{String b="",d="";List l=new ArrayList();while((i=System.in.read())>-1){if(10==i){if(d!=""){String[]v={p+".",b,"-"},t={p+"'",b,"-"};l.add(v);for(int u=0;u<Integer.parseInt(d);u++){l.addAll(z(p+"| "));}l.add(t);}else{h=b.length()+p.length()*2;if(m<h)m=h;String[]v={p,b," "};l.add(v);}break;}else if(i>47&&i<58){d+=(char)i;}else {b+=(char)i;}}return l;}}

essentially the same method as Keith Randall's Python code
Ungolfed version:
import java.util.*;

public class b {
    static int m, h, i;

    public static void main(String[] a) throws Throwable {
        for (Object o : z("")) {
            a = (String[]) o;
            String s = a[0] + a[1];
            i = a[0].length();
            for (h = 0; h < m - i * 2 - a[1].length(); h++) {
                s += a[2];
            }
            for (h = i; h > 0; h--) {
                s += a[0].charAt(h - 1);
            }
            System.out.println(s);
        }
    }

    static List z(String p) throws Throwable {
        String b = "", d = "";
        List l = new ArrayList();
        while ((i = System.in.read()) > -1) {
            if (10 == i) {
                if (d != "") {
                    String[] v = { p + ".", b, "-" }, t = { p + "'", b, "-" };
                    l.add(v);
                    for (int u = 0; u < Integer.parseInt(d); u++) {
                        l.addAll(z(p + "| "));
                    }
                    l.add(t);
                } else {
                    h = b.length() + p.length() * 2;
                    if (m < h)
                        m = h;
                    String[] v = { p, b, " " };
                    l.add(v);
                }
                break;
            } else if (i > 47 && i < 58) {
                d += (char) i;
            } else {
                b += (char) i;
            }
        }
        return l;
    }
}

I think you can get rid of one space each time there is a throws.

yes! also elminated a few more chars. (can assume each line is terminated with newline char, redundant break;)

probably could finesse the char comparisons by looking at ascii codes for longer...but i have to go get ready for vacation

Perl - 200 199 chars
Same algorithm as Keith Randall's Python (nice design, Keith), but a tiny bit more compact in this Perl take on it.
sub P{$_=<>;chop;$m>($l=length"$_@_@_")or$m=$l;/^\d/?(["@_.","","-"],(map{P("| @_")}1..$_),["@_'","","-"]):["@_",$_," "]}map{($q,$t,$f)=@$_;print"$q$t",($f x($m-length"$q$t$q")).reverse($q),"\n"}(P);

$_@_@_ looks like someone chasing the dollar sign

F# - 341 characters
let rec f(x,y)=[
 let l=stdin.ReadLine()
 let q,d=Core.int.TryParse l
 if q then
  yield x+".","",'-',"."+y
  for i=1 to d do yield!f(x+"| ",y+" |")
  yield x+"'","",'-',"'"+y
 else yield x,l,' ',y]
let l=f("","")
for w,x,y,z in l do printfn"%s"(w+x.PadRight(List.max(l|>List.map(fun(w,x,y,z)->2*w.Length+x.Length))-2*w.Length,y)+z)

An F# version of Keith's solution. Lists are immutable by default, so this version stuffs the entire recursive function into a list, returns the list, from which the items are extracted using the for..do loop and a yield!. I couldn't find a way to reverse the prefix concisely, so I just attached the suffix onto the triples.
FYI, the TryParse method returns a double (bool,int).

Clojure - 480 chars
(use '[clojure.contrib.string :only (repeat)])(let [r ((fn p[%](repeatedly % #(let [x (read-line)](try(doall(p(Integer/parseInt x)))(catch Exception e x))))) 1)]((fn z[m,n,o] (let[b #( let[p(dec o)](println(str(repeat p "| ")%(repeat(- m(* 4 p)2)"-")%(repeat p " |"))))](b \.)(doseq[i n](if(seq? i)(z m i(inc o))(println(str(repeat o "| ")i(repeat(- m(count i)(* o 4))" ")(repeat o " |")))))(b \')))((fn w[x](reduce max(map(fn[%](if(seq? %)(+ (w %)4)(count %)))x)))r)(first r) 1))

This is my first Clojure program as well as my first Clojure golf attempt, so, needless to say, this shouldn't be taken as representative of Clojure solutions in general. I'm sure it could be shortened significantly, especially if Keith Randall's method of parsing and building the boxes at once was implemented.

Man, half of this source must be whitespace. And mandatorily so :-). Interesting, though and I wonder whether one will see a Lisp variant win a code golf ;-)

I'm sure its possible... though like I said, I'm probably not going to be the one to do it.

Scala - 475 characters
object N2 extends App{type S=String;def b(x:List[S],t:Int,s:S,e:S):List[S]={var l=x;o=o:+(s+".-±-."+e+"-");for(i<-1 to t)if(l.head.matches("\\d+"))l=b(l.tail,l.head.toInt,s+"| ",e+" |")else{o=o:+(s+"| "+l.head+"±"+e+" | ");l=l.drop(1)};o=o:+(s+"'-±-'"+e+"-");return l};var o:List[S]=List();val l=io.Source.stdin.getLines.toList;b(l.tail,l.head.toInt,"","");(o map(x=>x.replaceAll("±",x.last.toString*((o sortBy((_:S).length)).last.length-x.length)).dropRight(1)))map println}

C# - 472 470 426 422 398 characters
using System.Linq;using y=System.Console;class W{static void Main(){var c=new int[5];var s=new string[0].ToList();int n=0,i;var l="";do{try{c[n]=int.Parse(l=y.ReadLine());l=".{1}.";n++;i=1;}catch{l+="{0}";i=0;}G:while(i++<n)l="| "+l+" |";s.Add(l);if(n>0&&--c[n-1]<0){n--;l="'{1}'";i=0;goto G;}}while(n>0);s.ForEach(z=>y.WriteLine(z,l="".PadLeft(s.Max(v=>v.Length)-z.Length),l.Replace(' ','-')));}}

Nice. A goto! By the way, you can omit the parentheses around the lambda arguments z and v, bringing this down to 421.

C# 1198 1156 1142 689 671 634 Characters
using z=System.Console;using System.Collections.Generic;using System.Linq;
class T{bool U;List<T> a=new List<T>();string m;IEnumerable<string>R(int s){if(U){yield return ".".PadRight(s-1,'-')+".";foreach(var e in a.SelectMany(b=>b.R(s-4)))yield return ("| "+e).PadRight(s-e.Length)+" |";yield return "'".PadRight(s-1,'-')+"'";}else yield return m;}int L(){return U?a.Max(x=>x.L())+4:m.Length;}
static void Main(){var p=O(int.Parse(z.ReadLine()));z.WriteLine(string.Join("\r\n",p.R(p.L())));}
static T O(int n){var k=new T(){U=true};while(n-->0){var l=z.ReadLine();int c;k.a.Add(int.TryParse(l,out c)?O(c):new T{m=l});}return k;}}

Ungolfed version is up on github - https://github.com/paulduran/CodeGolf

Joining with \n appears to suffice in the end.

Getting rid of the interface freed up a lot of characters, the rest was mostly standard golfing.  There is plenty more that can be done here, I would expect this could get below 600.

Nice work Nick. I suspected the interface was a bit of overkill, to be honest. a simple flag would have sufficed in this situation as u have shown.

Java (1369 chars incl. EOLs)
Couldn't leave this without a Java implementation. Java is supposed to be more verbose that the slicks of Python and Ruby, so I went for an elegant, recursive solution.
The idea is a Tree (Graph) of objects (strings and boxes), containing one another starting from a "head" box. As you linearly parse the input file you add strings and boxes to the "current" box and while you are adding the maximum length of the container is adjusted. When a container reaches the amount of predefined items that it can hold you backtrack to the previous container. At the end of the input file, you have a "head" container that already has a "maxLength" calculated, so you simply call its print() method.
import java.io.*;import java.util.*;
public class N{private static String rPad(String s,int l){return s+str(l-s.length(),' ');}
private static String str(int l, char c){StringBuffer sb=new StringBuffer();while(l-->0){sb.append(c);}return sb.toString();}
private static class Box {Box prnt=null;String txt=null;int items;List<Box> c=new ArrayList<Box>();int maxLength=0;
public Box(Box p,int n){prnt=p;items=n;if(p!=null){p.c.add(this);}}
public Box(Box p,String s){prnt=p;txt=s;if(p!=null){p.c.add(this);p.notify(s.length());}}
public void print(String prefix,int l,String suffix){if (txt == null){System.out.println(prefix+"."+str(l-2,'-')+"."+suffix);for(Box b:c){b.print(prefix+"| ",l-4," |"+suffix);}System.out.println(prefix+"'"+str(l-2,'-')+"'"+suffix);}else{System.out.println(prefix+rPad(txt,l)+suffix);}}
protected void notify(int l){if (l+4>this.maxLength){this.maxLength=l + 4;if (this.prnt != null){this.prnt.notify(this.maxLength);}}}}
public static void main(String[] args)throws IOException{Box head=null;Box b=null;BufferedReader in=new BufferedReader(new InputStreamReader(System.in));String s;while ((s=in.readLine()) != null){try{int n=Integer.parseInt(s);b=new Box(b, n);}catch (NumberFormatException nfe){b=new Box(b, s);}if(head == null)head=b;while ((b != null) && (b.items == b.c.size())){b=b.prnt;}}head.print("",head.maxLength,"");}}

It is really an enjoyable solution to write. I liked the question a lot. As I mentioned earlier, I went for solution elegance not minimalist approach, sadly Java doesn't have Python's print "-"*4 to produce "----" :-)
Here's the ungolfed version:
import java.io.*;
import java.util.*;

public class NestedBoxes
{

    private static String rPad ( String s, int l )
    {
        return s + str(l - s.length(), ' ');
    }

    private static String str ( int l, char c )
    {
        StringBuffer sb = new StringBuffer();
        while (l-- > 0)
        {
            sb.append(c);
        }
        return sb.toString();
    }

    private static class Box
    {

        Box parent = null;
        String text = null;
        int items;
        List<Box> contents = new ArrayList<Box>();

        int maxLength = 0;

        public Box ( Box p, int n )
        {
            parent = p;
            items = n;
            if (p != null)
            {
                p.contents.add(this);
            }
        }

        public Box ( Box p, String s )
        {
            parent = p;
            text = s;
            if (p != null)
            {
                p.contents.add(this);
                p.notify(s.length());
            }
        }

        public void print ( String prefix, int l, String suffix )
        {
            if (text == null)
            {
                System.out.println(prefix + "." + str(l - 2, '-') + "." + suffix);
                for (Box b : contents)
                {
                    b.print(prefix + "| ", l - 4, " |" + suffix);
                }
                System.out.println(prefix + "'" + str(l - 2, '-') + "'" + suffix);
            }
            else
            {
                System.out.println(prefix + rPad(text, l) + suffix);
            }
        }

        protected void notify ( int l )
        {
            if (l + 4 > this.maxLength)
            {
                this.maxLength = l + 4;
                if (this.parent != null)
                {
                    this.parent.notify(this.maxLength);
                }
            }
        }
    }

    public static void main ( String[] args ) throws IOException
    {
        Box head = null;
        Box b = null;
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        String s;
        while ((s = in.readLine()) != null)
        {
            try
            {
                int n = Integer.parseInt(s);
                b = new Box(b, n);
            }
            catch (NumberFormatException nfe)
            {
                b = new Box(b, s);
            }

            if (head == null)
            {
                head = b;
            }

            while ((b != null) && (b.items == b.contents.size()))
            {
                b = b.parent;
            }
        }
        head.print("", head.maxLength, "");
    }
}

You know, this is a code golf. You should at least try aiming for a small solution. Elegance is all nice and well, but not actually required nor wanted here.

Pip, 89 bytes (non-competing)
(The language is newer than the challenge. Also, I couldn't quite outgolf APL.)
Code is 87 bytes, +2 for -rn flags.
(z:{I+YPOi{Y{Vz}M,ym:MX#*Y$ALyY'|.s._.sX++m-#_.'|MyY".."J'-X++mALyAL"''"J'-Xm}yALl}i:g)

Try it online!
The function z processes the first item of the input list (g, copied into global variable i so as to be available inside function calls). If this is a number n, it calls itself recursively n times, pads the resulting list of lines to a full rectangle, wraps each line in "| " " |", and adds .---. and '---' lines before returning the new list. If it is a string, it simply converts it to a one-item list and returns it. The final result is printed newline-separated (-n flag). More detail available on request.

I usually don't have a problem with languages newer than the challenge, especially considering that the problem isn't so trivial that a newly-created language would have operations specifically for solving it :-)

This fails the fourth sample.


text:
How to determine if a number is odd or even without mod -or- bitwise operations?
How to determine if a number is odd or even without mod -or- bitwise operations?
This challenge is grossly inefficient, but challenges your ability to think outside the box for a creative solution.
EDIT:
Please create a function. Also, while regex is a fun response, the function should accept any valid number.
BACKGROUND:
This question stems from my earliest programming days.  The homework for our first day of class was to write a simple program that printed 'odd' or 'even'.  Being the brat I was, I didn't read the book we had for the class where it simply showed us how to use % to determine that.  I spent about a half hour pacing back in forth in my room trying to think of a way to do this and had remembered from the lecture that numbers can lose and gain precision as they are cast from one primitive type to another.  Therefore, if you took the number, divided it by two and then multiplied it back didn't equal the original number, then you would know that the number was odd.
I was stunned the next day, while our instructor was evaluating our programs, that he thought that it was the most original, if inefficient, way of solving the problem.

Should we create a function or a program? How should IO happen if we have to do a program? Please, elaborate further.

What objective criterion will determine the accepted answer? Code size? Something else?

Is it definitely a number?  Should it give false positives for a string?

This has been around for quite a long time, but there doesn't seem to be a winning condition of any kind, which to my mind means there is no game here.

In most programming languages division returns quotient for integers. So you can simply check this
(i/2)*2==i

Not necessarily most, I'd say. Many, maybe.

to ensure it runs properly, you need to make sure you cast everything into an int/long type

@warren Depends on the programming language/compiler optimizations/etc. Additionally, you can use floor(). That works perfectly in C and C++.

I marked yours as the answer because it had the widest usability in different languages.  It also happened to be the solution I came up with eons ago to solve the same problem. :)

Is 0 a even number?

@userunknown: Yes, zero is even.

Python
print('even' if (-1)**n==1 else 'odd')

The simple beauty / beautiful simplicity of mathematics...very nice!

I like this one a lot.

Slow but creative.

Mathematica
SawtoothWave[x / 2] == 0
Exp[I Pi x] - 1 == 0
Sin[5 x / Pi] == 0

Can you split these two solutions into different answers?

Aren't those four solutions?

Actually, all built-in names in Mathematica are capitalized, so as funny as it looks, you should use I and Pi instead of i and pi.

Brainf*** (179)
This is one of the more interesting problems involving conditional logic that I have done in BF.
+[>,]<--------------------------------------->>+++++[>+++++++
++++++>+++++++++++++++<<-]>++++>++++<<+<+<-[>-<-[>+<-[>-<-[>+<-[>-<-[>
+<-[>-<-[>+<-[>-<[-]]]]]]]]]]>[>>>.<<-<-]>[>.<-]

It takes a text input with a number. If the number is even, it outputs E, and if it is odd, it outputs O.
I'm proud enough of it that I'll show off a more human readable form:
+[>,]                                                   steps through input until it reaches eof.
<---------------------------------------                gets the numerical value of the last digit
>>+++++[>+++++++++++++>+++++++++++++++<<-]>++++>++++    store E and O
<<+<+<                                                  store a bit indicating parity, and a temporary bit
-[>-<                                                   !1
  -[>+<                                                 && !2
    -[>-<                                               && !3
      -[>+<                                             && !4
        -[>-<                                           && !5
          -[>+<                                         && !6
            -[>-<                                       && !7
              -[>+<                                     && !8
                -[>-<[-]]                               && !9
              ]
            ]
          ]
        ]
      ]
    ]
  ]
]
>[>>>.<<-<-]>[>.<-]                                     Display E or O based on the value of the parity bit.

C
Multiplied by itself a few times any even number will overflow to 0 given a finite size integer, and any odd number will continue to have at least the least significant bit set.
#include "stdio.h"
long long input=123;
int main(){
    int a;
    for(a=6;a;a--){
        input*=input;
    }
    if(input){
        printf("Odd");
    }
    else{
        printf("Even");
    }
    return 0;
}

Edit: As a simple function:
int isOdd(long long input){
    int a;
    for(a=6;a;a--){
        input*=input;
    }
    return !!input;
}

Be sure to use unsigned integers.  Overflow of signed integers is undefined behavior in C, so optimization could do something weird if it wanted.

JavaScript
/[02468]$/.test(i)

yields true for an even number. This only works with reasonably sized integers (e.g. not scientific notation when converted to a string and not having a fractional part.)

To meet the "function" requirement you could change it to simply /[02468]$/.test.

It wasn't exactly clear in the question but it could be possible that the input isn't a number at all, /[02468]$/.test('I am a fake even number 0').  In that case you could do /^[0-9].[02468]$/.test(i)

/-?^\d*[02468]$/ would be a little stricter than your regex. You would need more work for this to work properly for numbers that are toString'ed using scientific notation.

Python (Slow)
n=1234
while n > 1: n -= 2 #slow way of modulus.
print "eovdedn"[n::2]

Works for positive...i suppose i could add a abs() call in the beginning.

@Josh: That trick appeared here a few times already by now :)

Credits to gnibblr :)

@Joey: I didn't figure it was new, but style doesn't have to be original. :)

Python
Since I'm not really sure what the scoring criteria are, here's a bunch of solutions I've come up with for amusement's sake. Most of them use abs(n) to support negative numbers. Most, if not all, of them should never be used for real calculation.
This one is kind of boring:
from __future__ import division
def parity(n):
    """An even number is divisible by 2 without remainder."""
    return "Even" if n/2 == int(n/2) else "Odd"

def parity(n):
    """In base-10, an odd number's last digit is one of 1, 3, 5, 7, 9."""
    return "Odd" if str(n)[-1] in ('1', '3', '5', '7', '9') else "Even"

def parity(n):
    """An even number can be expressed as the sum of an integer with itself.

    Grossly, even absurdly inefficient.

    """
    n = abs(n)
    for i in range(n):
        if i + i == n:
            return "Even"
    return "Odd"

def parity(n):
    """An even number can be split into two equal groups."
    g1 = []
    g2 = []
    for i in range(abs(n)):
        g1.append(None) if len(g1) == len(g2) else g2.append(None)
    return "Even" if len(g1) == len(g2) else "Odd"

import ent # Download from: http://wstein.org/ent/ent_py
def parity(n):
    """An even number has 2 as a factor."""
    # This also uses modulo indirectly
    return "Even" if ent.factor(n)[0][0] == 2 else "Odd"

And this is my favorite although it unfortunately doesn't work (as pointed out by March Ho below: just because all even numbers are the sum of two primes, doesn't mean that all odd numbers aren't).
import itertools
import ent    # Download from: http://wstein.org/ent/ent_py
def parity(n)
    """Assume Goldbach's Conjecture: all even numbers greater than 2 can
    be expressed as the sum of two primes.

    Not guaranteed to be efficient, or even succeed, for large n.

    """
    # A few quick checks
    if n in (-2, 0, 2): return "Even"
    elif n in (-1, 1): return "Odd"
    if n < 0: n = -n    # a bit faster than abs(n)
    # The primes generator uses the Sieve of Eratosthenes
    # and thus modulo, so this is a little bit cheating
    primes_to_n = ent.primes(n)
    # Still one more easy way out
    if primes_to_n[-1] == n: return "Odd"
    # Brutish!
    elif n in (p1+p2 for (p1, p2) in itertools.product(primes_to_n, primes_to_n)):
        return "Even"
    else:
        return "Odd"

Cute solutions :-)

Really an old necro, but doesn't your Goldbach's conjecture answer print Even for 9? Seems like a case of affirming the consequent fallacy

Yup, you're absolutely, one hundred percent right, @MarchHo. Egg on my face.

Haskell
This is, of course, in no way the creative, thinking-outside-the-box solution you're looking for, but how many times am I going to get to post a Haskell answer shorter than GolfScript, really?  It's really a shame this isn't a code golf.
odd

But more seriously:
data Parity = Even | Odd
            deriving (Show)

parity = p evens odds
  where p (x:xs) (y:ys) i | i == x = Even
                          | i == y = Odd
                          | otherwise = p xs ys i
        evens = interleave [0,2..] [-2,-4..]
        odds = interleave [1,3..] [-1,-3..]
        interleave (x:xs) ys = x : interleave ys xs

looks longer than the GolfScript answer to me

I was referring to the first block (odd) which is a builtin function that returns True if the number is odd.  That's a complete answer on its own and shorter than the current GolfScript answer (which at the time of writing this is 10 chars, but I expect that to go down).  The question is also a bit underspecified, which is why I assert that odd is sufficient.  That may change as well.

missed the first reply in your answer :)

At the very least the parity algorithm works on all Num instances that are integers. That's hot! Though I probably would have done evens = [0,2..] >>= \n -> [-n, n]. Similar for odds.

Using a deliberately perverse reading of the question, "How to determine if a number is odd or even", here's a C implementation (assume bool and true are defined appropriately):
bool is_odd_or_even(int n)
{
    return true;
}

The question mentions number, not integer. Number like 0.5 returns true when it shouldn't.

What, no randomized algorithms yet??
C
#include<stdio.h>
#include<stdlib.h>

void prt_parity_of(int n){
  int i,j=2;
  char o[]="eovdedn"
     , f[n=abs(n)]; for(i=n;i-->0;f[i]=1);

  while(j>1){
    while((i=rand()%n)
       == (j=rand()%n)
       || (f[i]&f[j]>0)
       && (f[i]=f[j]=0)
    );for(i=j=0; ++i<n; j+=f[i])
  ;}for(;j<7;j+=2)putchar(o[j]);
}

Randomly pairs numbers in the range 0..n-1 until less than 2 are left. It's quite amazingly inefficient: O(n3).

Completely different:
Haskell
import Data.Complex

ft f = (\ω -> sum[ f(t) * exp(0:+2*pi*ω*t) | t<-[-1,-0.9..1] ] )

data Parity = Even | Odd deriving (Show)

parity n
  | all (\(re:+im) -> abs re > abs im) [ft ((:+0).(^^n)) ω | ω<-[0..20]]  = Even
  | otherwise                                                             = Odd

Uses the fact that the Fourier transform of an even function (e.g. \x->x^^4) is real, while the Fourier transform of an odd function is imaginary.

Coq, 103
Fixpoint even n:=match n with O=>true|S n=>odd n end with odd n:=match n with O=>false|S n=>even n end.

As far as I can tell this is the first coq entry on codegolf.
Even shorter (59):
Fixpoint even n:=match n with O=>true|S n=>negb(even n)end.

Windows PowerShell
function OddOrEven([long]$n) {
  if (0,2,4,6,8 -contains "$n"[-1]-48) {
    "Even"
  } else {
    "Odd"
  }
}

Convert to string
Pick last letter (digit) (essentially a mod 10).
Check if it is 0, 2, 4, 6 or 8.

No bitwise operators, no modulus, as requested.

Ruby
n.odd?

If you want to print out the result:
f[n] = ->(n){puts n.odd?? 'odd' : 'even'}

I'm fairly use ruby uses mod in the .odd? definition.

Unlambda
The world needs more Unlambda.
Unlambda has a killer advantage here: its default (ahem) representation for numbers are Church numerals, so all that's needed is to apply them to function binary-not to function true.  Easy!
PS: Markdown and Unlambda are definitely not made for one another.
true  = i
false = `ki
not   = ``s``s``s`k``s``si`k`kk`k`kii`k`ki`ki
even? = ``s``si`k``s``s``s`k``s``si`k`kk`k`kii`k`ki`ki`ki

Verification for the first few integers:
```s``si`k``s``s``s`k``s``si`k`kk`k`kii`k`ki`ki`ki`ki                   => i
```s``si`k``s``s``s`k``s``si`k`kk`k`kii`k`ki`ki`kii                     => `ki
```s``si`k``s``s``s`k``s``si`k`kk`k`kii`k`ki`ki`ki``s``s`kski           => i
```s``si`k``s``s``s`k``s``si`k`kk`k`kii`k`ki`ki`ki``s``s`ksk``s``s`kski =>`ki

Golfscript
~,2/),1=\;

Python
print (["even"] + (["odd", "even"] * abs(n)))[abs(n)]

Similar performance to the earlier version. Works for 0 now.
Incorrect Earlier version:
print ((["odd", "even"] * abs(n))[:abs(n)])[-1]

Not particularly efficient; time and memory both obviously O(n): 32 msec for 1,000,000; 2.3 msec for 100000; 3.2 usec for 100. Works with negative numbers. Throws an error for 0, because 0 is neither even nor odd.

Zero is definitely even.  See also: http://en.wikipedia.org/wiki/Parity_of_zero

@jloy: Aw, crap. I thought that was "a feature, not a bug". More revisions...

Fractran
[65/42,7/13,1/21,17/7,57/85,17/19,7/17,1/3]

applied to
63*2^abs(n)

yields either 5 if n is odd or 1 if n is even.
Update: Much shorter but not so interesting:
[1/4](2^abs(n))

is 2 for odd n and 1 for even n.

Perl
What about
use Math::Trig;
print(cos(pi*@ARGV[0])>0?"even":"odd")

MMIX (4 Bytes)
This is kind of cheating. I use neither mod nor bit fiddling operations. It's rather that testing for odd / even numbers is builtin. Assuming that $3 contains the number to test and the result goes into $2:
ZSEV $2,$3,1

sets $2 to 1 if $3 is even and to 0 if not. The mnemnoric ZSEV means zero-set even and has the following semantics:
ZSEV a,b,c: if (even b) a = c; else a = 0;

For the above line, mmixal generates these four bytes of assembly:
7F 02 03 01

Scheme
This is the most inefficient solution I know of.
(letrec ([even? (lambda (n)
                 (if (zero? n) "even"
                     (odd? (- n 2))))]
         [odd? (lambda (n)
                 (if (= n 1) "odd"
                     (even? (- n 2))))])
  (even? (read)))

Python
zip((False, True)*(i*i), range(i*i))[-1][0]

testing the square of i, so it works for negative numbers too

F#
Mutual recursion for the win.
A number n is even if it is zero or (n-1) is odd.
A number n is odd if it is unequal to zero and (n-1) is even.
(abs added in case anyone's interested in the parity of negative numbers)
let rec even n = n = 0 || odd (abs n - 1)
    and odd n = n <> 0 && even (abs n - 1)

JavaScript, 36
function(i){while(i>0)i-=2;return!i}

Returns true if even, false if not.

Perl
$n x '0' =~ /^(00)*$/

Clojure
  (defmacro even?[n]
  `(= 1 ~(concat (list *) (repeat n -1))))

What qualifies as bitwise operations?  Under the hood, integer division by 2 is likely to be implemented as a bit-shift.
Assuming bitshifts aren't out:
C/C++
(unsigned char)((unsigned char)(n > 0 ? n : -n) << 7) > 0 ? "odd" : "even"

edit  Missed some parentheses, and ultimately changed to remove a shift to make it do less.  You can test this with the following (in *nix):
echo 'main(){ std::cout<< (unsigned char)((unsigned char)(n > 0 ? n : -n) << 7) > 0 \
        ? "odd\n" : "even\n";}' \
  | gcc --include iostream -x c++ -o blah -
./blah

... though in Linux/tcsh, I had to escape the backslash on \n even though it was in single-quotes.  I tested in little & big-endian, it works correctly in both.  Also, I hand-copied this; the computer I'm posting with doesn't have a compiler, so it may have mistakes.
x86 asm
            mov eax, n          # Get the value
            cmp eax,0           # Is it zero?
            jge pos_label       # If >= 0, skip the next part
            neg eax
pos_label:

.
            imul al, 128

or
            shl  al, 7

or
            lea  eax, [eax*8]    # Multiply by 2^3 (left-shift by 3 bits)
            lea  eax, [eax*8]    # ... now it's n*2^6
            lea  eax, [eax*2]    # ... 2^7, or left-shift by 7 bits

... followed by:
            cmp al,  0          # Check whether the low byte in the low word is zero or not
            jz  even_label      # If it's zero, then it was an even number
            odd_label           # ... otherwise it wasn't

Alternatively, the shift & compare stuff could be done this way as well:
            sar al,1            # signed integer division by 2 on least-significant byte
            jc  odd_label       # jump if carry flag is set

BTW, shl and friends are disallowed...

On a 68000 processor you could move a word value from the address defined by the value to test:
 move.l <number to test>,a0
 move.w (a0),d0
 ; it's even if the next instruction is executed

and let the hardware trap for address error determine the odd/even nature of the value - if the exception is raised, the value was odd, if not, the value was even:
 <set up address error trap handler>
 move.l <pointer to even string>,d1
 move.l <number to test>,a0
 move.w (a0),d0
 <reset address error trap handler>
 <print string at d1>
 <end>

 address_error_trap_handler:
 move.l <pointer to odd string>,d1
 rte

Doesn't work on Intel x86 CPUs as those are more flexible about data access.

Python
I decided to try for the ugliest, most confusing solution I could think of:
n=input();r=range(n+1)
print [j for i in zip(map(lambda x:str(bool(x))[4],[8&7for i in r]),
map(lambda x:str(x)[1],[[].sort()for x in r])) for j in i][n]

Prints e if even, o if odd.

Q
Keep subtracting 2 until x<2 then convert to bool
{1b$-[;2]/[2<=;abs x]}

Mathematica
Edit:
This is the unimaginative check that many folks, including me, use. If an integer ends in 0,2,4, 6,or 8, it is even, otherwise odd.
f[n_?IntegerQ] := Print[n, " is ",
If[MemberQ[{0, 2, 4, 6, 8}, IntegerDigits[n][[-1]]], "even.", "odd."]]

Original solution:
The following is even more unimaginative and uselessly slow  for "large" integers, but in principle, it works.
If an integer has 2 is its lowest prime factor, it is even.
f[n_?IntegerQ]:= Print[n, " is ", If[FactorInteger[n][[1, 1]] == 2, "Even", "Odd"]

scala:
scala> def evenOrOdd (n:Int) : Unit = n match {
     | case 0 => println ("even")
     | case 1 => println ("odd")
     | case _ => evenOrOdd (n-2) }
evenOrOdd: (n: Int)Unit

scala> evenOrOdd (123456789)
odd

(less than one second)

Are we allowed to submit utterly terrible ways to do this?  If so...
C
#include <stdio>

void oddOrEven(int number)
{
   char test[128];
   sprintf(test, "%d", number);

   int index = strlen(test) - 1;

   if((test[index]=='0')||(test[index]=='2')||(test[index]=='4')||
        (test[index]=='6')||(test[index]=='8'))
   {
      printf("Even.");
   } else {
      printf("Odd.");
   }
}

I apologize for any errors, I don't have a chance to compile or test this.  Fixed one bug, per comment by Joey Adams.
This answer is similar to the one posted by idealmachine

You'll need strlen(test) - 1 for this to work.  test[index] currently refers to the null terminator of the string.

@Joey Adams Thanks, I knew there'd be at least one bug.

Considering efficiency isn't a metric here, this solution is as good as any really.

For C or C++, easy enough:
int Temp = 20
double Temp2 = ((double)Temp/2);
Temp2 = Temp2 - ((int)Temp/2);
if(Temp2 != 0.0)
{
    printf("It's odd!\n");
}
else
{
    printf("It's even!\n");
}

Perl
sub is_odd {$#{[split/\./,$_[0]/2]}}

What's the $#{} do?

it dereferences the array references [] and returns the last index (i.e. N-1 since Perl indexes start at 0). This is essentially sub is_odd {$input = shift; $input /= 2; my @parts = split /\./, $input; return ( scalar(@parts) - 1) }

Thanks that cleared it up, I got the $#array bit but I missed that you were turning the ouput of split into a reference with [] then dereferenceing with ${} and adding the # to get the last index, very cool.

its essentially the babycart "operator" @{[]}, but the index of that :) http://www.mail-archive.com/fwp@perl.org/msg03595.html

Cool, thanks for the clarification

C++ (63)
Token absurd recursive solution. Even golfed!
#include <math.h>
bool o(int v){return v==0?false:!o(abs(v)-1);}

C#
Sorry for my previous response, I'm totally messed up today.
bool Even(int i){return i==0||!Even(i-1);}

function isEven(i) {
    return i == 0 || !isEven(i - (i > 0 ? 1 : -1));
}

return exp(sqrt(-1)*x*pi)==1?"even":"odd";

Nice approach, what language is this supposed to be, though? Exact complex arithmetic is quite uncommon outside CASs.

You got me there. I use Matlab a lot, but this isn't real Matlab code. Anyway, it could also be done with a cosine function and a real argument (x*pi).  And as far as exactness goes, even testing within limits would become a problem for large x. (This is my first code golf. Looks like fun!)

C++11
(for C++03, replace long long with long and -2ull with -2ul)
Yet another solution which takes advantage of the fact that integers have finite size, together with the fact that unsigned arithmetic is defined as modulo arithmetic. It also uses the fact that conversion of integer types to bool gives true iff the converted number is nonzero.
bool odd(unsigned long long n) // note: signed->unsigned conversion preserves oddity
{
  return n * (1 + -2ull / 2);
}

Perl
if ((int(($number/2)) * 2) == $number) { print ("even"); }

Bash
This script asks Wolfram|Alpha whether a number is even or odd:
#!/bin/bash

curl -s "http://www.wolframalpha.com/input/?i=even($1)" | grep 'is even' > /dev/null

if [ $? -eq 0 ]
then
    echo Yes
else
    echo No
fi

Haskell, Recduction from Towers of Hanoi
When moving n pegs from A to B, then for even n, the first move is A->C.
Doesn't work for n=0.
data Peg = A|B|C deriving Eq
third :: Peg -> Peg -> Peg
third x y
    | x/=A && y/=A = A
    | x/=B && y/=B = B
    | x/=C && y/=C = C

data Move = Move Peg Peg deriving Eq

-- Move n pegs from a to b
hanoi :: Int -> Peg -> Peg -> [ Move ]
hanoi 0 _ _ = []
hanoi n a b = (hanoi (n-1) a c) ++ [Move a b] ++ (hanoi (n-1) c b) where
    c = third a b

-- n is even if the first step in moving n discs from A to B is A->C.
iseven :: Int -> Bool
iseven n = (head $ hanoi n A B) == Move A C

Perl
This always returns a . when the number is odd, and either an integer or nothing when it is even.
chop($_=<>/2);print chop

If you want it to actually print the word "odd" or "even" then it needs to be expanded to the following:
chop($_=<>/2);if(chop=='.'){print"Odd"}else{print"Even"}

OR, if you want the program to exit once it gives a result, this can be written as:
chop($_=<>/2);if(chop=='.'){die"Odd"}die"Even"

Only works with numbers greater than 18. However, changing == to eq might fix it (requires an extra space though).

VB.Net
return (i\2)*2=i

Notice the use of the backslash operator \ that performs a integer division and discards any reminders. The usage of a forvard slash operator / would not work for this solution.

Haskell
odd = (<)0.(^)(-1)
even = (>)0.(^)(-1)

J
odd =: 0>_1&^
even =: 0<_1&^

If (-1)n<0, n is odd; if
(-1)n>0, n is even.
odd =: [:|[:{:@+.0j1&^
even =: [:|[:{.@+.0j1&^

Taking the imaginary/real part of in would be a neat way to do it too, but needs better thresholding than this.

use queue and push pop, if element remains at last, it's odd, else is even:
var q = new Queue<int>();
for (int i=0;i<n;i++)
{
   if (q.Count > 0)
     q.Pop();
   else q.Push(0);
}

if (q.Count != 0)
  return "Odd";
return "Even";

Python
Somebody already used this idea, but this implementation is more concise:
def even(n):return str(n)[-1]in'02468'

Squeak Smalltalk
Since printing in base 2 would be too obvious and a big waste of time because only the last digit counts
odd
    ^(self printStringBase: 2) last = $1

I decided to rather print in base 3 to at least scan all the digits
odd
    ^self ~= 0 and: [self = 1 or: [((self printStringBase: 3) occurrencesOf: $1) odd]]

Of course, if we have more CPU to waste, we can just enumerate
odd
    ^(1 to: self abs) inject: false into: [:odd :int | odd not]

Finally, if we are impatient, this might be a bit faster
odd
    (0 to: self abs by: 2) size - (1 to: self abs by: 2) size = 0

R
is.even<-function(n){
    options(warn=-1)
    res<-ifelse(sum(matrix(1:abs(n),nrow=2)==1)!=1, "Odd", "Even")
    options(warn=0)
    res
    }

The idea is to build a 2-rows matrix with the sequence 1 to the absolute value of n (to allow negative numbers). If the number is odd, the sequence has to be recycled to fill the 2 rows, so the matrix contains twice the number 1.
Due to the method, it doesn't work with large numbers but it works with zero.
> is.even(0)
[1] "Even"
> is.even(467)
[1] "Odd"
> is.even(-46798)
[1] "Even"
> is.even(9999999999)
Error in 1:abs(n) : result would be too long a vector