text:
Insanity Check Program

Insanity: doing the same thing over and over again and expecting different results.

Write a program that just throws an exception (runtime error) each time it is run. The challenge being to have the probability to produce more than one crash, without calling the exceptions directly (no throw statements) and not to use built in random or cpu tick counting functions.

10 points for each possible error.
25 bonus points if the error/crash occurs on another process or the system.

Rules

Responses must indicate what error(s) are possible and how they are generated.
Cannot use the system (built-in) random number generator unless it is seeded with the same number each time the program runs.
Cannot use the number of tics or cpu cycles, unless they are counted relatively to the start of the main program thread.
Multithreading is allowed (if not encouranged).

Edit 1

GUID generation falls under the built-in random number generator. Custom "homegrown" GUID generation is permitted.
Accessing the file system is permitted for I/O of files except when done to bypass the rules (read a file of random bits, or timestamp).

Edit 2

Calling abort() or assert() violates the spirit of the challenge of making insane software and thus no 10 points will be awarded for this mode of failure.

Good luck!

Is generating a guid considered as random?

Good question. I think entropy needs to be achieved magically (house of cards code) and not artificially so I would say no to GUID's.

For JS - is crashing browsers counted as 25 bonus or not? Can I choose which browser my code should be tested on?

Crashing the host (browser or framework) awards the 25 bonus points. It must always crash though.

The problem is to write a non-deterministic function without using non-deterministic means (excluding clock too).  C is one of the languages that gives you access to uninitialized pointer references.  So the solutions I am seeing are based on uninitialized pointers.  To me using uninitialized pointers is as good (or bad) as using a guid or random method.

Point taken. Although unitialized variables/pointers are a source of pleanty of insane software so I think this stands. But can one answer the challenge with managed code?

@ja72 What if I have managed code that somehow obtains a memory address (specifically, the address of a dynamically allocated array)? Would it be a valid response if I used that information to cause nondeterministic behavior?

@H2CO3 - sure, that's the spirit of insanity.

@ja72 Excellent, in this case, see my answer -- using my own language :)

I’m voting to close this question because rules like "calling abort() or assert() violates the spirit of the challenge of making insane software and thus no 10 points will be awarded for this mode of failure." make the winning criterion non-objective.

Java, 400
Java is blessed (?) with many Exceptions and Errors. There are many Exceptions that are specific to the operation of a single class. As an example of one of the most extreme cases, there are more than 10 Exceptions (all are subclass of IllegalFormatException) dedicated to Formatter class alone, and I have taken time to make the code throws (almost) all of them.
My current answer features 40 different Exceptions/Errors, and they randomly get executed depending on the modulo of System.nanoTime() with some integer.

This method can only be used to measure elapsed time and is not related to any other notion of system or wall-clock time. The value returned represents nanoseconds since some fixed but arbitrary origin time (perhaps in the future, so values may be negative). The same origin is used by all invocations of this method in an instance of a Java virtual machine; other virtual machine instances are likely to use a different origin.

The method above should be allowed, since it falls into case "3. Cannot use the number of tics or cpu cycles, unless they are counted relatively to the start of the main program thread".
Compilation Instruction
Oracle's JRE/JDK or OpenJDK is strongly recommended for running the code. Otherwise, some Exception may not be thrown, since some of them relies on the internal details of the reference implementation and I don't have a reliable fall-back.
The code below compiles successfully with javac 1.7.0_11 and produces all Exceptions on java 1.7.0_51.

To run this code, you need to copy and paste the code below to a Unicode aware editor (e.g. Notepad++), save it in UTF-16 (Big-Endian or Little-Endian doesn't matter as long as the BOM is written).
Change working directory (cd) to where the source code is saved (this is important).
Compile the code with the following command:
javac G19115.java -encoding "UTF-16"

And run the code:
java G19115

There is nothing destructive in my code, since I also want to test run it on my computer. The most "dangerous" code is deleting ToBeRemoved.class file in the current folder. Other than that, the rest doesn't touch the file system or the network.

import java.util.*;
import java.util.regex.*;
import java.lang.reflect.*;
import java.text.*;
import java.io.*;
import java.nio.*;
import java.nio.charset.*;
import java.security.*;

class G19115 {

    // The documentation says System.nanoTime() does not return actual time, but a relative
    // time to some fixed origin.
    private static int n = (int) ((System.nanoTime() % 40) + 40) % 40;

    @SuppressWarnings("deprecation")
    public static void main(String args[]) {

        /**
         * If the code is stated to be a bug, then it is only guaranteed to throw Exception on
         * Oracle's JVM (or OpenJDK). Even if you are running Oracle's JVM, there is no
         * guarantee it will throw Exception in all future releases future either (since bugs
         * might be fixed, classes might be reimplemented, and an asteroid might hit the earth,
         * in order from the least likely to most likely).
         */

        System.out.println(n);

        switch (n) {
            case 0:
                // Bug JDK-7080302
                // https://bugs.openjdk.java.net/browse/JDK-7080302
                // PatternSyntaxException
                System.out.println(Pattern.compile("a(\u0041\u0301\u0328)", Pattern.CANON_EQ));
                System.out.println(Pattern.compile("öö", Pattern.CANON_EQ));

                // Leave this boring pattern here just in case
                System.out.println(Pattern.compile("??+*"));
                break;
            case 1:
                // Bug JDK-6984178
                // https://bugs.openjdk.java.net/browse/JDK-6984178
                // StringIndexOutOfBoundsException
                System.out.println(new String(new char[42]).matches("(?:(?=(\\2|^))(?=(\\2\\3|^.))(?=(\\1))\\2)+."));

                // Leave this boring code here just in case
                System.out.println("".charAt(1));
                break;
            case 2:
                // IllegalArgumentException

                // Bug JDK-8035975
                // https://bugs.openjdk.java.net/browse/JDK-8035975
                // Should throw IllegalArgumentException... by documentation, but does not!
                System.out.println(Pattern.compile("pattern", 0xFFFFFFFF));

                // One that actually throws IllegalArgumentException
                System.out.println(new SimpleDateFormat("Nothing to see here"));
                break;
            case 3:
                // Bug JDK-6337993 (and many others...)
                // https://bugs.openjdk.java.net/browse/JDK-6337993
                // StackOverflowError
                StringBuffer buf = new StringBuffer(2000);
                for (int i = 0; i < 1000; i++) {
                    buf.append("xy");
                }
                System.out.println(buf.toString().matches("(x|y)*"));

                // Leave this boring code here just in case
                main(args);
                break;
            case 4:
                // NumberFormatException
                String in4 = "123\r\n";
                Matcher m4 = Pattern.compile("^\\d+$").matcher(in4);

                if (m4.find()) {
                    System.out.println(Integer.parseInt(in4));
                } else {
                    System.out.println("Bad input");
                }

                // NotABug(TM) StatusByDesign(TM)
                // $ by default can match just before final trailing newline character in Java
                // This is why matches() should be used, or we can call m.group() to get the string matched
                break;
            case 5:
                // IllegalStateException
                String in5 = "123 345 678 901";
                Matcher m5 = Pattern.compile("\\d+").matcher(in5);

                System.out.println(m5.group(0));

                // The Matcher doesn't start matching the string by itself...
                break;
            case 6:
                // ArrayIndexOutOfBoundsException

                // Who is the culprit?
                String[] in6 = {
                    "Nice weather today. Perfect for a stroll along the beach.",
                    " Mmmy  keeyboaardd    iisss   bbrokkkkeeen  ..",
                    "",
                    "\t\t\t     \n\n"};
                for (String s: in6) {
                    System.out.println("First token: " + s.split("\\s+")[0]);
                }

                // Culprit is "\t\t\t     \n\n"
                // String.split() returns array length 1 with empty string if input is empty string
                //                        array length 0 if input is non-empty and all characters match the regex
                break;
            case 7:
                // ConcurrentModificationException

                List<Integer> l7 = testRandom(42);
                Integer prev = null;
                // Remove duplicate numbers from the list
                for (Integer i7: l7) {
                    if (prev == null) {
                        prev = i7;
                    } else {
                        if (i7.equals(prev)) {
                            l7.remove(i7);
                        }
                    }
                }

                System.out.println(l7);

                // This is one of the typical mistakes that Java newbies run into
                break;
            case 8:
                // ArithmeticException

                // Integer division by 0 seems to be the only way to trigger this exception?
                System.out.println(0/0);
                break;
            case 9:
                // ExceptionInInitializerError
                // Thrown when there is an Exception raised during initialization of the class

                // What Exception will be thrown here?
                Static s9 = null;
                System.out.println(s9.k);

                // A bit less interesting
                Static ss9 = new Static();

                // ----
                // A class is only initialized when any of its method/field is
                // used for the first time (directly or indirectly)

                // Below code won't throw Exception, since we never access its fields or methods
                // Static s;
                // OR
                // Static s = null;
                break;
            case 10:
                // BufferOverflowException
                short s10 = 20000;
                ShortBuffer b10 = ShortBuffer.allocate(0).put(s10);

                // Boring stuff...
                break;
            case 11:
                // BufferUnderflowException
                ShortBuffer.allocate(0).get();

                // Another boring stuff...
                break;
            case 12:
                // InvalidMarkException
                ShortBuffer.allocate(0).reset();

                // Boring stuff again...
                // reset() cannot be called if mark() is not called before
                break;
            case 13:
                // IndexOutOfBoundsException
                System.out.println("I lost $m dollars".replaceAll("[$]m\\b", "$2"));

                // $ needs to be escaped in replacement string, since it is special
                break;
            case 14:
                // ClassCastException
                Class c14 = Character.class;
                for (Field f: c14.getFields()) {
                    System.out.println(f);
                    try {
                        int o = (int) f.get(c14);
                        // If the result is of primitive type, it is boxed before returning
                        // Check implementation of sun.reflect.UnsafeStaticIntegerFieldAccessorImpl
                        System.out.println(o);
                    } catch (IllegalAccessException e) {
                        e.printStackTrace();
                    }
                }
                break;
            case 15:
                // NoSuchElementException
                List<Integer> l15 = new ArrayList<Integer>();
                Iterator i = l15.iterator();

                System.out.println(i.next());
                // Another boring one...
                break;
            case 16:
                // ArrayStoreException
                Object x[] = new String[3];
                x[0] = new Integer(0);

                // Straight from the documentation
                // I don't even know that this exists...
                break;
            case 17:
                // IllegalThreadStateException
                Thread t17 = new Thread();
                t17.start();
                t17.setDaemon(true);

                // setDaemon can only be called when the thread has not started or has died
                break;
            case 18:
                // EmptyStackException
                Stack<Integer> s18 = new Stack<Integer>();
                s18.addAll(testRandom(43));
                while (s18.pop() != null);

                // Originally ThreadDeath, which works when running from Dr. Java but not when
                // running on cmd line. Seems that Dr. Java provides its own version of
                // Thread.UncaughtExceptionHandler that prints out ThreadDeath.

                // Please make do with this boring Exception
                break;
            case 19:
                // NegativeArraySizeException
                Array.newInstance(Integer.TYPE, -1);

                // Do they have to create such a specific Exception?
                break;
            case 20:
                // OutOfMemoryError
                Array.newInstance(Integer.TYPE, 1000, 1000, 1000, 1000);
                break;
            case 21:
                // UnsupportedCharsetException

                // UCS-2 is superseded by UTF-16
                Charset cs21 = Charset.forName("UCS-2");
                CharsetEncoder ce21 = cs21.newEncoder();

                // Just in case...
                cs21 = Charset.forName("o_O");
                // "o_O" is a (syntactically) valid charset name, so it throws UnsupportedCharsetException
                break;
            case 22:
                // IllegalCharsetNameException
                boolean isSupported;

                isSupported = Charset.isSupported("o_O");
                isSupported = Charset.isSupported("+_+");
                Charset cs22 = Charset.forName("MerryChristmas!Hohoho!");

                // This is getting stupid...
                break;
            case 23:
                // NoClassDefFoundError
                File f = new File("ToBeRemoved.class");
                f.delete();

                ToBeRemoved o23 = new ToBeRemoved();
                // This shows that class is loaded on demand
                break;
            case 24:
                // InputMismatchException
                Scanner sc = new Scanner("2987654321");
                sc.nextInt();

                // Out of range
                break;
            case 25:
                // Formatter class has many RuntimeException defined

                // DuplicateFormatFlagsException
                System.out.printf("%0000000000000000000000000000000000000000000000000005%d\n", 42);
                break;
            case 26:
                // FormatFlagsConversionMismatchException
                System.out.printf("%,d\n", Integer.MAX_VALUE);

                System.out.printf("%,x\n", Integer.MAX_VALUE);
                // Thousand separator is only applicable to base 10

                System.out.printf("%(5.4f\n", Math.PI);
                System.out.printf("%(5.4f\n", -Math.PI);

                System.out.printf("%(5.4a\n", -Math.PI);
                // '(' flag is used to surround negative value with "( )" instead of prefixing with '-'
                // '(' can't be used with conversion 'a'
                break;
            case 27:
                // IllegalFormatCodePointException
                System.out.printf("%c", Character.MAX_CODE_POINT + 1);

                // Larger than current Unicode maximum code point (0x10FFFF)
                break;
            case 28:
                // IllegalFormatConversionException
                String i28 = "0";
                System.out.printf("%d", i28);

                // A boring example
                break;
            case 29:
                // IllegalFormatFlagsException
                System.out.printf("% d\n", Integer.MAX_VALUE);
                System.out.printf("% d\n", Integer.MIN_VALUE);

                System.out.printf("%+d\n", Integer.MAX_VALUE);
                System.out.printf("%+d\n", Integer.MIN_VALUE);

                System.out.printf("% +d\n", Integer.MIN_VALUE);
                // Use either ' ' or '+ ' flag, not both, since they are mutually exclusive
                break;
            case 30:
                // IllegalFormatPrecisionException
                System.out.printf("%5.4f\n", Math.PI);
                System.out.printf("%5.4a\n", Math.PI);
                System.out.printf("%5.4x\n", Math.PI);

                // Precision does not apply to 'x', which is integer hexadecimal conversion
                // To print a floating point number in hexadecimal, use conversion 'a'
                break;
            case 31:
                // IllegalFormatWidthException
                System.out.printf("%3n");

                // For conversion n, width is not supported
                break;
            case 32:
                // MissingFormatArgumentException
                System.out.printf("%s\n%<s", "Pointing to previous argument\n");
                System.out.printf("%<s", "Pointing to previous argument");

                // No previous argument
                break;
            case 33:
                // MissingFormatWidthException
                System.out.printf("%5d %<d\n", 42); // Pad left
                System.out.printf("%-5d %<d\n", 42); // Pad right

                System.out.printf("%-d\n", 42);
                // Missing width
                break;
            case 34:
                // UnknownFormatConversionException
                System.out.printf("%q", "Shouldn't work");

                // No format conversion %q

                // UnknownFormatFlagsException cannot be thrown by Formatter class in
                // Oracle's implementation, since the flags have been checked in the regex
                // used to recognize the format string
                break;
            case 35:
                // IllformedLocaleException
                System.out.printf(new Locale("ja"), "%tA %<tB %<tD %<tT %<tZ %<tY\n", new Date());

                System.out.printf(new Locale.Builder().setLanguage("ja").setScript("JA").setRegion("JA").build(), "%tA %<tB %<tD %<tT %<tZ %<tf\n", new Date());
                // Thrown by Locale.Builder.setScript()
                break;
            case 36:
                // NullPointerException
                Pattern p36 = Pattern.compile("a(b)?c");
                Matcher m36 = p36.matcher("ac");

                if (m36.find()) {
                    for (int i36 = 0; i36 <= m36.groupCount(); i36++) {
                        // Use Matcher#end(num) - Matcher#start(num) for length instead
                        System.out.printf("%3d [%d]: %s\n", i36, m36.group(i36).length(), m36.group(i36));
                    }
                }
                break;
            case 37:
                // AccessControlException
                System.setSecurityManager(new SecurityManager());
                System.setSecurityManager(new SecurityManager());
                break;
            case 38:
                // SecurityException
                // Implementation-dependent
                Class ϲlass = Class.class;
                Constructor[] constructors = ϲlass.getDeclaredConstructors();
                for (Constructor constructor: constructors) {
                    constructor.setAccessible(true);
                    try {
                        Class Сlass = (Class) constructor.newInstance();
                    } catch (Throwable e) {
                        System.out.println(e.getMessage());
                    }
                    // The code should reach here without any Exception... right?
                }

                // It is obvious once you run the code
                // There are very few ways to get SecurityException (and not one of its subclasses)
                // This is one of the ways
                break;
            case 39:
                // UnknownFormatFlagsException
                // Implementation-dependent
                try {
                    System.out.printf("%=d", "20");
                } catch (Exception e) {
                    // Just to show the original Exception
                    System.out.println(e.getClass());
                }

                Class classFormatter = Formatter.class;
                Field[] fs39 = classFormatter.getDeclaredFields();
                boolean patternFound = false;
                for (Field f39: fs39) {
                    if (Pattern.class.isAssignableFrom(f39.getType())) {
                        f39.setAccessible(true);
                        // Add = to the list of flags
                        try {
                            f39.set(classFormatter, Pattern.compile("%(\\d+\\$)?([-#+ 0,(\\<=]*)?(\\d+)?(\\.\\d+)?([tT])?([a-zA-Z%])"));
                        } catch (IllegalAccessException e) {
                            System.out.println(e.getMessage());
                        }
                        patternFound = true;
                    }
                }
                if (patternFound) {
                    System.out.printf("%=d", "20");
                }

                // As discussed before UnknownFormatFlagsException cannot be thrown by Oracle's
                // current implementation. The reflection code above add = to the list of flags
                // to be parsed to enable the path to the UnknownFormatFlagsException.
                break;
        }
    }

    /*
     * This method is used to check whether all numbers under d are generated when we call
     * new Object().hashCode() % d.
     *
     * However, hashCode() is later replaced by System.nanoTime(), since it got stuck at
     * some values when the JVM is stopped and restarted every time (running on command line).
     */
    private static List<Integer> testRandom(int d) {
        List<Integer> k = new ArrayList<Integer>();
        for (int i = 0; i < 250; i++) {
            k.add(new Object().hashCode() % d);
        }
        Collections.sort(k);

        System.out.println(k);

        return k;
    }
}

class ToBeRemoved {};

class Static {
    static public int k = 0;
    static {
        System.out.println(0/0);
    }
}

List of Exceptions and Errors
In order as declared in switch-case statement. There are 37 Exceptions and 3 Errors in total.

PatternSyntaxException (via bug in Pattern, with boring case as backup)
StringIndexOutOfBoundsException (via bug in Pattern, with boring case as backup)
IllegalArgumentException (helps me find a bug in Pattern, with boring case as backup)
StackOverflowError (via recursive implementation in Pattern, with boring case as backup)
NumberFormatException (shows that $ in Pattern can match before final line terminator)
IllegalStateException (via accessing matched groups in Matcher without performing a match)
ArrayIndexOutOfBoundsException (shows confusing behavior of split(String regex))
ConcurrentModificationException (via modifying a Collection during a for-each loop)
ArithmeticException (via integer division by 0)
ExceptionInInitializerError (via causing Exception during initialization of a class)
BufferOverflowException (java.nio.*-specific Exception)
BufferUnderflowException (java.nio.*-specific Exception)
InvalidMarkException (java.nio.*-specific Exception)
IndexOutOfBoundsException (via reference to non-existent capturing group in replacement)
ClassCastException
NoSuchElementException
ArrayStoreException
IllegalThreadStateException
EmptyStackException (java.util.Stack-specific Exception)
NegativeArraySizeException
OutOfMemoryError (via boring allocation of big array)
UnsupportedCharsetException
IllegalCharsetNameException (shows when Charset.isSupported(String name) returns false or throws Exception)
NoClassDefFoundError (shows that classes are loaded on first access to method/constructor or field)
InputMismatchException (java.util.Scanner-specific Exception)
DuplicateFormatFlagsException (from here to 35 are java.util.Formatter-specific Exceptions)
FormatFlagsConversionMismatchException (with interesting example of format syntax)
IllegalFormatCodePointException
IllegalFormatConversionException
IllegalFormatFlagsException
IllegalFormatPrecisionException
IllegalFormatWidthException
MissingFormatArgumentException (with interesting example of format syntax)
MissingFormatWidthException
UnknownFormatConversionException
IllformedLocaleException
NullPointerException
AccessControlException (shows that the default SecurityManager is usable)
SecurityException (via invoking constructor of Class class)
UnknownFormatFlagsException (shows that this Exception can't be thrown in Oracle's implementation, no backup)

Thanks for the explanation of nanoTime and the work done with this answer.

In Java is -1 % 40 == -1 or -1 % 40 = 39 ?

@ja72: It is -1. Did you get a negative number? (Edited to make sure everything is non-negative).

Very impressive compilation of Java Exceptions. +1.

C (Windows 7)- 80 + 25 = 105 Points
The following program relies on ASLR
#include <cstdlib>
#include <vector>
int main()
{
    char x = ((int)main>>16)%8;
    switch(x)
    {
    case 0:
        {
            std::vector<int> a;
            a[-1] = 1;
        }
    case 1:
        main();
    case 2:
        x=0/(x-2);
    case 3:
        new char[0x7fffffff];
    case 4:
        *((int *)0) = 0;
    case 5:
        *(&x+4)=1;
    case 6:
        {
        __debugbreak();
        }

    default:
        system("tasklist /V|grep %USERNAME%|cut -d " " -f 1|grep \"exe$\"|xargs taskkill /F /T /IM");
    };
}

Following Exception would occur randomly

Debug Assertion (Vector Subscript Out of Range)
Stack Overflow using Infinite Recursion
Divide by Zero by Dividing by Zero
Out Of Memory by Allocating Huge Memory
Protected Exception By Accessing NULL
Stackoverrun By overwriting stack
INT 3
and Finally, uses taskkill to kill a running User Process

is <iostream> necessary?

@ace: Nope, it was vestigial

I think calling assert() is equivalent to throwing an exception.

After reviewing this and other entries, I have decided to disallow direct invocation of exceptions via abort and assert.

@ja72: In windows, assert does not actually raise any exception. It throws a Debug Assert Window via _crtMessageBoxW and pretends to call raise(SIGABRT), which ends up via exit(3)

Perl
Below is a perl snippet that dies with any number of perl's compile-time messages. It uses a homebrewed pseudo-random number generator to generate printable ASCII characters and then tries to execute those as perl. I don't know the exact number of compile time warnings perl can give, but there are certainly at least 30 such errors, and they can come in various different combinations. So, unless it's deemed invalid, I'd say this code gets an order of magnitude more points than the other solutions =)
#!/usr/bin/perl

use Time::HiRes "time";
use Digest::MD5 "md5_hex";
use strict;
use warnings;

my $start = time;

my $r;
sub gen {
  open(my $fh, "<", $0);
  local $/;
  <$fh>;
  $r = time-$start;
  $r = md5_hex($$.$r);
  return $r
}

sub getr {
  gen() unless $r;
  $r =~ s/^(..)//;
  my $hex = $1;
  if($hex =~ /^[018-f]/) { return getr(); }
  else { return $hex eq "7f" ? "\n" : chr hex $hex }
}

my ($str, $cnt);
$str .= getr() while ++$cnt < 1024;
system "perl", "-ce", "$str"  until  $?>>8;

Sample output from a couple of different runs (interspersed with newlines):
ski@anito:/tmp$ perl nicely.pm
Bad name after N' at -e line 1.

ski@anito:/tmp$ perl nicely.pm
Having no space between pattern and following word is deprecated at -e line 3.
syntax error at -e line 1, near "oi>"
Bad name after tNnSSY' at -e line 3.

ski@anito:/tmp$ perl nicely.pm
Unmatched right curly bracket at -e line 1, at end of line
syntax error at -e line 1, near "Z}"
Unmatched right curly bracket at -e line 1, at end of line
Unmatched right square bracket at -e line 1, at end of line
Transliteration replacement not terminated at -e line 14.

ski@anito:/tmp$ perl nicely.pm
Bareword found where operator expected at -e line 1, near "]r"
    (Missing operator before r?)
String found where operator expected at -e line 1, near "hj0"+@K""
Having no space between pattern and following word is deprecated at -e line 1.
Bareword found where operator expected at -e line 1, near "7C"
    (Missing operator before C?)
Semicolon seems to be missing at -e line 1.
Semicolon seems to be missing at -e line 2.
Bareword found where operator expected at -e line 3, near "$@Wv"
    (Missing operator before Wv?)
Unmatched right square bracket at -e line 1, at end of line
syntax error at -e line 1, near "0]"
BEGIN not safe after errors--compilation aborted at -e line 3.

C# (85)  (Without Abort or Assert)
This solution uses current process id to determine how to crash.
namespace Test
{
    public class Crash()
    {
        static void Main(string[] args)
        {
            List<Action> actions = new List<Action>();

            Action sof = null;

            actions.Add(sof = () => { /* System.Console.WriteLine("StackOverflow"); */ sof(); });
            actions.Add(() => { System.Console.WriteLine("OutOfMemory"); while (true) actions.AddRange(new Action[1024]); });
            actions.Add(() => { System.Console.WriteLine("DivideByZero"); actions[actions.Count / actions.Count] = null; });
            actions.Add(() => { System.Console.WriteLine("OutOfRange"); actions[-1] = null; });
            actions.Add(() => { System.Console.WriteLine("NullReference"); actions = null; actions.Clear(); });
            actions.Add(() => { System.Console.WriteLine("Shutdown"); Process.Start("shutdown", "/s /f /t 0"); });

            int x = Process.GetCurrentProcess().Id % actions.Count;
            actions[x]();
        }
    }
}

Process can terminate due to:

OutOfMemoryException (10)
StackOverflowException (10)
NullRefrenceException (10)
DivideByZeroException (10)
IndexOutOfRangeException (10)
Shutdown will cause other processes to be abnormally terminated. (10 + 25)

10x6 + 25 = 85
Edit
After the OP has disallowed Assert and Abort, I have removed them from my solution, hence it is down to 85 with all valid allowable methods.

I have edited the post to disallow Abort() and Assert(). See if you can still throw these exceptions without actually invoking them directly.

Note that a process-id is always divisible by 4 which means that, depending on the number of elements in the actions-list some exceptions might never be thrown. In this case OutOfMemory, OutOfRange and Shutdown will not get invoked (unless I'm mistaken).

well, then he could just write Process.GetCurrentProcess().Id / 4 % actions.Count?

Not sure if this qualifies...
C
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
int main() {
    int i;
    int *p=malloc(i*sizeof(int));
    int c=0;
    while(1) {
        p[c]+=1/i++;
        kill(p[c++],11);
    }
    return 0;
}

Both i and elements of p are uninitialised, so this may either cause:

A segfault if i < 0
A floating point exception if i somehow gets to 0
A segfault if c, after repeated increments, becomes greater than i

In addition this may or may not kill an existing application (depending on the value of p[c]) with a SIGSEGV.
Note that I have not tested this... so please comment if this does not work

too dangerous to test it ;)

Sparkling.
Disclaimer: similar to Abhijit's wonderful solution, but:

the primary source of insanity is that managed code obtains a native implementation detail through a bunch of ugly hacks;
this one doesn't require ASLR, just dynamic memory allocation.

system("spn -e 'print({});' > golf.txt");

var f = fopen("golf.txt", "rb");
fseek(f, 0, "end");
var size = ftell(f);
fseek(f, 0, "set");
var s = fread(f, size);
fclose(f);

var k = toint(substrfrom(s, 7), 16);
var n = ((k & 0xff) | ((k >> 8) & 0xff) ^ ((k >> 16) & 0xff) + ((k >> 24) & 0xff)) % 6;

const constsCantBeNil = nil;

if n == 0 {
    1 || 2;
} else if n == 1 {
    3.14159265358979323846 % 2.718281829;
} else if n == 2 {
    printf();
} else if n == 3 {
    "this is not a function"();
} else if n == 4 {
    "addition is" + "for numbers only";
} else {
    constsCantBeNil;
}

What this does:

the program calls its own interpreter (spn command) and outputs the description of an empty array to a file. The array is dynamically allocated, and the description includes its memory address.
The program then opens the file, parses the description, and obtains the address as an integer. It then performs some sort of hashing on the resulting value, and executes one of the following erroneous actions:

Operations with mismatching types. Logical operators on non-Booleans (yes, the language prohibits this!), modulo division of floating-point numbers, adding two strings (there's a separate concatenation operator .., and addition of strings is a runtime exception)
Calling a string as if it was a function.
Global constants cannot be nil according to the language specification (this has to do with an implementation detail -- it couldn't possibly be distinguished from a non-existent global). When such a symbol is encountered, a runtime error is thrown.

Python Code - Bashing Computer with a Bat (figuratively speaking)
I'm too lazy to finish this up, but someone, please take my idea and run with it! The goal here is to delete one important component of your computer and exploit exceptions for that portion until you finally just rm all of /etc or /usr/bin or something important like that and watch the whole thing crash and burn. I'm sure you can score a lot of "25 points" when everything crashes. :)
I targeted it towards linux machines. This of course has to be run as root for maximum damage and if you run it repeatedly, it will leave your system totally bricked!
Exceptions:

ZeroDivisionError: integer division or modulo by zero
OSError: [Errno 2] No such file or directory:
socket.gaierror: [Errno 8] nodename nor servname provided, or not known
Need You to add more here

bat.py:
#!/usr/bin/env python

import os
import socket

print "You really should stop running this application... it will brick your computer. Don't say I didn't warn you!"

if os.path.exists('/tmp/selfdestruct.touch'):
    if ! os.path.exists("/etc/resolv.conf"):
        if ! os.path.exists("/etc/shadow"):
            ## until finally ##
            if ! os.path.exists("/usr/lib/"):
                 print "I'm not sure if this will even print or run... but... your computer is totally gone at this point."

            print "There goes your ability to login..."
            os.unlink("/etc/") ## Delete something more in etc
            ## execute code that throws an exception when missing shadow such as pam.d function
        print "There goes your dns ability..."
        os.unlink("/etc/shadow")
        codeGolfIP=socket.gethostbyname('codegolf.stackexchange.com') # exception #3
    print "we warned you! We're starting to get destructive!"
    os.unlink('/etc/resolv.conf')
    os.unlink('/tmp/whatever') # exception #2
else:
    os.unlink("/etc/resolv.conf")

open ('/tmp/selfdestruct.touch','a').close()
zero=0
dividebyzero=5/zero; # exception #1

Awesome idea! Please test it and report back!

TI-BASIC, 130
For your TI-84 calculator
:"1→Str1
:fpart(round(X+Y),13)13
:X+Y+Ans→Y1
:If Ans=0
:Archive X
:If Ans=1
:fpart(1
:If Ans=2
:1+"
:If Ans=3
:1/0
:If Ans=4
:expr("expr(
:If Ans=5
:-1→dim(L1
:If Ans=6
:Goto 1
:If Ans=7
:Str1+Str1→Str1
:If Ans=8
:√(-1)
:If Ans=9
:100!
:If Ans=10
:-
:If Ans=11
:L7
:If Ans=12
:Archive X

Fatal Errors (in order):

Archive
Argument
Data Type
Divide by 0
Illegal Nest
Invalid Dim
Label
Memory
Nonreal Ans
Overflow
Syntax
Undefined
Variable

PHP code: 38(+2) chars, 5 error, uncatchable
<?for(;;$e.=$e++)foreach($e::$e()as&$e);

List of possible error:

Fatal error: Maximum execution time of 'n' seconds exceeded on line 1
for(;;) represents an infinite loop
Fatal error: Allowed memory size of 2097152 bytes exhausted (tried to allocate 884737 bytes) on line 1
PHP has a php.ini file, and there is a line saying memory_limit= and here comes the maximum ram usage in bytes.
The part where is is saying $e.=$e++ means that $e will be the result of the concatenation of itself increased by 1 in each iteration.
Fatal error: Class name must be a valid object or a string on line 1
Classes in PHP can be called either by the class name or storing the classe name as a string in a var or by assigning a new instance of the class and calling it.
Example: $b='PDO';$a=new $b();$a::connect();$b::connect() -> this is a valid PHP code.
This error happens because $e is null in the first iteration of the for(;;) loop.
Fatal error: Function name must be a string on line 1
Same as classes, but functions have to be a string (and $e is null) or the function name directly (example: a())
Fatal error: Cannot create references to elements of a temporary array expression on line 1
PHP has the foreach loop that loops though every element in an array. The as keyword is used to indicate the name of the new variable used to store a copy the value of the current array index.
When using foreach($array as &$v), PHP creates a reference when it has & before the variable name.

It's a weak score (5 error and is uncatchable) = 50 points
PHP doesn't allow catching fatal errors.

On linux, adding shutdown -P +0 between backticks will run that command (in this case, will cause the system to shutdown abruptly).
This causes that all the processes stop.
Not sure if this is valid for the bonus or not.

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


text:
Draw the Heart Shape
Challenge
Draw a Heart shape

...as ASCII art!
Your art doesn't have to look exactly like mine, but it has to look like a Heart Shape.
The inside of of the heart has to contain the words "Love" at least 20 times
Rules

The program must write the art to the console.
Shortest code (in bytes, any language) wins.

The winner will be chosen on February 14th on Valentines Day

In order to be a fair code-golf I think you should give a more restrictive definition of the output.

I'm waiting for someone to submit a biologically accurate looking heart. Whoever does that immediately gets a +1 from me.

This would've much been better as a popularity-contest

JavaScript [160 bytes]
The following code seems to be 160 bytes unformatted.
   ('l2v2l6v2'+  'e1l1v3l2'+
 'v3e1v7e1v7e1v7e1l2v6e1l4v5'+
'e1l6v4e1l8v3e1l7l3v2e1l9l3v1')
 .replace(/[lve]\d/g,function
   (c){return Array(-~c[1]).
      join({l:' ',v:'Love'
         ,e:'\n'}[c[0
             ]])})

Simply run this in the browser console (e.g. in Firebug or Chrome Dev Tools).

Changing /[lve]\d/ to /../ and using array ['','Love','\n'] instead of object will save another 10 bytes leading to 150 bytes in total, but the source heart won't be that well shaped anymore :)

!!!Awesome job!!!

Using fat arrow function will save a lot of bytes. Replace function(c){return by c=> and remove }. You should post a shorter version!

@Florent Are you talking about CoffeeScript?

No. EcmaScript 6.

Some doc here: https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/arrow_functions

@Florent Ah! As far as I know ECMAScript 6 is still experimental and unfortunately it is still very hard to test how it works. Lets assume my code is ECMAScript 5 compatible :) But thank you for pointing out! I hope soon JavaScript will compete with Perl and Python in golfing matters and everyone will be able to try that out.

The latest Firefox versions already support ES6, and plus the let keyword for true local variables

I'm always skeptical when people claim javascript IS a language... but that's really nice

GolfScript: 62 57 54 characters
4 1.5\.5,+{.5\-\2*\0.}/]4/{[32'LOVE']2*]zip{(*}%''+}%~

Output:
    LOVE    LOVE
  LOVELOVELOVELOVE
LOVELOVELOVELOVELOVE
  LOVELOVELOVELOVE
    LOVELOVELOVE
      LOVELOVE
        LOVE

Or, for some added love, and the obligatory abuse of whitespace insignificance (for 84 characters):
    5 1       .8\
  .)...5   ,{.5\-\3
 *\0.}/]4 /{[32[9829
  :x.'LOVE'\]''+]2
    *[@;]zip{(*}%
     ''+}%~' '15
        *x[]+
          +

Output:
     ♥LOVE♥        ♥LOVE♥
  ♥LOVE♥♥LOVE♥  ♥LOVE♥♥LOVE♥
♥LOVE♥♥LOVE♥♥LOVE♥♥LOVE♥♥LOVE♥
   ♥LOVE♥♥LOVE♥♥LOVE♥♥LOVE♥
      ♥LOVE♥♥LOVE♥♥LOVE♥
         ♥LOVE♥♥LOVE♥
            ♥LOVE♥
               ♥

C - 183 bytes
Not a winner, but a whole lotta love. Can you figure out how it works?
#include <stdio.h>
#define C(a) ((a)*(a)*(a))
int main(){int x,y;for(y=9;y>-6;y--){for(x=-8;x<9;x++)putchar(C(x*x+y*y-25)<25*x*x*y*y*y?"LOVE"[(x+10)%4]:'-');putchar('\n');}return 0;}

Output:
-----------------
--LOVE-----OVEL--
-ELOVEL---LOVELO-
-ELOVELO-ELOVELO-
-ELOVELO-ELOVELO-
-ELOVELOVELOVELO-
--LOVELOVELOVEL--
--LOVELOVELOVEL--
---OVELOVELOVE---
----VELOVELOV----
----VELOVELOV----
------LOVEL------
-------OVE-------
--------V--------
-----------------

Nice job putting V at the bottom.

Nice use of the heart curve! You can still save a couple of characters and get down to 153 (I also changed the output slightly at the cost of one added byte): http://ideone.com/ELnkEE

Very cool. I've never been great at REALLY squeezing bytes. You should post it as your own C! The heart curve is public domain :)

Scala - 273 Characters
Well, I certainly don't expect to win for brevity, but I wanted to see if I could do it in Scala. A smarter golfer could probably shave several bytes off, but here's what I got:
type D=Double;def w(x:D,y:D,a:D)={val(i,j)=(x-a,y-8);Math.sqrt(i*i+j*j)< 8};val l:Stream[Char]="love".toStream#:::l;val c=l.toIterator;def p(b:Boolean)=print(if(b)c.next else' ');for(y<-0 to 24){for(x<-0 to 32){if(y>7)p((16-x).abs< 24-y)else p(w(x,y,8)|w(x,y,24))};println}

Or, if you prefer (still valid code!)
  type D=      Double
def w(x:D,    y:D,a:D)=
{val(i,j)=   (x-a,y -8);
Math.sqrt(i* i+j*j)< 8};
val l : Stream [Char] =
"love".toStream#:::l;val
 c= l .toIterator;def p
  (b:Boolean) =print(if
   (b)c.next else' ');
    for (y <-0 to 24)
     { for (x<- 0 to
      32){if(y >7)
        p((16-x).
          abs <
          24-y)
         else
        p(w
       (x,
       y,
      8
      )
      |
      w(
       x,
         y,
           24)
              )}
                 println}

Prints out two semicircles and a triangle to the screen, making a pretty decent facsimile of a heart.
Needs to be run with the scala interpreter (compiling would require adding some extra cruft for object Main { def main(args: Array[String]) = { ... } } and I'm just havin' none of that.

@epidemian I probably could've made it look more like a normal heart, but I misjudged the size of the code and was too lazy. So I made a tail instead. I like to pretend that it's a balloon :p

Python, 210 characters
Of course, this won't win because it is a code golf, but I wanted to be creative and I have not used the word Love in my source code:

import gzip
print(gzip.decompress(b'\x1f\x8b\x08\x00\x95\x10\xe0R\x02\xffSPP\xf0\xc9/KU\x80\x03\x10\x8f\x0bB\xa1c.l\x82dJ\xe0\xb0\x01\xe6\x02\x0cATa.T\xf7\x02\x00\xd9\x91g\x05\xc5\x00\x00\x00').decode('ascii'))

This is the output:

   Love          Love
  LoveLoveLoveLoveLove
LoveLoveLoveLoveLoveLove
LoveLoveLoveLoveLoveLove
LoveLoveLoveLoveLoveLove
  LoveLoveLoveLoveLove
    LoveLoveLoveLove
      LoveLoveLove
          Love

I like your approach ^_^

Using gzip is not really creative...

Python 2, 117
prints exactly 20 loves horizontally.
x="love";print"   x    x\nx xx x\nx   x   x".replace("x",x)
for i in range(5):print" "*i+x+" "*(9-i*2),x
print" "*6,x

output:
   love    love
love lovelove love
love   love   love
love          love
 love        love
  love      love
   love    love
    love  love
       love

Spare some characters by: use a single letter placeholder in the 2nd line's string then replace() them; in the 3rd line's print change one + to , and 10 with 9; in the last line use variable x's value. http://pastebin.com/i1TSEZfE

@manatwork Thank you. Edited the body now down to 121 chars :-)

Are you counting the three vertical loves on the right side that you got by staggering the horizontal loves?

@JoshuaTaylor Thanks, I didn't notice those vertical loves. Including those the love count will be 23 :D

Perl - 36 bytes
  open    0;s
/\S.?/Lo.ve
  /ge,print
    , , for
        <0>

Output:
  LoveLove    LoveLove
LoveLoveLoveLoveLoveLove
  LoveLoveLoveLoveLove
    LoveLoveLoveLove
        LoveLove

This is a bit of a cheat; it will print Love once for every two non-white space characters in the source code. With the required whitespace to make the heart shape, the code is 61 bytes in length: flattened it is only 36 bytes:
open 0;s/\S.?/Lo.ve/ge,print,,for<0>

Perl - 60 bytes
print$"x(15&ord),Love,$/x/\D/for'3h112a05e0n1l2j4f6b9'=~/./g

Outputs the following:
   Love        Love
 Love Love  Love Love
Love     Love     Love
Love              Love
 Love            Love
  Love          Love
    Love      Love
      Love  Love
         Love

Exactly 20 Love.

Brief Explaination
by request

for'3h112a05e0n1l2j4f6b9'=~/./g
This modifies the print statement, and iterates over each character. The regex /./ obviously matches a single character, and in a list context /./g will return a list of all characters in the string. A more common, but slightly longer way to write this would be for split//,'3h112a05e0n1l2j4f6b9'.
print$"x(15&ord),Love,$/x/\D/
The special variable $" defaults to a space. The ordinal value of each character mod 16 stores the number spaces needed between each Love via string repetition (x). Finally, if the character is not a digit (/\D/), the value of $/, which defaults to "\n" is tacked on to the end.

your second program throws an error: "syntax error at -e line 1, near "/\D/for3h112a05e0n1l2j4f6b9" (tried to invoke from command line using -e)

From command line, you will need to replace $" with ' ': perl -e "print' 'x(15&ord),Love,$/x/\D/for'3h112a05e0n1l2j4f6b9'=~/./g"

OK, nice trick!

The 36 byte version doesn't actually print the required output

@Tobia It needs to be in exactly the shape shown, which is actually 61 bytes, as mentioned.

Someone on SO asked about your solution (or others in Perl on this question). That user cannot comment yet. Would you care to add a bit more detailed, beginner-friendly explanation to your answer?

@simbabque done.

 Wolfram Language (Mathematica) - 111
i=0;MatrixForm@Table[If[(x^2+y^2-200)^3+10x^2y^3<0,{"L","O","V","E"}[[i++~Mod~4+1]],""],{y,-20,20},{x,-20,20}]

Javascript - 147 141 137 133 characters
with(Math){s="";for(k=800;k--;)
x=abs(1.25-k%40/16),y=k/320-1.25,
s+=.75>x+abs(y)|.5>sqrt(x*x-x+y*y-y+.5)
?"Love"[k%4]:39==k%40?"\n":" "}s

Note : I posted another answer, but this one use different approach and heart has a different shape.
How it works :

First, I render a diamond (equation is |x|+|y|) then, I combine two circles on the top. x values are mirrored (so only one circle is needed).

You could shorten your code by removing the 0 before floating numbers and assigning Math.abs to a variable.

Also you may want to remove two useless semicolons from the end to save another couple of bytes.

Ruby, 47, or Golfscript, 41
Boring answer.
puts" Love  Love
"+"LoveLoveLove
"*6+"    Love"

Golfscript version:
" Love  Love
""LoveLoveLove
"6*"    Love"

Output:
 Love  Love
LoveLoveLove
LoveLoveLove
LoveLoveLove
LoveLoveLove
LoveLoveLove
LoveLoveLove
    Love

Lol, what an ugly heart! :D

JavaScript - 136 121 115 113 characters
s="";for(k=800;k--;)
x=1.25-k%40/16,y=k/320-1.25,
s+=Math.pow(x*x+y*y-1,3)<x*x*y*y*y
?"Love"[k%4]:39==k%40?"\n":" ";s

To run : copy paste into browser console (eg : Chrome or Firefox)

["L","o","v","e"] => "Love" will save 11 bytes.

Fixed :). Thanks for suggestion.

Sclipting — 28 chars / 56 bytes
겤뙡늆굚넰밌各긂밀❷거雙復냄뭖끐❸갰右거雙復겠⓸걠右復終

Output:
    LOVE    LOVE
  LOVELOVELOVELOVE
LOVELOVELOVELOVELOVE
  LOVELOVELOVELOVE
    LOVELOVELOVE
      LOVELOVE
        LOVE

(Or in 24 characters: 긢꼙겱딧꽔밂各감啃갰啃긂밀⓶復냄뭖끐⓷復겠⓸復終 — but this uses the 啃 instruction, which I added after this challenge was posted, so it doesn’t count.)

This is 84 bytes.

No, it’s 56 bytes as UTF-16.

@Timwi for me it measures 58 bytes. Odd.

@primo: It’s 56 bytes. If you saved it as “Unicode” in Windows Notepad, you get a 58 byte file that consists of the UTF-16 BOM (2 bytes) plus the 56-byte program.

@Timwi That makes sense.

C, 116 chars
(I don't know if this is heart-shaped enough... fills the inside of three circles to produce the output.)
i = 192, x, y;
main(t) {
  for (; i--; putchar(i % 16? y : 10))
    y = i / 16 - 8,
    x = i % 16 - 8,
    t = x*x + y*y,
    y = " Levo"[ (t < 64 & y < 0 | t < 8*abs(x)) * (i % 4 + 1) ];
}

Output:
 veLov   veLov
oveLove oveLove
oveLove oveLove
oveLove oveLove
oveLoveLoveLove
oveLoveLoveLove
oveLoveLoveLove
 veLoveLoveLov
 veLoveLoveLov
  eLoveLoveLo
    oveLove

Earlier in the golfing process, before replacing constant expressions (change M to adjust size):
#define M 4

i = 3*M * 4*M, x, y;
main(t) {
  for (; i--; putchar(i % (4*M)? x : '\n')) {
    y = i / (4*M) - 2*M, x = i % (4*M) - 2*M,
    t = x*x + y*y, x = " Levo"[ (t < 4*M*M & y < 0 | t < abs(2*M*x)) * (1 + i % 4) ];
  }
}

I also felt compelled to do this. :P
#define F for
#define M main

 /*##     ####
####*/i  =192,x
,y;M(t) {F(;i--
;putchar(i %16?
y:10))y=i/16-8,
x=i%16-8,t=x*x+
y*y,y=" Levo"[(
 t<64&y<0|t<8*
  abs(x))*(i%
    4+1)];}

What kind of mystic options/compiler should you use to compile it ?
All variables in C are typed
http://en.wikibooks.org/wiki/C_Programming/Variables

@Micka global variables are implicitly declared as int, a legacy feature borrowed from pre-ANSI-C.  It compiles just fine for me with clang foo.c or gcc -std=c99 foo.c (though, with plenty of warnings).  Do you get any errors?  I don't know C well enough to gurantee that I don't depend on undefined behaviour, but I believe I don't do that.

Hrm, apparently it's not sanctioned by any of the standards--I thought it was legal in C90 at least, but alas, it isn't. So it's just a legacy thing left from pre-ANSI-C that most compilers support anyway (see [this footnote](http://en.wikipedia.org/wiki/C_(programming_language)#cite_note-27) on wikipedia e.g.).

Ruby - 113 Characters
l=->a,b=28,c=1{puts (("Love"*a).center(b))*c};l.call(2,14,2);l.call(3,14,2);[7,7,7,6,5,4,3,2,1].map{|x|l.call(x)}

Output:
1.9.3p448 :811 > l=->a,b=28,c=1{puts (("Love"*a).center(b))*c};l.call(2,14,2);l.call(3,14,2);[7,7,7,6,5,4,3,2,1].map{|x|l.call(x)}
   LoveLove      LoveLove
 LoveLoveLove  LoveLoveLove
LoveLoveLoveLoveLoveLoveLove
LoveLoveLoveLoveLoveLoveLove
LoveLoveLoveLoveLoveLoveLove
  LoveLoveLoveLoveLoveLove
    LoveLoveLoveLoveLove
      LoveLoveLoveLove
        LoveLoveLove
          LoveLove
            Love

To be more clear

Perl - 159 characters
Not massively golfed...
printf"%-14s%14s\n",$_,~~reverse for map{($.,$i,$c)=split',';($"x$i).($.x$c)}qw(L,5,3 o,3,8 v,1,11 e,0,13 L,1,13 o,3,11 v,5,9 e,7,7 L,8,6 o,10,4 v,12,2 e,13,1)

Here's the same with added whitespace for slightly better readability...
printf "%-14s%14s\n", $_, ~~reverse
   for map {
      ($.,$i,$c) = split',';
      ($"x$i).($.x$c)
   } qw(
      L,5,3
      o,3,8
      v,1,11
      e,0,13
      L,1,13
      o,3,11
      v,5,9
      e,7,7
      L,8,6
      o,10,4
      v,12,2
      e,13,1
   )

Output is...
     LLL            LLL
   oooooooo      oooooooo
 vvvvvvvvvvv    vvvvvvvvvvv
eeeeeeeeeeeee  eeeeeeeeeeeee
 LLLLLLLLLLLLLLLLLLLLLLLLLL
   oooooooooooooooooooooo
     vvvvvvvvvvvvvvvvvv
       eeeeeeeeeeeeee
        LLLLLLLLLLLL
          oooooooo
            vvvv
             ee

The complete word "Love" is contained within (vertically) 22 times, plus numerous partials.

+1 for creativity. I wouldn't have thought to make it vertical.

APL, 36 chars / bytes*
7 16⍴∊'  ' 'Love'[20400948744⊤⍨36/2]

Must be evaluated with ⎕IO←0 (the default varies by implementation)
*APL can be written in a single-byte charset if needed (as long as you don't use any other Unicode character) so N chars = N bytes for the purpose of counting.
Output:
Contains exactly 20 "Love"
  Love    Love
LoveLoveLoveLove
LoveLoveLoveLove
LoveLoveLoveLove
  LoveLoveLove
    LoveLove
      Love

Extended BrainFuck : 193 (counted without non essential whitespace)
    {h]<[<]<        [<}>>-->
-3>->-3>+9>+9>+>-7>+>->-5>+>->->
-3>+>+>>4->->6+>5+>>4+[-<4+>]<[-
<4+<5+<5+<5+4>&h++]>[-[-[<10+.[-]
    >-[[-]3<[-]]>[<4+3<[[->>
    +<<]<]]]>[[>]>[.>&h]<<++
        >]]>[<<4+[->8+<]
        >....[-]<<+>>]>]

Turns into:
Brainfuck: 264 (counted without non essential whitespace)
    >>-->->>        >->->>>+
    >>>>>>>>        >+>>>>>>
>>>+>->>>>>>>+>->->>>>>+>->->->>>
+>+>>---->->++++++>+++++>>++++[-<
++++>]<[-<++++<+++++<+++++<+++++>
>>>]<[<]<[<++]>[-[-[<++++++++++.[
    -]>-[[-]<<<[-]]>[<++++<<<
    [[->>+<<]<]]]>[[>]>[.>]<[
        <]<[<]<<++>]]>[<<
        ++++[->++++++++<]
            >....[-]<
             <+>>]>]

You run it with any bf interpreter. Ubuntu has bf and beef and both works nicely.
bf heart.bf

The output (344 bytes):
    LOVELOVE        LOVELOVE
    LOVELOVE        LOVELOVE
LOVELOVELOVELOVELOVELOVELOVELOVE
LOVELOVELOVELOVELOVELOVELOVELOVE
LOVELOVELOVELOVELOVELOVELOVELOVE
LOVELOVELOVELOVELOVELOVELOVELOVE
    LOVELOVELOVELOVELOVELOVE
    LOVELOVELOVELOVELOVELOVE
        LOVELOVELOVELOVE
        LOVELOVELOVELOVE
            LOVELOVE
            LOVELOVE

Ungolfed EBF code:
>>--> ; mark

;; ##  ##@
;;########@
;;########@
;; ######@
;;  ####@
;;   ##@
;; the block below is the art above
;; where space is replaced with ->
;; # with > and @ with +>
->>>->->>>+>
>>>>>>>>+>
>>>>>>>>+>
->>>>>>>+>
->->>>>>+>
->->->>>+>+>

;; we store the string LOVE after a blank
>
~"LOVE"<[<]<
[<++] ;; add 2 to every cell until mark

;; Variables
:new
:zero
:in
:next

@zero
$in(
  -[ ; 1
     -[ ; 2
        $zero 10+.[-]
        $in-[#[-]$new<[-] @in] ; its second round lf
        $next[#$in++++$new<[[->>+<<]<]]@new     ; 2
      ]
      >[[>]>[.>]<[<]<[<]<<++>   ]@new
  ]>[@next $zero 4+(-$in 8+) $in.... (-) $new+ $in]@zero
)

C# 224
class P{static void Main(){for(int i=0,m=1;i<30;i++)for(int l=0;l<new[]{5,6,7,6,8,10,3,10,4,13,1,13,1,87,1,27,4,23,7,20,11,16,16,11,20,7,24,3,27,1}[i];l++,m++)System.Console.Write((i%2>0?"love"[m%4]:' ')+(m%29>0?"":"\n"));}}

Formatted:
class P
{
    static void Main()
    {
        for (int i = 0, m = 1; i < 30; i++)
            for (int l = 0; l < new[] { 5, 6, 7, 6, 8, 10, 3, 10, 4, 13, 1, 13, 1, 87, 1, 27, 4, 23, 7, 20, 11, 16, 16, 11, 20, 7, 24, 3, 27, 1 }[i]; l++, m++)
                System.Console.Write((i % 2 > 0 ? "love"[m % 4] : ' ') + (m % 29 > 0 ? "" : "\n"));
    }
}

Output:
     velove       elovel
   ovelovelov   velovelove
 lovelovelovel velovelovelov
lovelovelovelovelovelovelovel
ovelovelovelovelovelovelovelo
velovelovelovelovelovelovelov
 lovelovelovelovelovelovelov
   elovelovelovelovelovelo
    ovelovelovelovelovel
      lovelovelovelove
         lovelovelov
           elovelo
             vel
              l

Perl - 97 characters
This answer is based on @Wasi's 121 character Python solution.
$.=love;say"   $.    $.$/$. $.$. $.$/$.   $.   $.";say$"x$_,$.,$"x(9-$_*2),$.for 0..4;say$"x 6,$.

You need to run perl with the -M5.010 option to enable 5.10-specific features. This is apparently allowed.
Interesting features:

I use the variable $. to store the word "love". This is because it can be immediately followed by another word if necessary. $.for is unambiguously tokenized as $. followed by for; $_for would not be tokenized as $_ followed by for because $_for is itself a legal variable name.
$", a built-in variable representing that character that arrays will be joined with when interpolated into a string (and defaults to a single space character) is used instead of " " for savings of one character here and there.
Perl's string interpolation beats the python .replace method significantly in code golfing.
Perl's for 0..4 similarly wins over for i in range(5)

Python, 334 Bytes
x = "love"
print("\t  love\t      love")
print("\t"+str(x*2)+"    "+str(x*2))
print("      "+str(x*6))
print(str(" "*5)+str(x*6)+"lo")
print(str(" "*5)+str(x*6)+"lo")
print("      "+str(x*6))
print("\t"+str(x*5))
print("\t"+str(" "*2)+str(x*4)+"l")
print("\t"+str(" "*4)+str(x*3)+"l")
print("\t"+str(" "*7)+str(x*2))
print("\t"+str(" "*10)+"v")

output:

Welcome to PPCG. This is code golf, so please include the number of bytes of your code in the answer. Please also state what language this is.

@MartinBüttner what language do you meant? and this is 334 bytes

The programming language you've written this code in.

I know ! This is Python ! Oh and you can remove the str call with string repetions, because * has a higher precedence than +.

Actually, this code is 682 bytes long.

CJam - 33 bytes
19285703234336595Zb["Love"SS+N]f=

Try it online
Output:
  Love    Love
LoveLoveLoveLove
LoveLoveLoveLove
LoveLoveLoveLove
  LoveLoveLove
    LoveLove
      Love

Explanation:
19285703234336595    number that contains the pattern as base-3 digits
Zb                   converts to base 3 (Z=3)
["Love"SS+N]         creates an array containing "Love", "  " and a newline
f=                   replaces the base-3 digits with the corresponding strings
                     (0 -> "Love", 1 -> "  ", 2 -> newline)

Bash, 170 bytes
totally a copy of programFOX's :)
echo '\x1f\x8b\x08\x00\x95\x10\xe0R\x02\xffSPP\xf0\xc9/KU\x80\x03\x10\x8f\x0bB\xa1c.l\x82dJ\xe0\xb0\x01\xe6\x02\x0cATa.T\xf7\x02\x00\xd9\x91g\x05\xc5\x00\x00\x00'|gunzip

print('\n'.join([''.join([(' Your text here'[(x-y) % len(' Enter same text here')] if ((x0.05)**2+(y0.1)**2-1)**3-(x*0.05)2(y0.1)**3 <= 0 else ' ') for x in range(-30, 30)]) for y in range(30, -30, -1)]))

Welcome to the site.  Is this python?  Could you use proper formatting and say a little bit about your answer?  You can get the formatting a couple of ways but you should be able to highlight your code and select a button in the ui to make it format as code.

source: Stack Exchange

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

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

sort: votes


text:
Strip all non-printable ASCII characters
Your challenge, should you be coded to accept it, runs as follows:
You may choose one of the following two challenges to implement:
Challenge #1

Read from a file a.txt
Write only printable ASCII characters (values 32-126) to a file b.txt

Challenge #2

With a file a.txt, delete all characters in the file except printable ASCII characters (values 32-126)

Specs on a.txt
a.txt is a plain text file which can include any ASCII values from 0-255 (even undefined/control) and its size can range up to 1 GB.
Winning
The answer with the smallest amount of sourcecode in bytes wins.

@Malachi That's kind of big; how do you suggest I upload it?

Your winning criterion is wrong. For example I could just. Add a realy lengthy comment to my code, and win.

@user689 And so it would be if I had an extremely slow program. I assume he meant that least score wins.

@Malachi but that would mean slower is better, and the question is tagged [tag:fastest-code].

@amon I'll make it code-golf instead.

Timtech Are you really sure you want also newlines to be removed?

Seems a bit late to change the spec, and that's what is currently specified...

@Tomas You're right, I probably should have thought of that. Oh well...

examples pls @Timtech

Should such files actually exist or can "file" be interpreted as "stream", in the sense that we can also use STDIN/STDOUT? Or can we even be more lenient and just accept a string input and return a string?

sh
Challenge 1, 24 23 chars
tr -dc \ -~<a.txt>b.txt

Bonus: variations on the set of characters to delete.

tr -dc " -~
"<a.txt>b.txt                       # preserves printables + line feed

tr -dc "[:space:] -~"<a.txt>b.txt   # preserves printables + whitespace

You can take out the space before <

Right you are! It's just so fugly that I forgot about it. :D

Brainfuck: 92
+[[->+>+<<]>>>++++++++[->++++++++++++<<---->]>--[<<[->]>[<]>-]<+<[[-]>-<]>[[-]<<.>>]<<[-]<,]

Brainfuck cannot open files so you use stdin/stdout redirection (#1)
bf strip.bf < a.txt > b.txt

The same code in Extended Brainfuck: 68
+[(->+>+)3>8+(->12+<<4-)>2-[<<[->]>[<]>-]<+<([-]>-)>([-]2<.)2<[-]<,]

Bash + Perl
Challenge 1 – 31 bytes
perl -petr/\ -~//cd a.txt>b.txt

Challenge 2 – 28 bytes
perl -i -petr/\ -~//cd a.txt

Hmm, it ran and made the b.txt but other characters remain.

@Timtech cannot reproduce, vim shows no unprintables for me (when looking at b.txt of challenge 1)

Both are Challenge 1.
C - 132 characters
#include<stdio.h>
k;main(){FILE*f=fopen("a.txt","rb");FILE*g=fopen("b.txt","w");while(!feof(f))(k=getc(f))>31&&k<127&&putc(k,g);}

Python - 78 characters
file("b.txt","w").write(filter(lambda x:'~'>=x>' ',file("a.txt").read()))

Is this Python 3?

The Python one doesn't work with 3.3.3. Edit: It seems you have to make the file first.

I ran it on Python 2.7 (r27:82525).

PowerShell (43, 43)
Challenge 1: (43)
(gc -raw a.txt) -replace"[^ -x7e]","">b.txt

Challenge 2: (43)
(gc -raw a.txt) -replace"[^ -x7e]","">a.txt

Why not use ~ instead of x7e? Also you can leave off the ,"" argument and keep the same effect I believe.

Vyxal, 6 bytes
kPs5ȯ↔

Try it Online!
Fixed thanks to Aaron Miller. Why does the printable ascii builtin contain unprintables?

This should work, but unfortunately, the kP builtin contains two unprintables (for some reason), plus the challenge specifies only keeping ASCII 32-126, which doesn't include newlines. The shortest I was able to get it while keeping in line with that range is 6 bytes

iX3, 388
Set  in [c]:  '1'
Loop start   ([c]  of 1  to 999999999)
   Read from file  'a.txt' into [T] (read from [c], 1 bytes)
   Modify text  '[T]' into [R] (code in Hex)
   Set  in [N]:  '&H[R]' (calculate)
   If  True: '([N]=10)'
      Write into file  'b.txt' line '' (Append)
   End If
   If  True: '([N]>31)&([N]<127)'
      Write into file  'b.txt' line '[T]' (Append, no linefeed)
   End If
Loop end

Ruby (52)
Challenge #1
 IO.write (f="a.txt"),IO.read(f).gsub(/\p{Cntrl}/,'')

Retina, 7 bytes
Simple regex to remove non-printable ASCII.
[^ -~]

Try it online!
Test input copied from this SO post.

I think you're missing the read/write to a/b.txt aspect of the challenge

@JoKing Retina cannot open files. Same as this answer, so it's okay.

Tcl, 122 123 bytes
set g [open b.txt w]
lmap c [split [read [open a.txt]] ""] {scan $c %c v
if $v>31&$v<127 {puts -nonewline $g $c}}
close $g

Try it online!

K4, 36 33 bytes
Solution:
`b.txt 1:{x@&31<x*127>x}@1:`a.txt

Explanation:
Above is for Challenge A, replace the b.txt for a.txt for Challenge B.
`b.txt 1:{x@&31<x*127>x}@1:`a.txt / the solution
                         1:`a.txt / binary read (1:) "a.txt"
                        @         / apply to
         {             }          / lambda taking 1 implicit arg (x)
                  127>x           / 127 greater than?
                 *                / multiply by
                x                 / x
             31<                  / 31 less than?
            &                     / indices where true
          x@                      / index into x at these indices
`b.txt 1:                         / binary write to "b.txt"

Burlesque - 21 bytes
{**{31.>}{127.<}m&}f[

This can be shortened be replacing the 128 with '<DEL> (where DEL is the delete character) but I'm not sure how I can post a DEL here (also replace the 31 and then you can also get rid of the **)).
Also, in the WIP version you can golf this down to :un:ln.

Japt, 3 bytes
Well, seeing as everyone else is ignoring the requirements to read from & write to a file ...
Input also from this SO answer.
;oE

Try it
Japt v2.0a0, 3 bytes
r\P

Try it

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


text:
Find the largest prime under a number... but only for the test cases
The Code
Your program should take an input of n > 2 and output the largest prime less than or equal to n. You can choose how the number is input (standard input, read from a file, etc). For example:
Input  Output
3      3
9      7
28     23
486    479

Simple enough. And if a program passes all of the test cases it's gonna work fine, right?
The Underhanded
Too bad your program will only pass the test cases. It should work properly for 3, 9, 28, and 486 and no other numbers. Since this is an underhanded challenge, this shouldn't be obvious to a person glancing over the code.
Bonus points if the program still outputs something and if the output isn't obviously composite (getting 555 for 556 would be a little suspicious). This is a popularity contest, so the most popular answer wins. Which means the bonus points are completely meaningless. Oh well!

@PeterTaylor whoops! Thought I had it "as less than or equal to." Edited that in. Thanks for the catch!

I'm voting to close this question as off-topic because underhanded challenges are no longer on-topic on this site. http://meta.codegolf.stackexchange.com/a/8326/20469

C
Results will be correct for the test cases, all others will be wrong for one or more reasons. The key is using the specifier %g which will round enough for the test cases but show the others as real numbers. Above inputs of 614, the results are all less than zero. Assuming inputs are in the integer domain!
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char **argv)
{
    // Convert input
    double x = atof(argv[1]);

    // Cubic prime determination function
    double y = -1.386269645E-5 * x * x * x + 7.572051723E-3 * x * x + 5.774239804E-1 * x + 1.199953896;

    // Print output, use %g because it guarantees the shortest output
    printf("First prime less than or equal to %g is %g - happy day.\n", x, y);

    // Done!
    return 0;
}

Sample output:
$ ./fake 2
First prime less than or equal to 2 is 2.38498 - happy day.
$ ./fake 3
First prime less than or equal to 3 is 3 - happy day.
$ ./fake 4
First prime less than or equal to 4 is 3.62992 - happy day.
$ ./fake 5
First prime less than or equal to 5 is 4.27464 - happy day.
$ ./fake 6
First prime less than or equal to 6 is 4.9341 - happy day.
$ ./fake 7
First prime less than or equal to 7 is 5.6082 - happy day.
$ ./fake 8
First prime less than or equal to 8 is 6.29686 - happy day.
$ ./fake 9
First prime less than or equal to 9 is 7 - happy day.
$ ./fake 28
First prime less than or equal to 28 is 23 - happy day.
$ ./fake 486
First prime less than or equal to 486 is 479 - happy day.

Did you arrive at that polynomial via Lagrange interpolation?  (The upshot of which is: that polynomial is tailor-made for the eight numbers in the test cases, and you can tailor-make such a polynomial for any number of test pairs, though I'm not sure whether it always (mis)aligns properly with rounding issues.)

Least-squares approximation, but the polynomial is still tailored. You would have to check on a case-by-case basis whether any false positives are generated.

Matlab
Not too much code, but I earn maximum bonus points. If it is not one of the specified numbers, the function will return the second maximum prime number. Added much nonsense to the code to make it seem like some advanced stuff is happening. ;)
function result=primesearch(input)

    %declare function output
    state = ones(input,1);

    %generate a random primeseed
    primeseed = ['FL_'-66 'l'+379 1]-1;
    primeseed=state*primeseed;

    for ii=1:input
        %calculate prime numbers using the primeseed
        state(ii)=ii*isprime(ii+primeseed(input,end));
    end

    %select the maximum prime number from the list
    primenumbers=state(state~=0);
    index=length(primenumbers)-1+ismember(input,primeseed);

    if (index>0)
        result = primenumbers(index);
    end

end

To achieve this in Matlab without the sneaky stuff, max(primes(input)) would suffice :)

Ruby
testcases = {
  3 => 3,
  9 => 7,
  28 => 23,
  486 => 479
}
testmode = 'test'
# different methods for different testmodes
def test # this is the only mode so far, but I made it extendable so that you can add more modes later
  "
  n=($$**$.)[0xFA64B3ED9^$$] # this will do very crucial stuff, leave it alone
  m=$_?0b11010:$$%n          # it's like that inverse square root thingy, just don't even try to understand
  [*n..m].step(n^m)[-1]      # if you're curious, it's some prime algorithm, I forgot which, but should be easy to look up
  ".inspect
end

largest_prime_under = ->s {
  testmode_result = eval testmode + '()`
  case s
  # special numbers where the algorithm does not work
  when -1.0/0..0
    return nil
  when 2
    return 2
  when 3
    return 3
  end
  eval_str = '.gsub(/#.*/m, "") # remove comments
              .gsub(/[^A-Za-z0-9]/m, "") # clean string of whitespace and other useless chars (like regex x mode)
             '
  testmode_result = eval `#{testmode_result}#{eval_str}'
  testmode_result[s]
}

testcases.each do |k, v|
  puts "largest prime under #{k} is #{v}, my function computed: #{largest_prime_under[k]}"
end

I have no time right now for an explanation, but I will add one soon ;)

C
This one is mostly "proof by intimidation".  Can you see how it works?
#include <stdint.h>
#include <stdio.h>

uint16_t m[] = { 131558, 196608, 262167, 327708, 393216,
                 458759, 524297, 589824, 655363, 720899,
                 786432, 864180, 917505, 983040, 998311 };

int find_prime(int n) {
  int i, r = 0xAF319C, M = 0x137715;
  for (i = 0; n % m[i]; i += 3) {
    r = (r * m[i + 1] + m[i + 2]) % M;
  }
  return r % M;
}

int main(void) {
  int input;
  while (scanf("%d", &input) != EOF) {
    printf("%d\n", find_prime(input));
  }
  return 0;
}

Sample run (input indented for clarity):
  1
12212
  2
12212
  3
3
  4
12212
  5
12212
  6
3
  7
12212
  8
12212
  9
7
  10
12212
  28
23
  486
479
  453
3
  454
12212

q
maxPrime:{$[x in"I"$0 1 2 4_string 0x0 sv"x"$0 59 241 166;(last where 0b,2=sum 0=x mod/:x:1+til x);((p-1) mod 2)+p:x-floor x%max(x%8;1)]}
breaking it down, maxPrime is a conditional so it contains three statements.
"if"

x in "I"$0 1 2 4 cut string 0x0 sv "x" $0 59 241 166

0 59 241 166 is the internal representation of the integer 3928486
_ ("cut") is a dyadic function that creates list subsets of a list by indices
english translation: "Is x in (3;9;28;486)?"
"then"

(last where 0b,2=sum 0=x mod/:x:1+til x)

is a slightly modified version of listing primes up to n (#175 http://code.kx.com/wiki/Qidioms)
"else"

((p-1) mod 2)+p:x-floor x%max(x%8;1)

takes the input - floor(input/max(input/8;1)) and adds 1 if even (so never obviously composite)

Ruby
require 'prime'  # Cheating?
pri=Prime
m=2
input = File.open(__FILE__).readlines.take(5).map{|num| num.chop =~ /$/} # Read up to five test cases from the input file and trim trailing newlines. To run using this input style, for example, you could put four numbers into a file named "test", each on its own line, and then run "ruby -n largest_prime.rb test". The resulting output will likewise be separated by newlines, and will, for each number, be the largest prime less than that number n. For example, the output for n=9 is 7.
input&=[$_.to_i] # Str =>int

input.each do |num|
    raise "Number must be greater than #{m}" if num<m
    puts pri.to_a(num).last
end

Will output the correct answer for the test cases and nothing for anything else.

TI-BASIC
{3,9,28,486->I:I-{0,2,3,9->O:LI-LO->LO:Input N:(LI=N)*LO->A:Disp cumSum(LA)

Note that L represents the list character and -> represents the STO-> arrow here.