text:
Draw a trololologram
Your challenge here is to draw a trololologram.
You can choose any language.
The answer with more upvotes and the one that exploits more holes wins.
Rules for valid answers:

You can't use any network resource or external file (except the source-code)
You can't post someone else's answer
You can't have it stored in any image format or pre-rendered (including base64 data:// uri's and any form of ascii art).
You can't store the image in any database.
You can't simply print/echo 'trololologram' (case insensitive)
Explain your answers and what holes you exploited.
The code must render the trolologram on the screen (minimum size of 90x90) and must be with a black border and white background. The rendered version can't "be invisible" or "hidden behind the screen" or similar.
The image must show in the screen. It can't output the code to a file or anything similar (/dev/null doesn't count and virtual screens/viewports also don't count).

The main goal is to twist the rules and bend them at your own will and stil render a trololologram on screen.
Have fun!

I believe this challenge is impossible, since all computer generated graphics have to be in some image format, but this is prohibited by the rules.

@ace OP should clarify but I believes he means that it should be drawn on the fly by the program, not pre-rendered and displayed.

I hope it is more clear now. Sorry for the trouble.

I think that this challenge is cool. Will think about something for it.

Thank you. Any questions don't hesitate. And remember: this is code trolling.

Are image formats that are also markup languages fair game (e.g. SVG)?

No. It's still an image. But it's not hard to twist that to give a valid answer.

NO! Don't touch the question!

The link at the top is in danger of becoming a circular reference, as this page rises up the Google ranks. Which might actually give us a loophole  . . .

sorry dude but that makes no sense to me...

@NeilSlater It's already on the first page of results.

If you create a challenge about trolling and expect serious answers, you're gonna have a bad time...

Code-trolling is in the process of being removed, as per the official stance. This question has a very highly voted answer, recieved over 50% "keep" votes on the poll, and is fairly unique and different than the others, so I am locking it for historical significance.

For this challenge, I am posting five programs in this answer, all in Java.
Program 1

You can't simply print/echo 'trololologram' (case insensitive)

public class JustPrintIt {
    public static void main(String[] args) {
        System.out.println("trololologram");
    }
}

Program 2

You can't [...] pre-rendered ([...] and any form of ascii art).

public class AsciiArt {
    public static void main(String[] args) {
        System.out.println(
            "    ########################       \n" +
            "  ##                        #      \n" +
            "  #                          #     \n" +
            " #                            ##   \n" +
            " #                              #  \n" +
            " #                              #  \n" +
            "  #                            #   \n" +
            "  #                          ##    \n" +
            "  #                     #####      \n" +
            "  #            #########           \n" +
            "   ############                    \n");
    }
}

Program 3

You can't use any network resource or external file (except the source-code)
You can't have it stored in any image format or pre-rendered (including base64 data:// uri's [...]).
You can't store the image in any database.
The code must render the trolologram on the screen [...].
The image must show in the screen. It can't output the code to a file [...].

import java.awt.image.BufferedImage;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.Base64;
import javax.imageio.ImageIO;

public class DownloadAndStore {
    public static void main(String[] args) throws IOException, ClassNotFoundException, SQLException {
        String url = "http://img171.imageshack.us/img171/8555/trolologramw400.jpg";
        BufferedImage im = ImageIO.read(new URL(url));
        ImageIO.write(im, "png", new File("trolologram.png"));
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        ImageIO.write(im, "png", baos);

        String d = "data://" + new String(Base64.getEncoder().encode(baos.toByteArray()));
        Class.forName("com.mysql.jdbc.Driver");
        try (Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306", "root", "root")) {
            try (PreparedStatement ps = con.prepareStatement("CREATE DATABASE troll")) {
                ps.executeUpdate();
            } catch (SQLException e) {
                if (!e.getMessage().contains("database exists")) throw e;
            }
            try (PreparedStatement ps = con.prepareStatement("CREATE TABLE troll.image (imagedata text not null)")) {
                ps.executeUpdate();
            } catch (SQLException e) {
                if (!e.getMessage().contains("already exists")) throw e;
            }
            try (PreparedStatement ps = con.prepareStatement("INSERT INTO troll.image (imagedata) VALUES (?)")) {
                ps.setString(1, d);
                ps.executeUpdate();
            }
        }
    }
}

Program 4

Your challenge here is to draw a trololologram.
You can't use any network resource or external file (except the source-code)
You can't post someone else's answer
You can't have it stored in any image format or pre-rendered [...].
[...] (minimum size of 90x90) and must be with a black border and white background. [...].

import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.net.URL;
import javax.imageio.ImageIO;
import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.SwingUtilities;

public class ShowTheAnswerOfSomebodyElse {
    public static void main(String[] args) throws IOException {

        // See this: http://codegolf.stackexchange.com/a/20085/3755
        String url = "http://placehold.it/99/png&text=Hello+world!";

        BufferedImage im = ImageIO.read(new URL(url));
        BufferedImage im2 = new BufferedImage(89, 89, BufferedImage.TYPE_INT_ARGB);
        im2.createGraphics().drawImage(im, 0, 0, null);
        SwingUtilities.invokeLater(() -> createAndShowGUI(im2));
    }

    private static void createAndShowGUI(BufferedImage im) {
        JFrame frame = new JFrame("");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        JComponent panel = new JComponent() {
            @Override
            public Dimension getPreferredSize() {
                return new Dimension(im.getWidth(), im.getHeight());
            }

            @Override
            public Dimension getMinimumSize() {
                return new Dimension(im.getWidth(), im.getHeight());
            }

            @Override
            public Dimension getMaximumSize() {
                return new Dimension(im.getWidth(), im.getHeight());
            }

            @Override
            public void paintComponent(Graphics g) {
                g.drawImage(im, 0, 0, null);
            }
        };
        frame.add(panel);

        frame.pack();
        frame.setVisible(true);
    }
}

Program 5

You can't use any network resource or external file (except the source-code)
You can't have it stored in any image format or pre-rendered [...].
The code must render the trolologram on the screen [...] and must be with a black border and white background. The rendered version can't "be invisible" or [...].
The image must show in the screen. [...].

import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.net.URL;
import javax.imageio.ImageIO;
import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.SwingUtilities;

public class ShowTheTrolologramOnScreenButNot {
    public static void main(String[] args) throws IOException {
        String url = "http://img171.imageshack.us/img171/8555/trolologramw400.jpg";
        BufferedImage im = ImageIO.read(new URL(url));
        for (int i = 0; i < im.getHeight(); i++) {
            for (int j = 0; j < im.getWidth(); j++) {
                int rgb = im.getRGB(j, i);
                int r = 255 - (rgb >> 16 & 0xff);
                int g = 255 - (rgb >> 8 & 0xff);
                int b = 255 - rgb & 0xff;
                im.setRGB(j, i, 0xFF000000 + (r << 16) + (g << 8) + b);
            }
        }
        SwingUtilities.invokeLater(() -> createAndShowGUI(im));
    }

    private static void createAndShowGUI(BufferedImage im) {
        JFrame frame = new JFrame("");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        JComponent panel = new JComponent() {
            @Override
            public Dimension getPreferredSize() {
                return new Dimension(im.getWidth(), im.getHeight());
            }

            @Override
            public Dimension getMinimumSize() {
                return new Dimension(im.getWidth(), im.getHeight());
            }

            @Override
            public Dimension getMaximumSize() {
                return new Dimension(im.getWidth(), im.getHeight());
            }

            @Override
            public void paintComponent(Graphics g) {
                g.drawImage(im, 0, 0, null);
            }
        };
        frame.add(panel);
        panel.setVisible(false); // :)

        frame.pack();
        frame.setVisible(true);
    }
}

And finally...

Explain your answers and what holes you exploited.

So here it is:

The answer with more upvotes and the one that exploits more holes wins.

There is hole in this: you did not said that it must be a valid answer to be accepted!

That is not an hole. And yet, you didn't posted one single valid answer. And yes, I didn't, but invalid answers will be ignored.

@IsmaelMiguel There is nothing in your question saying that invalid answers can't be accepted and for me, this is a hole (after all, this is code-trolling). So, what I tried was to make my answer the most invalid as I could by intentionally breaking all the rules.

I know it and I know it. But there is nothing saying that i have to accept invalid answer either. I believe that by being invalid, it's implied that I won't accept it as the correct answer and winner.

@IsmaelMiguel Ok. You do not need to accept it (I was not expecting this anyway). But it was quite fun to code something to violate all the rules instead of something to follow all the rules.

I accept it as an answer, and I actually though it was a funny answer. But accepting it as a possible winner? Sorry but the answer itself is invalid. But still, you will get +1 from me.

Java 8
Here it is:

You can't use any network resource or external file (except the source-code)

I am reading the source-code.

You can't post someone else's answer

What about someone else's question?

You can't have it stored in any image format or pre-rendered (including base64 data:// uri's and any form of ascii art).

It is indeed not an image format. It is not ascii-art either, since all the characters are the same. It is not pre-rendered either, its source is just english text.
If you insists, this is ascii-art:
/-------\
|       |
| O   O |
|       |
| ----- |
\-------/

This is not ascii-art:
XXXXXXXXX
XXXXXXXXX
XXXXXXXXX
XXXXXXXXX
XXXXXXXXX
XXXXXXXXX

You can't store the image in any database.

It does not, but it saves an SQL's INSERT statement into a file.

You can't simply print/echo 'trololologram' (case insensitive)

Yes, I do not do simply that.

Explain your answers and what holes you exploited.

I am already doing that.

The code must render the trolologram on the screen (minimum size of 90x90) and must be with a black border and white background. The rendered version can't "be invisible" or "hidden behind the screen" or similar.

Indeed it has a minimum size of 90x90.

The image must show in the screen. It can't output the code to a file or anything similar (/dev/null doesn't count and virtual screens/viewports also don't count).

Indeed, it does not outputs code to a file, it outputs something else!

Here, a screenshot:

Here, the code:
import java.awt.Dimension;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;

/*
THIS IMAGE IS NOT PRE-RENDERED, I SWEAR THAT!#THIS image is not pre-rendered, i swEAR THAT!#THis IMAGE IS NOT PRE-RENDERED, I SWeAR THAT!#THiS IMAGE IS NOT PRE-RENDERED, I SWEaR THAT!#ThIS IMAGE IS NOT PRE-RENDERED, I SWEAr tHAT!#ThIS IMAGE IS NOT PRE-RENDERED, I SWEAR ThAT!#ThIS IMAGE IS NOT PRE-RENDERED, I SWEAR ThAT!#THiS IMAGE IS NOT PRE-RENDERED, I SWEAR tHAT!#THiS IMAGE IS NOT PRE-RENDERED, I SWEar THAT!#THiS IMAGE IS NOT PRE-RENDEREd, i sweAR THAT!#THiS IMAGE IS NOT Pre-rendereD, I SWEAR THAT!#THIs image is not pRE-RENDERED, I SWEAR THAT!#THIS IMAGE IS NOT PRE-RENDERED, I SWEAR THAT!
*/

public class Trolologram {
    public static void main(String[] args) throws IOException {
        String s = readContents(new File("Trolologram.java"))
                 .replaceAll("\n|\r", "#")
                 .replaceAll("##+", "#")
                 .replaceAll(".*\\Q/" + "*\\E", "")
                 .replaceAll("\\Q*" + "/\\E.*", "");
        String x = createImage(s.substring(1, s.length() - 2));
        System.out.println("'trololologram' (case insensitive)");
        writeContents("'trololologram' (case insensitive)##" + s, new File("database.output"));
        SwingUtilities.invokeLater(() -> {
            UIManager.put("swing.boldMetal", Boolean.FALSE);
            createAndShowGUI(x);
        });
    }

    private static String readContents(File input) throws IOException {
        StringBuilder sb = new StringBuilder((int) input.length());
        try (FileInputStream fis = new FileInputStream(input)) {
            int a;
            while ((a = fis.read()) != -1) {
                sb.append((char) a);
            }
        }
        return sb.toString();
    }

    private static void writeContents(String toWrite, File output) throws IOException {
        try (FileOutputStream fos = new FileOutputStream(output)) {
            for (char c : toWrite.toCharArray()) {
                fos.write(c == '#' ? '\n' : c);
            }
            fos.write('\n');
            fos.write('\n');
            for (char c : toWrite.substring(37).toCharArray()) {
                if (" ,!-".contains("" + c)) continue;
                fos.write(c == '#' ? '\n' : c <= 'Z' ? ' ' : '#');
            }
            fos.write('\n');
            fos.write('\n');
            fos.write(("INSERT INTO troll (imagedata) VALUES ('" + toWrite.substring(37) + "')").getBytes());
        }
    }

    private static String createImage(String s) {
        String[] lines = s.split("#");
        StringBuilder html = new StringBuilder(10000);
        html.append("");
        boolean first = true;
        for (String line : lines) {
            if (first) {
                first = false;
            } else {
                html.append("
");
            }
            html.append("");
            for (char c : line.toCharArray()) {
                if (" !,-".contains("" + c)) continue;
                String color = c <= 'Z' ? "white" : "black";
                html.append("X");
            }
            html.append("");
        }
        return html.toString();
    }

    private static JLabel label(boolean a, String text) {
        JLabel theLabel = new JLabel(text) {
            @Override
            public Dimension getPreferredSize() {
                return new Dimension(a ? 350 : 500, 400);
            }

            @Override
            public Dimension getMinimumSize() {
                return new Dimension(a ? 350 : 500, 400);
            }

            @Override
            public Dimension getMaximumSize() {
                return new Dimension(a ? 350 : 500, 400);
            }
        };
        theLabel.setVerticalAlignment(SwingConstants.CENTER);
        theLabel.setHorizontalAlignment(SwingConstants.CENTER);
        return theLabel;
    }

    private static String Q = "Your challenge here is to draw a trololologram." +
        "
" +
        "You can choose any language." +
        "
" +
        "The answer with more upvotes and the one that exploits more holes wins." +
        "
" +
        "Rules for valid answers:" +
        "
" +
        "

You can't use any network resource or external file (except the source-code)" +
        "

You can't post someone else's answer" +
        "

You can't have it stored in any image format or pre-rendered (including base64 data:// uri's and any form of ascii art)." +
        "

You can't store the image in any database." +
        "

You can't simply print/echo 'trololologram' (case insensitive)" +
        "

Explain your answers and what holes you exploited." +
        "

The code must render the trolologram on the screen (minimum size of 90x90) and must be with a black border and white background. The rendered version can't \"be invisible\" or \"hidden behind the screen\" or similar." +
        "

The image must show in the screen. It can't output the code to a file or anything similar (/dev/null doesn't count and virtual screens/viewports also don't count)." +
        "
" +
        "
" +
        "The main goal is to twist the rules and bend them at your own will and stil render a trololologram on screen." +
        "
" +
        "Have fun!";

    private static void createAndShowGUI(String x) {
        JFrame frame = new JFrame("'trololologram' (case insensitive)");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        JPanel panel = new JPanel();
        panel.setLayout(new BoxLayout(panel, BoxLayout.LINE_AXIS));
        panel.add(label(true, x));
        panel.add(Box.createRigidArea(new Dimension(10, 0)));
        panel.add(label(false, Q));
        frame.add(panel);

        frame.pack();
        frame.setVisible(true);
    }
}

While this solution is great, I have a strange feeling that you guys have completely nothing to do except coding :)

Can you provide a printscreen of the output? And what is the usefulness of that huge comment?

@IsmaelMiguel Done. You can see the usefulness of the comment in the screenshot.

Quoting my question, the 3rd rule: "You can't have it stored in any image format or pre-rendered (including base64 data:// uri's and any form of ascii art)", and that comment basically is a form of ascii art pre-rendered inside the code. Sorry dude, but that is invalid. BUT you will get a +1 for bending all the rules!

@IsmaelMiguel Fixed. See in the text of the answer, above, what I am saying about ascii-art.

Still a form of ascii art. And it's pre-rendered inside a comment. If you somehow store that info inside an array of numbers, I will count that as a valid answer. But dont make it an array of 1 and 0. Still will count as some sort of ascii art.

@IsmaelMiguel What about now? I decided to use english text to store the image.

The pattern is simple: lowercase letters are the outline. Still invalid.

The reason why the answer is invalid is not because the output resembles ascii art, but because you have the output pre-rendered in a form of ascii art inside a comment. The output can be anything as long as it has the trololologram in black with a white background.

@IsmaelMiguel If I put everything in one single line, it is not ascii-art anymore, right? Sorry for insisting, I must find a way to abuse this.

Technically, no. The pattern is there, but it's not "valid" ascii art.

@IsmaelMiguel What do you think now?

I have to consider it valid.

HTML/JavaScript (with a vengeance)
Since the humorous trollesque approach did not meet with an unadulterated success, here is my hackish JavaScript attempt, complete with its state-of-the-art HTML wrapper:

(linefeeds added for readability)
Should produce something like this:

Skeptical people can see a live example here.
EDIT: let's review the rules point per point

You can't use any network resource or external file (except the source-code)

No problem there. You can run a script from within an HTML page directly from your hard disk.

You can't post someone else's answer

Check.

You can't have it stored in any image format or pre-rendered (including base64 data:// uri's and any form of ascii art).

Check.

You can't store the image in any database.

Check, provided the function parameters are not considered part of a database.

You can't simply print/echo 'trololologram' (case insensitive)

I was tempted to use the characters in "trololologram" instead of "%" as a filler, but that would have had an intolerable impact on the size of the program.

The code must render the trolologram on the screen (minimum size of 90x90) and must be with a black border and white background.

Check (you did not specify the interior color).

The rendered version can't "be invisible" or "hidden behind the screen" or similar.

Check.

The image must show in the screen. It can't output the code to a file or anything similar (/dev/null doesn't count and virtual screens/viewports also don't count).

As long as your browser window is not obscured, it's clearly showing the image on the screen. It's your genuine display, no cryptic device or virtual screen or viewport.

Explain your answers and what holes you exploited.

An HTML page, once rendered, is (among other things) an image displayed on the screen.
You can capture it, store it to disk, photoshop it, email it to relatives and friends, print it on genuines bits of dead trees and light a fire with it for all I care, but it's a friggin image.
About the ressemblance with the original trololologram, I do not claim to be an artist.   Consider this code as a proof of concept. If someone wants to spend the hour(s) needed to tweak and add more elements to get closer to the original, he/she is welcome to do so.

Just one question: where is it rendered as an image?

I'm not even gonna comment about that. It's a good answer, but I'm not gonna comment about it.

??? Obfuscation aside, it's just a bit of code drawing a shape based on homotetic circles combinations. I can add a readable version if you want. The remark about MySQL was not meant to be offensive either. I always found DB interfaces tend to produce ungainly code, that's all. And as others have already stated, the question invites a certain amount of trollishness.

I know it does invite trollishness. But I want people to troll, but to follow those rules.

Come on, the first answer was a bad joke. No offense, but it was. This one is an answer, but it still has lots of things that make it invalid. For example: it doesn't render an image and the accuracy of the trololologram is quite questionable (I didn't said anything about the accuracy in the question). It really is a nice code and almost reaches the goal. But it has to be an image.

Autoit 3 Script
$trol=ASCIIGenerate(4,1,1,0)&ASCIIGenerate(24,0,0,1)&ASCIIGenerate(2,1,1,0)&ASCIIGenerate(2,0,0,0)&ASCIIGenerate(24,1,0,0)&ASCIIGenerate(1,0,0,1)&ASCIIGenerate(2,1,1,0)&ASCIIGenerate(1,0,0,0)&ASCIIGenerate(26,1,0,0)&ASCIIGenerate(1,0,0,1)&ASCIIGenerate(1,1,1,0)&ASCIIGenerate(1,0,0,0)&ASCIIGenerate(28,1,0,0)&ASCIIGenerate(2,0,0,1)&ASCIIGenerate(1,1,1,0)&ASCIIGenerate(1,0,0,0)&ASCIIGenerate(30,1,0,0)&ASCIIGenerate(1,0,0,1)&ASCIIGenerate(1,1,1,0)&ASCIIGenerate(1,0,0,0)&ASCIIGenerate(30,1,0,0)&ASCIIGenerate(1,0,0,1)&ASCIIGenerate(2,1,1,0)&ASCIIGenerate(1,0,0,0)&ASCIIGenerate(28,1,0,0)&ASCIIGenerate(1,0,0,1)&ASCIIGenerate(2,1,1,0)&ASCIIGenerate(1,0,0,0)&ASCIIGenerate(26,1,0,0)&ASCIIGenerate(2,0,0,1)&ASCIIGenerate(2,1,1,0)&ASCIIGenerate(1,0,0,0)&ASCIIGenerate(21,1,0,0)&ASCIIGenerate(5,0,0,1)&ASCIIGenerate(2,1,1,0)&ASCIIGenerate(1,0,0,0)&ASCIIGenerate(12,1,0,0)&ASCIIGenerate(9,0,0,1)&ASCIIGenerate(3,1,1,0)&ASCIIGenerate(12,0,0,1)
RunWait("cmd /C @echo off&color F0&"&$trol&"pause > nul")

Func ASCIIGenerate($num,$char,$echo,$and)
    Local $i=0
    Local $str=""
    If $echo=1 Then
        $str&="echo "
    EndIf
        Do
            Switch $char
                Case 0
                    $str&="#"
                Case 1
                    $str&=" "
            EndSwitch
            $i+=1
        Until $i=$num
    If $and=1 Then
        $str&="&"
    EndIf
    Return $str
EndFunc

Output:

Holes exploited:

You can't have it stored in any image format or pre-rendered (including base64 data:// uri's and any form of ascii art).

The ASCII art is generated by the script on the fly. The script itself only has info on which and how many characters it must draw onscreen and when start a new line.

You can't store the image in any database.
  The image must show in the screen. It can't output the code to a file or anything similar (/dev/null doesn't count and virtual screens/viewports also don't count).

The script doesn't create nor contain any files. When generated, the ASCII art is loaded onto the computer's RAM and then shown via CMD commands (without using any batch files, only cmd /c ).

The code must render the trolologram on the screen (minimum size of 90x90) and must be with a black border and white background. The rendered version can't "be invisible" or "hidden behind the screen" or similar.

The image displayed onscreen is way bigger than 90x90 and it's black on a white background.

You didn't exploited any hole.

Acutally, I did. You said no to any form of pre-rendered ASCII art and still, while the source code in itself doesn't contain any, it still generates and shows it onscreen. That pretty much sounds like a hole to me.

Generating ascii art is totally different from what I meant.

HTML/CSS

😆

You can't have it stored in any image format or pre-rendered (including base64 data:// uri's and any form of ascii art).

Well it's not me that does the rendering, it's the browser.
And there is no ASCII here, only unicode :p.

Is this a serious answer? Or are you trolling?

Since it's a question about trolling (practically asking to get troll-answers) the trolling in itself does not make this a bad answer (see the other answers). The end result, however, hardly resembles the requested output. So I'd have to guess that's why the downvotes. shrug

Must be my warped French sense of humor failing to translate or something :)...

Even ○ would be a better answer.

HTML

Even ○ would be a better answer. –  Ismael Miguel Feb 23 at 0:12

Well here it is:
○

(with the browser zoomed in until it gets 90x90)


text:
Print a string with vertical words
Your task is to take an input string of ascii characters and output the string as a series of vertical words separated by spaces. An example is shown below:
Given the string:
Hello, World! My name is Foo.

the output should be:
H W M n i F
e o y a s o
l r   m   o
l l   e   .
o d
, !

10 bonus points will be awarded if your program correctly handles strings which need to wrap-around the terminal, which we'll set at 80 characters.
50 points if your program can also do the reverse!

Quite similar to Transpose a page of text.

@manatwork: I suppose it is. It's not identical though - and I might argue my problem is a little easier.

It's not 100% identical, but it's close enough to count as a duplicate: the reduction to make it identical is just replacing each space with two newlines.

@PeterTaylor: Not quite. My problem has no requirement to respect newlines in the original string. That problem requires that new lines be converted into spaces, and spaces converted into two newlines. It's not quite a trivial reduction.

J, 15
|:>'\S+| 'rxall

Usage:
   |:>'\S+| 'rxall 'Hello, World! My name is Foo.'
H W M n i F
e o y a s o
l r   m   o
l l   e   .
o d
, !

APL, 22
{⍉⊃⍵⊂⍨1+0,+\2≠/⍵=' '}

Explanation
{              ⍵=' '}   A. check which chars are spaces
            2≠/         B. of that vector, which consecutive pairs are different
          +\            C. compute the partial sums
      1+0,              D. insert 0 at the front and add 1 to every item
   ⍵⊂⍨                     use this vector to split the original string
 ⍉⊃                        disclose into a matrix and transpose

    'W o w   S u c h   D o g e'
A.   0 0 0 1 0 0 0 0 1 0 0 0 0
B.    0 0 1 1 0 0 0 1 1 0 0 0
C.    0 0 1 2 2 2 2 3 4 4 4 4
D.  1 1 1 2 3 3 3 3 4 5 5 5 5

Example
      {⍉⊃⍵⊂⍨1+0,+\2≠/⍵=' '} 'Hello, World! My name is Foo.'
H W M n i F
e o y a s o
l r   m   o
l l   e   .
o d
, !

Javascript - 228 172 145 126
A=prompt().split(" "),B="",N=A;for(y=0;y<N.length;y++){for(i=0;i<N.length;i++){if(A[i][y]){B+=A[i][y];}else{B+=" ";}}B+="\n";}

My first code golf :)

Its great for your first attempt!

You should attempt to make your code as short as possible, for instance, remove spaces, also "Input ?" doesn't really affect the program's behaviour, remove it too.

Fixed Bugs. Should work as expected :)

Works correctly now. But some minor things: no need for variable N, store the array's length instead of asking it twice, some pointless braces, some unnecessary semicolons. A=prompt().split(" "),B="";for(y=0;y<(l=A.length);y++){for(i=0;i<l;i++)if(A[i][y])B+=A[i][y];else B+="_";B+="\n"}alert(B). (In the JavaScript Standards for IO meta question the mostly agreed opinion was that relying on REPL's implicit output should not be considered correct.)

hello world, gave me hw\neo.

Doesn't work for I love JavaScript

(untested) if(A[i][y]){B+=A[i][y];}else{B+=" ";} => B+=(x=A[i][y])?x:" "

Javascript 184 149 123
var a=s.split(" "),b="",c;for(c in a)b+="
"+a[c].split("").join("
")+"
";document.write(b);

With the example string defined:
var s = "Hello, World! My name is Foo.";
var a=s.split(" "),b="",c;for(c in a)b+="
"+a[c].split("").join("
")+"
";document.write(b);

You can copy the second statement to you browsers console.
Unminified:
var res = "Hello, World! My name is Foo.";
var t=res.split(" ");
var s ="";
for (var word in t){
    s+="
" + t[word].split("").join("
") + "
";
}
document.write(s);

JsFiddle Link: http://jsfiddle.net/FzMvK/
My first code golf post :P

Very nicely done

@FooBarrigno updated answer to support reverse

@FooBarrigno Updated answer, removed reverse support and changed logic completely to reduce byte count

Clever, I like it. Can't you just change to float:right for reverse?

Depends what "reverse" means. If the first letter should be at the bottom then it wont work. If it is simply reversing the words, then it should work yes

@RononDex for some reason I thought reverse meant writing it backwards. but you are probably right about the letters being on the bottom. I feel stupid now...

@RononDex I was wondering if you really needed the var declaration ...

Ruby, 91 87
s=gets.split
puts s.map{|x|x.ljust(s.map(&:size).max,' ').split''}.transpose.map &:join

Hooray, I beat Perl! :D
Ruby, 150 - 50 bonus = 100
s=$<.read
n=s.index"
"
s=s.split n ?'
':' '
o=s.map{|x|x.ljust(s.map(&:size).max,' ').split''}.transpose.map &:join
puts n ?o.map(&:strip).join(' '):o

It just detects for newlines, and applies special handling if they are detected.
Run it like
ruby transposegolf.rb < transposegolfinput.txt

Python:
One line of code to process the sting:
import sys
m = "Hello, World! My name is Foo."

map(lambda y: sys.stdout.write(' '.join(y)+'\n'), zip(*map(lambda x: x.ljust(max(map(len,m.split()))), m.split())))

Python 2.7, 108 103
I'm sure this can be golfed more, but here's an initial solution in python.
w=raw_input().split();m=max(map(len,w));i=0
while i<m:print" ".join(map(lambda x:x.ljust(m)[i],w));i+=1

Improvements:

split(" ") => split()
removed some extra spaces

Nice job! If you start with i=m and loop down to 0, you can shave another 3 characters for an even 100.

F#, 187
let o=Console.ReadLine()
let s=o.Split(' ')
let m=s|>Seq.map String.length|>Seq.max
for l=0 to m-1 do
 for w in s|>Seq.map(fun x->x.PadRight(m,' ').[l])do printf"%c "w
 printfn"%s"""

Ruby, 63
$F.map(&:size).max.times{|i|puts$F.map{|s|s[i]||' '}.join' '}

The algorithm is very straightforward; only golfed. Code is 61 bytes long, plus 2 bytes for the -na options that it needs to work. From ruby -h:
-n   assume 'while gets(); ... end' loop around your script
-a   autosplit mode with -n or -p (splits $_ into $F)

Sample run:
$ echo 'This sentence is false' | ruby -na cols.rb
T s i f
h e s a
i n   l
s t   s
  e   e
  n
  c
  e

Perl - 92 97
$_=<>;chop;@x=split$";do{print((substr$_,$q,1or$").$")for@x;$q++,print$/}while/@{['\S'x$q]}/

Does the job in a pretty straightforward way.

No need for parenthesis around statement modifiers' expressions.

Note that while as used here is also statement modifier.

Is it? Is it not a do{}while() loop?

Nope. do itself has nothing else, just a block. The while is a separate thing.

K, 33
{" "/:',:''x@'/:!max@#:'x:" "\:x}

Example input and output:
k){" "/:',:''x@'/:!max@#:'x:" "\:x}"Hello, World! My name is Foo."
"H W M n i F"
"e o y a s o"
"l r   m   o"
"l l   e   ."
"o d        "
", !        "

Are the " supposed to be there?

@belisarius It's how strings are represented in k. If you specifically want to write to stdout then you can with {-1@" "/:',:''x@'/:!max@#:'x:" "\:x;} (37 chars), which would produce the output without "

Well, I think the output should be the required one, notwithstanding the language

Python 2.7 - 137 112 bytes
s=raw_input().split()
for c in range(max(map(len,s))):
 for w in s:
    try:print w[c],
    except:print' ',
 print''

Someone else has already done it better, but I might as well throw this up. Adds spaces to each word in the input until it's the same length as the longest one (to avoid index errors for the next part), then prints the cth letter of every word while c goes from 0 to the length of each string.
I came up with a much better way of doing this and cut out 25 bytes. Rather than padding strings with spaces to avoid the index error, I handle the error directly! Whenever there's nothing to print, I print a single space in its place with try:print w[c],, except:print' ',. I also remembered that I don't need a space between a print statement and a string literal, which saved one byte.
Note that Python 2 allows you to mix tabs and spaces and considers them separate levels of indentation. SE's Markdown interpreter replaces a tab character with four spaces, but every line of this program except the first has exactly one byte of indentation.
Formatting was pretty easy, since print 'something', prints 'something ' rather than 'something\n'. I did that for each character, and used an empty print statement to get the newline where I needed it.

C, 111 110 95 90 bytes
This solution uses VT-100 control codes to move the cursor on the terminal
main(int _,char**v){char*s=*++v;printf("^[7");while(*s)' '==*s?(s++,printf("^[8^[[2C^[7")):printf("%c^[[B^H",*s++);}

the ^[ sequence is a placeholder for the single ASCII ESC character, that can't be displayed here.

^[7 saves the current pointer position
^[8 restores the cursor position to the saved position
^[[2C moves 2 steps right
^[[B moves 1 step down

edit 1: the ^[[D (1 step left) VT-100 code has been replaced by a backspace (shown as ^H here, but is only one ASCII char) ; also forgot the "separated by spaces" instruction, now fixed
edit 2:
7 chars saved by using a for loop instead of while, and 32 instead of ' ':
main(int _,char**v){printf("^[7");for(char*s=*++v;*s;s++)32==*s?printf("^[8^[[2C^[7"):printf("%c^[[B^H",*s);}

8 more chars saved by calling one less printf: the ternary ?: operator is now used in the printf parameters
main(int _,char**v){printf("^[7");for(char*s=*++v;*s;s++)printf(32==*s?"^[8^[[2C^[7":"%c^[[B^H",*s);}

edit 3:
Got rid of the local variable s, working directly with argv aka v. This is totally hideous. But saved 4 chars. Also replaced == with ^ and therefore switched the ?: operands, to save 1 more char.
main(int c,char**v){printf("^[7");for(v++;**v;)printf(32^*(*v)++?"%c^[[B^H":"^[8^[[2C^[7",**v);}

Usage
$ gcc transpose.c -o transpose --std=c99
$ ./transpose 'Hello, World! My name is Foo.'
H W M n i F
e o y a s o
l r   m   o
l l   e   .
o d
, !

Un-golfed version (first version)
main (int _,char**v) {
    char*s=*++v; // init s with the address of the first letter
    printf("^[7"); // save the current cursor position
    while(*s)
        ' '==*s ? ( /* if current char is a space */
            s++,printf("^[8^[[2C^[7") /* return to the saved location, move right, save position */
        ) : /* kind of else */
            printf("%c^[[B^H",*s++); /* print the current char, move down, move left */
}

Un-golfed version (last version)
main(int c,char**v) {
    printf("^[7");
    for(v++;**v;) /* v++: make v point to argv[1] */
        printf(
            32^*(*v)++? /* test if **v is different from ' ', and make *v point to
                           the next char */
                "%c^[[B^H":
                "^[8^[[2C^[7",
            **v); /* this undefined behaviour (using *v and (*v)++ in the same expression)
                     works as "expected" with gcc 4.7.2 */
}

That un-golfed version looks suspiciously like Befunge. :)

I answered this question a long time ago. It was one of my first contributions to the site, actually. I recently came across it again and was kind of embarrassed. 112 bytes?! Unacceptable. So I gave it another shot:
Python 3 - 92 bytes
s=input().split()
print('\n'.join(map(' '.join,zip(*[a.ljust(max(map(len,s)))for a in s]))))

In the 109 days since I posted that first answer, I like to think I've come a long way. Even something like using Python 3 over 2.71 wouldn't have occurred to me. With this code golfed down to under 100 bytes, my soul can finally rest and I can proceed to the afterlife.
Explanation
s=input().split()

This gets a line from stdin and creates a list by splitting it at whitespace characters. The only whitespace likely to be in the input is spaces, so this line gets a list of words.
Let's take the second line from the inside out:
                                           max(map(len,s))

map takes a function and an iterable as arguments. It applies the function to each element of the iterable, and returns a new iterable of the results. Here, I create an iterable with the lengths of each input word. max gets the maximum value from an iterable. This gets us the longest word in the input.
                                  [a.ljust(              )for a in s]

A list comprehension is similar to map. It does something to every element of an iterable, and returns a list the results. For every word in the input, I do that_word.ljust(some code). ljust is short for "left justify". It takes an integer as an argument and adds spaces to the string until it's that long.
                             zip(*                                    )

This is a neat trick. In this context, * means "unzip this iterable as multiple arguments". This way, zip can be used to transpose a matrix (e.g. zip(*[(1,2),(3,4)]) -> [(1,3),(2,4)]). The only restriction is that all the rows in the matrix have to be the same length, or elements from all rows but the shortest are cut off to match.
                map(' '.join,                                          )

We already know what map does. The only new thing here is join, which takes an iterable of strings and makes it a single string using the delimiter it's attached to. For example, 'a'.join(['I', 'can', 'play', 'the', 'saxophone'])2 becomes Iacanaplayatheasaxophone.
print('\n'.join(                                                        ))

This join takes a bunch of strings and seperates them by newlines. All that's left is to print to stdout and we're done!
All together now:
print('\n'.join(map(' '.join,zip(*[a.ljust(max(map(len,s)))for a in s]))))

Find the length of the longest word from the input, append spaces to every word until they're the same length, transpose with the zip(*3 trick, use join to seperate each character in a row with spaces, join again to seperate each row with a newline, and print! Not bad for the only non-input-handling line in a 92 byte program.

1. The extra characters spent on print()'s parentheses are outweighed by the 4 characters I drop from raw_input()->input().
2. I can't actually play the saxophone.
3. ). You're welcome.

I have no idea why this is CW. I might have hit the button by accident. Oh well.

You can change print("\n".join(...)) to *map(print,...),. Try it online!

05AB1E, score 8 -20 -21 (30 29 bytes - 50 bonus):
|Dgi#ζεSðý}»}ë¹ε2ô€¬}ζJεðÜ}ðý

Try it online (regular single-line input).
Try it online (multi-line reversed input).
Explanation:
|                     # Take the input split on newlines:
                      #  i.e. 'This is a test' → ['This is a test']
                      #  i.e. 'T i a t\nh s   e\ni     s\ns     t'
                      #    → ['T i a t','h s   e','i     s','s     t']
 Dg                   #  Duplicate this list, and take the length
                      #   i.e. ['This is a test'] → 1
                      #   i.e. ['T i a t','h s   e','i     s','s     t'] → 4
   i         }        # If the length is exactly 1:
    ¹                 #  Take the input again
     #                #  Split the input-string by spaces
                      #   i.e. 'This is a test' → ['This','is','a','test']
      ζ               #  Zip with space-filler: Swap all rows and columns
                      #   i.e. ['This','is','a','test'] → ['Tiat','hs e','i  s','s  t']
       ε   }          #  For each item:
        S             #   Convert the item to a list of characters
                      #    i.e. 'Tiat' → ['T','i','a','t']
         ðý           #   Join them by a single space
                      #    i.e. ['T','i','a','t'] → 'T i a t'
            »         #  Join the result by newlines (and output implicitly)
    ë                 # Else:
     ε    }           #  For each item:
      2ô              #   Split it into chunks of two characters
                      #    i.e. 'h s   e' → ['h ','s ','  ','e']
        €¬            #   Take the head (first character) of each:
                      #    i.e. ['h ','s ','  ','e'] → ['h','s',' ','e']
           ζ          #  Zip with space-filler: Swap all rows and columns
                      #   i.e. [['T','i','a','t'],['h','s',' ','e'],['i',' ',' ','s'],['s',' ',' ','t']]
                      #     → [['T','h','i','s'],['i','s',' ',' '],['a',' ',' ',' '],['t','e','s','t']]
            J         #  Join each inner list to a single string
                      #   i.e. [['T','h','i','s'],['i','s',' ',' '],['a',' ',' ',' '],['t','e','s','t']]
                      #     → ['This','is  ','a   ','test']
             ε  }     #  For each item:
              ðÜ      #   Remove any trailing spaces
                      #    i.e. 'is  ' → 'is'
                 ðý   #  Join the items by a single space (and output implicitly)

Original 8-byte answer:
#ζεSðý}»

Try it online.
Explanation:
#           # Split the input-string by spaces
            #  i.e. 'This is a test' → ['This','is','a','test']
 ζ          # Zip with space-filler: Swap all rows and columns
            #  i.e. ['This','is','a','test'] → ['Tiat','hs e','i  s','s  t']
  ε   }     # For each item:
   S        #  Convert the item to a list of characters
            #   i.e. 'Tiat' → ['T','i','a','t']
    ðý      #  Join them by a single space
            #   i.e. ['T','i','a','t'] → 'T i a t'
       »    # Join the result by newlines (and output implicitly)

Javascript, 141
a=prompt().split(' '),c=0,d=a.map(function(a){b=a.length;c=c<b?b:c});for(j=0;j<c;j++){b='';for(i in a)b+=a[i][j]?a[i][j]:' ';console.log(b);}

Sample
hello, world! this is code golf

hwticg
eohsoo
lri dl
lls ef
od
,!

GolfScript [41 bytes]
' '%:x{.,x{,}%$-1=-abs' '*+}%zip{' '*}%n*

How it works:
' '%:x          split text into words and store array in 'x'
{               for each word in the array:
    .,              from word's length
    x{,}%$-1=-      substract the length of the longest word in 'x'
    abs             get absolute value (maybe there is a shorter way?)
    ' '*+           add corresponding number of spaces
}%
zip{' '*}%      transpose array of words and add spaces between letters
n*              join words with a new line character

You may see the online demo here.
P.S.: This is my first GolfScript code ever, so don't judge me strictly ;)

R, 116
z=t(plyr::rbind.fill.matrix(lapply(strsplit(scan(,""),""),t)));z[is.na(z)]=" ";invisible(apply(cbind(z,"\n"),1,cat))

 Mathematica 49
Clearly Mathematica isn't the best for this one:
Grid[PadRight@Characters@StringSplit@s^T]/. 0->" "

Note ^T (transpose) is only one char (I can't find the right char code now)

Bash + coreutils, 54
eval paste `printf " <(fold -w1<<<%s)" $@`|expand -t2

Output:

$ ./transpose.sh Hello, World! My name is Foo.
H W M n i F
e o y a s o
l r   m   o
l l   e   .
o d
, !
$

Suggestion for an update: backticks for command substitution is depreciated. Using the $() construct is now the common method for command substitution.

@Yokai - This is code-golf - here we are optimizing for code length and not for standards/best-practices compliance.  https://codegolf.stackexchange.com/a/25572/11259

I figured since the norm had changed for command substitution, I would suggest an update. You don't have to. It was just a suggestion. It would only add a single new character to the count anyways.

APL: 18
⍉↑1↓¨a⊂⍨' '=a←' ',

Explanation:
a←' ',  put a space in front of the string and assign to a
' '= find spaces, produces a boolean
1↓¨a⊂⍨ make substrings starting where the boolean has 1's and drop first element of each (so the space)
⍉↑ Make matrix out of the resulting substrings, and reverse it along the diagonal

R, 81 bytes
Save a byte by storing a newline as e, which can be used in both scan calls, the compare call and cat.
w=scan(,e,t=scan(,e<-"
"));while(any((s=substr(w,F<-F+1,F))>e))cat(pmax(" ",s),e)

Try it online!

K (oK), 26 bytes
Solution:
`0:{" "/'+(|/#:'x)$x}@" "\

Try it online!
Explanation:
`0:{" "/'+(|/#:'x)$x}@" "\ / the solution
                      " "\ / split input on whitespace
   {                }@     / apply (@) lambda
                  $x       / pad ($) input (x)
          (      )         / do this together
             #:'x          / count (#:) each (')
           |/              / max
         +                 / transpose / flip
    " "/'                  / join each with whitespace
`0:                        / print to stdout

Python 3, 124
a=input().split()
l=max(map(len,a))
print("\n".join(" ".join(c[i] for c in [i+" "*(l-len(i)) for i in a]) for i in range(l)))

Python 2.7 - 119 106
Take 1 - 166. The reversing of lists was needed to make pop work in the order I wanted, but this seemed wasteful. And when I tried to combine into a single comprehension for fun, the pop screwed things up.
w=raw_input().split(' ');l=max([len(l) for l in w]);
q=[list(p)[::-1]for p in w]+[['\n']*l]
t=[' '+(v.pop() if v else' ')for i in range(l)for v in q]
print ''.join(t)

Take 2 - 119. So I changed to simple list indexing. Still seems clunky though, especially the padding of spaces and new lines.
w=raw_input().split(' ');l=max([len(l)for l in w]);print''.join([' '+(v+' '*l)[i]for i in range(l)for v in w+['\n'*l]])

Take 3 - thanks to @grc
w=raw_input().split();l=max(map(len,w));print''.join(' '+(v+' '*l)[i]for i in range(l)for v in w+['\n'*l])

[len(l)for l in w] can be shortened to map(len,w), .split(' ') to .split(), and .join([...]) to .join(...).

I haven't gone over your code in too much detail so this might not work, but: "The reversing of lists was needed to make pop work in the order I wanted" Couldn't you use v.pop(0) to pop the first element instead of the last one?

Haskell, 112
Golfed:
import Data.List
r s=unlines$transpose$p$words s
p w=m(\s->s++replicate(maximum(m l w)-l s)' ')w
m=map
l=length

Explained:
import Data.List

-- Break on spaces, then pad, then transpose, then join with newlines
r s=unlines$transpose$p$words s

-- Pads each String in a list of String to have the same length as the longest String
p w=m(\s->s++replicate(maximum(m l w)-l s)' ')w

-- Aliases to save space
m=map
l=length

Example:
*Main Data.List> putStrLn $ r "Hello Doge"
HD
eo
lg
le
o

JavaScript, 139 (156 with console.log output)
s=" ",b="",a=prompt().split(s),l=0;for(var i in a){m=a[i].length;l=(l<m)?m:l;}for(i=0;i<l;i++){for(var j in a)b+=((x=a[j][i])?x:s)+s;b+="\n"}console.log(b);

I think this is as golfed as I can get it. I just split, find the largest word and transpose accordingly, adding spaces if the char doesn't exist in the shorter words. More than the previous submitted JavaScript answer, but that answer doesn't seem to work?

Japt -R, 5 bytes
¸y¬m¸

Try it

Explanation
¸         :Split on spaces
 y        :Transpose
  ¬       :Split columns
   m      :Map rows
    ¸     :  Join with spaces
          :Implicitly join with newlines and output

Pyth, 8 bytes
jbjL\ Cc

Try it online!
Pretty straightforward. Takes input enclosed in quotes, i.e. "Hello World"
jbjL\ CcQ
---------
       cQ    Chop the input Q on spaces
      C      Matrix transpose
  jL\        Join each element by spaces,
             i.e. interleave spaces between the characters of each element
jb           Join by newlines

C truncates to the length of the shortest entry, so this doesn't work. Here's a quick fix which is also 8 bytes.

APL(NARS), 79 chars, 158 bytes
{m←⌈/↑∘⍴¨z←(' '≠⍵)⊂,⍵⋄v←∊m{⍵\⍨∊(k⍴1)(0⍴⍨⍺-k←↑⍴⍵)}¨z⋄((2×↑⍴z)⍴1 0)\[2]⍉(↑⍴z)m⍴v}

test:
  f←{m←⌈/↑∘⍴¨z←(' '≠⍵)⊂,⍵⋄v←∊m{⍵\⍨∊(k⍴1)(0⍴⍨⍺-k←↑⍴⍵)}¨z⋄((2×↑⍴z)⍴1 0)\[2]⍉(↑⍴z)m⍴v}
  f 'Hello, World! My name is Foo.'
H W M n i F
e o y a s o
l r   m   o
l l   e   .
o d
, !

The old function have output not perfect:
  {⍪¨(' '≠⍵)⊂,⍵}'Hello, World! My name is Foo.'
 H  W  M  n  i  F
 e  o  y  a  s  o
 l  r     m     o
 l  l     e     .
 o  d
 ,  !

Julia - 109 bytes
i=split(readline());m=maximum(map(x->length(x),i));for c∈1:m println(join([rpad(w,m)[c] for w∈i]," "))end

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:
A program that ends but never ends
Write a program that starts itself again when finishes.
There should be no more than one instance of the program running at same time.  Not even for a slightest moment of time.
You can ignore any instance that is manually started by user during your cycle.  But your code should not do it in your restart cycle.
Program can start after any amount of time, as long as it is guaranteed that it starts again.
The only way to stop the cycle is to kill the process.
Your solution should not involve restarting of the environment (in which program is running, includes OS, machine, VM, shell etc).  Only your program is allowed to restart.

Are we allowed to write a supplement program?

Isn't this just what exec does in linux?

Supplement programs are allowed, as long as they do not coexist with the main program or with another instance of themselves too, at any point of time.

@mniip I don't think the PID changes in this case, so it's arguable that the program never terminates.

I'm a little lazy to write it right now, but my submission would be(for windows): "Edit the registry so that my program boots on startup. Run shutdown -r -t 0 -f".

Killing the process won't kill your cycle though.

@microbian It will if you can theoretically end it before the shutdown gets run. If you consider that infeasible you can add as long of a sleep as you want before the shutdown call.

@Cruncher, That is doable, though a program without sleep will leave your system unusable :)  Since there are no answers yet, I am going to disallow system restarts as valid answers.

@microbian Lol, windows isn't completely dumb. I'm pretty sure if you booted into safe mode you could fix the problem. Or even boot into a linux disk and delete the exe from your harddrive. FYI: You should edit that into your question asap, however I'm not sure what solutions you're looking for. I thought the restart was a nice creative solution for a popularity contest

Only infinite loop will satisfy your conditions ;) Program that quits and starts itself breaks condition '2 instances at the same time are not allowed', especially 'Not even for a slightest moment of time.' It must start new instance of itself before it quits. Any type of script/scheduler that runs your program breaks condition 'starts itself'. This is very tricky, script is process for itself in this case, it is not a part of program.

I'd use CreateRemoteThread on a random process to start another instance of the parent program after a short delay, but alas, I'm not on Windows.

I just realized: if I want to write a virus and don't know how, I could 1) go to StackOverflow, ask how. Get hate from everyone and probably the question will be closed. Or 2) Go to code golf, ask others how they'd do it. Get a handful of creative answers to select from, and the question is so popular it gets on the network-wide "hot" list. Mua ha ha ha ha.

Are building a modern TSR here?

@rumtscho You know, that's a good general strategy. Ok guys, for my next challenge, let's see who can write the smallest firmware for the prototype device sitting on my desk that meets all of the requirements in the linked document. To spice it up, this must be done by 8AM Monday morning. Go!

Bash script, 3 chars (Shortest, possibly the most elegant, though admittedly controversial)
$0&

Simply places a new instance of itself in the background (new process), then quits.  The new instance likely will remain in the scheduler run-queue until the previous instance is done.
Warning - this is hard to kill, as the PID is continually changing.  Temporarily renaming the script file is probably the simplest way to break the cycle.
A single-core system is assumed.  Of course this is not realistic with Linux on modern bare-metal hardware, but it is easily configurable when running in a VM.  We could probably achieve a similar trick using taskset, but that would reduce the impact of the 3-char solution.
This answer bends the rules a little bit in that it applies a specific meaning of "running".  There will be moments when the new process has been fork()ed and the old process is still alive - i.e. it may be possible to observe more than one PID.  However the new process will be placed on the Linux scheduler run-queue to wait for CPU cycles, while the existing process will continue to execute.  At this point all that needs to be done by the existing process is for bash itself to exit().  This does take a finite amount of time, though I'm fairly confident that it will be done way before the current timeslice/scheduler quantum is done.  Supporting evidence is the fact that bash starts up and shuts down in 2ms on my VM:

$ time bash -c :

real    0m0.002s
user    0m0.000s
sys 0m0.000s
$

Further supporting evidence that the new process does not actually run until the previous process is done can be seen in strace output:
strace -f -tt -o forever.strace bash -c ./forever.sh

In the output, we see the original process has PID 6929.  We can see the fork() call (actually clone()), which returns a new PID of 6930.  At this point there are 2 PIDs, but only 6929 is currently running:

6929  12:11:01.031398 clone(child_stack=0, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0x7f2f83ac49d0) = 6930
6929  12:11:01.031484 rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
6929  12:11:01.031531 rt_sigprocmask(SIG_BLOCK, [CHLD], [], 8) = 0
6929  12:11:01.031577 rt_sigprocmask(SIG_BLOCK, [CHLD], [CHLD], 8) = 0
6929  12:11:01.031608 rt_sigprocmask(SIG_SETMASK, [CHLD], NULL, 8) = 0
6929  12:11:01.031636 rt_sigprocmask(SIG_BLOCK, [CHLD], [CHLD], 8) = 0
6929  12:11:01.031665 rt_sigprocmask(SIG_SETMASK, [CHLD], NULL, 8) = 0
6929  12:11:01.031692 rt_sigprocmask(SIG_BLOCK, [CHLD], [CHLD], 8) = 0
6929  12:11:01.031726 rt_sigprocmask(SIG_SETMASK, [CHLD], NULL, 8) = 0
6929  12:11:01.031757 rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
6929  12:11:01.031803 rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
6929  12:11:01.031841 read(255, "", 4)  = 0
6929  12:11:01.031907 exit_group(0)     = ?
6930  12:11:01.032016 close(255)        = 0
6930  12:11:01.032052 rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0

Full strace output here.
We can see that 6930 does not issue any system calls until 6929 is completely done.  It is reasonable to assume that this means 6930 does not run at all until 6929 is done.  The perf utility would be the ultimate way to prove this.

"restarts ..., then quits", so more than one instances are running at the same time?

@microbian - I think we can assume the Linux scheduler will put the new process on the run queue, then let the existing process continue in its time-slice, at which point it will finish.  Only then will the new process start to "run".  At least I only ever observe one process in the top output.  I guess it might be necessary to ensure the new process is always restarted on the same core.

"...on single core" - yes, I would guess so too. On a many-core, you may probable be able to see many.

I think that qualifies though +1 from me!

If this was tagged code-golf, then this will definitely win! +1

@DigitalTrauma What's the update frequency of top?

@DigitalTrauma You're making huge assumptions about how long it takes bash to shut itself down. top tells you nothing -- it only updates once every few (tens of) seconds but you're spawning many processes per second.

@JohnOdom The point of the excercise was that the program restart itself without doing so directly. While interesting, I think this solution falls a bit short of the mark.

@DavidRicherby - you're absolutely right - top is not the right tool to use here.  However I see that time bash -c : takes only 2ms on my Ubuntu VM, so I don't think its unreasonable to expect bash to complete its shutdown before its scheduling quantum is done.

I want to run this and try to take it down using psDoom.

@DigitalTrauma it's a race. It might work but it doesn't have to in future. Even now - Linux can have 1000 HZ timer configured just fine (-ck patchset have it by default and adds even highier) where quanta have 1 ms (mainline default is 4ms). So it is totally reasonable to expect bash to not be able to finish it quanta even without considering some delays (swapping for example).

Solution 1
PHP, 32 chars
It sends the header and then it stops. After 3 seconds, the page gets reloaded.
file a.php
header("Refresh: 3; url=a.php");

This can be stopped by terminating the execution of the page before the headers are sent, or simply by killing the browser.

Solution 2
PHP, 2 pages
Let's consider the two files two different programs. The two files are in the same folder.
file a.php
header("Location:b.php");

file b.php
header("Location:a.php");

Terminating one of the pages before the headers are sent terminates the program (killing the browser works, too).
Here's the same program in
ASP.NET
file a.aspx
Response.Redirect("b.aspx")

file b.aspx
Response.Redirect("a.aspx")

That's a nice solution.  I hope others come with answers different than this.  That's why I kept it as a popularity contest.

Whether your 3 second reload answer is valid or not, I leave it to the php experts.  I think it might be valid, because it is the browser who is waiting not your php (I am no expert).

While technically PHP is run as a module of a web server and your web server didn't restart, I think it is valid if you consider a .php file as a script and the script is run multiple times.

@TwiNight Thanks for the feedback, I appreciate it :)

For your second solution, wouldn't the browser detect a redirect loop and stop on its own? http://www.thedan1984.com/wp-content/uploads/2012/02/this-webpage-has-a-redirect-loop.png

@TwiNight That's only true for apache + mod_php setups. If you'Re running CGI or FastCGI, PHP may be restarted for every script. For FastCGI + PHP-FPM it depends on FPM pool configuration wether the PHP process / thread is terminated after the script ends or not.

@Ajedi32 Hm, you've got a point, it seems a quite interesting issue. From my researches now, I found out that Chrome handles error 310 - too many redirects with the screen you linked; Firefox has a page too. In a website I read that IE does not handle that and goes on over and over again. I'm going to check that out! Thanks for the feedback! :D

sh
echo $PWD/$0 | at tomorrow

This will work on any Posix-compliant system.
To kill it, delete the file or use atrm.

bash
exec "$0"

exec replaces the shell without creating a new process. This makes sure that there cannot be a second instance.

Better put it in ~/.bash_profile!

@yegle: $0 is -bash when .bash_profile is sourced, so that would just result in a syntax error.

Oops, you are right.

exec ${0##-} in ~/.bash_profile works :-)

Windows Task Scheduler (Native)
C++. A nightmare of COM programming. Meets all challenge requirements.
#define _CRT_SECURE_NO_WARNINGS
#include <windows.h>
#include <taskschd.h>
#include <comutil.h>

#pragma comment(lib, "taskschd.lib")
#pragma comment(lib, "comsuppw.lib")

static void timeplus (int seconds, char timestr[30]);

int main () {

    CoInitializeEx(NULL, COINIT_MULTITHREADED);
    CoInitializeSecurity(NULL, -1, NULL, NULL,
        RPC_C_AUTHN_LEVEL_PKT_PRIVACY,
        RPC_C_IMP_LEVEL_IMPERSONATE, NULL, 0, NULL);

    const char *name = "Restarter";

    char path[MAX_PATH + 1];
    GetModuleFileNameA(NULL, path, sizeof(path));
    path[sizeof(path) - 1] = 0; // workaround for xp

    ITaskService *taskman;
    CoCreateInstance(CLSID_TaskScheduler, NULL, CLSCTX_INPROC_SERVER,
        IID_ITaskService, (void **)&taskman);

    taskman->Connect(_variant_t(), _variant_t(), _variant_t(), _variant_t());

    ITaskFolder *root;
    taskman->GetFolder(_bstr_t("\\"), &root);

    // Delete the task.
    root->DeleteTask(_bstr_t(name), 0);

    // pause for 5 seconds to give user a chance to kill the cycle
    fprintf(stderr, "If you want to kill the program, close this window now.\n");
    Sleep(5000);
    fprintf(stderr, "Sorry, time's up, maybe next time.\n");

    // Create the task for 5 seconds from now.
    ITaskDefinition *task;
    taskman->NewTask(0, &task);

    IPrincipal *principal;
    task->get_Principal(&principal);
    principal->put_LogonType(TASK_LOGON_INTERACTIVE_TOKEN);

    ITaskSettings *settings;
    task->get_Settings(&settings);
    settings->put_StartWhenAvailable(VARIANT_TRUE);
    settings->put_DisallowStartIfOnBatteries(VARIANT_FALSE);
    settings->put_StopIfGoingOnBatteries(VARIANT_FALSE);

    ITriggerCollection *triggers;
    task->get_Triggers(&triggers);

    ITrigger *trigger;
    triggers->Create(TASK_TRIGGER_TIME, &trigger);

    char when[30];
    ITimeTrigger *trigger_time;
    trigger->QueryInterface(IID_ITimeTrigger, (void **)&trigger_time);
    trigger_time->put_Id(_bstr_t("TimeTrigger"));
    timeplus(10, when);
    trigger_time->put_StartBoundary(_bstr_t(when));
    timeplus(300, when);
    trigger_time->put_EndBoundary(_bstr_t(when));

    IActionCollection *actions;
    task->get_Actions(&actions);

    IAction *action;
    actions->Create(TASK_ACTION_EXEC, &action);

    IExecAction *action_exec;
    action->QueryInterface(IID_IExecAction, (void **)&action_exec);
    action_exec->put_Path(_bstr_t(path));

    IRegisteredTask *regtask;
    root->RegisterTaskDefinition(_bstr_t(name), task,
        TASK_CREATE_OR_UPDATE, _variant_t(), _variant_t(),
        TASK_LOGON_INTERACTIVE_TOKEN, _variant_t(""),
        &regtask);

    regtask->Release();
    action_exec->Release();
    actions->Release();
    trigger_time->Release();
    trigger->Release();
    triggers->Release();
    settings->Release();
    principal->Release();
    task->Release();
    root->Release();
    taskman->Release();
    CoUninitialize();

}

// outputs current utc time + given number of seconds as
// a string of the form YYYY-MM-DDTHH:MM:SSZ
static void timeplus (int seconds, char timestr[30]) {

    SYSTEMTIME when;
    FILETIME whenf;
    LARGE_INTEGER tempval;

    GetSystemTimeAsFileTime(&whenf);
    tempval.HighPart = whenf.dwHighDateTime;
    tempval.LowPart = whenf.dwLowDateTime;
    tempval.QuadPart += seconds * 10000000LL; // 100 nanosecond units
    whenf.dwHighDateTime = tempval.HighPart;
    whenf.dwLowDateTime = tempval.LowPart;
    FileTimeToSystemTime(&whenf, &when);

    sprintf(timestr, "%04hu-%02hu-%02huT%02hu:%02hu:%02huZ",
        when.wYear, when.wMonth, when.wDay,
        when.wHour, when.wMinute, when.wSecond);

}

Compile with MSVC (or MinGW GCC if you have all dependencies).
Program will start and register a one-time task with the Windows task scheduler to start itself 5 seconds later (Control Panel -> Administrative Tools -> Task Scheduler to view, task is named "Restarter"). Program will pause for 5 seconds to give you a chance to kill it before it creates the task.
Challenge Requirements:

Starts itself again when finishes.
Yes. Task is scheduled just prior to program exit.
No more than one instance of the program running at same time.
Yes. Program exits fully and does not run for 5 seconds. It is started by the scheduler.
You can ignore any instance that is manually started by user during your cycle.
Yes, as a side-effect of using a constant task name.
As long as it is guaranteed that it starts again.
Yes, provided that Task Scheduler is running (it is in a standard Windows configuration).
The only way to stop the cycle is to kill the process.
Yes, the process can be killed during the 5 second window while it is running. The program deletes the task prior to the 5 second delay, killing it at this time will not leave a stray task in the scheduler.
Your solution should not involve restarting of the environment
Yes.

By the way, if anybody ever wondered why Windows applications used to be so unstable (before the advent of .NET and C#), this is one reason why. The amount of error handling required (had I included it), resource management, and verbosity sets up very error-prone situations if a programmer is even the slightest bit lazy (the above code is extremely lazy).
A much easier and shorter alternative is to invoke schtasks.exe. I have submitted a version with that in a .BAT script as well.

BBC BASIC - a tribute to Snow Patrol
Emulator at bbcbasic.co.uk
This one's a little different. It prints a verse of the song "Run" and plays an arpeggio of the chords so you can sing along. It was inspired by the fact that the command to execute (and therefore the last line of the program) is of course RUN.
All variables are cleared at the start of the program, so it takes the screen colour left behind by the previous iteration to decide what verse to print next.
    5 C=POINT(0,0) MOD 4
   10 COLOUR 129+C
   15 CLS
   20 RESTORE 110+C
   25 READ A$
   30 PRINT A$
   35 FORK = 1 TO 4
   40   RESTORE K+100
   45   READ P
   50   FORM= 1 TO 8
   55     SOUND 1,-15,P,7
   60     SOUND 1,-15,P-20,7
   65   NEXT
   70 NEXT
  101 DATA 100
  102 DATA 128
  103 DATA 136
  104 DATA 120
  110 DATA Light up light up - As if you have a choice - Even if you can not hear my voice - I'll be right beside you dear.
  111 DATA Louder louder - And we'll run for our lives - I can hardly speak - I understand - Why you can't raise your voice to say.
  112 DATA Slower Slower - We dont have time for that - All I want is to find an easier way - To get out of our little heads.
  113 DATA Have heart my dear - We're bound to be afraid - Even if its just for a few days - Makin' up for all of this mess.
  120 RUN

OUTPUT (montage of 4 different screen shots)

+1 for the color solution as "shared memory" alternative.

HTML/JavaScript:
<form /><script>document.forms[0].submit()</script>

The code triggers the destruction of the page it is running on, then the re-creation of another instance of itself when the browser loads the page anew.
AFAIK, the only way out is to kill the tab the page is running in.
EDIT: as per popular request, a valid HTML5 code:
<!doctype html><meta charset=utf-8><title> </title><form></form>
<script>document.forms[0].submit()</script>

@JasonC I disagree. I think that reasonable pages should comply with the specs, but [tag:popularity-contest]s are quite supposed to be reasonable, are they? :D so +1, I really like this one.

C
This program acts like a lot of malware. Just before it closes, it creates a shell script in the /tmp directory. It forks to start the shell script, which lets the original program close and cancel the original PID. After a brief period of time (2 seconds) the shell script starts a new process with the program. For brevity, the program location is hard-wired as '/tmp/neverend/'.
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>

void rebirth(){
    char t[] = "/tmp/pawnXXXXXX";
    char* pawnfile = mktemp(t);
    if(pawnfile){
        int fd = open(pawnfile, O_RDWR|O_CREAT);
        const char msg[]="sleep 2\n/tmp/neverend\n";
        if(fd>0){
            int n = write(fd, msg, sizeof(msg));
            close(fd);
            pid_t pid = fork();
            if(pid==0){
                char* args[3] = {"bash", pawnfile, NULL};
                execvp(args[0], args);
            }
        }
    }
}

int main(int argc, char* argv[]){
    printf("Starting %s\n", argv[0]);
    atexit(rebirth);
    printf("Exiting %s\n", argv[0]);
}

There is only ever one 'neverend' process running at a time. Each new process gets a new PID. The easiest way to kill this is to delete the executable. If you wanted to make it more malignant, you could copy both the executable and the script to make sure there are multiple copies on the program on disk at any time.

I am expecting to see more innovative answers.  See comments for question about 'supplement programs'.  To me, a supplement program is just a part of your program that hangs around.

Forking means you'll have two instances of the process running at the same time, even if they're doing different things.

@BarryFruitman easy to avoid, though, by really using two different executables. It's valid then, but way less elegant.

I suppose you could use system() if the rules don't count a fork+exec to /bin/sh as a supplementary program.

Perl
`perl -e"kill 9,$$"|perl $0`

The script issues a system command to kill itself, and pipe the result into another instance of itself. The Perl interpreter is used to do the killing, for cross platform reasons.
Stop the madness by deleting the script.

Atari 8-bit Basic
1L.:R.

Tokenizes to:
1 LIST : RUN

Internally it is clearing the internal structures, essentially wiping out the program, before running it again from the listing.
This is fundamentally different from:
1L.:G.1

Which tokenizes to:
1 LIST : GOTO 1

This is a basic infinite loop. When you run them, you see the difference in speed (first is slower).

I'm not quite clear why "list" during program execution would clear out any interenal structures.  I think the Atari has a keyboard buffer, so one could list the program, stuff the keystrokes to run it, and do a "new" with the cursor positioned to "retype" it.

@supercat - LIST doesn't, RUN does.

By that logic, one could omit the "LIST".  On the other hand, if the program stuffed the keyboard buffer, with a few carriage returns, put "NEW" followed by the program and "RUN" at the right spots on screen, homed the cursor, and exited, it would genuinely erase itself and retype itself automatically.

@supercat - without the LIST, you wouldn't see it running. I chose LIST because it has the shortest input L.. I like the idea of putting that into a keyboard buffer, it's certainly short enough!

Am I remembering correctly that the Atari, like the Commodore machines, reads text off the screen when you push Return?  How big is the keyboard buffer?  On the VIC-20 and C64, it's ten bytes.  A program which does enough pokes to load the keyboard buffer probably wouldn't fit in the keyboard buffer, but I've written programs which would modify themselves by printing changes to the screen followed by RUN, and stuff a few Return keystrokes.  Such things were especially useful on the 64 since it didn't have the [IIRC] IN command the Atari has for merging lines into a program.

On an IBM Mainframe running z/OS, you run a utility which copies a dataset (file) to another dataset (file). The input is the source of the JCL (Job Control Language) that you have submitted to cause it to run. The output is the Internal Reader (INTRDR). You will also need to ensure that your system does not allow the running of multiple identical jobnames. Good to use a job-class which only has one initiator (place where a JOB can run in batch).
There are no PIDs involved (in z/OS), so fails the challenge set.
You halt the process by draining and/or flushing. If something has gone wrong, by draining and/or flushing, swearing, kicking, attempting a warm-start and finally  by a cold-start or hitting the Big Red Button (and shooting the programmer).
I may have exaggerated along the way, but don't try this at work...
Example using SORT. Details on the JOB card are very site-dependant. Site policy may either forbid or prevent the use of INTRDR. A specific class may be required to use the INTRDR. If your site policy forbids its use do not use it unless you want to take your belongings for a walk in a cardboard box.
Although there are good uses for the INTRDR, do not use it for this purpose. You won't even have a chance to get your box.
//jobname JOB rest is to your site standards
//*
//STEP0100 EXEC PGM=SORT
//SYSOUT   DD SYSOUT=*
//SORTOUT  DD SYSOUT=(,INTRDR) minimum required, site may require more
//SYSIN    DD *
  OPTION COPY
//SORTIN   DD DISP=SHR,DSN=YOUR.LIBRARY.WITHJOB(JOBMEMBR)

Other utilities are available. A quick program would be easy to do as well, just read a file, write a file.
If you want an example of this going wrong, try: http://ibmmainframes.com/viewtopic.php?p=282414#282414
The traditional way to copy a dataset is to use the IBM utility IEBGENER, as ugoren alludes in their comment.
However, these days, many sites will have IEBGENER "aliased" to ICEGENER. ICEGENER will, if it can, use IBM's DFSORT (or its rival SyncSort) to do a copy, because the SORT products are much more hihgly optimised for IO than IEBGENER is.
I'm just cutting out the middle-man by using SORT.
If you work at an IBM Mainframe site, you know the format of the JOB card that you should use. The minimal JOB card is as I have shown, without the comment. The comment will be important, because you may be supposed to be supplying accounting information, for instance. The jobname will likely have a site-specific format.
Some sites ban, or prevent, the use of the INTRDR. Be aware.
Some sites allow multiple jobs with the same name to run at the same time. Be aware.
Although unless you are a System's Programmer you can't set up such a class, you should look for a class which allows only one initiator. With that, the process is fairly safe - but be absolutely sure about that the class is working as described. Test. Not with this job.
If you are a System's Programmer, you know not to do anything outside of your remit. 'nuff said.
With one job with the same name allowed at the same time and a single initiator, this will be a constant stream of job start/finish next job start/finish - until you fill the spool (another bad thing to do) with the output from thousands of jobs (or run out of job numbers). Watch a JES Console for warning messages.
Basically, don't do this. If you do do it, don't do it on a Production machine.
With a little brushing up, I'll consider another Answer for how to do it on another IBM Mainframe operating system, z/VSE... z/VSE uses JCL. z/OS uses JCL. They are different :-)

The idea looks good, but it isn't an answer. Show us the JCL - JOB, EXEC and DD - then it will be an answer.

Haven't submitted a job for an awful long, so I'm not sure what to make of it. If the missing parts are just local customization, then OK. But if you hide stuff to prevent an abuse, then make up your mind - post the real thing, or post nothing. P.S. We used IEBGENER back then to simply copy.

@ugoren Further update, including explanation of why IEBGENER was not selected for the task. Removing the comment text on the JOB statement gives the necessary JCL for it to run, but it being sufficient JCL depends on local site standards, either for the job to work or for the programmer to avoid being sacked.

Windows Task Scheduler (.BAT)
Windows batch script. Meets all challenge requirements.
As far as I can see this is the only Windows solution so far that meets all requirements and has no nonstandard dependencies (my other solution is similar but requires compilation).
@ECHO OFF
SETLOCAL

schtasks /Delete /TN RestarterCL /F

ECHO Close this window now to stop.
TIMEOUT /T 5

FOR /f "tokens=1-2 delims=: " %%a IN ("%TIME%") DO SET /A now=%%a*60+%%b
SET /A start=%now%+1
SET /A starth=100+(%start%/60)%%24
SET /A startm=100+%start%%%60
SET /A end=%now%+3
SET /A endh=100+(%end%/60)%%24
SET /A endm=100+%end%%%60

schtasks /Create /SC ONCE /TN RestarterCL /RI 1 /ST %starth:~1,2%:%startm:~1,2% /ET %endh:~1,2%:%endm:~1,2% /IT /Z /F /TR "%~dpnx0"

ENDLOCAL

Program behaves similarly to my C++/COM answer.
Program will start and register a one-time task with the Windows task scheduler to start itself up to 60 seconds later (Control Panel -> Administrative Tools -> Task Scheduler to view, task is named "Restarter"). Program will pause for 5 seconds to give you a chance to kill it before it creates the task.
Makes use of command line Task Scheduler interface schtasks.exe. Arithmetic in script is to compute time offsets while keeping the time valid and in HH:MM format.
Challenge Requirements:

Starts itself again when finishes.
Yes. Task is scheduled just prior to program exit.
No more than one instance of the program running at same time.
Yes. Program exits fully and does not run for ~60 seconds. It is started by the scheduler.
You can ignore any instance that is manually started by user during your cycle.
Yes, as a side-effect of using a constant task name.
As long as it is guaranteed that it starts again.
Yes, provided that Task Scheduler is running and schtasks.exe is present (both true in default Windows configurations).
The only way to stop the cycle is to kill the process.
Yes, the process can be killed during the 5 second window while it is running. The program deletes the task prior to the 5 second delay, killing it at this time will not leave a stray task in the scheduler.
Your solution should not involve restarting of the environment
Yes.

Note: Due to limited command line interface, restart time must be specified in minutes and the task will not restart on laptops without the AC adapter plugged in (sorry).

Python (72 bytes)
import os
os.system('kill -9 %s && python %s' % (os.getpid(), __file__))

Could be make smaller I guess. First, by hardcoding the name of the file (instead of using __file__). But here, you can put this code in a file and run it, whatever its name is :)

You can probably change && to &.

Since when is that allowed, user2509848?

Well, you could start by removing the whitespace…

Since it's not tagged [tag:code-golf], I will keep the code like this :-)

Unix shell
I haven't seen many solutions yet that rely on an unrelated program to restart it. But this is exactly what the at(1) utility was made for:
echo "/bin/sh $0"|at now + 1 minute

It's hard to actually catch the program running, since it only runs once per minute and exits so quickly. Fortunately the atq(1) utility will show you that it's still going:
$ atq
493     Fri Feb 21 18:08:00 2014 a breadbox
$ sleep 60
$ atq
494     Fri Feb 21 18:09:00 2014 a breadbox

And atrm(1) will allow you to break the cycle:
$ atq
495     Fri Feb 21 18:10:00 2014 a breadbox
$ atrm 495
$ atq

You can replace 1 minute with 1 hour, or 1 week. Or give it 1461 days to have a program that runs once every 4 years.

PowerShell
I am abusing (and possibly breaking) my own rule.
[System.Threading.Thread]::Sleep(-1)

It takes infinite amount of time to restart itself.
It can be killed by killing the host process.
Just wait and see ;)

+1 for creativity, but -1 for cheating.

Ha, but is it "guaranteed that it starts again" if it never stops?

That's why I said I probably be breaking the rule. It's the philosophical beauty of infinity that you can assume that anything can happen after that. Turing machine works that way too.

-100 because I don't support you winning your own contest, especially on a technicality, but +101 because waiting for it to restart is the best procrastination excuse ever.

Well, you know, then while true; do sleep 1; done quilifies, doesn't it?

Visual Base 6 :)
Sub Main:Shell "cmd ping 1.1.1.1 -n 1 -w 500>nul&&"""&App.Path &"\"&App.EXEName& """":End Sub

To run, create a new project, add a module with this code, set the start-up object to "Sub Main", compile, and then run the executable.

More readable version:
Sub Main()
    Call Shell("cmd ping 1.1.1.1 -n 1 -w 3000 > nul && """ & App.Path & "\" & App.EXEName & """")
End Sub

VB6 is a real man's VB. The last of its kind!

Bash
echo -e "$(crontab -l)\n$(($(date "+%M")+1)) $(date '+%H %e %m * /repeat.sh')" | crontab -

Save this as repeat.sh in the / directory and give it execute permission.
It can be killed by deleting the file
This works by putting an entry in the crontab to run it 1 minute later.

JavaScript
Without "going to the network" when not necessary :-) JavaScript's event loop scheduling allows us to write programs that fulfill the given requirements very easily:
(function program() {
    // do what needs to be done
    setTimeout(program, 100);
})();

This "restarts" the program function at a 10-times-per-second pace. It is guaranteed by JavaScript's nature that only a single task will be running at the same  time, and it does not "restart the environment" as in "reload the page".

C + MPI Environment
mpifork.c:
#include <stdio.h>

main(int argc, char * argv[])
{
    srand(time(NULL));
    int host = rand()%(argc-1)+1;
    FILE * logFile = fopen("mpifork.log", "a");
    if(logFile == NULL){
        fprintf(stderr, "Error: failed to open log file\n");
    } else {
        fprintf(logfile, "Jumping to %s\n", argv[host]);

        char * args[argc+5];
        args[0] = "mpirun";
        args[1] = "-H";
        args[2] = argv[host];
        args[3] = argv[0];
        for(host = 0; host < argc-1; host++) args[host+4] = argv[host+1];
        args[argc+3] = NULL;

        execvp("mpirun", args);
        fprintf(stderr, "exec died\n");
        perror("execvp");
    }
}

You must have OpenMPI or some other MPI implementation installed. Compile with
mpicc -o mpifork mpifork.c

Now that I think about it, there's no reason you have to use mpicc - gcc or whatever compiler will work. You just have to have mpirun.
gcc -o mpifork mpifork.c

To run it, you should probably include the full path name, and include a list of hosts. For example, I added some entries in /etc/hosts that all pointed to localhost, and ran it like this:
/home/phil/mpifork localhost localhost1 localhost2 localhost3 localhost4

The executable must be in the same directory on any machine that you want to run this on.

Essentially, this takes a list of hosts provided on the command line, selects one of the hosts, and launches the executable on the target host with the same arguments. If everything goes perfectly, mpirun will call itself over and over on different machines (or the same machine if you only provide 'localhost'. The executable itself (mpifork) does terminate - after calling execvp, it is no longer executing on the first machine.
If you wanted to be evil, you could instead make this launch on every machine, by including the full list of hosts that is provided on the command line in args. That would re-spawn a copy of itself on every machine, over and over - a cluster forkbomb.
However, in this form, I'm pretty sure this satisfies the rules.

HTML / JAVASCRIPT
HTML FILE a.html
<script>window.location = "a.html"</script>

Bash
Longer than it has to be, but I'm tired, and don't care :)
while true; do sleep 1; done; bash $0;

You said that it has to restart itself when it finishes, you didn't specifically say that it had to do so repeatedly, or indefinitely.  Also, you said that it should never have two instances running at once... it never will.
;)
There are any great number of ways to do this.  My personal favorite, would be to do something like send a packet somewhere distant, and then (via any number of methods), have the response trigger the process.

Technically, the sleep process restarts when it finishes

If the program is a program that restarts itself, then it is implied that it has to do so indefinitely -- otherwise it is restarting something else that isn't itself.

@Jason C: Without getting too philosophical, to the extent that it possibly can, it does restart itself.  We could debate how complex it has to be to truly restart itself, but I think that's well beyond what the author meant.  Though, if you want it to really restart itself, then it would probably be something that uses goto, or JMP, or whatever construct your language may offer, to go back to the start, so it's "restarting" itself. Otherwise, it's just executing something that is distinctly like itself. But then someone will likely take issue that that's not truely restarting. So I digress.

Android:
An alarm will restart the Activity after 1 second
public class AutoRestart extends Activity
{

@Override
public void onCreate()
{
    finish();
}

@Override
public void onDestroy() {

    Intent restartServiceIntent = new Intent(getApplicationContext(), this.getClass());
    restartServiceIntent.setPackage(getPackageName());

    PendingIntent restartServicePendingIntent = PendingIntent.getService(getApplicationContext(), 1, restartServiceIntent, PendingIntent.FLAG_ONE_SHOT);
    AlarmManager alarmService = (AlarmManager) getApplicationContext().getSystemService(Context.ALARM_SERVICE);
    alarmService.set(
            AlarmManager.ELAPSED_REALTIME,
            SystemClock.elapsedRealtime() + 1000,
            restartServicePendingIntent);

    super.onDestroy();
}

}

x86 Assembly
Not entirely sure this fits your criteria as it doesn't spawn a new process, but here it is anyway.
The program will show a message box, allocate some memory, copy its own code section into the allocated memory, and then jump to that location starting the cycle over. It should run until malloc fails.
format PE GUI 4.0
entry a

include 'include/win32a.inc'

section '.text' code readable executable

    a:
        push    0
        push    _caption
        push    _message
        push    0
        call    [MessageBoxA]

        push    b-a
        call    [malloc]

        push    b-a
        push    a
        push    eax
        call    [memcpy]

        call    eax
    b:

section '.data' data readable writeable

    _caption db 'Code challenge',0
    _message db 'Hello World!',0

section '.idata' import data readable writeable

    library user,'USER32.DLL',\
        msvcrt,'msvcrt.dll'

    import user,\
        MessageBoxA,'MessageBoxA'

    import msvcrt,\
        malloc,'malloc',\
        memcpy,'memcpy'

Compiled with fasm.

Since it is part of your program to call the newly copied code, so technically your program never finished at all.

From a low level viewpoint, the same could be said of all the programs here.  :-)

@BrianKnoblauch I disagree. The most interesting answers here seem to modify the system environment so that a new copy of the process is started some time after the first one is killed. For example, I would think that creating a chron job to run the process in the future would be a good way of letting the process completely die, then be restarted.

@BrianKnoblauch Not really. A process is an operating system construct (which these days - as in since the advent of protected mode in the 286 in 1982 - is also backed by hardware via virtual address spaces and protected memory). When it ends, all that info goes away. While it wasn't stated explicitly in the challenge, I take the spirit of the challenge to mean that "restart" implies that a new process ID is assigned.

Well, I would give +1 if you managed to free the memory on the way (please ping me by @ once you manage, since I likely won't keep my eye on it).

Linux upstart init
Given the strictest reading of the question, I think this is impossible.  In essence it is asking for a program to spontaneously start with the help of no other running programs.
There are some at and chron-based answers, but with the strictest reading, atd and anacron are supplementary programs which are running all the time, so they may be disqualified.
A related approach, but a little lower level is to use Linux's init.  As root, add this .conf file to /etc/init/:

description "forever"

start on runlevel [2345]
stop on runlevel [!2345]

respawn

exec sleep 10

Then have init re-read its .conf files:
sudo telinit 5

This will start a sleep process which will live for 10 seconds, then exit.  init will then respawn the sleep once it detects the previous one has gone away.
Of course this is still using init as a supplementary program.  You could argue that init is a logical extension of the kernel and will always be available in any Linux.
If this is not acceptable, then I guess the next lower-level thing to do would be to create a kernel module which respawns a userspace process (not sure how easy that is).  Here it can be argued that the kernel is not a process, and therefore not a program (supplementary).  On the other hand, the kernel is a program in its own right, from the point of the CPU.

TI-BASIC: 5 characters
call it prgmA
:prgmA

I can count 6 chars. Is there anything special about counting TI-BASIC program size?

The : is just the start of line symbol whenever you're programming in TI-basic. It's not something you type in, it's just there in the editor.

Isn't that recursive invocation? Try incrementing A and using a value of it as a base case, you'll see it stepping out eventually.

Well all variables are globals in ti-basic, so I'm not sure. It might be

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


text:
Hidden easter egg
Here's a fun idea:
Write a simple game (tic-tac-toe, guess the number, etc) that has an easter egg in it, that can be triggered by a specific, special input from the user and does something cool, but the code for the game does not appear to contain any easter eggs (or any obviously obfuscated code) at first glance.
This is a popularity contest, so highest vote by the community wins.

Nice idea, but you should have more specific requirements.  Please use the sandbox on meta to refine your question, then repost it.

I think the question is too clear: a simple game with an easter egg.

TI-BASIC
Lock Screen for your TI-84 calculator
:Repeat Str1="PASSWORD"
:Input Str1
:End

First one to find the egg gets a chicken ;)