text:
Acronym to phrase
Task:
Create a program that will take an acronym as input, for example dftba, and generate some possible phrases that the acronym could stand for. You can use wordlist as word input. Inspired by https://www.youtube.com/watch?v=oPUxnpIWt6E
Example:
input: dftba
output: don't forget to be awesome

Rules:

Your program can't generate the same phrase every time for the same acronym, there must be randomization
Input will be all lowercase
Post a few examples (input and output)
Any language is accepted
It's a popularity-contest, so most upvotes win!

Please show an example output.

@MukulKumar added it

It needs to be meaningful ? or any combination?

It does not need to be meaningful

How many times is the user allowed to run the program? At some point the program can't but break rule #1.

@MrLister i was referring to about 5 tries

"Any language is accepted" — does that refer to the programming language, or to the language the acronym is expanded in?

@celtschk - any programming language

HTML, CSS, and JavaScript
HTML

CSS
.letter {
    border: 1px solid black;
    padding: 5px;
}

#word-shower {
    border-bottom: 3px solid blue;
    padding-bottom: 5px;
}

JS
var acronym = 'dftba', $letters = $('#letter-container')
for (var i = 0; i < acronym.length; i++) {
    $letters.append($('
').text(acronym[i]).attr('class', 'letter'))
}

var $word = $('#word-shower')
setInterval(function() {
    $.getJSON('http://whateverorigin.org/get?url=' + encodeURIComponent('http://randomword.setgetgo.com/get.php') + '&callback=?', function(word) {
        word = word.contents.toLowerCase()
        $word.text(word)
        $letters.children().each(function() {
            if (word[0] == this.innerText) {
                this.innerText = word
                return
            }
        })
    })
}, 1000)

Uses a random word generator and shows live results as it looks for words.
Here is a fiddle if you want to run it yourself.
Here's a GIF of the output:

Java
Fetches a word list from wiktionary.  Chooses a random word from that list that starts with the correct letter.  Then uses Google suggest recursively to look for possible next words.  Outputs a list of possibilities.  If you re-run it with the same acronym, you will get different results.
import java.io.*;
import java.net.*;
import java.util.*;

public class Acronym {

    static List<List<String>> wordLists = new ArrayList<List<String>>();
    static {for(int i=0; i<26; i++) wordLists.add(new ArrayList<String>());}
    static String acro;

    public static void main(String[] args) throws Exception {
        acro = args[0].toLowerCase();

        //get a wordlist and put words into wordLists by first letter
        String s = "http://en.wiktionary.org/wiki/Wiktionary:Frequency_lists/PG/2006/04/1-10000";
        URL url = new URL(s);
        BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));

        String inputLine;
        while ((inputLine = in.readLine()) != null) {
            if(inputLine.contains("title")) {
                int start = inputLine.indexOf("title=\"");
                int end = inputLine.lastIndexOf("\">");
                if(start>=0 && end > start) {
                    String word = inputLine.substring(start+7,end).toLowerCase();
                    if(!word.contains("'") && !word.contains(" ")) {
                        char firstChar = word.charAt(0);
                        if(firstChar >= 'a' && firstChar <='z') {
                            wordLists.get(firstChar-'a').add(word);
                        }
                    }
                }
            }
        }

        //choose random word from wordlist starting with first letter of acronym
        Random rand = new Random();
        char firstChar = acro.charAt(0);
        List<String> firstList = wordLists.get(firstChar-'a');
        String firstWord = firstList.get(rand.nextInt(firstList.size()));

        getSuggestions(firstWord,1);

    }

    static void getSuggestions(String input,int index) throws Exception {
        //ask googleSuggest for suggestions that start with search plus the next letter as marked by index
        String googleSuggest = "http://google.com/complete/search?output=toolbar&q=";
        String search = input + " " + acro.charAt(index);
        String searchSub = search.replaceAll(" ","%20");

        URL url = new URL(googleSuggest + searchSub);
        BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));

        String inputLine;
        while ((inputLine = in.readLine()) != null) {
            String[] parts = inputLine.split("\"");
            for(String part : parts) {
                if(part.startsWith(search)) {
                    //now get suggestions for this part plus next letter in acro
                    if(index+1<acro.length()) {
                        String[] moreParts = part.split(" ");
                        Thread.sleep(100);
                        getSuggestions(input + " " + moreParts[index],index+1);
                    }
                    else {
                        String[] moreParts = part.split(" ");
                        System.out.println(input + " " + moreParts[index]);
                    }
                }
            }
        }
        in.close();
    }
}

Sample output:
$ java -jar Acronym.jar ght
great harvest trek
great harvest tulsa
great harvest taylorsville
great harvest temecula
great harvest trek
great harvest twin
great harvest tempe
great harvest twin
great harvest turners
great harvest twitter
great horned toad
great horned toads
great horned tomato
great horned tomato
great horned turtle
great harvest trek
great harvest tulsa
great harvest taylorsville
great harvest temecula
great harvest trek
great harvest twin
great harvest tempe
great harvest twin
great harvest turners
great harvest twitter
great horned toad
great horned toads
great horned tomato
great horned tomato
great horned turtle
great harvest trek
great harvest tulsa
great harvest taylorsville
great harvest temecula
great harvest trek
great harvest twin
great harvest tempe
great harvest twin
great harvest turners
great harvest twitter
great horror thriller
great horror tv
great horror thriller
great horror titles
great horror tv
great holiday traditions
great holiday treats
great holiday toasts
great holiday tech
great holiday travel
great holiday treat
great holiday tips
great holiday treat
great holiday toys
great holiday tour
great harvest trek
great harvest tulsa
great harvest taylorsville
great harvest temecula
great harvest trek
great harvest twin
great harvest tempe
great harvest twin
great harvest turners
great harvest twitter
great horned toad
great horned toads
great horned tomato
great horned tomato
great horned turtle

Unfortunately, the Google suggest URL stopped working after a while - perhaps my IP was blacklisted by Google for mis-use?!

Ruby
so ruby. many doge. wow.
Online Version
@prefix = %w[all amazingly best certainly crazily deadly extra ever few great highly incredibly jolly known loftily much many never no like only pretty quirkily really rich sweet such so total terribly utterly very whole xtreme yielding zippily]
@adjective = %w[appealing app apl attractive brave bold better basic common challenge c++ creative credit doge durable dare enticing entertain extreme fail fabulous few favourite giant gigantic google hello happy handy interesting in improve insane jazz joy j java known kind kiwi light laugh love lucky low more mesmerise majestic open overflow opinion opera python power point popular php practice quirk quit ruby read ready stunning stack scala task teaching talking tiny technology unexpected usual useful urban voice vibrant value word water wow where xi xanthic xylophone young yummy zebra zonk zen zoo]

def doge(input)
  wow = ""
  input.chars.each_slice(2) do |char1, char2|
    if char2 == nil
      wow << (@prefix + @adjective).sample(1)[0] + "."
      break
    end
    wow << @prefix.select{|e| e[0] == char1}.sample(1)[0]
    wow << " "
    wow << @adjective.select{|e| e[0] == char2}.sample(1)[0]
    wow << ". "
  end
  wow
end

puts doge("dftba")
puts doge("asofiejgie")
puts doge("iglpquvi")

Examples:
deadly favourite. terribly better. challenge.
all scala. only favourite. incredibly enticing. jolly giant. incredibly extreme.
incredibly gigantic. loftily popular. quirkily usual. very interesting.

certainly light. ever voice. extra ready. extra stack. terribly attractive. never stunning. whole entertain. rich stunning. only favourite. amazingly ruby.

deadly fail. terribly brave. lucky.
all scala. only few. incredibly entertain. jolly google. incredibly entertain.
incredibly google. loftily python. quirkily unexpected. very improve.

Mathematica
Some terms that commonly appear in acronyms.
terms = {"Abbreviated", "Accounting", "Acquisition", "Act", "Action", "Actions", "Activities", "Administrative", "Advisory", "Afloat", "Agency", "Agreement", "Air", "Aircraft", "Aligned", "Alternatives", "Analysis", "Anti-Surveillance", "Appropriation", "Approval", "Architecture", "Assessment", "Assistance", "Assistant", "Assurance", "Atlantic", "Authority", "Aviation", "Base", "Based", "Battlespace", "Board", "Breakdown", "Budget", "Budgeting", "Business", "Capabilities", "Capability", "Capital", "Capstone", "Category", "Center", "Centric", "Chairman", "Change", "Changes", "Chief", "Chief,", "Chiefs", "Closure", "College", "Combat", "Command", "Commandant", "Commander","Commander,", "Commanders", "Commerce", "Common", "Communications", "Communities", "Competency", "Competition", "Component", "Comptroller", "Computer", "Computers,", "Concept", "Conference", "Configuration", "Consolidated", "Consulting", "Contract", "Contracting", "Contracts", "Contractual", "Control", "Cooperative", "Corps", "Cost", "Council", "Counterintelligence", "Course", "Daily", "Data", "Date", "Decision", "Defense", "Deficiency", "Demonstration", "Department", "Depleting", "Deployment", "Depot", "Deputy", "Description", "Deskbook", "Determination", "Development", "Direct", "Directed", "Directive", "Directives", "Director", "Distributed", "Document", "Earned", "Electromagnetic", "Element", "Engagement", "Engineer", "Engineering", "Enterprise", "Environment", "Environmental", "Equipment", "Estimate", "Evaluation", "Evaluation)", "Exchange", "Execution", "Executive", "Expense", "Expert", "Exploration", "Externally", "Federal", "Final", "Financial", "Findings", "Fixed","Fleet", "Fleet;", "Flight", "Flying", "Followup", "Force", "Forces,", "Foreign", "Form", "Framework", "Full", "Function", "Functionality", "Fund", "Funding", "Furnished", "Future", "Government", "Ground", "Group", "Guidance", "Guide", "Handbook", "Handling,", "Hazardous", "Headquarters", "Health", "Human", "Identification", "Improvement", "Incentive", "Incentives", "Independent", "Individual", "Industrial", "Information", "Initial", "Initiation", "Initiative", "Institute", "Instruction", "Integrated", "Integration", "Intelligence", "Intensive", "Interdepartmental", "Interface", "Interference", "Internet", "Interoperability", "Interservice", "Inventory", "Investment", "Joint", "Justification", "Key", "Knowledge", "Lead", "Leader", "Leadership", "Line", "List", "Logistics", "Maintainability", "Maintenance", "Management", "Manager", "Manual", "Manufacturing", "Marine", "Master", "Material", "Materials", "Maturity", "Measurement", "Meeting", "Memorandum", "Milestone", "Milestones", "Military", "Minor", "Mission", "Model", "Modeling", "Modernization", "National", "Naval", "Navy", "Needs", "Network", "Networks", "Number", "Objectives", "Obligation", "Observation", "Occupational", "Offer", "Office", "Officer", "Operating", "Operational", "Operations", "Order", "Ordering", "Organization", "Oversight", "Ozone", "Pacific", "Package", "Packaging,", "Parameters", "Participating", "Parts", "Performance", "Personal", "Personnel", "Planning", "Planning,", "Plans", "Plant", "Point", "Policy", "Pollution", "Practice", "Preferred", "Prevention", "Price", "Primary", "Procedure", "Procedures", "Process", "Procurement", "Product", "Production", "Professional", "Program", "Programmatic", "Programming", "Project", "Proposal", "Protection", "Protocol", "Purchase", "Quadrennial", "Qualified", "Quality", "Rapid", "Rate", "Readiness", "Reconnaissance", "Regulation", "Regulations", "Reliability", "Relocation", "Repair", "Repairables", "Report", "Reporting", "Representative", "Request", "Requirement", "Requirements", "Requiring", "Requisition", "Requisitioning", "Research", "Research,", "Reserve", "Resources", "Responsibility", "Review", "Reviews", "Safety", "Sales", "Scale", "Secretary", "Secure", "Security", "Selection", "Senior", "Service", "Services", "Sharing", "Simulation", "Single", "Small", "Software", "Source", "Staff", "Standard", "Standardization", "Statement", "Status", "Storage,", "Strategy", "Streamlining", "Structure", "Submission", "Substance", "Summary", "Supplement", "Support", "Supportability", "Surveillance", "Survey", "System", "Systems", "Subsystem", "Tactical", "Target", "Targets", "Team", "Teams", "Technical", "Technology", "Test", "Tool", "Total", "Training", "Transportation", "Trouble", "Type", "Union", "Value", "Variable", "Warfare", "Weapon", "Work", "Working", "X-Ray", "Xenon", "Year", "Yesterday", "Zenith", "Zoology"};

Code
f[c_]:=RandomChoice[Select[terms,(StringTake[#,1]==c)&]]
g[acronym_]:=Map[f,Characters@acronym]

Examples
Ten randomly generated candidates for the acronym ABC.
Table[Row[g["ABC"], "  "], {10}] // TableForm

Action  Breakdown  Corps
  Accounting  Budget  Commerce
  Air  Budgeting  Control
  Acquisition  Breakdown  Computer
  Action  Budgeting  Cost
  Aligned  Breakdown  Common
  Aligned  Budgeting  Course
  Advisory  Budgeting  Capability
  Aligned  Battlespace  Common
  Anti-Surveillance  Battlespace  Comptroller

FMP
Table[Row[g["FMP"], "  "], {10}] // TableForm

Findings  Manager  Protocol
  Final  Manual  Purchase
  Flying  Measurement  Personnel
  Full  Manufacturing  Plans
  Form  Measurement  Programming
  Financial  Model  Programmatic
  Future  Modernization  Proposal
  Financial  Measurement  Package
  Form,  Maintenance  Planning
  Full  Modeling  Programmatic

STM
Table[Row[g["STM"], "  "], {10}] // TableForm

Standardization  Total  Modernization
  Service  Tactical  Milestone
  Surveillance  Transportation  Management
  Subsystem  Trouble  Materials
  Structure  Test  Military
  Scale  Test  Materials
  Strategy  Tool  Modernization
  Small  Technology  Minor
  Supportability  Transportation  Manufacturing
  Status  Tool  Management

CRPB
Table[Row[g["CRPB"], "  "], {10}] // TableForm

Cooperative  Regulation  Protection  Business
  Commander  Request  Policy  Base
  Changes  Repair  Programming,  Business
  Closure  Reviews  Project  Budget
  Commerce  Regulations  Parameters  Base
  Contracts  Rapid  Price  Base
  College  Relocation  Practice  Budgeting
  Course  Reporting  Personnel  Battlespace
  Course  Requirement  Procedures  Budget

SARDE
Table[Row[g["SARDE"], "  "], {10}] // TableForm

Supplement  Actions  Requiring  Directives  Estimate
  Scale  Aligned  Requirement  Daily  Estimate
  Secretary  Atlantic  Requisitioning  Director  Expense
  Software  Action  Review  Direct  Exploration
  Support  Act  Readiness  Defense  Electromagnetic
  Software  Abbreviated  Requirement  Decision  Exchange
  Submission  Assessment  Requisition  Description  Executive
  Streamlining  Accounting  Rate  Depot  Evaluation
  Surveillance  Assistant  Requisitioning  Depot  Engagement
  Survey  Assistance  Resources  Deficiency  Expense

D
This mostly produces nonsense, but occasionally it will produce something sensible, or something so silly as to be humourous.
Words are pulled from this JSON file (~2.2MB).
Program takes the acronym from the first command line argument, and supports an optional second argument which tells the program how many phrases to generate.
import std.file : readText;
import std.conv : to;
import std.json, std.random, std.string, std.stdio, std.algorithm, std.array, std.range;

void main( string[] args )
{
    if( args.length < 2 )
        return;

    try
    {
        ushort count = 1;

        if( args.length == 3 )
            count = args[2].to!ushort();

        auto phrases = args[1].toUpper().getPhrases( count );

        foreach( phrase; phrases )
            phrase.writeln();
    }
    catch( Throwable th )
    {
        th.msg.writeln;
        return;
    }
}

string[] getPhrases( string acronym, ushort count = 1 )
in
{
    assert( count > 0 );
}
body
{
    auto words = getWords();
    string[] phrases;

    foreach( _; 0 .. count )
    {
        string[] phrase;

        foreach( chr; acronym )
        {
            auto matchingWords = words.filter!( x => x[0] == chr ).array();
            auto word = matchingWords[uniform( 0, matchingWords.length )];
            phrase ~= word;
        }

        phrases ~= phrase.join( " " );
    }

    return phrases;
}

string[] getWords()
{
    auto text = "words.json".readText();
    auto json = text.parseJSON();
    string[] words;

    if( json.type != JSON_TYPE.ARRAY )
        throw new Exception( "Not an array." );

    foreach( item; json.array )
    {
        if( item.type != JSON_TYPE.STRING )
            throw new Exception( "Not a string." );

        words ~= item.str.ucfirst();
    }

    return words;
}

auto ucfirst( inout( char )[] str )
{
    if( str.length == 1 )
        return str.toUpper();

    auto first = [ str[0] ];
    auto tail  = str[1 .. $];

    return first.toUpper() ~ tail.toLower();
}

Examples:
D:\Code\D\Acronym>dmd acronym.d

D:\Code\D\Acronym>acronym utf 5
Unchallenged Ticklebrush Frication
Unparalysed's Toilsomeness Fructose's
Umpiring Tableland Flimsily
Unctuousness Theseus Flawless
Umbrella's Tarts Formulated

BASH
for char in $(sed -E s/'(.)'/'\1 '/g <<<"$1");
do
    words=$(grep "^$char" /usr/share/dict/words)
    array=($words)
    arrayCount=${#array[*]}
    word=${array[$((RANDOM%arrayCount))]}
    echo -ne "$word "
done
echo -ne "\n"

So: $ bash acronym-to-phrase.sh dftba resulted in
deodorization fishgig telolecithal bashlyk anapsid
demicivilized foretell tonogram besmouch anthropoteleological
doer fightingly tubulostriato bruang amortize

And: $ bash acronym-to-phrase.sh diy resulted in
decanically inarguable youthen
delomorphous isatin yen
distilling inhumorously yungan

Finally: $ bash acronym-to-phrase.sh rsvp
retzian sensitizer vestiarium pathognomonical
reaccustom schreiner vincibility poetizer
refractorily subspherical villagey planetule

...
My initial reaction? whelpless transportal fireling

Python
So, this probably won't win any popularity contests, but I figured Python needed representation. This works in Python 3.3+. I borrowed @tony-h's json file of words (find it here). Basically, this code just takes the json list, and organizes all the words into a dictionary indexed on the letters of the alphabet. Then, whatever acronym is passed into the python application is used as an index into the dictionary. For each letter in the acronym, a random word is selected from all the words indexed under that letter. You can also provide a number of outputs desired, or if nothing is specified, 2 options will be generated.
The code (I saved it as phraseit.py):
import argparse
import json
import string
from random import randrange

parser = argparse.ArgumentParser(description='Turn an acronym into a random phrase')
parser.add_argument('acronym', nargs=1)
parser.add_argument('iters',nargs='?',default=2,type=int)
args = parser.parse_args()

acronym=args.acronym[0]
print('input: ' + acronym)

allwords=json.load(open('words.json',mode='r',buffering=1))

wordlist={c:[] for c in string.ascii_lowercase}
for word in allwords:
    wordlist[word[0].lower()].append(word)

for i in range(0,args.iters):
    print('output:', end=" ")
    for char in acronym:
        print(wordlist[char.lower()][randrange(0,len(wordlist[char.lower()]))], end=" ")
    print()

Some sample outputs:
$ python phraseit.py abc
input: abc
output: athabaska bookish contraster
output: alcoholism bayonet's caparison

Another:
$ python phraseit.py gosplet 5
input: gosplet
output: greenware overemphasiser seasons potential leprosy escape tularaemia
output: generatrix objectless scaloppine postulant linearisations enforcedly textbook's
output: gutturalism oleg superstruct precedential lunation exclusion toxicologist
output: guppies overseen substances perennialises lungfish excisable tweed
output: grievously outage Sherman pythoness liveable epitaphise tremulant

Finally:
$ python phraseit.py nsa 3
input: nsa
output: newsagent spookiness aperiodically
output: notecase shotbush apterygial
output: nonobjectivity sounded aligns

source: Stack Exchange

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

sort: votes


text:
Solve a System of Linear Equations
Write a program to solve a series of linear equations as short as possible. It must solve arbitrary number of equations problems. They can inputted however you like, coefficients of augmented matrix is probably the easiest. The program doesn't have to handle non-integer coefficients or solutions. No degenerate or invalid cases will be tested. The program must output the value of each variable or reduced row echelon form.
No equation solving libraries, matrix functions, or any way to automatically solve is allowed. You can simulate matrices with arrays or lists.
Example input (or equivalent):
m={{2,1,-1,8},{-3,-1,2,-11},{-2,1,2,-3}}

This represents 2x+y-z=8, -3x-y+2z=-11, -2x+y+2z=-3
Example output (or equivalent):
{2,3,-1}

This represents x=2, y=3, z=-1

Can the coefficients of the variables and the constant terms be separated into two arrays in the input?

@ace yes, that's fine

What exactly are you saying by degenerated cases? I guess that you are refering to all of those cases: 1) Malformed input; 2) Things like 0x=0 or 0x=5; 4) Cases where the number of equations is different than the number of variables; 5) Contradictory cases like x+5y=7, x+5y=8; 6) Cases without linear independency, like x+3y=6, 2x+6y=12. Am I right?

@Victor Yes, any input that has any ambiguity at all or isn't solvable.

What about cases which aren't degenerate but are ill-conditioned? (Or, in other words, what kind of pivoting is required?)

@PeterTaylor I'm not exactly sure what's meant by ill-conditioned, but only (relatively) small integer solutions need to work, and any pivoting method should be fine.

The problem specification requires a program.  Do you need a whole program or just a function (like the Javascript answer)?   If so, I can shorten my Java answer considerable.

@Wally A function is okay

Cool - I'll golf all of the program boilerplate out of my answer!

Python 169 166
Implementation
def s(a):
 if a:b=a[0];r=s([[x-1.*y*b[0]/r[0]for x,y in zip(b[1:],r[1:])]for r in a[1:]]);return[round((b[-1]-sum(x*y for x,y in zip(b[1:-1],r)))/b[0])]+r
 return[]

Demo
>>> arr=[[2, 1, -1, 8], [-3, -1, 2, -11], [-2, 1, 2, -3]]
>>> s(arr)
[2.0, 3.0, -1.0]

Note
If you are OK with the float approximation, then you can remove the round function call and further golf to 159 characters

APL, 1 char
I know it doesn't fit the (revised) requirements, but it's too good not to post:
⌹

Symbol "domino" ⌹ (division ÷ inside a rectangle) performs matrix division, therefore it can solve any system of linear equations. You just have to put it between the constant term vector and the matrix with the other terms:
      8 ¯11 ¯3 ⌹ ⊃(2 1 ¯1)(¯3 ¯1 2)(¯2 1 2)
2 3 ¯1

(if you want to try it on TryApl, ⊃ is ↑)

Javascript (284 181) - Gauss Elimination method
function f(A){l=A.length;d=1;for(i=0;i+1;i+=d){v=A[i][i];for(k=0;k<l+1;k++)A[i][k]/=v;for(j=i+d;A[j];j+=d)for(k=0,w=A[j][i];k<l+1;k++)A[j][k]-=w*A[i][k];if(i==l-d)d=-1,i=l}return A}

Test
f([[2,1,-1,8],[-3,-1,2,-11],[-2,1,2,-3]]);

=> [[1,0,0,2],[0,1,0,3],[-0,-0,1,-1]]

The returned array combine the identity matrix and the solution.

You can save couple more characters.

Instead of l=A.length;for(i=0;i<l;i++) use for(i=0;i<l=A.length;i++).

Instead of for(i=l-1;i>=0;i--) use for(i=l;--i;).

You can also move w=A[j][i] into for() and skip {} around.

Thanks everyone, I managed to merge forward and backward steps in one single step, saving a hundred chars and some of your tips are not valid anymore. (except @MarcinJuraszek tip)

Java - 522 434 228 213 chars
Solves by systematically checking all possible integer n-tuples by direct multiplication until one is found that works.
Function takes augmented matrix, A, trial solution vector, x, and dimension, n, as input - outputs solution vector, x.  Note that the vector x is actually one larger than the dimension to help step through possible solutions.  (If I declared variables A,x,n,j,k,s as instance variables, the function would be 31 chars shorter - for a total of 182, but that feels like bending the rules too far.)
int[]Z(int[][]A,int[]x,int n){int j,k,s;for(;;){for(j=0;j<n;j++){for(k=s=0;k<n;s+=A[j][k]*x[k++]);if(s!=A[j][n])j+=n;}if(j==n)return x;for(j=0;j<=n;j++)if(x[j]!=x[n]||j==n){x[j]++;for(k=0;k<j;x[k++]=-x[n]);j=n;}}}

Program for testing (somewhat ungolfed):
import java.util.*;
class MatrixSolver{
    public MatrixSolver() {
        Scanner p=new Scanner(System.in); //initialize everything from stdin
        int j,k,n=p.nextInt(),A[][]=new int[n][n+1],x[]=new int[n+1];
        for(j=0;j<n;j++)for(k=0;k<=n;A[j][k++]=p.nextInt());
        x=Z(A,x,n); //call the magic function
        for(j=0;j<n;j++) System.out.print(x[j]+" "); //print the output
    }
    public static void main(String[]args){
        new MatrixSolver();
    }

    int[]Z(int[][]A,int[]x,int n){
        int j,k,s;
        for(;;){
            for(j=0;j<n;j++){ //multiply each row of matrix by trial solution and check to see if it is correct
                for(k=s=0;k<n;s+=A[j][k]*x[k++]);
                if(s!=A[j][n])j+=n;
            }
            if(j==n)return x; //if it is correct return the trial solution
            for(j=0;j<=n;j++)if(x[j]!=x[n]||j==n){//calculate the next trial solution
                x[j]++;
                for(k=0;k<j;x[k++]=-x[n]);
                j=n;
            }
        }
    }
}

Program takes input from stdin as space separated integers as follows: first, the dimension of the problem, second, the entries of the augmented matrix by row.
Sample run:
$java -jar MatrixSolver.jar
3 2 1 -1 8 -3 -1 2 -11 -2 1 2 -3
2 3 -1

I shaved several characters by following Victor's advice about loops and "public", storing the RHS in the augmented matrix instead of separately, and adding an extra entry to my trial solution to simplify the generation of each new trial solution.  The OP also said that a function is enough - no need to count the entire program.

while(true){f=0;for(j=0;j<n;j++) can be replaced by while(true){for(f=j=0;j<n;j++). Further your class don't need to be public. For-loops with only one instruction in the body don't need the curly-braces.

I think that for(j=0;j<n;j++){for(k=0;k<n;k++){A[j][k]=p.nextInt();}b[j]=p.nextInt();} can be replaced by for(j=0;j<n;b[j++]=p.nextInt())for(k=0;k<n;)A[j][k++]=p.nextInt();

@Victor Thanks, I made those, and other, changes.

while(true) can be changed to for(;;)

@ace thanks - changed that and a couple other things and shaved 15 chars.

This answer no longer fits the question after the rule change as it uses a matrix function.*
Sage, 32
~matrix(input())*vector(input())

Sample input:
[[2, 1, -1], [-3, -1, 2], [-2, 1, 2]]
[8, -11, -3]

Sample output:
(2, 3, -1)

*Arguably, matrix() is a typecast, not a function (running import types; isinstance(matrix, types.FunctionType) gives False). Also, the ~ and * are operators, not functions.

I've updated the rules. The code must handle different number of equations and you now can't use matrix functions.

JavaScript (ES6),  152  151 bytes
Implementation of Cramer's rule.
Takes input as (m)(v), where \$m\$ is the matrix of variable coefficients and \$v\$ is the vector of constant terms.
m=>v=>m.map((_,i)=>(D=m=>m+m?m.reduce((s,[v],i)=>s+(i&1?-v:v)*D(m.map(([,...r])=>r).filter(_=>i--)),0):1)(m.map((r,y)=>r.map((k,x)=>x-i?k:v[y])))/D(m))

Try it online!

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

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


text:
Brainf**k Debugger
Your challenge is to take input like this (a Hello World program):
++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.+++++++..+++.>>.<-.<.+++.------.--------.>>+.>++.

And output a prompt (which will be "> "):
>

The user can then enter anything at the prompt. Your simple debugger must have these commands:

S - step

Output the current location (see L) after stepping.
S(a positive integer) - step that many spaces

L - location

The term "location" always refers to where you are in the program (i.e., the instruction pointer).
Formatted like this:
  v
+++++++[>+++++++<-]>.

This means that the current location of the program is at the third +.

G(an integer) - go to

This means keep stepping until you get to that location. If you reach the end of the program and you haven't gotten there, simply exit the program.
A negative integer means that many characters from the end. Yes, this means that -0 is different than 0, and -1 is the second to last character.
Don't output anything for this command.

D - dump array

Formatted like 1, 2, 3, 4, 5
If the array is 1, 2, 3, 0, 0, 0, 0, 0, ..., only output 1, 2, 3.
D(a positive integer) (a positive integer) - dump all array items between those two positions (inclusive)

(a positive integer) - output the item currently at that array position
P - output the index of the BF pointer (the thing you change with > and <).

When the program requests input, show the prompt "I> ". (You may input one character at a time.)
When it outputs something, show "O> " + (the output). Multiple outputs between commands must be chained together (i.e. you can't do > G-0 O> H O> e O> l O> l O> o ..., it has to be > G-0 O> Hello, World!).
Output "Done" and exit once you reach the end of the program.

Sample run:
++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.+++++++..+++.>>.<-.<.+++.------.--------.>>+.>++.
> S
1
> S
2
> S2
4
> S0
4
> L
    v
++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.+++++++..+++.>>.<-.<.+++.------.--------.>>+.>++.
> D
4
> 0
4
> D10 15
0, 0, 0, 0, 0, 0
> G-0
O> Hello, World!
Done

Sample run showing stepping through loops and the P instruction (calculates 3*2+1)
+++[>++<-]>+
> S3
3
> L
   v
+++[>++<-]>+
> S3
6
> L
      v
+++[>++<-]>+
> P
1
> S3
9
> L
         v
+++[>++<-]>+
> S
3
> L
   v
+++[>++<-]>+
> D
2, 2
>

Sample run showing I/O
>+[>,---------------------------------]<[<]>[>.]
> G37
I> H
I> e
I> l
I> l
I> o
I> !
> D
0, 39, 68, 75, 75, 78
> G-0
O> 'DKKN
Done

This is code-golf, so the shortest code will win.

PHP - 1008
<?php
$_=trim(fread(STDIN,1e5));$z=$p=0;$t=$l=[];$q='';function s(){global$p,$t,$l,$_,$q,$z;switch($_[$z++]){case'>':$p++;break;case'<':$p--;break;case'+':@$t[$p]++;break;case'-':@$t[$p]--;break;case'.':$q.=chr($t[$p]);break;case',':echo"I>";$t[$p]=ord(trim(fread(STDIN,2)));break;case'[':$l[]=$z;if(!isset($t[$p])||$t[$p]==0){$c=1;while($c>0){$b=$_[$z++];if($b=='[')$c++;elseif($b==']')$c--;}array_pop($l);}break;case']':$z=array_pop($l)-1;break;}if($z==strlen($_)){if($q)echo'O>'.$q."\n";die("Done\n");}}for(;;){echo">";$c=trim(fread(STDIN,1e5));$g=strlen($c);switch($c[0]){case'L':echo str_repeat(' ',$z)."v\n".$_."\n";break;case'D':if($g)$x=$t;else{list($a,$b)=explode(' ',substr($c,1));$x=array_slice($t,$a-1,$b);}echo implode(', ',$x)."\n";break;case'S':if($g)s();for($i=0;$i<substr($c,1);$i++)s();echo $z."\n";break;case'G':if($c[1]=='-')$x=strlen($_)-substr($c,2);else$x=substr($c,1);while($z!=$x)s();break;case'P':echo$p."\n";default:if(is_numeric($c))echo$t[$c]."\n";}if($q)echo'O>'.$q."\n";$q='';}

The output for cells that were never written is slightly different:
[timwolla@/data/workspace/php/PCG]php pcg-22585.php
+
>D15 20

>

Large version:
<?php
$_=trim(fread(STDIN,1024));
$z=$p=0;
$t=$l=[];
$q='';

function step() {
    global $p, $t,$l,$_,$q,$z;
    switch ($_[$z++]){
        case '>':
            $p++;
        break;
        case '<':
            $p--;
        break;
        case '+':
            @$t[$p]++;
        break;
        case '-':
            @$t[$p]--;
        break;
        case '.':
            $q.=chr($t[$p]);
        break;
        case ',':
            echo "I>";
            $t[$p] = ord(trim(fread(STDIN, 2)));
        break;
        case '[':
            $l[] = $z;
            if (!isset($t[$p]) || $t[$p] == 0) {
                $counter = 1;
                while ($counter > 0) {
                    $char = $_[$z++];
                    if ($char == '[') $counter++;
                    else if ($char == ']') $counter--;
                }
                array_pop($l);
            }
        break;
        case ']':
            $z = array_pop($l)-1;
        break;
    }
    if($z==strlen($_)) {
        if ($q) echo 'O>'.$q."\n";
        die("Done\n");
    }
}

for(;;){
    echo ">";
    $c=trim(fread(STDIN,100));
    switch ($c[0]) {
        case 'L':
            echo str_repeat(' ', $z)."v\n".$_."\n";
        break;
        case 'D':
            if(strlen($c) == 1)$x=$t;
            else {
                list($a,$b)=explode(' ',substr($c,1));
                $x=array_slice($t,$a-1,$b);
            }
            echo implode(', ', $x)."\n";
        break;
        case 'S':
            if(strlen($c)==1)step();
            for($i=0;$i<substr($c,1);$i++)step();
            echo $z."\n";
        break;
        case 'G':
            if($c[1]=='-')$x=strlen($_)-substr($c,2);
            else $x=substr($c,1);
            while ($z!=$x)step();
        break;
        case 'P':
            echo $p."\n";
        default:
            if(is_numeric($c)) echo $t[$c]."\n";
    }
    if ($q) {
        echo 'O>'.$q."\n";
        $q='';
    }
}

I fixed the third testcase.


text:
Limerick Hello World
A rhyming program you write
Attempting to win the fight
For winning the contest and vote
It must compute "Hello World"
Then print it very polite

The most popular poem will win.
The requirements are:

The poem should be of 5 lines with rhymes AABBA
It can print whatever you want, but the output should contain "hello world" (uppercase/lowercase does not matter, quotes not included in the output)
Symbols are read aloud. For example, the fourth line above is read: It must compute quote hello world quote
Post below your code, on another code preview, the "read-aloud" version of your code for disambiguation on special symbols.

Excluded are poems:

including dead code, or characters which could be safely removed without changing the rhymes or the functionality
Using comments as a way to rhyme (except if there is a good reason for that)
using the same symbol as end of phrase for rhyme.

In case of a tie, programs outputting a poem will win. If there is still a tie, shorter programs will win.
New lines do not count. spaces, tabs and newlines are not read aloud.
For example, "Hello, world!" would be read aloud "double-quote hello comma world exclamation point double-quote".

The whole program needs to be of five lines? Can't an answer simply be the snippet of required commands? Excluding the class/function declarations and all?

Yes, the whole program needs to be of five lines. Try to spread your definitions and includes along lines. Most PL have a way to include multiple sentences on a single line with the semi-colon or similar.

I see that many of the answers are attempting to produce limericks, because you mention that word in your title, but not in your requirements.

That's true. I only want the program to be a limerick.

I'm voting to close this as too broad because there is no way to objectively determine if an answer is valid.

I protest to re-open this question by removing the tie condition and removing all invalidity conditions.

Whitespace

A rhyming program I	wrote

this poem of whitespace and bloat

because newlines don't count

despite the amount

so deserves your sincerest upvote

Wikipedia: Whitespace (programming language)
Online Interpreter to Test Answer
Output:

Hello World

This somehow reminds me of the Beatles' Come Together.

It's certainly "over me"

..... Shoot me.

Excluded: Using comments as a way to rhyme

Well, I forgot that other chars were comments in whitespace. I don't think I will keep this rule because else this would ruin this winner.

@MikaëlMayer I think you should keep the rule. I suspect a lot of these votes are mostly from people who are just discovering the charm of Whitespace. Personally, I'm more interested in seeing answers in the spirit of the actual challenge of rhyming code.

Well, even HTML and javascript use comments to rhyme... so I would say if using comments is justificable, then it's ok. In the Whitespace case, the language itself cannot have any rhymes so comments are necessary.

@JasonC It's debatable whether or not the characters are "comments" as they're just invalid, ignored characters... There is no comment constructor.

@grovesNL That is true, or at least, it would probably hold up in court! (P.S. Weirdest trial ever.)

HTML

 Hello World! I'm a goat

I had to get a little liberal with pronunciation of the last line.  I hope it doesn't break the rules.  It's also not 100% valid per W3C, but works in most browsers.

+1 for clever re-pronunciations... + "Bang, I'm a goat" comment...

+1 for reading >< as "not equal"

A newbie a poem he wrote-a/ Hoping to get just one vote-a/ And now in this race/ He's in second place!/  With as much rep as several years on StackOverflow-ta.

Javascript
I know this isn't within the rules, but I couldn't resist
var girl, attractive = true;    // There once was a beautiful girl
var boy; girl = ' World';       // And a boy who thought she was his world
boy = 'Hello' + girl;           // When the boy said hello
if (boy != attractive)          // She said 'my goodness no!'
    alert(window['boy']);       // And the boy through the window she hurled.

Creative and ingenious.

There was no need to redefine girl on the second line but I still love it.

Python
a = [
'hello world']
print ''.\
join(a##
)

or,
a equals open square bracket
quote hello world quote close square bracket
print quote quote dot backslash
join paren a hash hash
and finally close unmatched bracket

I'm voluntarily signing up to additional rules, because I think (1) that limericks should have good metre and (2) that the best ones have a surprise in the last line.
(With the ending being interpreted in plain English, I figure you can work out for yourself what kind of bracket is unmatched.  As to the no dead code requirement, nothing in there can be removed without changing at least one of rhyme, rhythm or output).

One may remove a hash without changing functionality or rhyme. It does change the rhythm as you state, but the question‘s conditions are quite clear here, I think.

As the nature of poetry is to bend rules I can live with it.  That said, it's not clear to me that metre isn't part of the OP's concept of rhyme anyway.

Meh. Rhyming "bracket" with itself three times is just lazy limericking.

Yeah, I feel bad about that.  But it is a different symbol for each rhyme, as requested by OP.

Haskell
Taking some liberties with the pronunciation of certain
symbols, i.e. Tuple construction (,,)  and function application
($).
main = something that we wrote
     where something x y z = bloat
           bloat = flip ($) m putStrLn
           (that,we,wrote) = undefined
           m = "hello world"

The reading is supposed to be:
main is something that we wrote
where something x y z is bloat
bloat is flip apply m putStrLine
Tuple that we wrote is undefined
misquote hello world quote.

JavaScript
if (!!1) // and
  alert('❤ ❤ the world') // and
Burn = $.cache
return 1 > his_parts.the_sum

If in brackets one follows exclaiming marks
and alert the world inside brackets after entity hearts
slash, slash and burn
equals cash, cash, return
one is greater than the sum of his parts

I don't think I know anyone who pronounces "$" as "cash," although I admit to not writing JavaScript.

+1 I like the non-literal transcription, and "entity hearts" is kinda funny, despite the line break liberties.

BASIC
More specifically, Chipmunk Basic. The syntax rules have been stretched almost to breaking point, so it may be impossible to run this in other dialects without modification.
Source:
read hi$, u$, q
print hi$ " world how are you
  print "Or as they say
  print u$ q "day
data Hello, How R U, 2

"Read-aloud" version:
read hi string comma u string comma q
print hi string quote world how are you
  print quote Or as they say
  print u string q quote day
data Hello comma How R U comma 2

Notes:

There are no line numbers in the source code, but it will still load and run without any problems (see below).
The $ sigil is read as "string" in the context of BASIC programs (see, e.g., this Wikipedia page).

And here's proof that it does actually work:

How did you make this gif?

@Kartik I used an app called IShowU

Bash
As the answer is only forced to contain the phrase "Hello World", the easiest solution should be:
echo A rhyming program you write
echo Attempting to win the fight
echo For winning the contest and vote
echo It must compute "Hello World"
echo Then print it very polite

Legal within the rules, but this answer is no fun at parties. http://meta.codegolf.stackexchange.com/a/1063/3363

@JonathanVanMatre That is a sign that the problem is in the question. Anything different than just directly printing the output would be suprefluous. Further the first "excluded" rule inhibit anything more creative, even variable names with more than one char and code identing, it is a code-golf evaluated as popularity-contest, getting the worst of the two.

@JonathanVanMatre: Agreed, but I rather think this question/problem is not very good. (Sadly enough I am unable to downvote as I lack some reputation.)

@Keba, Yes, given the restrictions is the question, I think that there is nothing wrong with your answer, the OP practically asked specifically for this.

@Keba Downvoting is not the only way of showing your point of view to the authors.

@VisioN: Yes, so I gave this answer. ;)

This answer is invalid - The poem should be of 5 lines with rhymes AABBA Vote and World do not rhyme.

@Timtech: It‘s Vote and Quote.

True, but it still violates the rules.

Did you consider improving the question? / That might have made a better impression. / Though the damage is done / Wouldn't it be more fun / To make a real limerick-coding confection? :)

@Victor, "characters which could be safely removed" does seem to imply that you can't use multi-character variable names except where they are part of a rhyme. That is problematic.

Anyway, I upvoted your answer, because even if it is not very original and won't win the first place because others are not likely to upvote it compared to other answers, it has the merit to defy the question.

Ruby
comma = ""<<44
print "Hello" or
more = ""<<32
print comma if true
puts("World!") unless print more

Live: https://ideone.com/sirBBc
Pronounced as follows (with stressed syllables capitalized)
comma Equals quote-QUOTE cons four-FOUR
print QUOTE hello END quote OR
more equals QUOTE quote cons three-TWO  # ok, that was squished
print COMma if TRUE
puts QUOTE world QUOTE UNless print MORE

The m and e in both instances of more needs to be removed (ore is a valid word in that position too)

Hm, I don't think I can legally rhyme or with either or or ore.

This wouldn't be the only example of a limerick with duplicate words

Java
public static void main(String[] boat
){ int i = 1.0f
  ;if(i<2
  )System.out.println
("Hello world");} //hello world wrote

public static void main paren String arr boat
paren brace int i is one-point-oh float
sem-col if paren i is less than two
paren system dot out dot print line new //for some reason it's println, not printnl
paren quote hello world quote paren sem-col brace slash-slash hello world wrote

Note that comments are not really optional in Java

The b in "boat" needs to be removed ("oat' is a valid variable name, and fits)

Haskell
main = print . repeat
  $ head $ lines . init
     $ "Hello \
       \World!" #
         Just where (#) = const . id

Main equals printful stop repeat
  Dollar head dollar line's full stop i'nnit?
  Dollar quote hello back slash
  Back slashworld bang quote hash
  Just where parenthised hash equals constful, stop it!

This describes, hopefully, quite well the actual behaviour of the program.

TeX
I apologize in advance, because this code does not count as a limeric if you pronounce the names of each of the individual symbols (especially if you treat each letter unto itself as a token, which perhaps you ought). I have written it this way to produce the nicest possible output, which itself comes just short of being a poem.
You could safely turn it into an answer which complies with the rules by getting rid of \it and every non-alphabetic, non-whitespace character except for the final \bye (read aloud as backslash bye) and perhaps the first ! (read aloud as bang).
A \TeX\ program I think would comply,

And I'll tell you the reason for why:

``Hello world!'' tells the setter:

{\it ``Print each subsequent letter!''}

And we terminate with \bye.

You should remove comas and symbols at the end of each verse to let them rhyme properly. Or put them in the line afterwards.

@MikaëlMayer: see the remark in my second paragraph.

Brainf*ck
Ok, chide me now for the numerous rule violations. But I couldn't help making this.
++++++++[>+++++++++<-
]>.---.$#
+++++++..+
++.++++++++
.--------.+++.------.--------.

And the output (first violation of many: no space):
HELLOWORLD

Try it here: http://www.iamcal.com/misc/bf_debug/
The reading of it:
Eight plus left more nine plus less dash
Right more dot three dash dot cash hash
Sevén plus dot dot plus
Plus plus dot eight plus
Dot eight dash dot three plus dot six dash dot eight dash.

Note that the final dot in the program is placed as the period at the end of the limerick :) [second violation; this is cheap]. Also, the $ and # are ignored by the interpreter (I was very proud of myself for this line).
The accent on Sevén is to show the stress: seh-VEN
This violates the rule of using different symbols. But honestly I have a very limited symbol set and no space to add in other (ignored) characters.
I used all caps because those are faster to access in ASCII. I had no room for a space, unfortunately.

Finally: yes, I know the last line is terrible. Any suggestions to improve it? I'm not sure if you could compress this program anymore; maybe by storing repeated letters in their at their own positions?

Just realized that while this would make the code longer, unrolling the initial loop into 72 + would save some space in the limerick. But I'll keep my answer as is.

C#
I've taken a few slight liberties with the rules as truly phonetic C variants would involve far too much use of "semi-colon" which, as we all know, isn't a particularly good rhyme for anything.
{
     string unfurled = "Hello World!";
     Console.WriteLine(unfurled);
}

open brace, string called unfurled
created to read "hello world"
console write line
the string we defined
a final brace, one that is curled

You can always put semi-colon at the beginning of a newline, no?

True, Mikael, but it makes the code look very untidy!

Between untidy and rhyming, here the point is about rhyming. Don't worry, this code is not peer-reviewed.

Java
class Hello {public static void main
(String[] args)
{yellow = System; yellow
.out.print("Hello
world");} }

class Hello brace public static void main
paren string bracket bracket args paren
 brace yellow equals system sem-col yellow
 dot out dot print paren quote hello
world quote paren sem-col brace and brace again

This doesn't compile. How is yellow declared?

Batch
@echo off >dull
set /p "=Hello "<nul
set w=World
echo %w%! || Furled
del dull || cull

at echo off to dull
  set slash p quote equal Hello quote from nul
  set w equal World
  echo percent w percent bang pipe pipe Furled
  del dull pipe pipe cull

Can you find another rhyme dull/dull ?

@MikaëlMayer it's more useless code, but yes.

CSS
title>me
,body lets go party
only a stylesheet,html
:after { content: 'hello world'; font-family:Rockwell
; color: #adad20

Outputs:

title greater than me
comma body lets go party
only a stylesheet comma html
colon after bracket content colon quote hello world quote semicolon font-family colon Rockwell
semicolon color colon hashtag a dad twenty

Tested in Firefox and Chrome

#include <stdio.h> //
void main (void){
printf("Hello, World");
//just for rhyme I say stolon
} /**/

hash include less than stdio dot h greater than double slash after a space
void main left paren void right paren left brace
printf left paren quote Hello comma World quote right paren semi colon
double slash just for rhyme I say stolon
right brace and double asterisk between slashes at the last place

Nice one for the first two rhymes, but you use twice the same symbol to rhyme (semi-colon), which is not allowed.

Debugged, but I guess another bug appeared.

Windows Batch
The spoken words are also saved within the batch file, and skipped with the last line of actual code.
@echo off >nul
set hi=Hello World
rem Now print the string,
echo !hi!
goto :) to skip the words

at echo off, greater than nul,
set H I equals sign, Hello World,
rem Now print the string,
echo pling, H I, pling
goto smile, to skip the words

:)

Edit: You'll need delayed expansion enabled for the script to work. Use cmd /v:on and run it from there.

nul, world, and words do not rhyme. The pattern needs to be AABBA. Also the comma after string should be pronounced.

Python (3)
print('''Nose
No punctuation hear close
Hello World
Hurled and swerled
Goodbye now''')

Print open quote quote quote nose, No punctuation hear close, Hello World, Hurled and swerled, Goodbye now quote quote quote close.

Welcome to the site, and nice first post!


text:
Phone Multi-tap Spelling
Inspired by the Google Code Challenge:

The Latin alphabet contains 26 characters and telephones only have ten digits on the keypad. We would like to make it easier to write a message to your friend using a sequence of keypresses to indicate the desired characters. The letters are mapped onto the digits as shown below. To insert the character B for instance, the program would press 22. In order to insert two characters in sequence from the same key, the user must pause before pressing the key a second time. The space character ' ' should be printed to indicate a pause. For example, 2 2 indicates AA whereas 22 indicates B.
Each message will consist of only lowercase characters a-z and space characters ' '. Pressing zero emits a space.

Your challenge is to write the smallest function which takes the input string, and returns the sequence of keypresses necessary to produce the input as string or output it to stdout. The function which is the least amount of bytes wins.
Example Input/Output
phone("hi")
44 444
phone("hello world")
4433555 555666096667775553

Other clarifications

Pauses must only be added when necessary and must be a space ' '.
Each message will consist of only lowercase characters a-z and space characters ' '. Print 0 to signify spaces.
No external libraries.
Only the input string may be passed to your function.
To make other languages competitive, the primary function declaration doesn't count, and nor does importing other standard libraries. #includes, imports, and usings don't count. Everything else does. This does include #defines and helper functions. See rule 2 in this question if you are confused.
Multiple spaces can be denoted as 00 or 0 0 since you don't really have to pause between a space

Related with this: http://codegolf.stackexchange.com/questions/21327/letters-in-phone-numbers

Can we assume the input is lower/upper case?

@PhilH "lowercase characters a-z and space characters ' '"

Do you consider brackets {} a part of the function signature? For example, if my code is function f(){alert('hi');}, should I count the characters of alert('hi'); or {alert('hi');}?

@ProgramFOX alert('hi') is only counted.

As far as I remember t9 works differently: you have to click each key once to get a word.

@VisioN agreed, I copied googles name for the challenge. If you got a better name for it feel free to edit. My first phone worked similar to above for texting I don't know if it had a name for it like T9 though...

@Danny Maybe just Phonewords (by Wikipedia).

@VisioN that looks to use one number to represent a letter and is just for phone numbers. I think Multi-tap sounds closer.

@Danny Ah, yeah! This is the right word.

Is a pause required to be a space, or can it be something else?

@KendallFrey Yes pause must be a space

Does 0 have to be allowed, or is it really only a-z and space?

So if I enter "e0g", it prints "33 4"?

@hosch250 oh. No. The input is only 'a-z' and ' '. There are no numbers in the input. See second comment.

Well, you stated: •Each message will consist of only lowercase characters a-z and space characters ' '. Pressing zero emits a space.

@hosch250 that is meant for the output 0 emits a space. Maybe that could be worded better. Input will always be 'a-z' and ' ', sorry if any of my other comments might of mislead you.

Ruby, 129 122 115 111 108 107 105
Done with golfing...
Oops, completely forgot to remove unnecessary spaces - fixed...
Saved 2 chars thanks to Peter Taylor.
Online version
def t9(t)
(t.tr(" ",?`).bytes.map{|c|"09998887777666555444333222"[96-c..-1][/(.)\1*/]}*' ').gsub /(\d) (?!\1)/,'\1'
end

Explanation:
space is translated to the char with the ordinal 96
(t.tr(" ",?`).bytes

characters are first mapped to series of numbers:
- a to 2
- b to 22
- d to 3222
- h to 444333222
a regex expression then matches the first group of equal digits
map{|c|"09998887777666555444333222"[96-c..-1][/(.)\1*/]}

the array is joined
*' ')

all spaces in the occurences of "digit space different_digit" are removed
gsub /(\d) (?!\1)/,'\1'

Doesn't look to work 100% right. I see 6666 6 shouldn't ever need to be press 4 times in a row.

What's the point of \2 in that final regex? Surely the second group is a zero-width assertion?

You're absolutely right!

REBEL - 154 110 103
;0 2abc3def4ghi5jkl6mno7pqrs8tuv9wxyz/^;/$<;/([^\d-])(?=\D.*(\d)(\w)*\1)/$2$3-/(\d)-+\1/$1 $1/-//;/$>$`

This 'function' accepts input from stdin and sends results to stdout.
Test runs (so you don't have to install the interpreter):
hi
44 444

hello world
4433555 555666096667775553

yes
999337777

kthxbai
558449922 2444

I can never get your links to load! :(

JavaScript (124)
Run in Firefox.
t9=s=>s.replace(/./g,c=>'099998887777666555444333222'.slice(36-parseInt(c,36)).match(/(.)\1*/)[0]+' ').replace(/(.) (?!\1)/g,'$1')

GolfScript, 46 chars
{).," adgjmptw"&.,.1>*`@@)\;-*}/]{.2$^!" "*\}*

As usual, reads input from stdin, prints to stdout.
See online demo (with canned input).
Note that this code relies on a very strict interpretation of the input spec (only lowercase letters and spaces): in particular, any newlines in the input will crash it!  This issue can be fixed, at the cost of two extra chars, by prepending n- to the code to filter any newlines out.

VBA 220 253/258/219
Not counting Function lines here:
With String, 253:
Function t(s)
For Each c In Split(StrConv(s,64),Chr(0))
If c<>""Then If c=" "Then t=t & 0 Else b=Asc(c)-91:n=String(IIf(b>27,(b-4)Mod 4+1,IIf(b>23,(b-1)Mod 4+1,b Mod 3+1)),Trim(Str(Int(b/3)-IIf(b=24Or b=27Or b>29,1,0)))):t=t &IIf(Right(t,1)=Left(n,1)," " &n,n)
Next
End Function

With a For loop 258:
Added corrections for 7/9 key (thanks, Danny), which added a lot of chars.
Function t(s)
For Each c In Split(StrConv(s,64),Chr(0))
If c<>""Then
n=""
b=Asc(c)-91
For i=1To IIf(b>27,(b-4)Mod 4+1,IIf(b>23,(b-1)Mod 4+1,b Mod 3+1))
n=n &Int(b/3)-IIf(b=24Or b=27Or b>29,1,0)
Next
t=t &IIf(c=" ",0,IIf(Right(t,1)=Left(n,1)," " &n,n))
End If
Next
End Function

Using Choose 219:
I didn't want to run with this one, since is more basic in functionality, but it is the shorter code...
Function t(s)
For Each c In Split(StrConv(s,64),Chr(0))
If c<>"" Then:b=Asc(c)-96:n=Choose(b,2,22,222,3,33,333,4,44,444,5,55,555,6,66,666,7,77,777,7777,8,88,888,9,99,999,9999):t=t &IIf(c=" ",0,IIf(Right(t,1)=Left(n,1)," " &n,n))
Next
End Function

yes should be 999337777. I get 10338 using your function.

C++ - 365 characters without int main(){}
#include<iostream>
#include<string>
#include<cmath>
#define o std::cout<<
int main(){std::string s;getline(std::cin,s);for(int i=0;i<s.size();i++){if(s[i]==32)o 0;int j=s[i]-97;if(i>0&&j/3==(s[i-1]-97)/3)o ' ';if(-1<j&j<15){for(int k=j-j%3-1;k<j;k++)o 2+j/3;}if(14<j&j<19){for(int k=14;k<j;k++)o 7;}if(18<j&j<22){for(int k=18;k<j;k++)o 8;}if(21<j&j<26){for(int k=21;k<j;k++)o 9;}}}

Uses the same reasoning as my answer here, only using for loops to output each letter the appropriate number of times.

You can use s[i]==32 instead of s[i]==' '. The ASCII value of space is 32.

@ace Sure thing.

Perl - 107 110
$_=<>;y/ /0/;$z='a';$==2;for$l((3)x5,4,3,4){for$q(1..$l){s/$z/$=x$q.$"/ge,$z++}$=++}s/(.) (?!\1)/\1/g;print

Here's my previous solution in 120 128 130 155:
$_=<>;s//_/g;y/sz/79/;for$x(cfilorvy,behknqux,adgjmptw){s/(\d)_/\1\1_/g,eval"y/$x/2-9/"}y/ _/0 /;s/(.) (?!\1)/\1/g;print

Tests:
hi
 44 444

hello world
 4433555 555666096667775553

jackdaws loves my big sphinx
 52 222553297777055566688833777706999022444 407777 744 4446699

C, 165 163 153 149 138 chars
k(char*s){char*m="`cfilosvz",l=0,i,c;while(*s^0){for(i=0;*s>m[i];i++);c=*s-m[i-1];i==0?i=-1,c=1:i==l?putchar(32):1;while(c--)putchar(i+49);l=i;s++;}}

My first attempt at code golfing, any suggestions are appreciated.

Java - 243
Pretty naive java solution. Thanks to commenters for suggestions.
Fixed a bug that sometimes inserted unnecessary spaces, e.g. for the input "hello worlds sup".
    private static void t9(String s) {
        String[]t=",,abc,def,ghi,jkl,mno,pqrs,tuv,wxyz".split(",");String o="";int i,j,k,l=0;for(char c:s.toCharArray()){if(c==32){o+='0';l=0;}else for(j=0;j<10;j++){int n=t[j].indexOf(c);if(n>=0){if(j==l)o+=' ';for(k=0;k<n+1;k++)o+=j;l=j;}}}return o;
    }

Pretty good, but you need to golf it and provide the score.

I assume this is java.  Can you put that in your heading, like the other answers do?

One golf: replace t.length with 10

Also, considering that i is used only for iterating through the String, remove it and do a foreach loop: for(char c:s.toCharArray())

Also, change if(c==' '){o+='0';continue;} to if(c==' ')o+='0';else{ and add the appropriate }.

I don't know about Java, but in C you can do int c,i=0,j=0,k=0,l=-1; then skip the initialisation in the for loops. Besides, you can check whether it is a space by if(c==32) instead of if(c==' ').

C++ - 170 168 160
Golfed:
#define t std::cout<<
void g(char*s){char v,p,b,l=1;while(*s){v=*s++-97;p=(v==18)+(v==25)+(v-=v/18+v/25)%3;b=v<0?48:v/3+50;if(l==b)t' ';while(p--+1){t(l=b);}}}

Ungolfed
void numpresses(char* s)
{
char lastbutton = 1;
const char asciiOffset = 97;

while(*s)
{
    char val = *s++ - asciiOffset;

    char presses =
        (val == 18) + (val == 25)           //Z and S are special cases. Check for their ascii codes.
        + (val -= val / 18 + val / 25) % 3; //Simple mod 3 for number of presses. Also apply offset for characters above s and z.

    char button =
        val < 0                             //If the character is a space...
        ? '0'                               //The button character needs to be 0
        : val / 3 + '2';                    //Buttons are offset by the ascii code for the number 2

    if (lastbutton == button)               //Add a space if we need to pause
    {
        std::cout << ' ';
    }

    while (presses-- + 1)                   //Print the button once for each press required
    {
        std::cout << button;
        lastbutton = button;
    }
}
}

C: 136 characters
p(char*s){int i,c,l=1;while(c=*s%32,*s++)for(i=l!=(l=(c+149-c/18-c/25)/3-!c);i++<(c-!!c-c/18-c/25)%3+(c==19)+c/26+2;putchar(i^1?l:32));}

And slightly ungolfed (yes, that is how it was written):
p(char*s){
        int i,c,l=1;
        while(c=*s%32,*s++)for(
                i=l!=(l=(c+149-c/18-c/25)/3-!c);
                i++<(c-!!c-c/18-c/25)%3+(c==19)+c/26+2;
                putchar(i^1?l:32)
        );
}

I might be able to cut it down a little by applying some recursion, black magic and a fair amount of chili powder.

CoffeeScript - 202 (210 - 8)
t9=(s)->
    t=[3,3,3,3,3,4,3,4];l=-1;r=""
    for c in s
        n="";d=c.charCodeAt(0)-96
        if c is ' '
            n=0
        else((n+=k+2 for x in[0...d];break)if d<=v;d-=v)for v,k in t
        r+=if n[0]is l[0] then " "+n else n
        l=n
    r

Python 155 150
I wish i was better at this XD. Function definition not counted. First indentation level is a space, second is a tab, and third 2 tabs.
def p(s,l=None):
 for c in s:
    for i,g in enumerate(" ,,abc,def,ghi,jkl,mno,pqrs,tuv,wxyz".split(",")):
        if c in g:print"\b"+[""," "][l==i]+str(i)*(g.index(c)+1),;l=i

APL, 77 chars
{{⍵,⍨⍺,''↑⍨=/↑¨⍺⍵}/('0',⍨(⌈3.1×y-⌊y)/¨⍕¨2+⌊y←7.99,⍨.315×⍳25)[⍵⍳⍨⎕UCS 96+⍳26]}

Explanation

2+⌊y←7.99,⍨.315×⍳25 or, ungolfed, y←(0.315×⍳25),7.99 ◇ 2+⌊y samples a suitably tilted line (y = 0.315 x) on the points from 1 to 25; the line is tilted in such a way that the floor of these y values follows the repeating pattern 000111...777 except for the sixth group of digits 5555; a number is appended at the end to get the fourth 7, so that the final array plus 2 is 22233344455566677778889999;
⌈3.1×y-⌊y amplifies the difference between those y values and their floors, so that the ceilings of the differences give the pattern 123123... with a 4 on the last digits of the two groups of 4 digits;
'0',⍨( ... )/¨⍕¨ ... or (( ... ) /¨ ⍕¨ ...),'0'  uses the latter result to duplicate digits from the former, so that the output is the array of strings "2" "22" "222" "3" "33" "333"... with the correct "7777" and "9999" in place, and a "0" appended to the end;
⍵⍳⍨⎕UCS 96+⍳26 or (⎕UCS 96+⍳26)⍳⍵ computes the index of each input char, where "a" is 1, "z" is 26, and space (and every other char) is 27;
{ ... }/( ... )[ ... ] takes the latter result, the index for each input char, to translate each char into the respective string of digits, then concatenates the strings using the function in braces;
{⍵,⍨⍺,''↑⍨=/↑¨⍺⍵} or {(⍺,(=/↑¨⍺,⍵)↑''),⍵} appends each new string ⍺ to the accumulator ⍵, interposing a single space only if both arguments start with the same char.

Examples
      {{⍵,⍨⍺,''↑⍨=/↑¨⍺⍵}/('0',⍨(⌈3.1×y-⌊y)/¨⍕¨2+⌊y←7.99,⍨.315×⍳25)[⍵⍳⍨⎕UCS 96+⍳26]} 'hello world'
 4433555 555666096667775553
      {{⍵,⍨⍺,''↑⍨=/↑¨⍺⍵}/('0',⍨(⌈3.1×y-⌊y)/¨⍕¨2+⌊y←7.99,⍨.315×⍳25)[⍵⍳⍨⎕UCS 96+⍳26]} 'the quick brown fox jumped over the lazy dog'
 84433077884442225502277766696603336669905886733 3066688833777084433055529999 999036664

JavaScript 234
for(l=-1,r="",I=0,y=(s=prompt()).length;I<y;I++){c=s[I];n="";d=c.charCodeAt(0)-96;if(0>d)n=0;else for(k=J=0;J<8;k=++J){v="33333434"[k];if(d<=v){for(x=K=0;0<=d?K<d:K>d;x=0<=d?++K:--K)n+=k+2;break}d-=v}r+=n[0]==l[0]?" "+n:n;l=n}alert(r)

R 224
I'm sure there's a better way to do this, so I'm going to keep working on it.
a=strtoi(charToRaw(scan(,'',sep='\n')),16L)-95;a[a<0]=1;b=c(0,2,22,222,3,33,333,4,44,444,5,55,555,6,66,666,7,77,777,7777,8,88,888,9,99,999,9999)[a];c=append(b[-1],0)%%10;d=b%%10;b[c==d]=paste(b[c==d],'');paste(b,collapse='')


text:
Undefined Behavior Killed My Cat
Undefined Behavior Killed My Cat
It's well known that undefined behavior can kill your cat [citation needed].
But can it?
Your Task

Write a program that invokes undefined behavior.
Describe a scenario that starts with the above program being run, resulting in a Felis catus ending its life while in your ownership, as a result of the aforementioned UB.
Estimate the probability for each stage in the scenario.
Calculate the total probability that a single run of the program would kill your cat.

Rules

This is a popularity-contest, so be creative if you can.
This is a programming related challenge, so the chain of events should be mostly within the computer, not in the real world (of course, if has to reach the real world if that's where your cat is).
If you choose a language that doesn't have undefined behavior, use something similar.
No animals may be harmed in the production of your answer.

Scoring
Vote count plus the scenario's total probability (which can't exceed 1).
Example in C:
main(){printf();}

Scenario:

printf called with garbage from the stack - undefined behavior. Probablity: 100%.
The first parameter happens to be the string Your cat is ugly!. Probablity: (1/256)17 = (1.148 * 10-37)%.
Seeing the message, you pick up your gun and shoot your cat. Probability: 3%.
The cat dies. Probability: 93%.

Total probability: (3.202 * 10-39)%.

I don't really understand the calculation of the scoring. For example, why does number 3 give 3% as probability, and number 4 give 93%?

@ProgramFOX, The probabilities are my estimates, that's all. Note that the probability is no more than 1, so it's no more than a tie breaker.

@n̴̖̋h̷͉̃a̷̭̿h̸̡̅ẗ̵̨́d̷̰̀ĥ̷̳, Just try not to violate rule 4.

You might want to add in a stipulation that the total probability must be greater than 0.  Are there any special rules for those of us who don't own a cat?

Invoke undefined behavior 2) Remain inspired by the mere fact that you could invoke undefined behavior, and live a long, happy life 3) Cat dies of old age.  Total probability: 100%

@Geobits, but the cat's death isn't "a result of the aforementioned UB".

@Oberon I'd kill myself if I couldn't come up with a single way to create an UB after programming for so long. Then the cat would no longer be in my possession. Invoking the UB keeps me alive, so that "... ending its life while in your ownership , as a result...". Ambiguous parsing FTW.

Are special hardware interfaces allowed, eg. solenoids, shotguns?

@ProgramFOX the chance that you will shoot your cat based on said message are very low (3%). The chance of it dying when shot is high (93%).

@MartinJames, Everything is allowed. Will it get you upvotes? I don't know.

I'd be more amused if someone reinterprets this to kill the cat command or something of that sort.

-1 I love cats. Why cats? Why not killinig vermin?

@V-x Given the uncertainty, i'm pretty sure it's related to Schrödinger's cat.

That's obvious. I wanted to compensate a bit that I'm not happy about the manifestation of cat hate.

@V-X, Where's the cat hate? I want to understand how UB can kill cats, so we could fight this menacing problem and save feline lives.

@V-X The rules say that no animals may actually be harmed.  This is a clue for you that this is not to be taken seriously.  If Schrödinger had made his thought experiment using a plague-infested rat, this question would have been about a plague-infested rat.  The fact that *NIX has a command-line tool cat is just a serendipitous coincidence that improves the joke.

Calling printf without a prototype is undefined behavior, period.

"No animals may be harmed in the production of your answer." Can I at least harm a cat while testing after production?.... Gotta make sure to get those percentages right :D

@Kevin, Sorry, but cat lovers here would downvote me to death if I let you do that. Try testing it with tofu or something.

When I saw the question title in the hot network questions, I first thought this had been asked at [pets.SE] :-)

If a cat is to be eaten, Python is a solution.

Felis catus is your taxonomic nomenclature,
An endothermic quadruped, carnivorous by nature;
Your visual, olfactory, and auditory senses
Contribute to your hunting skills and natural defenses-> Sorry had to do it :-)

Simply letting a cat live wildly is undefined behavior. Chance of death is 100%. Do I win all your triangles? :D

Why is everybody struggling for a mechanism by which the felis catus dies? That's the simple part: an omnipotent being smites it. I'll leave it to everybody's imagination why that happens and how a program error my cause that situation to arise... ;-)

Hmm. Maybe I'll build an automatic cat feeder with a Raspberry Pi, and implement it with UB that can cause it to malfunction.

I don't get this. For this purpose, all programs with UB are fungible.

C
Most answers to this question misinterpreted the question in that it was killing the cat process on a UNIX system. Here is a program which can cause the demise of a biological lifeform of the species Felis Cattus as specificed by the question.
This example runs on Windows, but it could be easily ported to most UNIX operating systems by replacing iexplore -k with the command to launch an installed web browser.
#include <stdlib.h>
#include <stdio.h>

int main() {
    char i; // uninitialised
    printf("Redirecting you to a website which will inform you how to properly feed your cat.");
    if (i != 42) {
         system("iexplore -k https://pets.stackexchange.com/questions/tagged/cats+diet");
    } else {
         system("iexplore -k https://cooking.stackexchange.com/questions/tagged/chocolate");
    }
    return 0;
}

This program pretends to provide advise about cat diet to the user.
It will start Internet Explorer and direct the user to pets stackexchange listing lots of helpful questions about how to feed cats. There is, however, a low (1/256) chance that it will send the user to cooking stackexchange instead listing tips how to prepare dishes containing chocolate, which is highly toxic to cats. To make matters worse, it will launch internet explorer in kiosk mode (fullscreen), which hides the address bar and is hard to escape from for a non-tech-savy user.
This clever ruse will coax the user into feeding their cat chocolate believing that it is an appropriate diet for it, thus causing them to inadvertedly kill it.

The pen is mightier than the sword! :)

This looks like the only solution so far that has any realistic chance of actually killing a cat. I am forced to upvote, although I sincerely hope no one ever actually puts it into practice.

Internet Explorer might kill your cat all by itself.

Chocolate is highly toxic to all sorts of domestic animals. (Cats, dogs, horses, etc. should never be fed chocolate.)  Funny how it's not only yummy but actually supposed to be really good for humans...

@MichaelHampton I've chosen MSIE because it is the only browser you can reasonably expect to exist on every Windows system. I am pretty sure there must be a console command to open a website in the users default browser, but I was too lazy to search for it.

Just passing the URL to ShellExecute() is sufficient.

Can you add the scenario, step by step, that kills the cat, with the probability analysis (as in the example)? As it is, this isn't a valid answer.

@ugoren I could, but I see no entertainment value in doing so.

Depending on the compiler your chances may be as low as 0 or as high as 1 - depends if the compiler uses stackguards and what kind of ;)

In addition to what @Voo said the read of uninitialized variable in C is UB (in C90 and C11 except C99 where it is a bit more complicated) so you need to calculate probability of nasal demons killing the cat as well.

@Philipp, I'll accept the highest voted valid answer, and to be valid it has to follow the rules.

@ugoren I am a programmer, not a psychologist.

@ugoren: The probability seems straightforward enough.  Assuming that the probability distribution of 256 possible values of char is reasonably uniform, the odds are 1 in 256.  Chocolate is toxic to cats.

@RobertHarvey Nope.  You have to factor in the probability that the chocolate recipe will be so tasty that the greedy owner will eat it all up, with none left for poisoning kitty.  Although then maybe kitty would starve to death...

Using Internet Explorer induces undefined behaviour in ME. — sorry, had to say that.

Bash
According to this, INT_MIN % -1 may or may not be undefined (what ???), and so might cause trouble for any language implemented in c/c++.
#!/bin/bash

cat <<< $((2**63%-1))

The cat will be killed early if the parent bash process crashes, which may or may not happen.
On my VM I get this output:
$ ./schroedinger.sh
./schroedinger.sh: line 3:  7805 Floating point exception(core dumped) cat <<< $((2**63/-1))
$

(I don't really understand the scoring for this question, but here goes anyway)
Calculate $((2**63%-1)).  Crash always happens on bash 4.2.25, but seems to just hang on some 3.x versions.  More uncertainty.  I could tell you the exact probability, but due to the Heisenburg uncertainty principle I would then fall down a black hole.  Or something.  So I think we can safely say they probability is approximately 42%.

shouldn't it be cat <<< $((-2**63/-1))? Didn't you lose the - sign? Even if the behavior is the same, the minimum integer should be -

I know the use of < and <<, but what is the purpose of <<<? (used google but couldn't find anything)

@klingt.net: It is called "Here Strings" - it is much more googlable... it is shortcut for echo $((-2**63/-1)) | cat

Ah thanks, this is really useful!

+1 for using real cat.

@mardavi INT_MAX = 2^63 - 1.  If we add 1 to INT_MAX, the 64bit number space wraps around and we get INT_MIN.  In other words in signed 64bit integer arithmetic, 2^63 == -2^63.  I could have used -2**63, but preferred the terseness without the -, since the modular arithmetic is the same in this case.

https://bugzilla.redhat.com/show_bug.cgi?id=579622

Can you add the scenario, step by step, that kills the cat, with the probability analysis (as in the example)? As it is, this isn't a valid answer.

INT_MIN / -1 is always undefined behavior in C/C++, what wasn't clear was whether INT_MIN % -1 (modulo not division! 2^32 is not representable in 2 complement 32bit numbers, but 0 certainly is) was undefined behavior or not. According to your link they clarified that in C11 so good riddance for that.

This hangs my bash on OS X (requires Ctrl+C to kill); why is that? (Yes, undefined behaviour yadda yadda, but you'd expect this to at least just quit somehow...)

@ugoren I edited, but I'm not sure if this is what you're looking for

@nneonneo Yes, I got that behavior too on OSX.  Sorry, I don't have an answer as to why.

How can I upvote again given that the update mentions the probablity of killing the cat (42%)?

@devnull I'll do it for you ;)

@Voo INT_MIN / -1 is not always undefined behaviour, because INT_MIN is allowed to be equal to -INT_MAX, in which case the result of the division is representable.

@hvd good point.

It's spelled Shrödinger. But +1 for reference to quantum physics!

@AnonymousPi Ja, mit zwei punkte.

C (sequence point)
deadcat.c:
#include <stdio.h>
int main()
{
    int i=3;
    int k=0;
    k=i+(++i);
    if (k==7)
        printf("The cat is fine. k=i+(++i) =%d\n",k);
    else
        printf("Urgent Notice: Your cat has rabies. k=i+(++i) =%d\n",k);
}

Execution (or not):
$ clang -w deadcat.c -o deadcat; ./deadcat
The cat is fine. k=i+(++i) =7
$ gcc deadcat.c -o deadcat; ./deadcat
Urgent Notice: Your cat has rabies. k=i+(++i) =8

Scenario and probability
Assuming that five percent of people running this program use clang for compiling C code (versus 90 percent using gcc and 5 percent using other C compilers):

 Probability of getting "The cat is fine."                           =  .050
 Probability of getting "Urgent Notice: Your cat has rabies."        =  .950

 Probability of reacting to "Your cat has rabies" by putting it down =  .040
 Probability of ignoring the notice                                  =  .900
 Probability of taking the cat to the vet for treatment              =  .060

 Total probability of cat living:.05 + .95 * (.90 + .06)             =  .962
 Total probability of cat dying: .95 * .04                           =  .038
 Check: Total probability of cat living or dying:                    = 1.000

Explanation:
k=i+(++i) accesses and changes "i" between sequence points.
The probability is not determinable by the program; it depends upon the
choice of compiler, which is made by the user.  "Undefined" does not
necessarily mean "random".
See https://stackoverflow.com/questions/4176328/undefined-behavior-and-sequence-points

+1 for demonstrating the behavior with different compilers.

optimization level may also change the behavior

@ratchet freak: Yes, but I couldn't demonstrate that with this particular problem.  I tried -O0,-O1,-O2, and -O3 on a number of gcc versions ranging from gcc-4.2.3 to gcc-4.8.2, and cc-5.0 on SunOS, but all of those killed the cat.

Can you add the scenario, step by step, that kills the cat, with the probability analysis (as in the example)? As it is, this isn't a valid answer.

@ugoren: Working on that.  It's essentially the probability of the user using clang or gcc.  I can't find data on market shares but I believe clang's share isn't very big now but is increasing.  It's probably higher among Stack* members than among the general public.  So I'll just make a SWAG that it's 5 percent clang now, and that most of those use both clang and gcc.

I assumed that all the cats that were taken to the vet for treatment would live.  Probably some of those will die from catching a communicable feline disease or from veterinary malpractice.  That might change the final probabilities a little, to say .96/.04

Note that with the latest gcc that comes with XCode 5.1 this is no longer the case: gcc deadcat.c -o deadcat; ./deadcat
deadcat.c:7:10: warning: unsequenced modification and access to 'i' [-Wunsequenced]
k=i+(++i);
~  ^
1 warning generated.
The cat is fine. k=i+(++i) = 7

@MikeLischke I think that's because gcc that comes with XCode 5.1 is actually clang/LLVM.

@GlennRanders-Pehrson No, they are different. Clang does "the right thing" without bringing up a warning even with -Wall, while gcc displays a warning.

C
Backstory
My wife inherited a cat from family.† Unfortunately, I am very allergic to animals. The cat was well past its prime and should have been euthanized even before we got it, but she could not bring herself to get rid of it due to its sentimental value. I hatched a plan to end my its suffering.
We were going on an extended vacation, but she did not want to board the cat at the veterinarian's office. She was concerned about it contracting illness or being mistreated. I created an automatic cat feeder so that we could leave it at home. I wrote the microcontroller's firmware in C. The file containing main looked similar to the code below.
However, my wife is also a programmer and knew my feelings towards the cat, so she insisted on a code-review before agreeing to leave it at home unattended. She had several concerns, including:

main does not have a standards compliant signature (for a hosted implementation)
main does not return a value
tempTm is used uninitialized since malloc was called instead of calloc
the return value of malloc should not be cast
the microcontroller time may be inaccurate or roll over (similar to the Y2K or Unix time 2038 problems)
the elapsedTime variable may not have sufficient range

It took a lot of convincing, but she finally agreed that theses weren't problems for various reasons (it didn't hurt that we were already late for our flight). Since there was no time for live testing, she approved the code and we went on vacation. When we returned a few weeks later, my the cat's misery was over (though as a result I've now got plenty more).
† Entirely fictitious scenario, no worries.

Code
#include <time.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>

//#include "feedcat.h"
// contains extern void FeedCat(struct tm *);
// implemented in feedcat.c
// stub included here for demonstration only
#include <stdio.h>
// passed by pointer to avoid putting large structure on stack (which is very limited)
void FeedCat(struct tm *amPm)
{
    if(amPm->tm_hour >= 12)
        printf("Feeding cat dinner portion\n");
    else
        printf("Feeding cat breakfast portion\n");
}

// fallback value calculated based on MCU clock rate and average CPI
const uintmax_t FALLBACK_COUNTER_LIMIT = UINTMAX_MAX;

int main (void (*irqVector)(void))
{
    // small stack variables
    // seconds since last feed
    int elapsedTime = 0;
    // fallback fail-safe counter
    uintmax_t loopIterationsSinceFeed = 0;
    // last time cat was fed
    time_t lastFeedingTime;
    // current time
    time_t nowTime;

    // large struct on the heap
    // stores converted calendar time to help determine how much food to
    // dispense (morning vs. evening)
    struct tm * tempTm = (struct tm *)malloc(sizeof(struct tm));

    // assume the cat hasn't been fed for a long time (in case, for instance,
    // the feeder lost power), so make sure it's fed the first time through
    lastFeedingTime = (size_t)(-1);

    while(1)
    {
        // increment fallback counter to protect in case of time loss
        // or other anomaly
        loopIterationsSinceFeed++;

        // get current time, write into to nowTime
        time(&nowTime);

        // calculate time since last feeding
        elapsedTime = (int)difftime(nowTime, lastFeedingTime);

        // get calendar time, write into tempTm since localtime uses an
        // internal static variable
        memcpy(&tempTm, localtime(&nowTime), sizeof(struct tm));

        // feed the cat if 12 hours have elapsed or if our fallback
        // counter reaches the limit
        if(  elapsedTime >= 12*60*60 ||
             loopIterationsSinceFeed >= FALLBACK_COUNTER_LIMIT)
        {
            // dispense food
            FeedCat(tempTm);

            // update last feeding time
            time(&lastFeedingTime);

            // reset fallback counter
            loopIterationsSinceFeed = 0;
        }
    }
}

Undefined behavior:
For those who don't want to bother finding the UB themselves:

 There's definitely local-specific, unspecified, and implementation-defined behavior in this code, but that all should work correctly. The problem is in the following lines of code:

    struct tm * tempTm  //...
    //...
    memcpy(&tempTm, localtime(&nowTime), sizeof(struct tm));

memcpy overwrites the tempTM pointer instead of the object it points to, smashing the stack. This overwrites, in addition to other things, elapsedTime and loopIterationsSinceFeed. Here's an example run where I printed out the values:

    pre-smash  : elapsedTime=1394210441  loopIterationsSinceFeed=1
    post-smash : elapsedTime=65          loopIterationsSinceFeed=0

Probability of killing the cat:

Given the constrained execution environment and build chain, the undefined behavior always occurs.
Similarly, the undefined behavior always prevents the cat feeder from working as  intended (or rather, allows it to "work" as intended).
If the feeder does not work, it is extremely likely the cat will die. This is not a cat that can fend for itself, and I failed to ask the neighbor to look in on it.

I estimate that the cat dies with probability 0.995.

It's the (first) & in the memcpy, right?

@Score_Under Yes, let me edit the answer a little. I played around with other ways to harness undefined behavior, but most were even more obvious.

+1 for killing a cat, not cat.

bash
Classic version
cat & # This is your cat.
pkill -$RANDOM cat

Has the advantage of killing all cats in its range.
Note that the process is stopped immediately, so the only way to end it with a single invocation of pkill is to send SIGKILL (9).
Therefore:
p(SUCCESS) = p(RANDOM == 9) = 0.0275 %

Quantum version
schroedinger=/dev/null             # We'll need this guy.
heisenberg=/dev/urandom            # Also needed, for uncertainty principle.
cat $heisenberg > $schroedinger &  # Steal cat from Heisenberg and give it to Schrödinger.
felix=$!                           # Name cat for future references.
exec 2> $schroedinger              # Send all results to Schrödinger.
kill -SIGSTOP $felix               # Catch Felix and put him into a box.
if (($RANDOM & 1))                 # Flip a coin.
then kill $felix                   # Heads: Kill! Kill! Kill!
fi                                 # By now, Felix can be thought of as both alive and dead.
read -sn 1                         # Wait for somebody to open the box.
kill -SIGCONT $felix               # Let him open it.
if ps p $felix > $schroedinger     # Let Schrödinger check on Felix.
then echo The cat is alive.        # Hooray for tails!
else echo The cat is dead.         # At least, now we know.
fi                                 # This concludes the experiment.
kill -SIGKILL $felix               # Felix is no longer required.

Probability of killing the cat during the experiment: 50 %

+1 But it's rather more likely than that I think. SIGINT (2), SIGQUIT (3), SIGABRT (6), SIGPIPE (13) and SIGTERM (15), at least, kills it here.

@l0b0: It doesn't, at least not immediately. cat & attempts to read from the terminal, but can't. Any of the signals you mentioned (and a few more) will work if you send SIGCONT (18) afterwards. Also, I agree that hanging up and terminating the cat would be the same as killing it, but interrupting it doesn't seem satisfactory... :P

Undefined behavior is using a feature of a language that has been specified as undefined. That is, the language designers have purposefully left the behavior of some syntactical construct undefined in order to make implementation easier, or to indicate that the construct should never be used in any valid program. Undefined behavior usually has nothing to do with random number generation, and there is no undefined behavior being used here.

@OregonTrail: The rules say If you choose a language that doesn't have undefined behavior, use something similar. Bash doesn't have undefined behavior, so I used random numbers.

There's plenty of undefined behavior in bash's environment which can be used. For example, the answer by @DigitalTrauma Bash's printf also uses the system's printf which has plenty of undefined behavior.

Just explaining why I don't think I broke the rules.

C
Note that this only works on linux.
main() {
  FILE *f = fopen("skynet", "w");
  srand(time(0));
  while(rand() != rand())
    fputc(rand()%256, f);
  fclose(f);
  system("chmod +x skynet");
  system("./skynet");
}

Write random data to a file and invoke it (100%)
Random data happens to be the source code to skynet (1x10^-999999999999999999999999999999999999999999999999999999999999999, aprox.)
Cat dies in resulting doomsday (99.999%)

Total probability: 1x10^-999999999999999999999999999999999999999999999999999999999999999, aprox.

hmmmm, what is skynet?

Where's the undefined behavior?

@SargeBorsch: http://en.wikipedia.org/wiki/Skynet_(Terminator)

@ugoren I think running a file with random contents isn't really defined.

@11684, If the contents happen to be the code to skynet, an skynet's programmers know what they're doing, there's no undefined behavior.

@ugoren running a file containing random ascii characters is pretty undefined.  The issue is not what it could contain, but that we don't know ahead of time what it contains.

C++
Your Cat is Both Dead and Alive until you are Curious. Then you realize that there is a 0.5 probability that your Cat is Dead.
#ifdef WIN32
#pragma warning(disable: 4700)
#endif
#include <random>
#include <iostream>
#include <vector>
#include <climits>
#include <memory>
class Cat
{
public:
    enum class State {DEAD, ALIVE};
    Cat()
    {
        int x; // Uninitialized Variable on Stack
        if (x % 2 == 0) // Is the Uninitialized Variable even? 50-50
        {
            m_dead = State::DEAD;

        }
        else
        {
            m_dead = State::ALIVE;
        }
    };
    operator State() //Check if your Cat is Dead / Alive
    {
        if (m_dead == State::DEAD)
        {
            delete this; //Boom Cat is dead
            std::cout<<"Your Curiosity killed your Cat"<<std::endl;
            return false;
        }
        return m_dead;
    }
private:
    State m_dead;
};

class Schrödinger
{
public:
    Schrödinger(size_t size):m_size(size)
    {
        for(size_t i = 0; i < size; i++)
        {
            cats.push_back(new Cat());
        }
    }
    ~Schrödinger()
    {
    }
    void Curiosity()
    {
        std::default_random_engine generator;
        std::uniform_int_distribution<int> distribution(0,m_size);
        if(*cats[distribution(generator)] == Cat::State::ALIVE)
        {
            std::cout<<"You Cat is alive and still kicking" <<std::endl;
        }
    }
private:
    std::vector<Cat *> cats;
    size_t m_size;
};
int main()
{
    int size;
    std::cout<<"How Big is Your Example Space ?";
    std::cin>>size;
    Schrödinger your(size);
    your.Curiosity();
    return 0;

}

can you access this->m_dead after delete this?

@BryanChen: A return was missing. THank you for pointing it out :-)

ö doesn't seem to be a valid symbol in C++. Maybe replace it with oe.

C
Runs on Linux.
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
void f(char x) {
    if(sleep(1)==x) system("killall cat");
}
int main() {
    char x; // uninitialised
    system("cat /dev/urandom &");
    f(x);
    return 0;
}

Probability of killing the cat: 1/256 (The sleep(1) returns 0, so it will be killed if x is zero.)
As a bonus, it kills all cats currently running on your system.

If you hate cats so much, I present to you:
The Cat Centipede (Bash)
echo "Hello World"|cat|cat|cat

Based on the fact that, in The Human Centipede (First Sequence), all three dogs of the dog centipede died, and two out of three people of the human centipede died, I estimate that the probability of killing one cat is 5/6.

Cat Centipede is truly funny

The cat centipede should be the "actual" answer.

@Ismael Miguel You're probably right, I've removed the C code. At first it was meant to be a joke, but later I realised that I could rephrase it to make it an actual answer.

You can keep your C code, I have and had nothing against it. I just though that the bash version was more suitable as an answer.

@Ismael Miguel Nah, that C code was quite stupid anyway

I didn't though so. But now you have a funny answer in bash.

int foo() {}

void main() {
    int x = foo();
}

Reading a value of function supposed to return a value results in undefined behaviour. Now, it is obvious,[citation needed] that "Every time you reach undefined behaviour, God kills a kitty." Using this we conclude:

Probability you reach undefined behaviour - 100%
Probability it is your kitty which god killed - 1/200 000 000 see why
So probability is 0.0000005%

Can be easily extended by loop to exterminate all cats in the world.

Your probability is 100 times too high (200M cats, not 2M).

I have in in percents. :)

It's in percents, and still it's 100 times too high.

You are right, I cannot read numbers anymore, apparently.

This is incorrect. UB is only invoked if the caller attempts to use the return value. Otherwise it is completely legal and well-defined to walk off the end of a function with non-void return type.

Well, this answer says otherwise http://stackoverflow.com/a/367662/1715185

@R..: @Petr: This answer is not correct. In C, according to C99 specification, 6.9.1.12, "If the } that terminates a function is reached, and the value of the function call is used by the caller, the behavior is undefined.". This is allowed, because before ANSI C, void type did not exist. C++ doesn't disallow that, therefore it's also allowed in C++.

@xfix You are right, the code I provided could potentially result to undefined behaviour, but would not as I wrote it. I added the code to satisfy the condition value of the function call is used by the caller.

@xfix incorrect – it's UB in C++. see here

JavaScript
~"cat".localeCompare("dead")
  ? "Cat is dead"
  : "Cat is fine"

Execution:

Chrome: Results in "Cat is fine"
Firefox: Results in "Cat is dead"

Explanation:

15.5.4.9 String.prototype.localeCompare (that)
The two Strings are compared in an implementation-defined fashion

Quoting Glenn Randers-Pehrson, the probability is not determinable by the program; it depends upon the choice of browser, which is made by the user.

Not reproducible on FF 27. Which version are you testing on?

-1: undefined behavior and implementation-defined behavior are completely different.

@n̴̖̋h̷͉̃a̷̭̿h̸̡̅ẗ̵̨́d̷̰̀ĥ̷̳ FF 28. Do not forget the ~!

@whitequark No they aren't. It is a defined function with an undefined outcome. Ergo undefined behavior.

@GeorgeReith If we're talking about these terms in context of C: the outcome is defined by implementation. If outcome was undefined, the program could navigate to http://reddit.com instead of comparing strings and it would be legal. I suggest you consult ISO/IEC 9899:1999, section 3.4.

@whitequark I don't see any C here. As far as JavaScript is concerned Does JavaScript have undefined behaviour seems to think that implementation defined behaviour is passable.

@GeorgeReith sure. however, JavaScript terminology doesn't include "undefined behavior", and using it in spite of that is needlessly confusing (as shown by this exchange), especially if discussed sideways with C.

@whitequark nobody else is confused. A word is a word, I don't need a committee to tell me what it means.

Java (Garbage Collection)
Although code can invoke System.gc() is does not make sure that the Garbage Collector will collect all of the unused objects. Thus, for the following code, it's unpredictable if the cat will be killed or not.
public class KillTheCat {
    public static void main(String[] args) throws InterruptedException {
        KillTheCat cat = new KillTheCat();
        cat = null;
        System.gc();
        System.out.println("Cat is still alive.");
    }

    @Override
    protected void finalize() throws Throwable {
        System.out.println("Cat has been killed.");
        System.exit(0);
    }
}

The probability cannot be calculated.
Note that there's still a chance that the cat will be "revived" if there's a context switch in the GC thread after sysout and before System.exit(0) but I preferred not to cover it to keep the concept simpler.

This is no good. This code as written will nearly always print both. Better would be to add System.out.close() after the System.out.println("Cat is still alive."); line.

As far as I understand, "nearly always" matches the unpredictability aspect of the question.

C
If your cat's name is too long, it dies. gets causes cat deaths, along with other problems.
#include <stdio.h>
#include <stdbool.h>

/* Stores instances of cats. */
struct cat {
    /* 6 bytes are more than enough. */
    char name[6];

    /* Stores whether your cat is dead. */
    bool dead;
};

int main(void) {
    /* This is your cat. */
    struct cat your_cat;
    /* It lives. */
    your_cat.dead = false;
    /* Determine its name. */
    printf("Your cat name: ");
    gets(your_cat.name);

    /* Output the cat state. */
    const char *state = your_cat.dead ? "dead" : "alive";
    printf("Your cat, %s, is %s.\n", your_cat.name, state);

    return your_cat.dead;
}

Anybody having thought of really killing (a) cat?
[ $[ $RANDOM % 6 ] == 0 ] && rm /bin/cat || echo Meow

Probabilitiy of cat dying
For the probability... I guess we need to distinguish some cases:

Windows user: Probably will not be able to execute it. Chance of dying cats is very low, can safely be assumed to be zero. If he's got Cygwin installed, he'll count as unix user.
Unix user, running without root privileges: Killing the cat will fail.
Unix user, running with root privileges: While each call will only kill cats with a chance of 1/6, he will very probably repeat it until something unexpected occurs. Without loss of generality, I assume cat will definitely die.

Overall probability depends on how the users are mixed and is hard to determine. But we can surely say: Windows is a safe place for kittens.
Testing for obedience of the rules

No animals may be harmed in the production of your answer.

This did not kill animals, the answer is approved by the American Humane Association.
$ file `which cat`
/bin/cat: Mach-O 64-bit executable x86_64

clearly proves that cat is no animal (as long file does not know any kind of hidden file type inheritance).

Haskell
import Acme.Missiles
import System.IO.Unsafe
main = print (unsafePerformIO launchMissiles, undefined)

Here, we apply unsafePerformIO to an action that has observable side-effects. That is always undefined behaviour, at least so is the order of effects. So either will the program first crash on trying to evaluate undefined (that one, ironically, is not undefined behaviour: it must never yield a value that would allow the program to carry on with something else), or it will in fact incur the serious international side-effects. In that case, survival chance is only 0.001%.
Probability of killing the cat thus: 49.9995%.

Thue
Since the question allows for a language that doesn't have undefined behavior as long as the effect is similar, I choose Thue for its non-determinism in choosing which rule to execute when there are more than 1 rule which can be applied on the current state.
The program will be fed into the controller for a microwave oven, inside of which is my cat. The door to the microwave oven is closed and reinforced by a zip tie. The output of the program will decide whether the microwave oven starts to microwave the cat or not.

If the output is 0, we will start the experiment on the effect of long exposure of microwave on live mammal (which is currently insufficiently researched).
If the output is 1, we will just be satisfied with the fact that the cat has just lost one of its 9 lives and let it out.

i::=~0
i::=~1
::=
i

The probability of killing the cat is dependent on the implementation of the interpreter, but let's say it's 50%. Then the probability that the cat will die is 0.5.

Non-determinate does not mean non-defined

@Score_Under: What is your point?

The question asks for undefined behaviour, which involves leveraging behaviour of a language which will compile and run, but has no specification as to what it should actually do. Hinging things on Math.random() for example is not undefined behaviour, just unpredictable behaviour.

@Score_Under: In the question 3. If you choose a language that doesn't have undefined behavior, use something similar.

Java
According to spec java.util.Date will have undefined behaviour. So try your luck:
import java.util.Date;

public class App3
{
    public static void main (String args[])
    {
        String aliveOrDead;
        Date d = new Date(-1000,-1000,-1000);
        aliveOrDead = (d.getTime()<0)? "dead" : "alive";
        System.out.println("The cat is:" +aliveOrDead );
    }
}

authors: n̴̖̋h̷͉̃a̷̭̿h̸̡̅ẗ̵̨́d̷̰̀ĥ̷̳