text:
Add two numbers safely, in C
Everyone knows that C is a lovely, safe, high level programming language.  However you, as a coder are set the following task.

Write a program to add two numbers.

Input: Two space separated integers.
Output: The sum of the two numbers in the input.

The twist is that your code must be 100% safe. In other words, it must behave properly no matter what the input is.  If the input is indeed two space separated integers, both of which are less than 100 digits long, it must output the sum. Otherwise, it must output an error message and quit safely.
How hard can it be after all?
General kudos will be given to pathological input cases which break other people's answers :)
The code must compile without warnings using gcc -Wall -Wextra on ubuntu.

Clarification.

Input is from stdin.
Horizontal whitespace is only a single space character.  There should be nothing before the first number and the input should be terminated with either newline+EOF or just EOF.
the only valid input, specified in Augmented Backus-Naur Form, is:

    NONZERODIGIT = "1" / "2" / "3" / "4" / "5" / "6" / "7" / "8" / "9"
    POSITIVENUMBER = NONZERODIGIT *98DIGIT
    NEGATIVENUMBER = "-" POSITIVENUMBER
    NUMBER = NEGATIVENUMBER / POSITIVENUMBER / "0"
    VALIDINPUT = NUMBER SP NUMBER *1LF EOF

The error message is the single letter 'E', followed by a new line.
The code must terminate cleanly in less than 0.5s no matter what the input is.

I love how clear your spec became with a single use of the word "otherwise". Very well written (in my opinion). Too bad the challenge is only in C, but I can see why it has to be that way.

Without warnings + code-golf + C? This is bound to be interesting!

Decimal integers? "space-separated" == "whitespace-separated"?

@GlennRanders-Pehrson Yes decimal and horizontal white space separated as you say.

stdin or command line?

Could we get a strict acceptable input format? Such as no extra whitespace (or anything not a number) before the first number, any amount of horizontal whitespace (i.e. horizontal tabs and spaces) between the two numbers, and nothing except a linefeed or a carriage return together with a linefeed after the second number?

Is the input terminated by newline+EOF or just EOF?

Since it's a code-golf, you should probably give the exact error message to display.

Also, does space-separated mean 1) separated by one character with ASCII value 32, 2) separated by an arbitrary number of character with ASCII value 32, 3) separated by any one ASCII whitespace character (32, 10, 9, possibly 13?), 4) separated by an arbitrary number of a single whitespace character from the set of ASCII whitespace characters, or 5) separeted by an arbitrary number of any combination of the set of ASCII whitespace characters?

do I understand correctly we must reject inputs where either number is 100 characters or longer?

@JanDvorak Yes that is right.

Which version of gcc?

@dmckee gcc 4.8.2

100 digits? I'm pretty sure that will overflow.

Added some precision to the input definition.

Are negative numbers allowed? If so, the ABNF (with ;s) should be changed to:
POSITIVENUMBER = 1*100DIGIT;
NEGATIVENUMBER = "-" POSITIVENUMBER;
NUMBER = NEGATIVE NUMBER / POSITIVENUMBER;
VALIDINPUT = NUMBER SP NUMBER *1LF

@Scottleadley. Yes they are. Could you edit it as I can't right now?

@Lembik Also adjusted digit count from 100 to 99 to conform to "less than 100 digits long".

@ScottLeadley I am not 100% confident with ABNF so I just wanted to check but I think 001 is not a valid number. Does the ABNF you entered follow that rule? Also, the LF should be optional. Does 1*LF do that?

@Lembik 1*99DIGIT allows leading zeros. 1LF is short for 01LF, i.e. an optional LF.

@Lembick If you want to exclude leading zeros, use NONZERODIGIT = "1" / "2" / "3" / "4" / "5" / "6" / "7" / "8" / "9"; POSITIVENUMBER = NONZERODIGIT *98DIGIT

@Lembick Just realized that the current spec outlaws 0. Easiest fix (for you) is: NUMBER = NEGATIVENUMBER / POSITIVENUMBER / "0". Tacking it on to POSITIVENUMBER allows -0.

@Lembick I'm sure the compiler gods will smite us for this ugly syntax graph, but it seems to be complete.

Why no warnings? gcc warnings are broken and warn about perfectly correct stuff like putchar(c) == EOF || exit(1).

6610 bytes (unminified)
"Good boy" C program that meets all challenge criteria. Uses 10s complement for negative numbers. Also included, a test harness and test cases.
/*
Read input from STDIN. The input must conform to VALIDINPUT:

    NONZERODIGIT = "1" / "2" / "3" / "4" / "5" / "6" / "7" / "8" / "9"
    POSITIVENUMBER = NONZERODIGIT *98DIGIT
    NEGATIVENUMBER = "-" POSITIVENUMBER
    NUMBER = NEGATIVENUMBER / POSITIVENUMBER / "0"
    VALIDINPUT = NUMBER SP NUMBER *1LF EOF

Check syntax of input. If input is correct, add the two numbers and print
to STDOUT.

LSB => least significant byte
MSB => most significant byte
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <stdbool.h>
#include <assert.h>
#define NUL ('\0')
/*
    maximum characters in VALIDINPUT:
        '-'     1
        POSITIVENUMBER  MAXDIGITS
        ' '     1
        '-'     1
        POSITIVENUMBER  MAXDIGITS
        LF      1
*/
#define MAXDIGITS (99)
#define MAXVALIDINPUT (2*MAXDIGITS+4)

void die() { printf("E\n"); exit(1); }

/*
    Add two NUMBERs and print the result to STDOUT.  The NUMBERS have
been separated into POSITIVENUMBERS and sign information.

Arguments:
    first       - pointer to LSB of 1st POSITIVENUMBER
    firstSize   - size of 1st POSITIVENUMBER
    firstNegative   - is 1st # negative?
    second      - pointer to LSB of 2nd POSITIVENUMBER
    secondSize  - size of 2nd POSITIVENUMBER
    secondNegative  - is 2nd # negative?
    carry       - carry from previous place?

Returns:
    sum[]       - sum
    addNUMBERs()    - carry to next place?

- Don't use complementDigit(popDigit(p,s),n). Side-effects generate two pops.
*/
#define popDigit(p,s) ((s)--,(*(p++)-'0'))
#define complementDigit(c,n) ((n) ? 9-(c) : (c))

#define pushSum(c) (*(--sumPointer)=(c))
#define openSum() (pushSum(NUL))
#define closeSum() ;
char    sum[MAXVALIDINPUT];
char    *sumPointer = sum+sizeof(sum);
int addNUMBERs(char *first, int firstSize, bool firstNegative,
        char *second, int secondSize, bool secondNegative,
        int previousCarry) {
    int firstDigit, secondDigit;
    int mySum;
    int myCarry;

    /*
        1st half of the problem.

        Build a stack of digits for "first" and "second"
    numbers. Each recursion of addNUMBERs() contains one digit
    of each number for that place. I.e., the 1st call holds
    the MSBs, the last call holds the LSBs.

        If negative, convert to 10s complement.
    */
    assert((firstSize > 0) && (secondSize > 0));
    if (firstSize > secondSize) {
        firstDigit = popDigit(first, firstSize);
        firstDigit = complementDigit(firstDigit, firstNegative);
        secondDigit = 0;
    } else if (secondSize > firstSize) {
        firstDigit = 0;
        secondDigit = popDigit(second, secondSize);
        secondDigit = complementDigit(secondDigit, secondNegative);
    } else {
        //  same size
        firstDigit = popDigit(first, firstSize);
        firstDigit = complementDigit(firstDigit, firstNegative);
        secondDigit = popDigit(second, secondSize);
        secondDigit = complementDigit(secondDigit, secondNegative);
    }

    //  recursion ends at LSB
    if ((firstSize == 0) && (secondSize == 0)) {
        //  if negative, add 1 to complemented LSB
        if (firstNegative) {
            firstDigit++;
        }
        if (secondNegative) {
            secondDigit++;
        }
        myCarry = previousCarry;
    } else {
        myCarry = addNUMBERs(first, firstSize, firstNegative,
            second, secondSize, secondNegative,
            previousCarry);
    }

    /*
        2nd half of the problem.

        Sum the digits and save them in first[].
    */
    mySum = firstDigit + secondDigit + ((myCarry) ? 1 : 0);
    if ((myCarry = (mySum > 9))) {
        mySum -= 10;
    }
    pushSum(mySum + '0');
    return(myCarry);
}

//  Handle the printing logic.
void addAndPrint(char *first, int firstSize, bool firstNegative,
        char *second, int secondSize, bool secondNegative,
        int previousCarry) {

    openSum();
    addNUMBERs(first, firstSize, firstNegative,
        second, secondSize, secondNegative,
        previousCarry)
    closeSum();
    if (*sumPointer<'5') {
        //  it's positive
        for (; *sumPointer=='0'; sumPointer++) {} // discard leading 0s
        //  if all zeros (sumPointer @ NUL), back up one
        sumPointer -= (*sumPointer == NUL) ? 1 : 0;
        printf("%s\n", sumPointer);
    } else {
        //  it's negative
        char    *p;

        //  discard leading 0s (9s in 10s complement)
        for (; *sumPointer=='9' && *sumPointer; sumPointer++) {}
        //  if -1 (sumPointer @ EOS), back up one
        sumPointer -= (*sumPointer == NUL) ? 1 : 0;
        for (p=sumPointer; *p; p++) {
            *p = '0' + ('9' - *p); // uncomplement
            //  special handling, +1 for last digit
            *p += (*(p+1)) ? 0 : 1;
        }
        printf("-%s\n", sumPointer);

    }
    return;
}

/*
    Lex a number from STDIN.

Arguments:
    bufferPointer - pointer to a pointer to a buffer, use as
            **buffer = c;   // put "c" in the buffer
            *buffer += 1;   // increment the buffer pointer
            (*buffer)++;    // also increments the buffer pointer

All sorts of side-effects:
    - getc(stdin)
    - ungetc(...,stdin)
    - modifies value of **bufferPointer
    - modifies value of *bufferPointer

Returns:
    lexNUMBER() - number of bytes added to *bufferPointer,
            *1 if POSITIVENUMBER,
            *-1 if NEGATIVENUMBER
    *bufferPointer - points to the LSB of the number parsed + 1
*/
#define pushc(c) (*((*bufferPointer)++)=c)
bool lexNUMBER(char **bufferPointer) {
    char    c;
    int size = 0;
    bool    sign = false;

    /* lex a NUMBER */
    if ((c=getchar()) == '0') {
        pushc(c);
        c = getchar();
        size++;
    } else {
        if (c == '-') {
            sign = true;
            c = getchar();
            // "-" isn't a digit, don't add to size
        }
        if (c == '0') {
            die();
        }
        for (size=0; isdigit(c); size++) {
            if (size >= MAXDIGITS) {
                die();
            }
            pushc(c);
            c = getchar();
        }
    }
    if (size < 1) {
        die();
    }
    ungetc(c,stdin);        // give back unmatched character
    return (sign);
}

int main() {
    int c;
    char    buffer[MAXVALIDINPUT];
    char    *bufferPointer;
    char    *first, *second;
    int firstSize, secondSize;
    bool    firstNegative, secondNegative;

    bufferPointer = buffer + 1; // hack, space for leading digit
    //  parse 1st number
    first = bufferPointer;
    firstNegative = lexNUMBER(&bufferPointer);
    firstSize = bufferPointer - first;
    *(bufferPointer++) = NUL;   // hack, space for EOS
    bufferPointer++;        // hack, space for leading digit
    //  parse separating blank
    if ((c=getchar()) != ' ') {
        die();
    }
    //  parse 2nd number
    second = bufferPointer;
    secondNegative = lexNUMBER(&bufferPointer);
    secondSize = bufferPointer - second;
    *(bufferPointer++) = NUL;   // hack, space for EOS
    //  parse end of input
    c = getchar();
    if (! ((c == EOF) || ((c == '\n') && ((c=getchar()) == EOF))) ) {
        die();
    }
    //  Some very implementation-specific massaging.
    *(--first) = '0';       // prefix with leading 0
    *(first+(++firstSize)) = NUL;   // add EOS
    *(--second) = '0';      // prefix with leading 0
    *(second+(++secondSize)) = NUL; // add EOS
    //  add and print two arbitrary precision numbers
    addAndPrint(first, firstSize, firstNegative,
        second, secondSize, secondNegative, false);
    return(0);
}

Here's a little test harness and a few test cases to get you started. Feel free to tear out the excessive use of perl. The system it was developed on didn't have a modern bash.
#!/bin/bash
#
#   testharness.sh
#
# Use as: bash testharness.sh program_to_be_tested < test_data
#
# Each line in the test data file should be formatted as:
#
#   INPUT = bash printf string, must not contain '"'
#   OUTPUT = perl string, must not contain '"'
#           (inserted into the regex below, use wisely)
#   TESTNAME = string, must not contain '"'
#   GARBAGE = comments or whatever you like
#   INPUTQUOTED = DQUOTE INPUT DQUOTE
#   OUTPUTQUOTED = DQUOTE OUTPUT DQUOTE
#   TESTQUOTED = DQUOTE TESTNAME DQUOTE
#   TESTLINE = INPUTQUOTED *WSP OUTPUTQUOTED *WSP TESTQUOTED GARBAGE
TESTPROGRAM=$1
TMPFILE=testharness.$$
trap "rm $TMPFILE" EXIT
N=0         # line number in the test file
while read -r line; do
    N=$((N+1))
    fields=$(perl -e 'split("\"",$ARGV[0]);print "$#_";' "$line")
    if [[ $fields -lt 5 ]]; then
        echo "skipped@$N"
        continue
    fi
    INPUT=$(perl -e 'split("\"",$ARGV[0]);print "$_[1]";' "$line")
    OUTPUT=$(perl -e 'split("\"",$ARGV[0]);print "$_[3]";' "$line")
    TESTNAME=$(perl -e 'split("\"",$ARGV[0]);print "$_[5]";' "$line")
    printf -- "$INPUT" | $TESTPROGRAM > $TMPFILE
    perl -e "\$t='^\\\s*$OUTPUT\\\s*\$'; exit (<> =~ \$t);" < $TMPFILE
    if [[ $? -ne 0 ]]; then     # perl -e "exit(0==0)" => 1
        echo "ok $TESTNAME"
    else
        echo -n "failed@$N $TESTNAME," \
            "given: \"$INPUT\" expected: \"$OUTPUT\" received: "
        cat $TMPFILE
        echo
    fi
done

    A small set of test cases:

"0 0"       "0" "simple, 0+0=0"
"1 1"       "2" "simple, 1+1=2"

""      "E" "error, no numbers"
"0"     "E" "error, one number"
"0  0"      "E" "error, two/too much white space"
"0 0 "      "E" "error, trailing characters"
"01 0"      "E" "error, leading zeros not allowed"

"-0 0"      "E" "error, negative zero not allowed
"0 -0"      "E" "error, negative zero not allowed here either

"1 1\n"     "2" "LF only allowed trailing character

"\0001 1\n"    "E" "error, try to confuse C string routines #1"
"1\00 1\n"  "E" "error, try to confuse C string routines #2"
"1 \0001\n"    "E" "error, try to confuse C string routines #3"
"1 1\000\n"    "E" "error, try to confuse C string routines #4"
"1 1\n\000"    "E" "error, try to confuse C string routines #5"

"-1 -1"     "-2"    "add all combinations of -1..1 #1"
"-1 0"      "-1"    "add all combinations of -1..1 #2"
"-1 1"      "0" "add all combinations of -1..1 #3"
"0 -1"      "-1"    "add all combinations of -1..1 #4"
"0 0"       "0" "add all combinations of -1..1 #5"
"0 1"       "1" "add all combinations of -1..1 #6"
"1 -1"      "0" "add all combinations of -1..1 #7"
"1 0"       "1" "add all combinations of -1..1 #8"
"1 1"       "2" "add all combinations of -1..1 #9"

"0 123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789" "123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789" "0+99 digits should work"

"100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" "200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" "99 digits+99 digits should work"

"500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" "1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" "test for accumulator overflow"

"-123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 0" "-123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789" "0+negative 99 digits work"

"-100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" "-200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" "99 digits+99 digits (both negative) should work"

"-500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" "-1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" "test for negative accumulator overflow"

"1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890 0" "E" "error, 100 digits"

Fixed the last two large negative number tests. They weren't testing negative numbers.

I get lots of warnings with -Wall -Wextra from your code.

@Lembik Other posters can feel free to copy the lexer and fix the compiler warnings. It does implement a safe lexer & does do arbitrary precision arithmetic (sort of). I spent some effort on the mal-coding (see comments in the code), so you should get lots of compiler warnings. How about a gold star for the lexer and a swift boot in the rear for disregarding the other criteria?

That seems very reasonable :) Consider it done.

@Lembick Replaced with all C solution using 10s complement arithmetic. Moved "bad example" solution using bc to separate answer.

289
EDIT : This code works only for positive integers. The rules has changed since I post this answer.
#include <stdio.h>
#include <stdlib.h>
int r[101],s;void x(int i){r[i]|=32;if(r[i]>41)r[i+1]++,r[i]-=10,x(i+1);}void f(int b){int c=getchar();if(c!=b){if(s>99||c<48||c>57)exit(puts("E"));f(b);r[s]+=c-48;x(s++);}}int main(){f(32);s=0;f(10);for(s=100;s--;)if(r[s])putchar(r[s]+16);return 0;}

Ungolfed and commented version :
#include <stdio.h>
#include <stdlib.h>

//global variables are automatically init to zero
int result[101]; //101 because 2 numbers of 100 digits can give a 101-digits result
int currentNumber;

void reportAddition(int i) {
    result[i]|=0x20; //flag "active" value, 6th bit
    if(result[i]>9+0x20) {
        result[i+1]++;
        result[i]-=10;
        reportAddition(i+1);
    }
}

void addNumber(int endingChar) {
    int c=getchar();
    if(c!=endingChar) {
        if(currentNumber>99||c<'0'||c>'9') //error
            exit(puts("Error"));
        addNumber(endingChar);
        result[currentNumber]+=c-'0';
        reportAddition(currentNumber); //handle case when addition give a value greater than 9
        currentNumber++;
    }
}

int main() {

    addNumber(' '); //add first number
    currentNumber=0;
    addNumber('\n'); //add second

    for(currentNumber=100;currentNumber--;)
        if(result[currentNumber])
            putchar(result[currentNumber]+'0'-0x20); //display char
    return 0;
}

Do you reject inputs longer than 99 digits? It seems to me you should.

@JanDvorak, yes I do.

I get several compilation warnings: ./tmp.c: In function ‘f’: ./tmp.c:3:1: warning: suggest parentheses around comparison in operand of ‘|’ [-Wparentheses] ./tmp.c:3:1: warning: suggest parentheses around comparison in operand of ‘|’ [-Wparentheses] ./tmp.c: In function ‘main’: ./tmp.c:3:1: warning: control reaches end of non-void function [-Wreturn-type]

I didn't mean to specify the numbers were positive. Apologies.

@ace I don't have this warning here, is replacing (s>99|c<48|c>57) by (s>99||c<48||c>57) fix that ?

@Michael it fixes the first two warnings, but you still need a return value in main

I get no warnings now.

442
It is quite long, so I may golf it down further during the weekend. Assumes input is from stdin, EOF-terminated (without newline), separator is only one character of ASCII value 32 (that is, ' ' character).
#include<stdio.h>
char a[102],b[102],c[102],*p=a,d;int i,j=101,l,L,k,F=1;int main(){while(~(k=getchar())){if(47<k&&k<58){p[i++]=k;if(i==101)goto f;}else if(k==32&&F)p=b,l=i,F=0,i=0;else goto f;}L=i;for(i=(l<L?l:L)-1;i+1;i--){c[j]=(L<l?b[i]-48+a[i+l-L]:a[i]-48+b[i+L-l]);if(c[j--]>57)c[j]++,c[j+1]-=10;}for(i=(L<l?l-L-1:L-l-1);i+1;i--)c[j--]=(L<l?a[i]:b[i]);for(i=0;i<102;i++)if(c[i]&&(c[i]-48||d))d=putchar(c[i]);return 0;f:return puts("E");}

The error message will be a single character 'E', followed by a new line.
With newlines and a little bit of indentation added: (a readable version follows, so feel free to skip over here)
#include<stdio.h>
char a[102],b[102],c[102],*p=a,d;
int i,j=101,l,L,k,F=1;
int main(){
    while(~(k=getchar())){
        if(47<k&&k<58){
            p[i++]=k;
            if(i==101)goto f;
        }else if(k==32&&F)p=b,l=i,F=0,i=0;
        else goto f;
    }
    L=i;
    for(i=(l<L?l:L)-1;i+1;i--){
        c[j]=(L<l?b[i]-48+a[i+l-L]:a[i]-48+b[i+L-l]);
        if(c[j--]>57)c[j]++,c[j+1]-=10;
    }
    for(i=(L<l?l-L-1:L-l-1);i+1;i--)c[j--]=(L<l?a[i]:b[i]);
    for(i=0;i<102;i++)if(c[i]&&(c[i]-48||d))d=putchar(c[i]);
    return 0;
    f:return puts("E");
}

The readable version (some statements are slightly altered to make it more readable, but what they do should be the same):
#include <stdio.h>
char num1[102],num2[102],sum[102]; //globals initialised to 0
char *p=num1;
int outputZero=0, noExtraSpace=1;
int i=0, j=101, len1, len2, ch;
#define min(x,y) (x<y?x:y)
int main(){
    while((ch=getchar())!=-1) { //assumes EOF is -1
        if('0'<=ch && ch<='9') {
            p[i]=ch;
            i++;
            if(i==101) goto fail; //if input too long
        } else if(ch==' ' && noExtraSpace) {
            p=num2;
            len1=i;
            noExtraSpace=0;
            i=0;
        } else goto fail; //invalid character
    }
    len2=i;
    for(i=min(len1, len2)-1; i>=0; i--) {
        //add each digit when both numbers have that digit
        sum[j]=(len2<len1?num2[i]-'0'+num1[i+len1-len2]:num1[i]-'0'+num2[i+len2-len1]);
        if(sum[j]>'9') { //deal with carries
            sum[j-1]++;
            sum[j]-=10;
        }
        j--;
    }
    for(i=(len2<len1?len1-len2-1:len2-len1-1); i>=0; i--) {
        //copy extra digits when one number is longer than the other
        sum[j]=(len2<len1?num1[i]:num2[i]);
        j--;
    }
    for(i=0; i<102; i++) {
        if(sum[i] && (sum[i]-'0' || outputZero)) {
            putchar(sum[i]);
            outputZero=1;
            //if a digit has been output, the remaining zeroes must not be leading
        }
    }
    return 0;
    fail:
    puts("Error");
    return 0;
}

The goto fail; thing is here to mock Apple.
The version of gcc I used is gcc (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3, and there are no warnings.

What about -1 1 as input.

@Lembik prints error message because the input should be "Two space separated positive integers."

Oh sorry I mucked that up. I thought I had changed that.

Currently your code always outputs E for me. I tried "1 1" for example. Also could you make the input come from stdin?

@Lembik The input is from stdin (getchar() always gets from stdin). It is assumed to be EOF-terminated without newline. You can test this, either by entering [1][space][1][Ctrl+D][Ctrl+D], or echo -n '1 1' | program

Thanks.  The spec says " with either newline+EOF or just EOF" and that didn't even change late on :)

633 bytes
"Bad boy" C program that meets half the challenge. Abuses C, throws lots of warnings, but works ... sort of. Arbitrary precision arithmetic is actually done by bc.
#include<stdio.h>
#include<string.h>
#include<ctype.h>
#define g() getc(stdin)
#define z(c) b[i++]=c,b[i]='\0'
x(){puts("E\n");exit(1);}main(){int c,y=0,i=0;char b[232]="",*h="echo ",*t=" | bc -q | tr -d '\\\\\\012'";strcat(b,h);i=strlen(h);if((c=g())=='0'){z(c);y=1;c=g();}else{if(c=='-'){z(c);c=g();}c!='0'||x();ungetc(c,stdin);for(y=0;isdigit(c=g());y++){z(c);y<99||x();}}y>0||x();c==' '||x();z('+');y=0;if((c=g())=='0'){z(c);y=1;c=g();}else{if(c=='-'){z(c);c=g();}c!='0'||x();do{if(!isdigit(c))break;z(c);y++;y<=99||x();}while(c=g());}y>0||x();strcat(b+i,t);i+=strlen(t);if(!((c==-1)||((c=='\n')&&((c=g())==-1))))x();system(b);}

Unminified version
/*
Read input from STDIN. The input must conform to VALIDINPUT:

    NONZERODIGIT = "1" / "2" / "3" / "4" / "5" / "6" / "7" / "8" / "9"
    POSITIVENUMBER = NONZERODIGIT *98DIGIT
    NEGATIVENUMBER = "-" POSITIVENUMBER
    NUMBER = NEGATIVENUMBER / POSITIVENUMBER / "0"
    VALIDINPUT = NUMBER SP NUMBER *1LF EOF

Check syntax of input. If input is correct, use the shell command
"echo NUMBER+NUMBER | bc -q" to do the arbitrary precision integer arithmetic.

NB, this solution requires that the "normal" bc be 1st in the PATH.

    Fun C language features used:
    - ignore arguments to main()
    - preprocessor macros
    - pointer arithmetic
    - , operator
    - ?: operator
    - do-while loop
    - for loop test does input
    - implicit return/exit
    - short is still a type!
    - ungetc()
    - use int as bool and 0 & 1 as magic numbers
    - implicit type coersion

5/5/14, Stop fighting the syntax graph. Get rid of "positive" flag.
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#define MAXDIGITS (99)
#define pushc(c) (buffer[index++]=c,buffer[index]='\0')
#define pushs(s) (strcat(buffer+index,s),index+=strlen(s))

int die() { printf("E\n"); exit(1); }

int main () {
    int c;
    /*
    buffer budget:
    5               "echo "
    1+MAXDIGITS (include "-")   NUMBER
    1               "+"
    1+MAXDIGITS (include "-")   NUMBER
    25              " | bc -q | tr -d '\\\012'"
    1               NUL
    */
    char    buffer[5+1+MAXDIGITS+1+1+MAXDIGITS+25+1] = "";
    short   index = 0;
    short   digits;

    pushs("echo ");
    // parse 1st number
    digits = 0;
    if ((c=getchar()) == '0') {
        pushc(c);
        digits = 1;
        c = getchar();
    } else {
        if (c == '-') {
            // "-" doesn't count against digits total
            pushc(c);
            c = getchar();
        }
        (c != '0') || die();
        ungetc(c,stdin);
        for (digits=0; isdigit(c=getchar()); digits++) {
            pushc(c);
            (digits<MAXDIGITS) || die();
        }
    }
    (digits>=1) || die();
    // parse separating blank
    (c == ' ') || die();
    pushc('+');
    // parse 2nd number
    digits = 0;
    if ((c=getchar()) == '0') {
        pushc(c);
        digits = 1;
        c = getchar();
    } else {
        if (c == '-') {
            // "-" doesn't count against digits total
            pushc(c);
            c = getchar();
        }
        (c != '0') || die();
        do {
            if (!isdigit(c)) {
                break;
            }
            pushc(c);
            digits++;
            (digits<=MAXDIGITS) || die();
        } while(c=getchar());
    }
    (digits>=1) || die();
    pushs(" | bc -q | tr -d '\\\\\\012'");
    // parse end of input
    if (! ((c == EOF) || ((c == '\n') && ((c=getchar()) == EOF))) ) {
        die();
    }
    // add two arbitrary precision numbers and print the result to STDOUT
    system(buffer);
}


text:
What time is it? (Obfuscation)
Your goal is to write an obfuscated program that displays the current time.
Guidelines: The program can print local or global time. You are allowed to draw ASCII numbers, display an analog clock, etc. No input should be needed. Whether you include 12 or 24 hour, including AM/PM, milliseconds and seconds or not, it all doesn't matter. This is a popularity contest.
Inspired by sykes2.c, an impressive display of confusing naming, obscure language features, and clever tricks.

Why does the search feature on "Mark as duplicate" never work?

@TheDoctor Find me a duplicate, and I will delete or modify.

It is just not a very interesting challenge. No restrictions on using built-in time functions.

@TheDoctor That's subjective, and I think you missed the point of obfuscation. The purpose is to be creative in the display, not the method of getting the time.

I would retract my downvote if that were stated clearly in the question; i misunderstood.

Why the downvote again? When you downvote please tell us why

This question appears to be off-topic because it doesn't have an objective spec. One person's "obfuscated" is another person's "I just prefer this style".

Analog clock, JS
Analog clock? Challenge accepted.
Golfed/Obfuscated into the zone of not-exactly-understanding-what-it-does-even-after-reading-through-a-few-times:
for(var a=new Date,b=a.getMinutes(),c=a.getHours()+b/60,d=[],e=Math.round,f=Math.PI,g=Math.sin,h=Math.cos,k=0;11>k;k++)d[k]=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];for(var l=0;l<f;l+=0.05){var m=e(17/11*5*h(2*l)),n=e(5*g(2*l));d[n+5][m+8]=1}for(var p=0;2.5>=p;p+=0.5){var q=e(17/11*p*h(-(c*f/6)+f/2)),r=e(p*g(-(c*f/6)+f/2));d[r+5][q+8]=2}for(p=0;4.5>=p;p+=0.5){var s=e(17/11*p*h(-(b*f/30)+f/2)),t=e(p*g(-(b*f/30)+f/2));d[t+5][s+8]=3}d[5][8]=1;a="";for(k=d.length-1;-1<k;k--)a+=d[k].join("").replace(/0/g,".").replace(/1/g,"O").replace(/2/g,"h").replace(/3/g,"m")+"\n";console.log(a);

Outputs something like:
.....OOOOOOO......
...OO.......OO....
.OO...........O...
.O...h.........O..
O.....hh.......OO.
O......hOmmmmmmmO.
OO.............OO.
.O.............O..
.OO...........O...
...OO.......OO....
.....OOOOOOO......

...yeah, guess what time it is here. (Hint hint not AM)
Human readable version:
var date = new Date();
var min = date.getMinutes();
var hrs = date.getHours()+(b/60); // set up date
var a=[];
for(var i=0;i<11;i++)a[i]=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]; // set up array
function putX(x,y,i){a[y+5][x+8]=i;} // just for source neatness; this is expanded out in the obfuscated version
for(var p=0;p<Math.PI;p+=0.05){ // draw clock border
    putX(Math.round((17/11)*5*Math.cos(2*p)), Math.round(5*Math.sin(2*p)), 1);
}
for(var p=0;p<=2.5;p+=0.5){ // draw hour hand (transforming the angle to work)
    putX(Math.round((17/11)*p*Math.cos(-(hrs*2*Math.PI/12)+(Math.PI/2))), Math.round(p*Math.sin(-(hrs*2*Math.PI/12)+(Math.PI/2))), 2);
}

for(var p=0;p<=4.5;p+=0.5){ // draw the minute hand like the hour hand
    putX(Math.round((17/11)*p*Math.cos(-(min*2*Math.PI/60)+(Math.PI/2))), Math.round(p*Math.sin(-(min*2*Math.PI/60)+(Math.PI/2))), 3);
}

putX(0,0,1); // set the center point

date=""; // reuse date for maximum confusion :)
for(var i=a.length-1;i>-1;i--)date+=a[i].join("").replace(/0/g, ".").replace(/1/g, "O").replace(/2/g, "h").replace(/3/g, "m")+"\n"; // output ASCII art to string
console.log(date); // output string to console

Whoa, I just realized the hour hand doesn't actually move during the hour. Fixing...

It's fixed. Hopefully there aren't any more bugs

Python
Might as well.
exec(lambda s:s[::2]+s[1::2])('ipmepno r(t" hwtetbpb:r/o/wtsiemre;.wgeobvb/rHoTwMsLe5r/."o)')

JavaScript / HTML (757 bytes)
Prints an analog clock on an HTML5 canvas. There's probably a lot more efficient ways to do this, but I think it turned out looking nice.
<canvas><script>S=150;c=document.currentScript.parentNode;c.width=c.height=2*S;t=c.getContext("2d");z=Math;r=2*z.PI;o=r/4;h=[[1,0.93],[4,0.9],[8,0.7]];m=[0,0,0];function d(){t.clearRect(0,0,c.width,c.height);t.lineWidth=2;t.beginPath();t.moveTo(2*S,S);    t.arc(S,S,0.99*S,0,r);for (i=0;i<60;++i){a=r*(i/60)+o;x=0.99*S*z.cos(a);    y=0.99*S*z.sin(a);t.moveTo(S+x,S+y);s=0.96;if (!(i%5)) s=0.90;t.lineTo(S+s*x,S+s*y);}t.stroke();u=new Date();m[0]=r*u.getSeconds()/60-o;m[1]=r*u.getMinutes()/60-o;m[2]=r*(u.getHours()%12)/12+(m[1]+o)/12-o;for(g=0;g<3;g++){t.beginPath();t.lineWidth=h[g][0];t.strokeStyle="black";if (!g) t.strokeStyle="red";x=h[g][1]*S*z.cos(m[g]);  y=h[g][1]*S*z.sin(m[g]);t.moveTo(S+x,S+y);t.lineTo(S,S);t.stroke();}setTimeout(d,500);}d();</script>

Human readable version on JSFiddle here.

GolfScript
The ultimate example of a magic number!
230140410535893441750932406053255553

23/`3/{~}%+'"#{'\+'}"'+~

Explanation coming soon.

CJam
"et phone home"S/_,_@T=~><{_A<{R_,+\+}*':}/;

Prints the local time as HH:mm:ss (24-hour)
Spoilers:

 S/ splits by space (S=" ")
_,_ gets the resulting array length (3) twice
@T= extracts the "et" part (T=0)
~ evaluates et, which gives the current date and time in an array
>< extracts the time part (starting at index 3, length 3)
_A< checks if a value is less than 10 (A=10)
R_,+ evaluates to "0" (R="")
\+ prepends "0" to the number
{...}* executes the block if the condition (<10) was true
': is the colon character
{...}/ executes the block for each array element (hour, min, sec)
; pops the last value (a colon)

SVG + JavaScript (272 937 bytes)
I'm sorry; couldn't help myself. The SVG is probably way too big to fit on StackExchange, so you can access a live demo here (please note, it could lag your browser; do it at your own risk): http://varden.info/~mlindvall/jstime.obf.svg
Viewing the source code might crash your browser; do it at your own risk. Otherwise, downloading it and opening it in Notepad++ should be safe.
Since there are no rules, I'll have to admit I got huge help from an obfuscator, so this is more like a proof of concept rather than a real submission. Still, it was kind of fun to see this work.
Human readable version:
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg height="44" width="110" version="1.1" xmlns="http://www.w3.org/2000/svg">
<text x="10" y="14" style="font-size: 14px;">Current time is:</text>
<text id="id" x="0" y="44" style="font-size: 30px;"></text>
<script type="text/javascript">
function t() {
    var a = new Date(), timeArray=[a.getHours(), a.getMinutes(), a.getSeconds()], delimiter='', result='';
    for (c = 0; c != 3; c++) {
        while (('' + timeArray[c]).length != 2) {
            timeArray[c] = '0' + timeArray[c];
        }
        result += delimiter + b[c];
        delimiter = ':';
    }
    document.getElementById("id").textContent = result;
}
t();
setInterval("t()", 1000); // Run every second for an updating clock
</script>
</svg>

source: Stack Exchange

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

sort: votes


text:
Rotate a two-dimensional list by 45 degrees
TASK
The goal is to write a program that rotates any two-dimensional list by 45 degrees, it must be able to do this up to 7*45 (at once) before returning the list. The list will not necessarily be square or rectangular. You must include output for the examples in your answer. It must also work for cases that are not in the examples... circles, triangles etc. You cannot use a pre-existing function to do the whole thing.
All lists will have at least one axis of symmetry (N,S,E,W). All sublists are to be assumed as center-aligned. Odd-even lists will shift to the left one to align properly. See example 4 for gaps in the middle of a sublist.
INPUT
Your program will use a variable named l containing the list, and a variable named n specifying the amount the list will be rotated (n*45) (n will always be less than 7, and can be 0). It will have to accept l containing sublists of any printable data type (decimal, List, int, String[].. etc), but sublists will only contain one data type at a time.
You do not need to accept console input or use stdin. The lines specifying the test values of l and n are not included in the character count, but must be included in the submitted code.
OUTPUT
Your program must print the list in the correct orientation, NIL can be used to pad lists if you desire, but padding is not necessary (you get a smiley face if they are padded, though). Sub-lists do not have to be indented or separated by newlines as in the examples.
EXAMPLES
1
IN
l=
[[0 , 1 , 2],
 [3 , 4 , 5],
 [6 , 7 , 8]]
n=1

OUT
[    [0],
   [3 , 1],
 [6 , 4 , 2],
   [7 , 5],
     [8]    ]

2
IN
l=
[[a , b , c , d],
 [e , f , g , h]]
n=2

OUT
[[e , a],
 [f , b],
 [c , g],
 [h , d]]

3
IN
l=
[[A , B , C , D , E , F],
     [G , H , I , J],
         [K , L],
         [0 , 8],
         [M , N],
     [O , P , Q , R],
 [S , T , U , V , W , X]]
n=7

OUT
[          [F],
         [E],
       [D , J],
     [C , I],
   [B , H , L],
 [A , G , K , 8],
           [0 , N , R , X],
             [M , Q , W],
               [P , V],
             [O , U],
               [T],
             [U]          ]

4
IN
l=
[[9 , 8 , 7 , 6],
     [5],
 [4 , 3 , 2 , 1],
     [0]        ]
n=3

OUT
[  [0 , 4],
     [3],
   [2 , 5 , 9],
 [1 ,NIL, 8],
       [7],
     [6],     ]

5
IN
l=
[    [Q],
 [X ,NIL, Y],
     [Z]    ]
n=2

OUT
[    [X],
 [Z ,NIL, Q],
     [Y]     ]

Oooh. That's tough. Looks fun, though!

Two questions: 1) We do not have to pad lists, right? 2) Do you really want us to rotate the list n times and not by n·45 °? I am asking because I am pretty certain that I would not obtain the result of example 3 by applying seven 45 ° rotations.

No, you do not have to pad. The list should however be able to be arranged into the correct visual orientation, although it does not have to be output that way... the output will have no newlines. The list is rotated by n*45.

Python – 234 201
# example for defining lists and n
l=[[1,2,3,4],
     [5],
   [6,7,8,9]]
n=1

# counting code
j=1j
m=max(map(len,l))+len(l)
M=range(-m,m)
e=enumerate
d=[[v for x in M for i,u in e(l)for k,v in e(u)if[1,1+j,j,j-1,-1,-j-1,-j,1-j][n]*(k-(len(u)-1)/2+j*i)==x+y*j]for y in M]
print[x for x in d if x]

Ungolfed Version
rotation = [1,1+1j,1j,1j-1,-1,-1j-1,-1j,1-1j][n]
m = max(map(len,l))+len(l)
output = []
for y in range(-m,m):
    line = []
    for x in range(-m,m):
        for i,sublist in enumerate(l):
            for k,entry in enumerate(sublist):
                if rotation * ( k-(len(sublist)-1)/2 + i*1j ) == x + y*1j:
                    line += [entry]
    if line != []:
        output += [line]
print output

This uses that multiplication (of a complex number) by a complex number corresponds to rotating and stretching. [1,1+1j,1j,1j-1,-1,-1j-1,-1j,1-1j] are complex numbers corresponding to the required angles and using the smallest scaling factor such that for an integer complex input the output is again integer complex.

I'm trying to understand how this works, but I get lost at the complex numbers. Could I ask for an explanation?

@Ourous: Let x+iy=(x,y), then multiplying this by 1+i=(1,1), you get a rotation by 45 degrees.

Great solution. I'm trying to adapt it to also insert the appropriate padding in the output lists, but am not having much luck. Is that a non-trivial addition?

@tkocmathla: I did not test this, but try adding else: line += [None] after the fourth from the last line.

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


text:
Tips for golfing in Processing
Does anyone have any code-golf tips for golfing in Processing? It is a graphical extension of java, and is somewhat difficult to golf.

Nice question. I believe tips should be on Community Wiki. I flagged it for migration.

Downvote??? why?

Don't worry about the downvote... you'll lose all the rep you got from this post after it is marked as community wiki anyway...

@ace: Reputation gained before a post is marked CW will be kept: http://meta.stackexchange.com/a/11741/229438

If no animation is required, you can skip the void draw() and put everything into void setup().
Initialising the size of the canvas is sometimes not necessary - it will be initialised to (100, 100) by default.
If you need to use height and width in your code, it is usually shorter to use their numeric values instead. For example, with a canvas of size (100, 100), using 99 to replace height and width can save you 7 bytes.

If you only run code in the setup method then you don't need write the method outline. For example you can write:
rect(10,10,90,90);

instead of
void setup {
    rect(10,10,90,90);
}

And as long as you don't use any other methods then everything will be put in the setup method before running

This can be a bit buggy. I've noticed that if you try to define a function in static mode, Processing can get a bit confused: https://puu.sh/tpzP8.png

@quat as long as you don't define any other methods then everything will be put in the setup method. If you need to define methods then you'll need to explicitly name the setup method.

White #FFFFFF
Related: Colour Notation
Instead of using this for white:
color(255)     //10 bytes

you can do this:
color(-1)      //9 bytes

and save 1 byte.

Colours (R, G, B) notation
Hexadecimal colours
Processing is very flexible in colour format.
fill(255,255,0); //16 bytes

can be written using hexadecimal notation as
fill(#ffff00);   //14 bytes (2 bytes saved)

Grayscale
Here is a special usage for colours if all the Red, Green and the Blue values are the same (white):
fill(255,255,255); //18 bytes
fill(#ffffff);     //14 bytes
fill(255);         //10 bytes

All the three parameters can be shortened into one parameter containing the grayscale value: from 0 black to 255 white.
This can be extended for alpha as well:
fill(175,175,175,50); //translucent gray
fill(175,50);         //8 bytes shorter

Both mean the same colour, but the latter way is shorter by 8 bytes.
Alpha
Although obvious, it should be stated that the alpha parameter in specifying colours is optional since colours are defaulted to an alpha value of 255 (100% opaque).
Summary: Color formats
Use the shortest colour format to express your colour (remember to leave out unnecessary bits -depending on the context of the program- for example: alpha or grayscale)
R: Red
G: green
B: blue
A: alpha
g: grayscale
RRR,GGG,BBB
#RRGGBB
ggg
RRR,GGG,BBB,AAA
ggg,AAA

Abbreviate constants
If you're ever using one of the all-caps keywords in Processing (such as DIFFERENCE or TRIANGLE_FAN), see if the number they correspond to is shorter.
For example, DIFFERENCE is just an int that's equal to 32. Instead of using DIFFERENCE here, I could write 32, saving 8 characters.

Shorter alternative to void keyPressed(){}
void draw(){}void keyPressed(){foo;} //36 bytes
void draw(){if(key>0)foo;}           //26 bytes

The void draw(){} is needed by default in order for key to be updated. If the user hasn't pressed a key since the start of the program, key is given a value of 0. By checking if it is more than 0 (ie the user has pressed a key), we have golfier code and save 10 bytes.

Setting and committing pixels using set()
It's more efficient to set pixels via pixels[]:
pixels[0] = color(255)
updatePixels();

However, that requires updatePixels() and also using an index which depending on the scenario will require converting an x,y position to a pixel index.
To keep things short, even though it's less CPU efficient (as each call updates the whole buffer), set() allows a pixel to set and committed to buffer straight away in one call.
set(0,0,color(255));


text:
Frogger-ish game
How about giving the good ol' arcade game Frogger a revival, Code Golf-style!
Your task is to create a version of this classic game, with as few characters of code as possible. Use the language of your choice (libraries, like jQuery etc., are allowed).
Requirements

You have 3 lives, and lose 1 life from:

moving outside the game scene.
getting hit by a vehice.
jumping in to water.
jumping to an already occupied home.
running out of time.

The frog moves with arrow keys.
There is a bug "teleporting" with set intervals between the five homes (the spaces between the grass at the top).
You get 10 points when moving a step forward, 200 bonus points when catching a bug and 500 points when reaching an empty home.
A timer ticks down, faster every level (the vehicles, frogs and logs should move faster as well each level).
There should be 5 lanes of vehicles, and 3 lanes with logs and 2 with turtles.
Each lane should move in a randomly chosen speed (within reasons).
When an available home gets occupied, a frog appears at the starting point and you control that one from that point.
When all five homes have been occupied, the timer restarts and the homes become empty. When the game ends, points from all levels are calculated and shown.

Additional info
Start screen, music and highscore table is not needed. You also don't need to mimic the design to the pixel. Want it black and white? Want it really minimalistic? Or a cube instead of a frog or car? Works fine! Just keep the code tight. Shortest code wins!

Comments purged because they were obsolete. Please notify me of any lost information that may have been in deleted comments.

Python 3.3 - Ungolfed
I have not golfed this at all, as I was more interested in just getting a good-looking game working first. I am actually totally new to Tk, so if anyone has any suggestions, I would really appreciate them. The speeds now work properly. Let me know if you would like to see additional features, e.g. colors.
Code
import tkinter as tk
import queue
import random

class Lane():
 def __init__(self, row=-1, lanetype="none", direction=0, speed=0, width=0, maxnumber=0, replenish=0, length=0, gap=0):
  self.row = row
  self.type = lanetype
  self.direction = direction
  self.speed = speed
  self.width = width
  self.maxnumber = maxnumber
  self.replenish = replenish
  self.length = length
  self.gap = gap
  self.lanelastupdate = 0
  self.objects = []
  if(self.type == "car"):
   for index in range(self.width):
    if(len(self.objects) == self.maxnumber):
     break
    if((self.maxnumber - len(self.objects) == self.width - index) or random.random() < self.maxnumber/self.width):
     self.objects.append([index*self.direction + int((self.width-1)/2 - (self.width-1)*self.direction/2), self.row])
  if(self.type == "log" or self.type == "turtle"):
   if(self.direction == 1):
    start = 0
   else:
    start = self.width - 1
   lengthcounter = 0
   gapcounter = 0
   for index in range(self.width):
    if(lengthcounter < self.length):
     self.objects.append([start + index*self.direction, self.row])
     lengthcounter += 1
    else:
     gapcounter += 1
     if(gapcounter == self.gap):
      lengthcounter = 0
      gapcounter = 0
 ### end of __init__ ###
### end of Lane class ###

class Frogger():
 def __init__(self):
  # configure 'global' variables
  self.directions = ['Up', 'Down', 'Left', 'Right']
  self.width = 25
  self.height = 13
  self.frogstart = [12, 12]
  self.pointsforup = 10
  self.pointsforhome = 500
  self.pointsforbug = 200
  self.timerthreshold = 1000
  self.timerstart = 60
  self.speedchange = 2
  self.waterbordertop = 1
  self.waterborderbottom = 5
  self.minspeed = 10
  self.maxspeed = 15
  self.minbugspeed = 50
  self.maxbugspeed = 100
  self.timerspeed = 20

  # configure program state variables
  self.q = queue.Queue(maxsize=1)
  self.updateticks = 0

  # configure game variables
  self.gameover = False
  self.speedup = 0
  self.timer = self.timerstart
  self.lives = 3
  self.score = 0
  self.frogposition = [0, 0]
  self.frogposition[0] = self.frogstart[0]
  self.frogposition[1] = self.frogstart[1]
  self.highest = 12
  self.movedup = False

  # configure the lanes of cars, logs, and turtles
  self.init_lanes()

  # configure the homes and the bug
  self.init_special()

  # configure TK window
  self.root = tk.Tk()
  self.label = tk.Label(text="Score: "+str(self.score)+" Lives: "+str(self.lives)+" Time: "+str(self.timer))
  self.label.pack()
  self.text = tk.Text(self.root, width=self.width, height=self.height, font=("Courier New", 14))
  self.text.bind("<Key>", self.key_event)
  self.text.focus_set()
  self.text.pack()

  # configure drawing sprites
  self.init_sprites()

  # run the game
  self.update_clock()
  self.process_world()
  self.root.mainloop()
 ### end of init ###

 def init_sprites(self):
  self.symbols = {"frog":chr(0x238), "rightcar":chr(187), "leftcar":chr(171), "turtle":chr(920), "log":chr(685), "bug":chr(1217), "grass":chr(993), "freehome":chr(164), "fullhome":"@", "road":"-", "water":chr(0x2248), "saferow":"*"}
  self.sprites = {value:key for key, value in self.symbols.items()}
  self.text.tag_configure("frog", foreground="chartreuse", background="dark green")
  self.text.tag_configure("rightcar", foreground="yellow", background="black")
  self.text.tag_configure("leftcar", foreground="yellow", background="black")
  self.text.tag_configure("turtle", foreground="orange red", background="cyan")
  self.text.tag_configure("log", foreground="sienna", background="cyan")
  self.text.tag_configure("bug", foreground="maroon", background="green")
  self.text.tag_configure("grass", foreground="orange", background="green")
  self.text.tag_configure("freehome", foreground="forest green", background="green")
  self.text.tag_configure("fullhome", foreground="red", background="green")
  self.text.tag_configure("road", foreground="gray", background="black")
  self.text.tag_configure("water", foreground="navy", background="cyan")
  self.text.tag_configure("saferow", foreground="pink", background="black")
 ### end of init_sprites ###

 def update_clock(self):
  self.timer -= 1
  self.label.configure(text="Score: "+str(self.score)+" Lives: "+str(self.lives)+" Time: "+str(self.timer))
  if(self.gameover == False):
   self.root.after(max(1, self.timerthreshold - self.speedup), self.update_clock)
 ### end of update_clock ###

 def key_event(self, event):
  direction = event.keysym
  if(direction in self.directions):
   try:
    self.q.put(direction, block=False)
   except:
    pass
 ### end of key_event ###

 def process_world(self):
  # acquire user input and process it if necessary
  if(self.q.qsize() > 0):
   self.move_frog(self.q.get())

  # update the state of non-frog objects
  self.update_world()

  # draw the world
  self.draw_world()

  # schedule another pass unless the game is over
  if(self.gameover == False):
   self.root.after(self.timerspeed, self.process_world)
  else:
   self.root.after(self.timerspeed, self.gameover_screen)
 ### end of process_world ###

 def move_frog(self, d):
  x = self.frogposition[0]
  y = self.frogposition[1]
  if(d == 'Up'):
   y -= 1
  elif(d == 'Down'):
   y += 1
  elif(d == 'Left'):
   x -= 1
  else:
   x += 1
  if(x >= 0 and y >= 0 and x < self.width and y < self.height):
   self.frogposition[0] = x
   self.frogposition[1] = y
   self.movedup = False
   if(d == 'Up' and y < self.highest):
    self.movedup = True
 ### end of move_frog ###

 def gameover_screen(self):
  self.label2 = tk.Label(text="Game over! Your score was: " + str(self.score))
  self.label2.pack()
 ### end of gameover_screen ###

 def update_world(self):
  # update the internal timer
  self.updateticks += 1

  # check for loss conditions
  if((self.timer == 0) or self.hit_by_car() == True or self.in_water() == True or self.home_twice() == True or self.in_grass() == True):
   self.process_death()
   return

  # credit good moves up
  if(self.movedup == True):
   self.score += self.pointsforup
   self.highest = self.frogposition[1]
   self.movedup = False

  # check for win condition
  if(self.at_home() == True):
   self.process_victory()
   return

  # check for total win
  if(self.all_done() == True):
   self.process_win()
   return

  # update the positions of the cars, logs, and turtles
  self.update_positions()
 ### end of update_world ###

 def all_done(self):
  if(len([x for x in self.homes if x[1]==False])==0):
   return True
  return False
 ### end of all_done ###

 def process_win(self):
  self.gameover = True
  return
 ### end of process_win ###

 def process_death(self):
  self.lives -= 1
  if(self.lives < 1):
   self.gameover = True
   return
  self.frogposition[0] = self.frogstart[0]
  self.frogposition[1] = self.frogstart[1]
  self.highest = 12
  self.timer = self.timerstart
 ### end of process_death ###

 def hit_by_car(self):
  for lane in self.lanes:
   if(lane.type != "car"):
    continue
   for car in lane.objects:
    if(car == self.frogposition):
     return True
  return False
 ### end of hit_by_car

 def in_water(self):
  if(self.frogposition[1] < self.waterbordertop or self.frogposition[1] > self.waterborderbottom):
   return False
  for lane in self.lanes:
   if(lane.type == "turtle"):
    for turtle in lane.objects:
     if(turtle == self.frogposition):
      return False
   elif(lane.type == "log"):
    for log in lane.objects:
     if(log == self.frogposition):
      return False
  return True
 ### end of in_water

 def home_twice(self):
  for h in self.homes:
   if(h[0] == self.frogposition and h[1] == True):
    return True
  return False
 ### end of home_twice

 def in_grass(self):
  if(self.frogposition[1] == 0 and self.at_home() == False):
   return True
  return False
 ### end of in_grass

 def at_home(self):
  for h in self.homes:
   if(h[0] == self.frogposition):
    return True
  return False
 ### end of at_home ###

 def process_victory(self):
  self.score += self.pointsforhome
  if(self.bugposition == self.frogposition):
   self.score += self.pointsforbug
  for h in self.homes:
   if (h[0] == self.frogposition):
    h[1] = True
    break
  self.timer = self.timerstart
  self.frogposition[0] = self.frogstart[0]
  self.frogposition[1] = self.frogstart[1]
  self.highest = 12
  self.speedup += self.speedchange
 ### end of process_victory ###

 def init_lanes(self):
  random.seed()
  self.lanes = []
  self.lanes.append(Lane(row=11, lanetype="car", maxnumber=10, replenish=0.1, direction=1, width=self.width, speed=random.randint(self.minspeed, self.maxspeed)))
  self.lanes.append(Lane(row=10, lanetype="car", maxnumber=8, replenish=0.2, direction=-1, width=self.width, speed=random.randint(self.minspeed, self.maxspeed)))
  self.lanes.append(Lane(row=9, lanetype="car", maxnumber=5, replenish=0.6, direction=1, width=self.width, speed=random.randint(self.minspeed, self.maxspeed)))
  self.lanes.append(Lane(row=8, lanetype="car", maxnumber=9, replenish=0.4, direction=-1, width=self.width, speed=random.randint(self.minspeed, self.maxspeed)))
  self.lanes.append(Lane(row=7, lanetype="car", maxnumber=6, replenish=0.3, direction=1, width=self.width, speed=random.randint(self.minspeed, self.maxspeed)))
  self.lanes.append(Lane(row=5, lanetype="turtle", direction=-1, length=3, gap=4, width=self.width, speed=random.randint(self.minspeed, self.maxspeed)))
  self.lanes.append(Lane(row=4, lanetype="log", direction=1, length=3, gap=3, width=self.width, speed=random.randint(self.minspeed, self.maxspeed)))
  self.lanes.append(Lane(row=3, lanetype="log", direction=-1, length=8, gap=9, width=self.width, speed=random.randint(self.minspeed, self.maxspeed)))
  self.lanes.append(Lane(row=2, lanetype="turtle", direction=1, length=2, gap=6, width=self.width, speed=random.randint(self.minspeed, self.maxspeed)))
  self.lanes.append(Lane(row=1, lanetype="log", direction=-1, length=4, gap=4, width=self.width, speed=random.randint(self.minspeed, self.maxspeed)))
 ### end of init_lanes

 def init_special(self):
  self.bugposition = [2, 0]
  self.buglastupdate = 0
  self.bugspeed = random.randint(self.minbugspeed, self.maxbugspeed)
  self.homes = [[[2, 0], False], [[7, 0], False], [[12, 0], False], [[17, 0], False], [[22, 0], False]]
 ### end of init_special ###

 def update_positions(self):
  if(self.updateticks - self.buglastupdate >= self.bugspeed - self.speedup):
   self.buglastupdate = self.updateticks
   while(True):
    freeslots = [x for x in self.homes if x[1] == False]
    if(len(freeslots)==0):
     self.bugposition = [-1,-1]
     break
    if(len(freeslots)==1):
     self.bugposition = freeslots[0][0]
     break
    newhomeindex = random.randint(0, 4)
    if(self.homes[newhomeindex][0] != self.bugposition and self.homes[newhomeindex][1] == False):
     self.bugposition = self.homes[newhomeindex][0]
     break

  for lane in self.lanes:
   lanemovedfrog=False
   if(self.updateticks - lane.lanelastupdate >= lane.speed - self.speedup):
    lane.lanelastupdate = self.updateticks
   else:
    continue
   for o in lane.objects:
    if(o == self.frogposition and lanemovedfrog==False):
     self.move_frog(self.directions[int(0.5*lane.direction + 2.5)])
     lanemovedfrog=True
    o[0] += lane.direction
    if((o[0] < 0) or (o[0] >= self.width)):
     lane.objects.remove(o)
   if(lane.type == "car" and len(lane.objects) < lane.maxnumber and random.random() < lane.replenish):
    lane.objects.append([int((self.width-1)/2 - (self.width-1)*lane.direction/2), lane.row])
   if(lane.type == "log" or lane.type == "turtle"):
    if(lane.direction == 1):
     start = min([x[0] for x in lane.objects])
     nxt = min([x for x in range(start, self.width) if (len([y for y in lane.objects if y[0] == x]) == 0)])
     if(start >= lane.gap or (nxt - start) < lane.length):
      lane.objects.append([0, lane.row])
    else:
     start = max([x[0] for x in lane.objects])
     nxt = max([x for x in range(start, -1, -1) if (len([y for y in lane.objects if y[0] == x]) == 0)])
     if(self.width - start - 1 >= lane.gap or (start - nxt) < lane.length):
      lane.objects.append([self.width - 1, lane.row])
   lane.objects.sort()
 ### end of update_positions ###

 def draw_world(self):
  self.text.state = "normal"
  self.text.delete('1.0', str(self.width + 1) + '.' + '0')
  drawstr = ""
  # draw home row
  newstr = self.symbols["grass"] * self.width
  for h in self.homes:
   if(h[1] == False):
    if(self.bugposition == h[0]):
     newstr = self.str_replace(newstr, h[0][0], self.symbols["bug"])
    else:
     newstr = self.str_replace(newstr, h[0][0], self.symbols["freehome"])
   else:
    newstr = self.str_replace(newstr, h[0][0], self.symbols["fullhome"])
  drawstr += newstr
  drawstr += "\n"

  # draw water rows
  for index in range(self.waterborderbottom - self.waterbordertop + 1):
   newstr = self.symbols["water"] * self.width
   for lane in self.lanes:
    if(lane.row == index + self.waterbordertop):
     for o in lane.objects:
      if(lane.type == "log"):
       newstr = self.str_replace(newstr, o[0], self.symbols["log"])
      elif(lane.type == "turtle"):
       newstr = self.str_replace(newstr, o[0], self.symbols["turtle"])
   drawstr += newstr
   drawstr += "\n"

  # draw safe row
  drawstr += self.symbols["saferow"] * self.width
  drawstr += "\n"

  # draw car rows
  for index in range(len([l for l in self.lanes if l.type == "car"])):
   newstr = self.symbols["road"] * self.width
   for lane in self.lanes:
    if(lane.row == self.waterborderbottom + 2 +index):
     for o in lane.objects:
      if(lane.direction == 1):
       newstr = self.str_replace(newstr, o[0], self.symbols["rightcar"])
      elif(lane.direction == -1):
       newstr = self.str_replace(newstr, o[0], self.symbols["leftcar"])
   drawstr += newstr
   drawstr += "\n"

  # draw safe row
  drawstr += self.symbols["saferow"] * self.width

  # do actual drawing
  self.text.insert('1.0', drawstr)

  # draw frog
  self.text.delete(str(1 + self.frogposition[1]) + '.' + str(self.frogposition[0]))
  self.text.insert(str(1 + self.frogposition[1]) + '.' + str(self.frogposition[0]), self.symbols["frog"])

  # apply colors
  for sprite in self.sprites.keys():
   self.highlight_pattern(sprite, self.sprites[sprite])

  # turn off editability
  self.text.state = "disabled"
 ### end of draw_world ###

 def str_replace(self, targetstr, index, char):
  return targetstr[:index] + char + targetstr[index+1:]
 ### end of str_replace ###

 def highlight_pattern(self, sprite, tag):
  start = self.text.index("1.0")
  end = self.text.index("end")
  self.text.mark_set("matchStart", start)
  self.text.mark_set("matchEnd", start)
  self.text.mark_set("searchLimit", end)
  count = tk.IntVar()
  while True:
   index = self.text.search(sprite, "matchEnd", "searchLimit", count=count, regexp=False)
   if(index == ""):
    break
   self.text.mark_set("matchStart", index)
   self.text.mark_set("matchEnd", "%s+%sc" % (index, count.get()))
   self.text.tag_add(tag, "matchStart","matchEnd")
 ### end of highlight_pattern ###
### end of Frogger class ###

# Run the game!!!
frogger = Frogger()

I think the problem comes from updating the screen. If your program runs at 60fps, it takes around 16ms to do. This means your main-loop can't possibly run every 1ms. (This is the general logic, but I have no expertise with Tkinter or other GUI-systems)

Might be worth asking on SO about this. Please post a link here if you do.

I took your advice and asked on SO:
http://stackoverflow.com/questions/23999478/python-tkinter-call-to-after-is-too-slow The screen refresh rate is set to every 20 update ticks, which should be every 20ms, or a rate of 50fps. This seems like it should be trivially easy for any modern computer.

Based on the SO answer, I have changed the program to use a 20-ms timer. I have also fixed a few other bugs in the meantime. If there is enough interest, I will look to add colors to make the ASCII easier to see. Feel free to comment with suggestions, I will do my best to implement them.

This works really well (make sure to run with python3 filename rather than python filename). I've awarded you the bounty as the other answer isn't yet finished

Thanks! I cleaned up the code a bit and added colors. The color highlighting function is directly from: http://stackoverflow.com/questions/3781670/tkinter-text-highlighting-in-python

I added unicode characters for slightly better graphics, increased the font size, and fixed a number of small bugs. If anyone has further improvements to suggest, let me know! This was a lot of fun to write, and it's not even that bad to play ;)

C++ 1710
I started an ASCII console version. The frog can move. Still working on other requirements.
Haven't yet done object detection or scoring. Frog moves with keys w,a,s,d.
#include <iostream>
#include <stdlib.h>
#include <time.h>
using namespace std;
#define P(x) cout<<x<<endl
#define R 13
#define C 25
string bank="=========================";
string water="~~~~~~~~~~~~~~~~~~~~~~~~~";
string road="-------------------------";
string log="LOG";
string car="CAR";
string frog="FROG";
string leaf="LEAF";
string rows[R];
bool gameover=false;
int frogX,frogY;

void insertObject(string obj, int row, int pos)
{
    string tmp=rows[row].erase(pos,obj.size());
    tmp.insert(pos,obj);
    rows[row]=tmp;
}

void newBoard()
{
int r,r2;
for(int i=0;i<R;i++)
{
    r=rand()%2+1;//1-3
    if(i==0||i==6||i==12)
    {
        rows[i]=bank;
    }
    else if(i>0&&i<6)
    {
        rows[i]=water;
        for(int j=0;j<r;j++)
        {
            r2=rand()%21;
            insertObject(log, i, r2);
        }
    }
    else
    {
        rows[i]=road;
        for(int j=0;j<r;j++)
        {
            r2=rand()%21;
            insertObject(car, i, r2);
        }
    }
}
insertObject(frog, 12, (int)(C-4)/2);
frogX=(int)(C-4)/2;
frogY=12;
insertObject(leaf, 0, (int)(C-4)/2);
}

void showBoard()
{
#ifdef WIN32
system("cls");
#else
system("clear");
#endif
for(int i=0;i<R;i++)
{
    P(rows[i]);
}
}

void playGame()
{
char c;
int i=0;
while(!gameover)
{
cin>>c;
switch(c)
{
case 'a':
    if(frogX!=0)frogX--;
    break;
case 'w':
    if(frogY!=0)frogY--;
    break;
case 'd':
    if(frogX<21)frogX++;
    break;
case 's':
    if(frogY!=12)frogY++;
    break;
default:
    break;
}
insertObject(frog, frogY, frogX);
showBoard();
i++;
if(i>12) gameover=true;
}
}

int main()
{
    srand(time(0));
    char play='y';
    while(play=='y')
    {
        newBoard();
        showBoard();
        playGame();
        P("Play Again (y/n)?");
        cin>>play;
    }

    return 0;
}

#define s string for a bit more golfing (note: this appears to be one char shorter than typedef string s;)
Or you could do #define t typedef, then t string s;, although I don't know whether that works

also you might want to use ++i instead of i++


text:
How do I alias member functions in Python?
In Python, one can save bytes by aliasing functions that are used repeatedly. For example:
r=range
a=r(100)
b=r(200)
c=r(300)

However, when the functions are member functions together, I don't know how to alias them in a way that allows chaining. For example:
s='Hello'

// Plain code
s=s.replace('H','J').replace('e','i').replace('l','m').replace('o','y')

// What I am trying to do
q=replace
s=s.q('H','J').q('e','i').q('l','m').q('o','y')

Obviously, what I am trying to do is not valid. And neither is this:
q=s.replace
s=q('H','J') // Replaces the 'H' in 'Hello'
s=q('e','i') // Replaces the 'e' in 'Hello'... and the J is gone.
s=q('l','m')
s=q('o','y')

Is there a another way to alias member functions and chained functions that saves characters?

Define your own class, with its method q meaning what replace means in the class your using.

@Ypnypn I see. So you alias the class rather than the function. It seems obvious now that you said it. Do you want to post your answer? I'll even expand it with an example when I get around to it, but I don't get any rep for answering my own question.

I'm glad this hasn't been downvoted :)

I have literally no idea why this kind of tips question has to CW, too.

I've unwikied all the answers for now, but we haven't reached a strong enough consensus to call for unwiki-ing this and similar questions. See also: http://meta.codegolf.stackexchange.com/q/1555/3808

Now that the aforementioned meta discussion is semi-official (or at least most of us agree), I've gone ahead and removed the wiki on this post.

Your last version doesn't work. q is bound to the replace method of that specific str instance. Also, remember you can do single char replacements with "Hello".replace(*"HJ")

@gnibbler Wow, you're right. I guess I never actually tested the bad version. I'll modify the question.

No problemo! You can alias a method, but you have to know how to use it:
>>> r=str.replace
>>> a='hello'
>>> r(r(r(r(a,'h','j'),'e','i'),'l','m'),'o','y')
'jimmy'

The key is that you have to pass self explicitly, because the alias is a kind of function that takes an extra argument that takes self:
>>> type(r)
<type 'method_descriptor'>

How did I not see this before?

Define your own class, with a shorter method name.
For example, if you're using the method replace() belonging to the String class, you could make your own class S have a method called q which does the same thing.
Here is one implementation:
class m(str):
 def q(a,b,c):return m(a.replace(b,c))

Here is a much better implementation:
class m(str):q=lambda a,b,c:m(a.replace(b,c))

Use it like so:
s="Hello"
s=m(s).q('H','J').q('e','i').q('l','m').q('o','y')

This is a few characters shorter anyway
j=iter('HJeilmoy')
for i in j:s=s.replace(i,next(j))

even shorter for a small number of replacements is
for i in['HJ','ei','lm','oy']:s=s.replace(*i)

of course this just covers one particular case. However code golf is all about finding those special cases that can save you bytes.
It's possible to write a wrapper function that handles the general case, but the code will be too large to have a place in most code golf challenges.
You instead need to think "I can do this transformation efficiently (strokewise) with str.replace. Can I shift the internal representation of my solution to take advantage of that? (without wasting so many strokes to negate the advantage)"

I do like this answer because it describes good habits when golfing and definitely solves the specific example presented. I accepted another answer because it is applicable to the more general case.

You may use the reduce function.
reduce(lambda s,(a,b):s.replace(a,b),[('H','J'),('e','i'),('l','m'),('o','y')],'Hello')

If your answer different from this answer (as far as technique used, not necessarily written in the exact same form)?

@Rusher It is different. E.g. the number of invocations is hard-coded in the linked answer while here it is given only by the length of the second argument (which can be any iterator).

If you're doing a lot of replaces, you could do this:
s=''.join({'H':'J','e':'i','l':'m','o':'y'}[a] for a in list(s))

I was hoping for an answer that wasn't specific to replace. I just used that as an example.

This can only replace 1 char at a time, but it can insert multi-char replacements. And this is not fully golfed (remove the space after [a])

Doesn't the [a] have to be replaced with .get(a,a) (otherwise, we get some Key Error thing)? And why have list(s) instead of s?

How about defining a lambda function?
r=lambda s,a,b:s.replace(a,b)

s=r(r(r(r(s,'H','J'),'e','i'),'l','m'),'o','y')

No need: str.replace /is/ that lambda! See my answer.

If your replacements don't need to be chained, you can use `str.translate'. The numbers are the ASCII ordinals. Using it this way requires Python 3:
print("Hello".translate({72:74,101:105,108:109,111:121}))

Try it online


text:
Solve Einstein's riddle
Einstein wrote a riddle. He said that 98% of the world could not solve it.
I solved this riddle in about 25 minutes while on the train to work.
It's basically just deduction.
The riddle

There are 5 houses in 5 different colors in a row.
In each house lives a person with a different nationality.
The 5 owners drink a certain type of beverage, smoke a certain brand of cigar, and keep a certain pet.
No owners have the same pet, smoke the same brand of cigar, or drink the same beverage.
Question: Who owns the fish?

To solve this riddle Einstein provides 15 hints:

The Brit lives in the red house.
The Swede keeps dogs as pets.
The Dane drinks tea.
The green house is on the immediate left of the white house.
The green house's owner drinks coffee.
The owner who smokes Pall Mall rears birds.
The owner of the yellow house smokes Dunhill.
The owner living in the center house drinks milk.
The Norwegian lives in the first house.
The owner who smokes Blends lives next to the one who keeps cats.
The owner who keeps the horse lives next to the one who smokes Dunhill.
The owner who smokes Bluemasters drinks beer.
The German smokes Prince.
The Norwegian lives next to the blue house.
The owner who smokes Blends lives next to the one who drinks water.

With these hints you can come to a solution.
Your task:
Make a program that will solve this riddle for you.
Hard coding the solution isn't allowed (duh)
It is allowed to hardcode the hints in any format.
Example format:
//Hints in order
(Nationality:Brit)==(Color:Red)
(Nationality:Swede)==(Pet:Dogs)
(Nationality:Dane)==(Drink: Tea)
(Color:Green)/(Color:White)
(Color:Green)==(Drink:Coffee)
(Smoke:PallMall)==(Pet:Birds)
(Color:Yellow)==(Smoke:Dunhill)
(House:3)==(Drink:Milk)
(Nationality:Norwegian)==(House:1)
(Smoke:Blend)/\(Pet:Cats)

== means equals to
/ means on left side of
\ means on right side of
/\ means left or right of

Like I said its allowed to either hardcode hints or have them as input.
Output:
Output should be in the following format (With the correct values, just saying for the trolls ;) )
 _____________    _____________    _____________    _____________    _____________
|   Number    |  |   Number    |  |   Number    |  |   Number    |  |   Number    |
| Nationality |  | Nationality |  | Nationality |  | Nationality |  | Nationality |
|    Color    |  |    Color    |  |    Color    |  |    Color    |  |    Color    |
|    Drink    |  |    Drink    |  |    Drink    |  |    Drink    |  |    Drink    |
|    Smoke    |  |    Smoke    |  |    Smoke    |  |    Smoke    |  |    Smoke    |
|     Pet     |  |     Pet     |  |     Pet     |  |     Pet     |  |     Pet     |
---------------  ---------------  ---------------  ---------------  ---------------

The <Nationality> in the <Color> house owns the fish!

Ascii art boxes can be changed by you, as long as they are boxes, doesn't matter what symbols you use.
Any knowledge on this riddle and solution can not be used in the program.
It should use pure logic and deduction to solve the riddle.
Tagged this as a codegolf but might be a code challenge, not sure.
Any thoughts on winning criteria for a code challenge feel free to share :)
For now this is code-golf so the program with the lowest bytecount wins.
Good luck and Happy coding :)

If one were to hardcode the "instructions", do those count as characteres in the code?

Yes they would.

The claims of the first paragraph are almost certainly false.

@PeterTaylor What do you mean? The 98% and the einstein bit? Wouldn't know it for sure, the interwebs say it and regardless, its fun for the background :) I felt special when I solved it, "yay im in those 2%"

Both of those bits. The interwebs also feature the Timecube, so you would be well advised not to believe everything they say, especially when they don't adduce any evidence.

@PeterTaylor Yes I know, but like I also said, its fun for the background anyhow and its not like the fact, or fiction, is essential for the given problem. Also wikipedia states there is no real evidence for it :)

I think solutions should be able to generalize to an arbitrary number of houses, properties, and hints. Then it would be a truly interesting question which you wouldn't have to throw in "no hardcoding" as a rule. Which in my experience always leads to a question of how much it really is hardcoding.

Isn't this more suitable for Puzzling?

Prolog - 954 Characters
m(A,Z):-member(A,Z).
e:-e(Z),w(Z).
e(Z):-Z=[[1,A,F,K,P,U],[2,B,G,L,Q,V],[3,C,H,M,R,W],[4,D,I,N,S,X],[5,E,J,O,T,Y]],m([_,b,r,_,_,_],Z),m([_,s,_,d,_,_],Z),m([_,d,_,_,t,_],Z),m([WH,_,w,_,_,_],Z),m([GH,_,g,_,_,_],Z),GH=:=WH-1,m([_,_,g,_,c,_],Z),m([_,_,_,b,_,p],Z),m([_,_,y,_,_,d],Z),m([3,_,_,_,m,_],Z),m([1,n,_,_,_,_],Z),m([BH,_,_,_,_,b],Z),m([CH,_,_,c,_,_],Z),(BH=:=CH+1;BH=:=CH-1),m([DH,_,_,_,_,d],Z),m([HH,_,_,h,_,_],Z),(HH=:=DH+1;HH=:=DH-1),m([_,_,_,_,b,l],Z),m([_,g,_,_,_,r],Z),m([NH,n,_,_,_,_],Z),m([YH,_,b,_,_,_],Z),(NH=:=YH+1;NH=:=YH-1),m([SH,_,_,_,_,b],Z),m([XH,_,_,_,w,_],Z),(SH=:=XH+1;SH=:=XH-1),p([n,d,b,g,s],[A,B,C,D,E]),p([y,b,r,g,w],[F,G,H,I,J]),p([c,h,b,f,d],[K,L,M,N,O]),p([w,t,m,c,b],[P,Q,R,S,T]),p([d,b,p,r,l],[U,V,W,X,Y]).
t(X,[X|R],R).
t(X,[F|R],[F|S]):-t(X,R,S).
p([W|X],Y):-p(X,V),t(W,Y,V).
p([],[]).
b:-write('+--+--+--+--+--+--+'),nl.
z(A):-writef('|%2L|%2L|%2L|%2L|%2L|%2L|',A),nl.
w([A,B,C,D,E]):-b,z(A),z(B),z(C),z(D),z(E),b.

Output
+--+--+--+--+--+--+
|1 |n |y |c |w |d |
|2 |d |b |h |t |b |
|3 |b |r |b |m |p |
|4 |g |g |f |c |r |
|5 |s |w |d |b |l |
+--+--+--+--+--+--+

Key:

First column is house number;
Second column is nationality;
Third column is favorite color;
Fourth column is pet;
Fifth column is drink; and
Sixth column is cigarette (r = prince, l = bluemaster).

This is the right language for the job.

Shouldn't you spell out the names to make the golf numbers comparable?

Ruby 322 + input 442
Brute force search of nearly 25 billion possible answers.
My computer would take about 75 days to run this program.
I never verified if this program prints a correct answer!
Run as ruby riddle.rb < riddle.in
riddle.rb (332 bytes)
g=readlines
v=g.shift(5).map &:split
c,*d=v.map{|a|[*a.permutation]}
c.product(*d){|a|(f=eval a.map{|b|b.each_with_index.map{|s,i|"#{s}=#{i}\n"}.join}.join+'g.map{|h|eval h}.all?&&fish')&&(r=['-----------']*5
puts [r,[*0..4],*a,r].map{|s|s.map{|t|'|%11s|'%t}.join},"The #{a[0][f]} in the #{a[1][f]} house owns the fish!")}

riddle.in (442 bytes)
brit dane german norwegian swede
blue green red white yellow
beer coffee milk tea water
blends bluemasters dunhill pall_mall prince
birds cats dogs fish horse
brit==red
swede==dogs
dane==tea
green==white-1
green==coffee
pall_mall==birds
yellow==dunhill
2==milk
norwegian==0
blends==cats-1||blends==cats+1
horse==dunhill-1||horse==dunhill+1
bluemasters==beer
german==prince
norwegian==blue-1||norwegian==blue+1
blends==water-1||blends==water+1

The input file must contain 5 lines of names, followed by lines of logical expressions. House numbers are 0 to 4. There must be a fish.
The program calls Array#permutation five times to find all ways to order the arrays of nationalities, colors, drinks, smokes and pets. The long loop is c.product(*d){|a|...}, calling Array#product to iterate nearly 25 billion possible answers. The loop body has the form (f=eval ...)&&(...). The eval ... part evaluates the logical expressions. If all are true, then f is the house number of the fish and the &&(...) part prints the answer. House number 0 is true in Ruby.
Code golf means not adding code for speed! But I lack 75 days to run the program!

Even using one or two clues instead of brute force would save lots of searching.

I don't know Ruby, but the Internet says that it is slow. I bet that if you translated your answer to compiled language and then optimized it even slightly, you might get close(r?) to the 5000% speedup you need to verify correctness in a reasonable amount of time. If you wrote even the crudest, but well-documented, Java translation, I would be happy to optimize it for you and then verify correctness.

Prolog, 653 characters
a([],L,L).
a([H|T],L2,[H|L3]):-a(T,L2,L3).
m(X,L):-a(_,[X|_],L).
r(X,Y,L):-a(_,[X,Y|_],L).
n(X,Y,L):-r(X,Y,L);r(Y,X,L).
s:-s(S),w(S).
s(S):-length(S,5),m([b,r,_,_,_],S),m([s,_,_,_,d],S),m([d,_,t,_,_],S),r([_,g,_,_,_],[_,w,_,_,_],S),m([_,g,c,_,_],S),m([_,_,_,p,b],S),m([_,y,_,d,_],S),S=[_,_,[_,_,m,_,_],_,_],S=[[n,_,_,_,_],_,_,_,_],n([_,_,_,b,_],[_,_,_,_,c],S),n([_,_,_,d,_],[_,_,_,_,h],S),m([_,_,b,l,_],S),m([g,_,_,r,_],S),n([n,_,_,_,_],[_,b,_,_,_],S),n([_,_,_,b,_],[_,_,w,_,_],S),m([_,_,_,_,f],S).
b:-write('----------------+'),nl.
z(Y,A):-write(Y),writef('|%2L|%2L|%2L|%2L|%2L|',A),nl.
w([S1,S2,S3,S4,S5]):-b,z(1,S1),z(2,S2),z(3,S3),z(4,S4),z(5,S5),b.

I took the liberty of removing unnecessary spaces and linebreaks in your code, which gets it down to 653 characters.

Tested on SWI-Prolog , Just type ?- s.

Smalltalk 1332 chars
Using plain Smalltalk:
|n c v g p t r|n:=#(Brit Swede Dane Norwegian German
Red Green White Yellow Blue
Tea Coffee Milk Beer Water
PallMall Dunhill Blends Bluemasters Prince
Dogs Birds Cats Horses Fish).
v:=Dictionary new.n do:[:n|v at:n put:nil].g:=n splitForSize:5.
c:={{[:b :r|b==r].#Brit.#Red}.{[:s :d|s==d].#Swede.#Dogs}.{[:d :t|d==t].#Dane.#Tea}.
{[:g :w|g==(w-1)].#Green.#White}.{[:g :c|g==c].#Green.#Coffee}.
{[:p :b|p==b].#PallMall.#Birds}.{[:y :d|y==d].#Yellow.#Dunhill}.
{[:m|m==3].#Milk}.{[:n|n==1].#Norwegian}.{[:b :c|(b-c)abs==1].#Blends.#Cats}.
{[:h :d|(h-d)abs==1].#Horses.#Dunhill}.{[:m :b|m==b].#Bluemasters.#Beer}.
{[:g :p|g==p].#German.#Prince}.{[:n :b|(n-b)abs==1].#Norwegian.#Blue}.
{[:b :w|(b-w)abs==1].#Blends.#Water}}.
t:=[:c|x:=(c from:2collect:[:n|v at:n]).(x includes:nil)or:[c first valueWithArguments:x]].
p:=[|f|(((''-'',* 16),'' ''),*5)printCR.g do:[:n||w|w:=n collect:[:n|v at:n].w sortWith:n.
n do:[:n|''|''print.(n centerPaddedTo:14)print.''| ''print].''''printCR.].(((''-'',* 16),'' ''),*5)printCR.
f:=v at:#Fish.(''The %1 in the %2 house owns the fish''bindWith:(g first detect:[:n|(v at:n)==f])with:((g at:2) detect:[:n|(v at:n)==f]))printCR].
r:=[:gi|gi==0ifTrue:p ifFalse:[#(1 2 3 4 5)permutationsDo:[:perm|v declareAll:(g at:gi)from:perm.
(c conform:t)ifTrue:[r value:gi-1]].v declareAll:(g at:gi)from:#(nil),*5]].
r value:g size.

Output:
---------------- ---------------- ---------------- ---------------- ----------------
|  Norwegian   | |     Dane     | |     Brit     | |    German    | |    Swede     |
|    Yellow    | |     Blue     | |     Red      | |    Green     | |    White     |
|    Water     | |     Tea      | |     Milk     | |    Coffee    | |     Beer     |
|   Dunhill    | |    Blends    | |   PallMall   | |    Prince    | | Bluemasters  |
|     Cats     | |    Horses    | |    Birds     | |     Fish     | |     Dogs     |
---------------- ---------------- ---------------- ---------------- ----------------
The German in the Green house owns the fish

As the golfed version is almost unreadable, here is the developer's code with proper names, indentation and spaces for readability:
|names constraints foundSolution v groups printSolution testC test try|

names := #(Brit Swede Dane Norwegian German
 Red Green White Yellow Blue
 Tea Coffee Milk Beer Water
 PallMall Dunhill Blends Bluemasters Prince
 Dogs Birds Cats Horses Fish).

v := Dictionary new.
names do:[:n | v at:n put:nil].
groups := names splitForSize:5.

constraints := {
        {[:b :r | b==r] . #Brit . #Red   }.          "/ The Brit lives in the red house.
        {[:s :d | s==d] . #Swede . #Dogs }.          "/ The Swede keeps dogs as pets.
        {[:d :t | d==t] . #Dane . #Tea   }.          "/ The Dane drinks tea.
        {[:g :w | g==(w-1)] . #Green . #White }.     "/ The green house is on the immediate left of the white house.
        {[:g :c | g==c] . #Green . #Coffee}.         "/ The green house's owner drinks coffee.
        {[:p :b | p==b] . #PallMall . #Birds}.       "/ The owner who smokes Pall Mall rears birds.
        {[:y :d | y==d] . #Yellow . #Dunhill}.       "/ The owner of the yellow house smokes Dunhill.
        {[:m | m==3] . #Milk}.                       "/ The owner living in the center house drinks milk.
        {[:n | n==1] . #Norwegian }.                 "/ The Norwegian lives in the first house.
        {[:b :c | (b-c)abs==1] . #Blends . #Cats}.   "/ The owner who smokes Blends lives next to the one who keeps cats.
        {[:h :d | (h-d)abs==1] . #Horses . #Dunhill}."/ The owner who keeps the horse lives next to the one who smokes Dunhill.
        {[:m :b | m==b] . #Bluemasters . #Beer}.     "/ The owner who smokes Bluemasters drinks beer.
        {[:g :p | g==p] . #German . #Prince}.        "/ The German smokes Prince.
        {[:n :b | (n-b)abs==1] . #Norwegian . #Blue}."/ The Norwegian lives next to the blue house.
        {[:b :w | (b-w)abs==1] . #Blends . #Water}.  "/ The owner who smokes Blends lives next to the one who drinks water.
}.
testC := [:c | vi:=((c from:2) collect:[:n|v at:n]). (vi includes:nil) or:[c first valueWithArguments:vi]].
test := [constraints conform:testC].

printSolution :=
 [  |f|
    ((('-',* 16),' '),*5) printCR.
    groups do:[:names|
         |values|
         values := names collect:[:nm|v at:nm].
         values sortWith:names.
         names do:[:n| '|'print. (n centerPaddedTo:14)print.'| ' print].
         '' printCR.
    ].
    ((('-',* 16),' '),*5) printCR.
    f := v at:#Fish.
    ('The %1 in the %2 house owns the fish'
        bindWith:((groups at:1) detect:[:n|(v at:n)==f])
        with:((groups at:2) detect:[:n|(v at:n)==f]))printCR
 ].

try := [:gi |
    gi == 0
     ifTrue: printSolution
     ifFalse:[
        (1 to:5) asArray permutationsDo:[:perm |
            v declareAll:(groups at:gi) from:perm.
            test value ifTrue:[
                try value:(gi-1).
            ].
        ].
        v declareAll:(groups at:gi) from:#(nil nil nil nil nil).
    ].
].
try value:groups size.

Using a constraint solver library:
Using a constraint solver library, which is very similar to the one described in the OZ/Mozart manual.
As I expect you will complain this being not valid for the contest ;-), it is added for your amusement and inspiration only (look for a contraint package in your language), ungolfed, and not counting chars.
|solution|

solution := Solver
    anySolutionFor:[
        |Brit Swede Dane Norwegian German
         Red Green White Yellow Blue
         PallMall Dunhill Prince Blends Bluemasters
         Tea Coffee Water Beer Milk
         Dogs Birds Cats Horses Fish|

        Brit        := (1 %% 5) name:#Brit.
        Swede       := (1 %% 5) name:#Swede.
        Dane        := (1 %% 5) name:#Dane.
        Norwegian   := (1 %% 5) name:#Norwegian.
        German      := (1 %% 5) name:#German.

        Red     := (1 %% 5) name:#Red.
        Green   := (1 %% 5) name:#Green.
        White   := (1 %% 5) name:#White.
        Yellow  := (1 %% 5) name:#Yellow.
        Blue    := (1 %% 5) name:#Blue.

        PallMall     := (1 %% 5) name:#PallMall.
        Dunhill      := (1 %% 5) name:#Dunhill.
        Prince       := (1 %% 5) name:#Prince.
        Blends       := (1 %% 5) name:#Blends.
        Bluemasters  := (1 %% 5) name:#Bluemasters.

        Tea    := (1 %% 5) name:#Tea.
        Coffee := (1 %% 5) name:#Coffee.
        Milk   := (1 %% 5) name:#Milk.
        Water  := (1 %% 5) name:#Water.
        Beer   := (1 %% 5) name:#Beer.

        Dogs         := (1 %% 5) name:#Dogs.
        Birds        := (1 %% 5) name:#Birds.
        Cats         := (1 %% 5) name:#Cats.
        Horses       := (1 %% 5) name:#Horses.
        Fish         := (1 %% 5) name:#Fish.

        Solver allDistinct:{ Brit . Swede . Dane . Norwegian . German. }.
        Solver allDistinct:{ Red. Green. White. Yellow. Blue. }.
        Solver allDistinct:{ PallMall. Dunhill. Prince. Blends. Bluemasters. }.
        Solver allDistinct:{ Tea. Coffee. Milk. Water. Beer }.
        Solver allDistinct:{ Dogs. Birds. Cats. Horses. Fish. }.

        Brit       =: Red.           "/ The Brit lives in the red house.
        Swede      =: Dogs.          "/ The Swede keeps dogs as pets.
        Dane       =: Tea.           "/ The Dane drinks tea.
        Green =: (White - 1).        "/ The green house is on the immediate left of the white house.
        Green =: Coffee.             "/ The green house's owner drinks coffee.
        PallMall   =: Birds.         "/ The owner who smokes Pall Mall rears birds.
        Yellow =: Dunhill.           "/ The owner of the yellow house smokes Dunhill.
        Milk =: 3.                   "/ The owner living in the center house drinks milk.
        Norwegian =: 1.              "/ The Norwegian lives in the first house.
        (Blends - Cats) abs =: 1.    "/ The owner who smokes Blends lives next to the one who keeps cats.
        (Horses - Dunhill) abs =: 1. "/ The owner who keeps the horse lives next to the one who smokes Dunhill.
        Bluemasters =: Beer.         "/ The owner who smokes Bluemasters drinks beer.
        German =: Prince.            "/ The German smokes Prince.
        (Norwegian - Blue) abs =: 1. "/ The Norwegian lives next to the blue house.
        (Blends - Water) abs =: 1.   "/ The owner who smokes Blends lives next to the one who drinks water.
    ].

solution printCR.

Notice the "=:" operator, which means "unify with". The solver uses a backtracking algorithm on the set of constraints defined in the problem block.
The remaining code prints the solution into boxes:
    |pLine pSorted f |

    pLine := [
        (1 to:5) do:[:i | ('-' ,* 15) print] separatedBy:[' ' print].
        '' printCR.
    ].
    pSorted := [:keys |
        |items t|

        items := keys collect:[:k| solution at:k].
        t := keys copy. items values sortWith:t.
        pLine value:(t collect:[:x | '| ',(x centerPaddedTo:11),' |']).
    ].

    pLine value.
    pSorted value:#( Brit Swede Dane Norwegian German ).
    pSorted value:#( Red Green White Yellow Blue ).
    pSorted value:#( Tea Coffee Milk Water Beer ).
    pSorted value:#( PallMall Dunhill Prince Blends Bluemasters ).
    pSorted value:#( Dogs Birds Cats Horses Fish ).
    pLine value.

    f := solution at:'Fish'.
    ('The %1 in the %2 house owns the fish!'
        bindWith:(#( Brit Swede Dane Norwegian German ) detect:[:n| (solution at:n) == f])
        with:(#( Red Green White Yellow Blue ) detect:[:n| (solution at:n) == f])
            ) printCR.

Output:
Solution(Brit->3 Swede->5 Dane->2 Norwegian->1 German->4 Red->3 Green->4
 White->5 Yellow->1 Blue->2 PallMall->3 Dunhill->1 Prince->4 Blends->2
 Bluemasters->5 Tea->2 Coffee->4 Milk->3 Water->1 Beer->5 Dogs->5 Birds->3
 Cats->1 Horses->2 Fish->4)
--------------- --------------- --------------- --------------- ---------------
|  Norwegian  | |    Dane     | |    Brit     | |   German    | |    Swede    |
|   Yellow    | |    Blue     | |     Red     | |    Green    | |    White    |
|    Water    | |     Tea     | |    Milk     | |   Coffee    | |    Beer     |
|   Dunhill   | |   Blends    | |  PallMall   | |   Prince    | | Bluemasters |
|    Cats     | |   Horses    | |    Birds    | |    Fish     | |    Dogs     |
--------------- --------------- --------------- --------------- ---------------
The German in the Green house owns the fish!

Edit: oops - I forgot to print the "who owns the fish" line in the plain version.

Ruby 1166 characters
Edit: Updated for correct output format
Runs consistently in under 0.2 seconds on a MBP i5.
Source: View On Github
One-liner:
def q(a);a.permutation;end;def z(a,b,c,d);l(a,b,c,d)||l(c,d,a,b);end;def l(a,b,c,d);(0..4).any?{|i|a[i]==b&&c[i+1]==d};end;def i(a,b,c,d);(0..4).any?{|i|a[i]==b&&c[i]==d};end;def t(i);['White','Yellow','Blue','Red','Green','German','Swede','Brit','Norwegian','Dane','Birds','Cats','Horses','Fish','Dogs','Beer','Water','Tea','Milk','Coffee','Blends','PallMall','Prince','Bluemasters','Dunhill'][i];end;def y(s);l=13-s.length;'|'+' '*(l/2.0).floor+s+' '*(l/2.0).ceil+'|';end;def d(s);b=[' '+(0..4).map{'_'*13}.join(' '*4)];u='  ';b<<[1,2,3,4,5].map{|i|y(i.to_s)}.join(u);s.each{|i|b<<i.map{|j|y(t(j))}.join(u)};b<<(0..4).map{'-'*15}.join(u);b<<'';z=s[4].index(13);b<<"The #{t s[0][z]} in the #{t s[1][z]} house owns the fish!";b.join "\n";end;q([0,1,2,3,4]).each{|c|l(c,4,c,0)||next;q([5,6,7,8,9]).each{|n|i(n,7,c,3)||next;n[0]==8||next;z(n,8,c,2)||next;q([10,11,12,13,14]).each{|a|i(n,6,a,14)||next;q([15,16,17,18,19]).each{|d|d[2]==18||next;i(c,4,d,19)||next;i(n,9,d,17)||next;q([20,21,22,23,24]).each{|s|z(a,12,s,24)||next;i(s,21,a,10)||next;z(s,20,d,16)||next;z(s,20,a,11)||next;i(n,5,s,22)||next;i(c,1,s,24)||next;i(s,23,d,15)||next;puts d([n,c,d,s,a]);exit}}}}}

Padded with newlines to fit the page:
def q(a);a.permutation;end;def z(a,b,c,d);l(a,b,c,d)||l(c,d,a,b);end
def l(a,b,c,d);(0..4).any?{|i|a[i]==b&&c[i+1]==d};end;def i(a,b,c,d);
(0..4).any?{|i|a[i]==b&&c[i]==d};end;def t(i);['White','Yellow','Blue',
'Red','Green','German','Swede','Brit','Norwegian','Dane','Birds',
'Cats','Horses','Fish','Dogs','Beer','Water','Tea','Milk','Coffee',
'Blends','PallMall','Prince','Bluemasters','Dunhill'][i];end;def y(s);
l=13-s.length;'|'+' '*(l/2.0).floor+s+' '*(l/2.0).ceil+'|';end;
def d(s);b=[' '+(0..4).map{'_'*13}.join(' '*4)];u='  ';
b<<[1,2,3,4,5].map{|i|y(i.to_s)}.join(u);s.each{|i|b<<i.map{|j|
y(t(j))}.join(u)};b<<(0..4).map{'-'*15}.join(u);b<<'';
z=s[4].index(13);
b<<"The #{t s[0][z]} in the #{t s[1][z]} house owns the fish!";
b.join "\n";end;q([0,1,2,3,4]).each{|c|l(c,4,c,0)||next;
q([5,6,7,8,9]).each{|n|i(n,7,c,3)||next;n[0]==8||next;z(n,8,c,2)||next;
q([10,11,12,13,14]).each{|a|i(n,6,a,14)||next;
q([15,16,17,18,19]).each{|d|d[2]==18||next;i(c,4,d,19)||next;
i(n,9,d,17)||next;q([20,21,22,23,24]).each{|s|z(a,12,s,24)||next;
i(s,21,a,10)||next;z(s,20,d,16)||next;z(s,20,a,11)||next;i(n,5,s,22)||next;
i(c,1,s,24)||next;i(s,23,d,15)||next;puts d([n,c,d,s,a]);exit}}}}}

Outputs:
 _____________    _____________    _____________    _____________    _____________
|      1      |  |      2      |  |      3      |  |      4      |  |      5      |
|  Norwegian  |  |    Dane     |  |    Brit     |  |   German    |  |    Swede    |
|   Yellow    |  |    Blue     |  |     Red     |  |    Green    |  |    White    |
|    Water    |  |     Tea     |  |    Milk     |  |   Coffee    |  |    Beer     |
|   Dunhill   |  |   Blends    |  |  PallMall   |  |   Prince    |  | Bluemasters |
|    Cats     |  |   Horses    |  |    Birds    |  |    Fish     |  |    Dogs     |
---------------  ---------------  ---------------  ---------------  ---------------

The German in the Green house owns the fish!

Ungolfed Code
@colors        = [:white, :yellow, :blue, :red, :green].shuffle.permutation
@cigars        = [:blends, :pall_mall, :prince, :bluemasters, :dunhill].shuffle.permutation
@nationalities = [:german, :swedish, :british, :norwegian, :danish,].shuffle.permutation
@drinks        = [:beer, :water, :tea, :milk, :coffee].shuffle.permutation
@pets          = [:birds, :cats, :horses, :fish, :dogs].shuffle.permutation

def next_to?(set_a, val_a, set_b, val_b)
  left_of?(set_a, val_a, set_b, val_b) ||
  left_of?(set_b, val_b, set_a, val_a)
end

def left_of?(set_a, val_a, set_b, val_b)
  (0..4).any? do |i|
    set_a[i]   == val_a &&
    set_b[i+1] == val_b
  end
end

def implies?(set_a, val_a, set_b, val_b)
  (0..4).any? do |i|
    set_a[i] == val_a &&
    set_b[i] == val_b
  end
end

def solve
  i = 0
  @colors.each do |colors|
    i += 1
    next unless left_of?(colors, :green, colors, :white)
    @nationalities.each do |nationalities|
      i += 1
      next unless implies?(nationalities, :british, colors, :red)
      next unless nationalities[0] == :norwegian
      next unless next_to?(nationalities, :norwegian, colors, :blue)
      @pets.each do |pets|
        i += 1
        next unless implies?(nationalities, :swedish, pets, :dogs)
        @drinks.each do |drinks|
          i += 1
          next unless drinks[2] == :milk
          next unless implies?(colors, :green, drinks, :coffee)
          next unless implies?(nationalities, :danish, drinks, :tea)
          @cigars.each do |cigars|
            i += 1
            next unless next_to?(pets, :horses, cigars, :dunhill)
            next unless implies?(cigars, :pall_mall, pets, :birds)
            next unless next_to?(cigars, :blends, drinks, :water)
            next unless next_to?(cigars, :blends, pets, :cats)
            next unless implies?(nationalities , :german, cigars, :prince)
            next unless implies?(colors, :yellow, cigars, :dunhill)
            next unless implies?(cigars, :bluemasters,  drinks, :beer)
            return [colors, nationalities, pets, drinks, cigars], i
          end
        end
      end
    end
  end
end

class Symbol
  def humanize
    result = self.to_s
    result.gsub!('_', ' ')
    result.split(' ').collect{|part| part.capitalize }.join(' ')
  end
end

solution, attempts = solve

puts "\nSolved in #{attempts} attempts.\n\n"

for i in (0..4)
  number, color, nationality, cigar, drink, pet = i+1, solution[0][i], solution[1][i].humanize, solution[4][i].humanize, solution[3][i], solution[2][i]
  puts "House #{number} is #{color}. The owner is #{nationality}, smokes #{cigar}, drinks #{drink}, and keeps #{pet}."
end

puts "\n"

Outputs:
Solved in 37663 attempts.

House 1 is yellow. The owner is Norwegian, smokes Dunhill, drinks water, and keeps cats.
House 2 is blue. The owner is Danish, smokes Blends, drinks tea, and keeps horses.
House 3 is red. The owner is British, smokes Pall Mall, drinks milk, and keeps birds.
House 4 is green. The owner is German, smokes Prince, drinks coffee, and keeps fish.
House 5 is white. The owner is Swedish, smokes Bluemasters, drinks beer, and keeps dogs.

The use of shuffle in the initial setup ensures unique solution paths every time. You can see this by the number of attempts altering between runs. This mitigates the need to feed in the input separately, though altering the code to do so would be trivial.

The output does not match the required format.

Here at PPCG, it's not enough to have the right solution. Answers must match the specification, which includes formatting it the right way.

Ok. Original post updated with formatting code to meet the challenge spec.