text:
Tic Tac Tae Toe
(Better known as 3D Tic Tac Toe; I just made up a name that sounded catchy ;-) )
Let two people play this game against each other.
Specifications:

Output

the easiest way of explaining this will be with an example:
+-+-+-+-+
|X| | | |
+-+-+-+-+
| |O| | |
+-+-+-+-+
| | | | |
+-+-+-+-+
|O| | | |
+-+-+-+-+

+-+-+-+-+
| | | | |
+-+-+-+-+
| |X| | |
+-+-+-+-+
| | | |O|
+-+-+-+-+
| | | | |
+-+-+-+-+

+-+-+-+-+
| | | | |
+-+-+-+-+
| |O| | |
+-+-+-+-+
|O| |X| |
+-+-+-+-+
| | | |X|
+-+-+-+-+

+-+-+-+-+
| | | | |
+-+-+-+-+
| | | | |
+-+-+-+-+
| | | | |
+-+-+-+-+
| | | |X|
+-+-+-+-+

in this case X has won (top left corner of layer #1 to bottom right corner of layer #2)
it is also okay to display the four layers horizontally, with one space between them
grids may be non-text; in this case you must represent a third dimension in a reasonable way; see also scoring section below
after each player's turn, output "{player} wins" if a player wins, "tie" if the board fills up and nobody has won, or the board if the game is not over yet (or notifiy the user of a win/tie in a reasonable way)

Input

xyz coordinates, 0-based
example: input 031 is this location:
+-+-+-+-+
| | | | |
+-+-+-+-+
| | | | |
+-+-+-+-+
| | | | |
+-+-+-+-+
| | | | |
+-+-+-+-+

+-+-+-+-+
| | | | |
+-+-+-+-+
| | | | |
+-+-+-+-+
| | | | |
+-+-+-+-+
|X| | | |
+-+-+-+-+

+-+-+-+-+
| | | | |
+-+-+-+-+
| | | | |
+-+-+-+-+
| | | | |
+-+-+-+-+
| | | | |
+-+-+-+-+

+-+-+-+-+
| | | | |
+-+-+-+-+
| | | | |
+-+-+-+-+
| | | | |
+-+-+-+-+
| | | | |
+-+-+-+-+

alternate between X and O, starting with X, and prompt the user with the text "{player}'s turn: "

Winning condition

a player wins if the player gets 4 of their symbol (X or O) in a row, horizontally, vertically, or diagonally. For example, these are all wins (in the input format I have specified) if a player has played any of them:
000, 001, 002, 003
120, 130, 100, 110
000, 110, 220, 330
300, 122, 033, 211

Scoring

[ws] 10 base points for a working solution
[gr] +20 points if you have a graphical (meaning non-text) grid

[cc] +30 points if you can click on a cell to go there

[cp] +20 points for building a computer player to play against

[ai] +10 to 100 points for how good the AI is (judged by me)
[ot] +15 points if you can choose between one and two player

[ex] +3 points for each interesting or confusing thing in your code that you explain in your answer (interesting, so don't say "n++ adds one to n" and expect to get 3 points. just be reasonable.)

for example, you could say "I used [a,b,c].map(max).sum%10 because it takes the foos and converts them into a bar, because {{insert explanation here}}, which I use to frob the baz."
if you golf part of or all of your code, you will of course find many more interesting things to explain, but golfing is not required.

[wl] +10 points for showing the winning line, for example "000 001 002 003," or highlighting the squares in some way (if you're using a GUI)
+5 points for every upvote (this is the popularity-contest part)
downvotes don't count
include your score in the answer by using the IDs I have placed for the bonuses

example: 10 [ws] + 20 [gr] + 20 [cp] = 50
don't include upvotes since those change often; I will count those myself

I will accept the highest scored answer in one week; if a higher scored answer appears I will accept it
if two answers tie, the earlier posted answer will win

So this is in essential Qubic?

@JohannesKuhn I suppose; that seems to be another version of 3D tic tac toe which I mentioned in the question

Is the output format strict or would any readable representation of four planes suffice?

Doesn't this make more sense as a code-challenge?  In code golf, there will be so many parameters (with 1 letter names) that the code will be unreadable.

@Fors No, the output must be in that format.

@David Maybe; if this process to be too unreadable or difficult as a code golf, I might make it a coffee challenge (but then I would have to make it a bit harder... ;-) )

@DavidCarraher I made it a [tag:code-challenge]

Good idea.  Hopefully you'll have several attempts.

@Doorknob you talk about a graphical grid; if we do that, do we need to allow textual input?

@Doorknob So far, the program looks huge (and I'm not near finished...). ~250 lines. I've never seen an answer on this stackexchange site that large.

@Quincunx http://codegolf.stackexchange.com/questions/4838/most-complex-hello-world-program-you-can-justify :P

@Quincunx You can allow textual input, or you can allow input by clicking a square to go there (by the [cc] bonus, you would get 30 extra points for that)

can I not output anything if the game is not finished? Also, can I choose what form to output "wins" or "ties"?

HTML/CSS/JS+JQuery
10[ws] + 20[gr] + 30[cc] + 20[cp] + ?[ai] + 15[ot] + 10[wl] + ?[ex] = 105+
Finished the AI, though a really crappy one.

"Is there any way to make it play itself?"
  "Yes. Number of players: zero."

For those who don't get the reference: http://www.youtube.com/watch?v=NHWjlCaIrQo
* sign* It's much less cool of a reference now that I have explained it...
JSFiddle

AI
The AI logic goes like this:

If there is a winning move for me, take it.
If there is a winning move for opponent, block it.
Take the "best" unoccupied corner.
Take a random unoccupied space.

HTML
X's turn

JS
var currentPlayer = true, end = false, players = parseInt(prompt('Number of players":'));

function cell(x,y,z){return $('td').eq(x*16+y*4+z);}
function f(i,x){switch(x){case -1: return i; case -2: return 3-i; default: return x;}}
function line(x,y,z){
    var t = $();
    for(var i=0; i<4; i++) t = t.add(cell(f(i,x),f(i,y),f(i,z)));
    return t;
}
function check(x,y,z,t){
    var u = line(x,y,z);
    if(u.map(function(){return $(this).text()==t;}).get().reduce(function(a,b){return a&&b;})) u.css({color: 'red'});
    else return false;
    return end = true;
}
function move(x,y,z){
    if(end) return false;
    var t = currentPlayer?'X':'O';
    cell(x,y,z).text(t);
    if(check(-1,y,z,t)) return true;
    if(check(x,-1,z,t)) return true;
    if(check(x,y,-1,t)) return true;
    if(check(x,-1,-1,t)) return true;
    if(check(x,-1,-2,t)) return true;
    if(check(-1,y,-1,t)) return true;
    if(check(-1,y,-2,t)) return true;
    if(check(-1,-1,z,t)) return true;
    if(check(-1,-2,z,t)) return true;
    if(check(-1,-1,-1,t)) return true;
    if(check(-2,-1,-1,t)) return true;
    if(check(-1,-2,-1,t)) return true;
    if(check(-1,-1,-2,t)) return true;
    currentPlayer = !currentPlayer;
    $('span').text(currentPlayer?'X':'O');
    if(players==2||players==1&&currentPlayer) return false;
    else return ai();
}

function ai_tri(x1,y1,z1,x2,y2,z2,t){
    var u = false;
    for(var i=0;i<4;i++) for(var j=0;j<4;j++)
        if(x1==x2){
            if(cell(x1,i,j).text()==t)
                if(i==y2&&(j==1||j==2) || j==z2&&(i==1||i==2))
                    if(u) return false;
                    else u = true;
                else return false;
        }else if(y1==y2){
            if(cell(i,y2,j).text()==t)
                if(i==x2&&(j==1||j==2) || j==z2&&(i==1||i==2))
                    if(u) return false;
                    else u = true;
                else return false;
        }else{
            if(cell(i,j,z1).text()==t)
                if(i==x2&&(j==1||j==2) || j==y2&&(i==1||i==2))
                    if(u) return false;
                    else u = true;
                else return false;
        }
    return true;
}
function ai_tri2(x1,y1,z1,x2,y2,z2,t){
    var u = false;
    for(var i=0;i<4;i++) for(var j=0;j<4;j++)
        if(x1!=x2){
            if(cell(i,j,j).text()==t)
                if(j==y2&&(i==1||i==2) || i==x2&&(j==1||j==2))
                    if(u) return false;
                    else u = true;
                else return false;
        }else if(y1!=y2){
            if(cell(j,i,j).text()==t)
                if(i==z2&&(j==1||j==2) || j==y2&&(i==1||i==2))
                    if(u) return false;
                    else u = true;
                else return false;
        }else{
            if(cell(j,j,i).text()==t)
                if(i==x2&&(j==1||j==2) || j==z2&&(i==1||i==2))
                    if(u) return false;
                    else u = true;
                else return false;
        }
    return true;
}
function ai_cn(x,y,z,t){
    return ai_tri(x,y,z,x,!y*3,!z*3,t) + ai_tri(x,y,z,!x*3,y,!z*3,t) + ai_tri(x,y,z,!x*3,!y*3,z,t) + ai_tri2(x,y,z,!x*3,y,z,t) + ai_tri2(x,y,z,x,!y*3,z,t) + ai_tri2(x,y,z,x,y,!z*3,t) + ai_tri(!x*3,y,z,x,!y*3,z,t) + ai_tri(!x*3,y,z,x,y,!z*3,t) + ai_tri(x,!y*3,z,!x*3,y,z,t) + ai_tri(x,!y*3,z,x,y,!z*3,t) + ai_tri(x,y,!z*3,!x*3,y,z,t) + ai_tri(x,y,!z*3,x,!y*3,z,t) + ai_tri2(x,!y*3,!z*3,!x*3,!y*3,!z*3,t) + ai_tri2(!x*3,y,!z*3,!x*3,!y*3,!z*3,t) + ai_tri2(!x*3,!y*3,z,!x*3,!y*3,!z*3,t);
}
function ai_check(x,y,z,t){
    var v = [$(),$(),$()], u = line(x,y,z);
    $.each(u.map(function(){return $(this).text();}).get(),function(i,e){if(e=='X') v[0]=v[0].add(u.eq(i)); else if(e=='O') v[1]=v[1].add(u.eq(i)); else v[2]=v[2].add(u.eq(i));});
    if((t==='X'?v[0]:v[1]).length==3 && v[2].length==1) return [true,v[2]];
    else if((t==='X'?v[1]:v[0]).length==3 && v[2].length==1) return [false,v[2]];
    else return null;
}
function ai_check_all(t){
    var u = null, v = null;
    for(var i=0;i<4;i++){
        for(var j=0;j<4;j++){
            if((u=ai_check(i,j,-1,t))!==null) if(u[0] || v!==null) return u[1]; else v = u[1];
            if((u=ai_check(i,-1,j,t))!==null) if(u[0] || v!==null) return u[1]; else v = u[1];
            if((u=ai_check(-1,i,j,t))!==null) if(u[0] || v!==null) return u[1]; else v = u[1];
        }
        if((u=ai_check(i,-1,-1,t))!==null) if(u[0] || v!==null) return u[1]; else v = u[1];
        if((u=ai_check(i,-1,-2,t))!==null) if(u[0] || v!==null) return u[1]; else v = u[1];
        if((u=ai_check(-1,i,-1,t))!==null) if(u[0] || v!==null) return u[1]; else v = u[1];
        if((u=ai_check(-1,i,-2,t))!==null) if(u[0] || v!==null) return u[1]; else v = u[1];
        if((u=ai_check(-1,-1,i,t))!==null) if(u[0] || v!==null) return u[1]; else v = u[1];
        if((u=ai_check(-1,-2,i,t))!==null) if(u[0] || v!==null) return u[1]; else v = u[1];
    }
    if((u=ai_check(-1,-1,-1,t))!==null) if(u[0] || v!==null) return u[1]; else v = u[1];
    if((u=ai_check(-1,-1,-2,t))!==null) if(u[0] || v!==null) return u[1]; else v = u[1];
    if((u=ai_check(-1,-2,-1,t))!==null) if(u[0] || v!==null) return u[1]; else v = u[1];
    if((u=ai_check(-2,-1,-1,t))!==null) if(u[0] || v!==null) return u[1]; else v = u[1];
    return v;
}
function ai(){
    var t1 = currentPlayer?'X':'O', t2 = currentPlayer?'O':'X', u = [0,0,0,0], v = 0, w = ai_check_all();
    if(w!==null) return move(w.closest('table').index(),w.closest('tr').index(),w.index());
    for(var i=0;i<4;i+=3) for(var j=0;j<4;j+=3) for(var k=0;k<4;k+=3)
        if(cell(i,j,k).text()==='' && (v=ai_cn(i,j,k,t2))>u[3]) u = [i,j,k,v];
    if(u[3]>0) return move(u[0],u[1],u[2]);
    u = $('td').filter(function(){return $(this).text()=='';});
    if(u.length===0) return end = true;
    w = u.eq(Math.floor(Math.random()*u.length));
    return move(w.closest('table').index(),w.closest('tr').index(),w.index());
}

$('table').on('click','td',function(){
    if(end || $(this).text() !== '') return true;
    move($(this).closest('table').index(),$(this).closest('tr').index(),$(this).index());
});

if(players == 0) ai();

CSS
body{font-family: Arial, san-serif;}
table{float:left; margin-right: 20px; border-collapse: collapse;}
td{width:20px; height:20px; border:1px solid black; text-align: center;}

Wow, very nice! Looking forward to seeing the AI :) +1

Why are corners inherently better than other spaces?

Java
10[ws] + 20[gr] + 30[cc] + 4*3[ex] = 72
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.event.MouseEvent;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
import javax.swing.event.MouseInputListener;

public class Game {

    public static void main(String[] args) {
        //Initial threads
        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                new Game();
            }
        });
    }
    JFrame frame;
    Grid grid;

    Game() {
        grid = new Grid();
        frame = new JFrame("Tic Tac Tae Toe");

        frame.add(grid);

        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.pack();
        frame.setVisible(true);
    }
}

class Grid extends JPanel implements MouseInputListener {

    static final int BEGIN_X = 50, BEGIN_Y = 50;
    static final int GAP = 50;
    static final int TILE_WIDTH = 40;
    XO[][][] grid;
    int lastX, lastY, lastZ;
    int mouse_x, mouse_y;
    JLabel turn;
    boolean won;

    public Grid() {
        // Just because. I felt like copy-paste.
        grid = new XO[][][]{
            {
                {XO.N, XO.N, XO.N, XO.N},
                {XO.N, XO.N, XO.N, XO.N},
                {XO.N, XO.N, XO.N, XO.N},
                {XO.N, XO.N, XO.N, XO.N}
            },
            {
                {XO.N, XO.N, XO.N, XO.N},
                {XO.N, XO.N, XO.N, XO.N},
                {XO.N, XO.N, XO.N, XO.N},
                {XO.N, XO.N, XO.N, XO.N}
            },
            {
                {XO.N, XO.N, XO.N, XO.N},
                {XO.N, XO.N, XO.N, XO.N},
                {XO.N, XO.N, XO.N, XO.N},
                {XO.N, XO.N, XO.N, XO.N}
            },
            {
                {XO.N, XO.N, XO.N, XO.N},
                {XO.N, XO.N, XO.N, XO.N},
                {XO.N, XO.N, XO.N, XO.N},
                {XO.N, XO.N, XO.N, XO.N}
            }
        };

        lastX = -1;
        lastY = -1;
        lastZ = -1;
        won = false;

        turn = new JLabel("X");

        add(turn);

        this.setPreferredSize(new Dimension(2 * BEGIN_X + 4 * TILE_WIDTH,
                2 * BEGIN_Y + 4 * (4 * TILE_WIDTH + GAP) - GAP));
        this.addMouseListener(this);
        this.addMouseMotionListener(this);
    }

    public XO determineWinner() {
        XO type = grid[lastZ][lastY][lastX];

        //start on same z-plane

        for (int x = 0; x < 4; x++) {
            if (grid[lastZ][lastY][x] != type) {
                break;
            }
            if (x == 3) {
                return type; //type won!
            }
        }
        for (int y = 0; y < 4; y++) {
            if (grid[lastZ][y][lastX] != type) {
                break;
            }
            if (y == 3) {
                return type; //type won!
            }
        }
        //first diagonal
        if (lastX == lastY) {
            for (int x = 0, y = 0; x < 4; x++, y++) {
                if (grid[lastZ][y][x] != type) {
                    break;
                }
                if (x == 3) {
                    return type; //type won!
                }
            }
        } //second diagonal
        else if (lastX == 3 - lastY) {
            for (int x = 0, y = 3; x < 4; x++, y--) {
                if (grid[lastZ][y][x] != type) {
                    break;
                }
                if (x == 3) {
                    return type; //type won!
                }
            }
        }
        //first plane finished
        //now onto changing z's
        //vertical column
        for (int z = 0; z < 4; z++) {
            if (grid[z][lastY][lastX] != type) {
                break;
            }
            if (z == 3) {
                return type; //type won!
            }
        }
        //descending y. note: descending means stair-like (diagonal)
        if (lastZ == lastY) {
            for (int z = 0, y = 0; z < 4; z++, y++) {
                if (grid[z][y][lastX] != type) {
                    break;
                }
                if (z == 3) {
                    return type; //type won!
                }
            }
        } //ascending y
        else if (lastZ == 3 - lastY) {
            for (int z = 0, y = 3; z < 4; z++, y--) {
                if (grid[z][y][lastX] != type) {
                    break;
                }
                if (z == 3) {
                    return type; //type won!
                }
            }
        } //ascending x. note: ascending means stair-like, but other way
        if (lastZ == 3 - lastX) {
            for (int z = 0, x = 3; z < 4; z++, x--) {
                if (grid[z][lastY][x] != type) {
                    break;
                }
                if (z == 3) {
                    return type; //type won!
                }
            }
        } //descending x
        else if (lastZ == lastX) {
            for (int z = 0, x = 0; z < 4; z++, x++) {
                if (grid[z][lastY][x] != type) {
                    break;
                }
                if (z == 3) {
                    return type; //type won!
                }
            }
        }

        //diagonals, changing all three
        if (lastZ == lastX && lastZ == lastY) {
            for (int z = 0, x = 0, y = 0; z < 4; z++, x++, y++) {
                if (grid[z][y][x] != type) {
                    break;
                }
                if (z == 3) {
                    return type; //type won!
                }
            }
        } else if (3 - lastZ == lastX && 3 - lastZ == lastY) {
            for (int z = 3, x = 0, y = 0; z < 4; z--, x++, y++) {
                if (grid[z][y][x] != type) {
                    break;
                }
                if (x == 3) {
                    return type; //type won!
                }
            }
        } else if (lastZ == lastX && lastZ == 3 - lastY) {
            for (int z = 0, x = 0, y = 3; z < 4; z++, x++, y--) {
                if (grid[z][y][x] != type) {
                    break;
                }
                if (z == 3) {
                    return type; //type won!
                }
            }
        } else if (lastZ == 3 - lastX && lastZ == lastY) {
            for (int z = 0, x = 3, y = 0; z < 4; z++, x--, y++) {
                if (grid[z][y][x] != type) {
                    break;
                }
                if (z == 3) {
                    return type; //type won!
                }
            }
        }

        //check for tie
        out: for (int z = 0; z < 4; z++){
            for (int y = 0; y < 4; y++){
                for (int x = 0; x < 4;x++){
                    if (grid[z][y][x] == XO.N){
                        break out;
                    }
                }
            }
            if (z == 3){
                return XO.N;
            }
        }

        return null;
    }

    @Override
    public void paintComponent(Graphics graphics) {
        super.paintComponent(graphics);

        Graphics2D g = (Graphics2D) graphics;
        g.setColor(Color.BLACK);

        //Looks a little nicer, but this could be left out.
        g.setFont(new Font("Courier New", Font.BOLD, 20));

        //paint grid rectangles.
        for (int z = 0; z < 4; z++) {
            int begin_y = BEGIN_Y + z * (4 * TILE_WIDTH + GAP);

            //draw left line
            g.drawLine(BEGIN_X, begin_y,
                    BEGIN_X, begin_y + 4 * TILE_WIDTH);

            //draw bottom line
            g.drawLine(BEGIN_X, begin_y + 4 * TILE_WIDTH,
                    BEGIN_X + 4 * TILE_WIDTH, begin_y + 4 * TILE_WIDTH);

            for (int y = 0; y < 4; y++) {
                for (int x = 0; x < 4; x++) {
                    //draw individual grid lines
                    g.drawLine(BEGIN_X + (x + 1) * TILE_WIDTH, begin_y + y * TILE_WIDTH,
                            BEGIN_X + (x + 1) * TILE_WIDTH, begin_y + (y + 1) * TILE_WIDTH);
                    g.drawLine(BEGIN_X + x * TILE_WIDTH, begin_y + y * TILE_WIDTH,
                            BEGIN_X + (x + 1) * TILE_WIDTH, begin_y + y * TILE_WIDTH);

                    //if this was the last chosen square...
                    if (lastX == x && lastY == y && lastZ == z) {
                        g.setColor(Color.ORANGE);
                        //fill it orange! (not required, but I think it looks nice)
                        g.fillRect(BEGIN_X + x * TILE_WIDTH + 1,
                                begin_y + y * TILE_WIDTH + 1,
                                TILE_WIDTH - 1, TILE_WIDTH - 1);
                        g.setColor(Color.BLACK);
                    }

                    //if mouse is over this square...
                    if ((BEGIN_X + x * TILE_WIDTH) < mouse_x
                            && (BEGIN_X + (x + 1) * TILE_WIDTH) > mouse_x
                            && (begin_y + y * TILE_WIDTH) < mouse_y
                            && (begin_y + (y + 1) * TILE_WIDTH) > mouse_y) {
                        g.setColor(new Color(100, 100, 255));
                        //fill it blue! (not required, but I think it looks nice)
                        g.fillRect(BEGIN_X + x * TILE_WIDTH + 1,
                                begin_y + y * TILE_WIDTH + 1,
                                TILE_WIDTH - 1, TILE_WIDTH - 1);
                        g.setColor(Color.BLACK);
                    }

                    //paint value of tile
                    g.drawString(grid[z][y][x].val,
                            BEGIN_X + x * TILE_WIDTH + TILE_WIDTH / 2,
                            begin_y + y * TILE_WIDTH + TILE_WIDTH / 2);

                }
            }
        }
    }

    @Override
    public void mouseClicked(MouseEvent e) {
        if (!won) {
            int x = e.getX(), y = e.getY();
            x -= BEGIN_X;
            x /= TILE_WIDTH;

            y -= BEGIN_Y;

            int z = 0;
            while (y > 4 * TILE_WIDTH) {
                z++;
                y -= 4 * TILE_WIDTH + GAP;
            }

            y /= TILE_WIDTH;

            //**********************************
            //DOES NOT ALWAYS GET PAST HERE!
            //**********************************
            if (x < 0 || y < 0 || z < 0 || x >= 4 || y >= 4 || z >= 4) {
                return;
            }
            if (grid[z][y][x] == XO.N) {
                grid[z][y][x] = XO.valueOf(turn.getText());
            } else {
                return;
            }

            lastX = x;
            lastY = y;
            lastZ = z;

            XO who_won = determineWinner();
            if (who_won == null){
                if (turn.getText().equals("X")) {
                    turn.setText("O");
                } else {
                    turn.setText("X");
                }
            }
            else if (who_won != XO.N) {
                turn.setText(who_won.toString() + " wins");
            } else{
                turn.setText("tie");
            }
            repaint();
        }
    }

    @Override
    public void mousePressed(MouseEvent e) {
    }

    @Override
    public void mouseReleased(MouseEvent e) {
    }

    @Override
    public void mouseEntered(MouseEvent e) {
    }

    @Override
    public void mouseExited(MouseEvent e) {
    }

    @Override
    public void mouseDragged(MouseEvent e) {
    }

    @Override
    public void mouseMoved(MouseEvent e) {
        mouse_x = e.getX();
        mouse_y = e.getY();
        repaint();
    }
}

enum XO {

    X("X"), O("O"), N(" ");
    String val;

    XO(String c) {
        val = c;
    }
}

This is a working solution, but I will work on it a lot more.
[ex]:

runs using Initial Threads
informs player's whose turn it is (letter at top of window, will be improved) using a JLabel called turn. This label is also used to say who won.
shows the last move by storing the last x, y and z values and painting the corresponding square orange during paintComponent()
shows the location of the mouse pointer (blue square) by computing it during paintComponent()

Screenshot:

your explanations are not explanations... except for the first one, maybe. all you're doing is saying what your program does. you actually have to explain how it works... +1 anyway for being the first answer :D

@Doorknob do the comments in code count? For example, I have many comments in my "check if won" algorithm. They don't make sense separate from the code.

just put [ex] next to the interesting comments or something and refer to them in your post I guess

Right now I feel like stealing your answer and redo it in groovy :) Groovy is essentially Java (and uses Java libraries), but with shorter syntax, ie. for (int z = 0; z < 4; z++) can be written as for (z in 0..3)

@Fels Why do you feel so? First, doing so is exactly what you said: stealing. Second, it is more fun to code it yourself. If you happen to end up with the same code, the good. Third, my code is not optimal.

Ti-Basic 84
10[ws]+20[gr]+20[cp]+10[ai]+15[ot]+3[ex]=78
Programmable and playable from a Ti-84 calculator. +100?
Also, -> represents the STO-> button.
:Disp LOOKS-LIKE-THIS-MIGHT-BE-SOMETHING-INTERESTING-IN-THE-CODE
:ClrHome
:Disp "TIC TAC TAE TOE"
:Disp "HOW MANY PLAYERS"
:Input P
:If P=1 :Disp "YOUR OPPONENTS NAME IS AI BOB"
:If P=2 :Disp "YOUR OPPONENTS NAME IS AI BOB EVEN THOUGH YOU WANT TO PLAY TWO PLAYERS"
:Horizontal -10
:Horizontal -5
:Horizontal 0
:Horizontal 5
:Horizontal 10
:Vertical -10
:Vertical -5
:Vertical 0
:Vertical 5
:Vertical 10
:0->A
:Lbl M
:Disp "YOUR MOVE X-POS"
:Input X
:Disp "YOUR MOVE Y-POS"
:Input Y
:Circle(2,X,Y)
:Circle(2,rand,rand)
:Disp "UGH, HE DIDNT ALIGN IT CORRECTLY"
:Disp "YOU MIGHT WANT TO STOP PLAYING"
:If A=>4 :Goto W
:If A<4 :A+1->A
:Goto M
:Lbl W
:Disp "HAVE YOU WON, 1 IS YES, 0 IS NO"
:Input W
:If W=1 :Goto E
:Goto M
:Lbl E
:Disp "YOU HAVE WON! GOOD JOB!"
:Disp "ENTER TO EXIT"
:Pause

Something interesting: the line of code at the beginning (:Disp LOOKS-LIKE-THIS-MIGHT-BE-SOMETHING-INTERESTING-IN-THE-CODE) prints 0 and then is immediately cleared from the screen.
Feel free to give me more points for my AI's skill, but I'm pretty sure you'll stick with 10.

...you can't ask the player if he has won. That's obviously cheating. You didn't display the grid correctly either. You can't choose between one and two player. Pretty sure this is a joke, but still... -1

@Doorknob The grid actually displays

but you don't even display any of the symbols! this is clearly a wrong answer, even though I don't know any TI-basic at all

@Doorknob A circle represents O

okay, but you're just displaying the circle in a random position and you're not even displaying any of the symbols correctly at all. commenting further seems pointless, so I'm just going to stop now

@Doorknob You don't have to reply, but for other people - it actually asks you where you want to place your move, both X and Y, then draws it there.

just for future readers: it doesn't even remember where you placed it... and it never shows the opponent's symbol... and it's just... not even a game (this is my last comment here :P)

@FutureReaders The calculator knows where you place it (it just has short term memory)


text:
Generate a 5-pointed star
Your challenge is generate a 5 pointed star like below. The star doesn't need to be filled.
Shortest code wins.

Your image shows a Five-pointed-star, a pentagram has the connecting lines.

"Don't need to be filled" means that it can be filled? And, how are we defining "filled"? In the case of a pentagram, as Johannes has mentioned, there would normally be lines on the inside which create a pentagon across the inside-facing points. Would that qualify, or is an answer only valid if the star is either completely filled or a perfect outline?

@Iszi Looks like shortest question wins.

wingdings, 1: « (character 0xAB), or unicode: Pentagram: ⛤ U+26E4 ⛤ New in Unicode 6

@SeanC Forbidden loopholes. Graphics using unicode is forbidden by default.

@SIGSEGV, challenge doesn't exclude standard loopholes

@SeanC They're standard. That means you don't have to specifically state they are disallowed.

Love how the top voted answer is a Unicode star, but mines invalid due to floating point limitations of graphics in Java ._.

@mbomb007, but the standard loopholes were not discussed until after this question was asked:  First edit: asked Feb 22 '14 at 23:30

So? Meta discussions are often applied retroactively. The entire site is held to the same standards and cleaned up after the fact, rather than only new questions having to abide by new rules. This is because old questions can always be answered later.

@mbomb007, so I should now delete comments that were valid at the time, but now don't conform?

If you see them, yeah. We do that for questions already.

@mathe Is outputting the unicode character allowed?

@SIGSEGV There is no loophole for that in the standard loopholes thread.

PHP, 1 character
Although very short it will probably not become the accepted answer.
☆

(this is U+2606). May work also in other languages (untested).

interestingly, my JRuby console and my phone render this as a real five-pointed star, but my Chrome/Win7 renders this as an ordinary (five-pointed) asterisk, which is filled and nowhere as straight-edged as the star it is supposed to be.

@Jan I get the correct star on chrome/win7 and my android phone

oh, wait, I do get a real star, but it's so small it looks a bit like an asterisk. Never mind...

This is 2 bytes, is it not?

Also, this answer is invalid, because the challenge is [graphical-output], not [ascii-art].

@mbomb007 Character glyphs are hardly ASCII art.

So it's unicode. Either way, it's not valid.

@mbomb007 I'm not nitpicking because you said ASCII. ASCII art uses several characters to resemble a shape; this is different. Provided that a proper font is used, this prints the desired output in a terminal or a web browser, so I fail to see why it would be invalid.

Because that's not in the spirit of the challenge. If every answer used print"☆" or some variant because it's the shortest, this wouldn't be a challenge.

@mbomb007 That's a flaw of the challenge, not the answer.

LOGO, 32 29 bytes
REPEAT 5[FW 9LT 144FW 9RT 72]

Run at logo.twentygototen.org

Actually you don't need spaces after the numbers (3 chars)

@Howard: thanks for the tip.

Can be shorter if you make the pentagram defined in the OP's link: REPEAT 5[FW 9LT 144]

VBA PowerPoint, 92 bytes
Sub s()
ActivePresentation.Slides(1).Shapes.AddShape msoShape5pointStar, 0, 0, 99, 99
End Sub

Because everything looks better in PowerPoint:

If you convert this to an immediates window function, convert msoShape5pointStar to its constant value (92) and remove the whitespace between the commas and values (ActivePresentation.Slides(1).Shapes.AddShape 92,0,0,99,99) you can condense the byte count to 57 bytes

Mathematica, 19 18 bytes
This is easy, using CirculantGraph.
I drew a pentagram as defined in the link the OP used.
5~CirculantGraph~2

A slightly longer way, but equally straightforward, is to use the curated "Lamina" entity. This returns a filled pentagram.
 "FilledPentagram"~LaminaData~"Image"

or
 EntityValue[Entity["Lamina","FilledPentagram"],"Image"]

Is the space actually necessary? I don't speak Mathematica, but I know many other languages would be forgiving of omitting the space in a circumstance such as this.

No, the space is not necessary. That's why I didn't count the space. Just about the only time space matters is inside a string and in the case of implicit multiplication (e.g. 3 5 == 15). "==" is equals in Mathematica.

One char less 5~CirculantGraph~2

Python 3, 137 bytes
Polar plot.
import pylab as P,numpy as N
S=N.sin
p=N.pi
a=.9*p
d=8e-4*p
A=lambda t:N.arange(0,t,d)
P.polar(A(4*p),list(S(a)/S(a-A(.8*p)))*5)
P.show()

import pylab as P,math as M;α=[4*M.pi*i/5for i in range(6)];A=[1]*6;P.polar(α,A);P.show() (89 chars) paints similar figure

@AMK nice, I see the trick. You could write it as a new answer.

Non-ASCII characters are not a single byte. Edited to make ASCII-only in order for the byte count to be correct.

Small Basic, 50 bytes
For i=1To 5
Turtle.Move(9)
Turtle.Turn(144)
EndFor

A verbose language, but it has built in turtle functionality. Slowly draws a very, very tiny pentagram.

HTML & CSS: 270 269 bytes

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:
Display Continued Fractions
Your challenge is to convert a positive rational number into a finite simple continued fraction., in 2D, with horizontal fraction bars separating numerator from denominator.  [A simple continued fraction only has numerators equal to 1.] Your solution should be able to represent a continued fraction with up to 8 terms.
Input: The rational number may be input in any format, including (but not restricted to)

string: "7/16"
list:  {7, 16}, (7, 16), [7, 16]
simple ordered pair: 7 16
function: f[7,16]
decimal number: 0.657

Output: A continued fraction, in 2D, with horizontal fraction bars separating numerator from denominator. Only continued fractions with numerators equal to 1 are valid. It is not necessary to make the font size vary according to depth. A leading zero (for proper fractions) is optional.
Depth: Your code must be able to display at least 8 levels of depth.
Winning criterion: Shortest code wins. You must include several test cases showing input and output.
Test Examples (Input followed by output)

Input
2D Output

\$\frac 5 4\$
\$1 + \cfrac 1 4\$

\$\frac 5 3\$
\$1 + \cfrac 1 {1 + \cfrac 1 2}\$

\$\frac 5 7\$
\$0 + \cfrac 1 {1 + \cfrac 1 {2 + \cfrac 1 2}}\$

\$\frac 9 {16}\$
\$0 + \cfrac 1 {1 + \cfrac 1 {1 + \cfrac 1 {3 + \cfrac 1 2}}}\$

\$\frac {89} {150}\$
\$0 + \cfrac 1 {1 + \cfrac 1 {1 + \cfrac 1 {2 +  \cfrac 1 {5 + \cfrac 1 {1 + \cfrac 1 {1 + \cfrac 1 2}}}}}}\$

what's the criteria for how deep you must go? for example, why can't we just do 0 + 89 / 250 for the last one?

I was presupposing that the only acceptable numerator was 1.  I'll add that.

ah okay, don't have much of a math background :) Wikipedia helped. How about languages that can't display things in this format? Is it okay if we do something like 0 + 1 / (1 + 1 / (1 + 1 / (2 + 1 / (3 + 1 / (1 + 1 / (1 + 1 / (2)))))))? What about without the parenthesis? Or if we just display the blue numbers, like 0 1 1 2 5 1 1 2?

Your notation appears to be mathematically correct.  But the main point of the challenge is to figure out a way to display the fraction in column and row format (which I referred to above loosely as 2D).

I know this is an old challenge but there are a couple of close votes now, so I'd like to say that "A continued fraction, in 2D, with horizontal fraction bars separating numerator from denominator." would need further specification by our modern standards.

Mathematica, 40 36 chars
f=If[⌊#⌋≠#,⌊#⌋+"1"/#0[1/(#-⌊#⌋)],#]&

Example:
f[89/150]

Output:

Python 2, 158 155 147 142
a,b=input()
c=[]
while b:c+=[a/b];a,b=b,a%b
n=len(c)
while b<n-1:print'  '*(n+b),'1\n',' '*4*b,c[b],'+','-'*(4*(n-b)-7);b+=1
print' '*4*b,c[b]

Test:
$ python cfrac.py
(89,150)
                 1
 0 + -------------------------
                   1
     1 + ---------------------
                     1
         1 + -----------------
                       1
             2 + -------------
                         1
                 5 + ---------
                           1
                     1 + -----
                             1
                         1 + -
                             2

Python 2, alt. version, 95
Basically a port of breadbox's answer. Safer output.
a,b=input();i=2
while a%b:print'%*d\n%*d + ---'%(i+5,1,i,a/b);a,b=b,a%b;i+=5
print'%*d'%(i,a/b)

Test:
$ python cfrac2.py
(98,15)
      1
 6 + ---
           1
      1 + ---
                1
           1 + ---
                7

+1 Good idea! Though there are problems if numbers greater than 9 are produced. Check, e.g., 40,3 as input.

XSLT 1.0
I thought it'd be nice to display the fractions with HTML, so here's an XSLT solution.
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                              xmlns:msxsl="urn:schemas-microsoft-com:xslt" >
  <xsl:template match="/f">
    <xsl:variable name="c" select="floor(@a div @b)"/>
    <xsl:variable name="next">
      <f a="{@b}" b="{@a mod @b}"/>
    </xsl:variable>

          <xsl:value-of select="$c"/>+

        1

          <xsl:apply-templates select="msxsl:node-set($next)"/>

  </xsl:template>
  <xsl:template match="/f[@a mod @b=0]">
    <xsl:value-of select="@a div @b"/>
  </xsl:template>
</xsl:stylesheet>

To test it, save the xslt as fraction.xslt and open the following file in IE:
<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet  href="fraction.xslt" type="text/xsl"?>
<f a="89" b="150"/>

I LOVE this solution. Nice work!

Ruby, 175 (with ASCII art) or 47 (without)
Without ASCII art, 47
n,d=eval gets
while d!=0
puts n/d
n,d=d,n%d
end

Since Ruby can't really do graphics like that, I just output the blue numbers in your examples.
c:\a\ruby>cont
[5,4]
1
4

c:\a\ruby>cont
[5,3]
1
1
2

c:\a\ruby>cont
[5,7]
0
1
2
2

c:\a\ruby>cont
[9,16]
0
1
1
3
2

c:\a\ruby>cont
[89,150]
0
1
1
2
5
1
1
2

With ASCII Art, 181 178 175
n,d=eval gets
a=[]
n,d=d,n%d,a.push(n/d)while d!=0
i=0
j=2*a.size-3
k=a.size-2
a.map{|x|puts' '*i+"#{x}+"+' '*k+?1
i+=2
k-=1
puts' '*i+?-*j
j-=2}rescue 0
puts' '*i+a.last.to_s

Wow, that ASCII art took up a lot of code, and I was even being evil and using rescue 0 :P Sample:
c:\a\ruby>cont
[89,150]
0+      1
  -------------
  1+     1
    -----------
    1+    1
      ---------
      2+   1
        -------
        5+  1
          -----
          1+ 1
            ---
            1+1
              -
              2

@DavidCarraher Ok, then it works. Edited

You output the partial quotients.  Although they are essential for formulating a continued fraction, they are only part of the requirement.

@DavidCarraher I suppose I could try some kind of ASCII art... there's really not much of a way to do this in Ruby.

@DavidCarraher Okay, I have to leave, but I'll work on making an ASCII representation of the fraction soon.

Great. I look forward to seeing the results of your effort.

@DavidCarraher Done! I edited it into the answer

C, 119 characters
n,d,r;main(i){for(scanf("%d%d",&n,&d);r=n%d;n=d,d=r,i+=5)
printf("%*d\n%*d + ---\n",i+5,1,i,n/d);printf("%*d\n",i,n/d);}

Here are some examples of output:
$ echo 15 98 | ./cfrac
     1
0 + ---
          1
     6 + ---
               1
          1 + ---
                    1
               1 + ---
                    7
$ echo 98 15 | ./cfrac
     1
6 + ---
          1
     1 + ---
               1
          1 + ---
               7
$ echo 98 14 | ./cfrac
7

While the truncated fraction line isn't as pretty-looking as some of the examples here, I wish to point out that this was a common technique for formatting continued fractions back in the days before desktop computers were ubiquitous.

Okay, here's a much longer version (247 characters) that does full-on formatting of the output:
c,h,i,j,n,d,w[99];char s[99][99];main(r){for(scanf("%d%d",&n,&r);d=r;n=d)
h+=w[c++]=sprintf(s[c],"%d + ",n/d,r=n%d);for(;j+=w[i],i<c-1;puts(""))
for(printf("%*d\n%*s",j+(r=h-j)/2,1,j,s[i++]);--r;printf("-"));
s[i][w[i]-2]=0;printf("%*s\n",j-1,s[i]);}

Some examples of its output:
$ echo 89 150 | ./cfr
                 1
0 + ---------------------------
                   1
    1 + -----------------------
                     1
        1 + -------------------
                       1
            2 + ---------------
                         1
                5 + -----------
                           1
                    1 + -------
                             1
                        1 + ---
                             2
$ echo 151 8919829 | ./cfr
                 1
0 + ----------------------------
                     1
    59071 + --------------------
                       1
            1 + ----------------
                         1
                2 + ------------
                           1
                    1 + --------
                             1
                        1 + ----
                             21
$ echo 293993561 26142953 | ./cfr
               1
11 + ---------------------
                 1
     4 + -----------------
                   1
         14 + ------------
                       1
              4410 + -----
                      104

Wow, we may have a winner in one of the least likely languages to win a CG! Impressive! :-)

Sage Notebook, 80
c=continued_fraction(n)
LatexExpr('{'+'+\\frac{1}{'.join(map(str,c))+'}'*len(c))

Here n can be anything Sage can approximate by a rational / floating point number.  Default precision is 53 bits, unless n is a Rational.  Gotta love MathJax.

APL (78)
{(v↑' '⍪⍉⍪⍕⍺),(' +'↑⍨v←⊃⍴x),x←('1'↑⍨⊃⌽⍴v)⍪v←'─'⍪⍕⍪⍵}/⊃{⍵≤1:⍺⋄a w←0⍵⊤⍺⋄a,⍵∇w}/⎕

Example:
      {(v↑' '⍪⍉⍪⍕⍺),(' +'↑⍨v←⊃⍴x),x←('1'↑⍨⊃⌽⍴v)⍪v←'─'⍪⍕⍪⍵}/⊃{⍵≤1:⍺⋄a w←0⍵⊤⍺⋄a,⍵∇w}/⎕
⎕:
      89 150
   1
 0+─────────────
     1
   1+───────────
       1
     1+─────────
         1
       2+───────
           1
         5+─────
             1
           1+───
               1
             1+─
               2

Mathematica, 77
Fold[#2+1/ToString[#1]&,First[#1],Rest[#1]]&[Reverse[ContinuedFraction[#1]]]&

Just learned Mathematica for this. Takes a surprisingly long program to do this.

Perl 128 114 chars
($a,$b)=split;$_=" "x7;until($b<2){$==$a/$b;($a,$b)=($b,$a%$b);$_.="1\e[B\e[7D$= + ---------\e[B\e[4D"}$_.="$a\n"

But as this use console placement, you have to clear console in order before run:
clear
perl -pe '($a,$b)=split;$_=" "x7;until($b<2){$==$a/$b;($a,$b)=($b,$a%$b);$_.=
"1\e[B\e[7D$= + ---------\e[B\e[4D"}$_.="$a\n"' <<<$'5 7 \n189 53 \n9 16 \n89 150 '

output:
       1
 0 + ---------
          1
    1 + ---------
             1
       2 + ---------
                2
       1
 3 + ---------
          1
    1 + ---------
             1
       1 + ---------
                1
          3 + ---------
                   1
             3 + ---------
                      2
       1
 0 + ---------
          1
    1 + ---------
             1
       1 + ---------
                1
          3 + ---------
                   2
       1
 0 + ---------
          1
    1 + ---------
             1
       1 + ---------
                1
          2 + ---------
                   1
             5 + ---------
                      1
                1 + ---------
                         1
                   1 + ---------
                            2

First post: 128 chars
($a,$b)=split;$c=7;while($b>1){$==$a/$b;($a,$b)=($b,$a%$b);printf"%s1\n%${c}d + %s\n"," "x($c+=5),$=,"-"x9}printf" %${c}d\n",$=

Splitted for cut'n paste:
perl -ne '($a,$b)=split;$c=7;while($b>1){$==$a/$b;($a,$b)=($b,$a%$b);printf
"%s1\n%${c}d + %s\n"," "x($c+=5),$=,"-"x9}printf" %${c}d\n",$a' \
    <<<$'5 7 \n189 53 \n9 16 \n89 150 '

Will render:
            1
      0 + ---------
                 1
           1 + ---------
                      1
                2 + ---------
                      2
            1
      3 + ---------
                 1
           1 + ---------
                      1
                1 + ---------
                           1
                     3 + ---------
                                1
                          3 + ---------
                                2
            1
      0 + ---------
                 1
           1 + ---------
                      1
                1 + ---------
                           1
                     3 + ---------
                           2
            1
      0 + ---------
                 1
           1 + ---------
                      1
                1 + ---------
                           1
                     2 + ---------
                                1
                          5 + ---------
                                     1
                               1 + ---------
                                          1
                                    1 + ---------
                                          2

Same using LaTeX:
perl -ne 'END{print "\\end{document}\n";};BEGIN{print "\\documentclass{article}\\pagestyle".
  "{empty}\\begin{document}\n";};($a,$b)=split;$c="";print "\$ $a / $b = ";while($b>1){$==$a
  /$b;($a,$b)=($b,$a%$b);printf"%s + \\frac{1}{",$=;$c.="}";}printf"%d%s\$\n\n",$a,$c'  \
   <<<$'5 7 \n189 53 \n9 16 \n89 150 ' >fracts.tex

pslatex fracts.tex

dvips -f -ta4 <fracts.dvi |
  gs -sDEVICE=pnmraw -r600 -sOutputFile=- -q -dNOPAUSE - -c quit |
  pnmcrop |
  pnmscale .3 |
  pnmtopng >fracts.png

Perl : 140 ,133 121 chars
($a,$b)=<STDIN>;while($b>1)
{$g=$i+++4;print" "x$g."1\n"." "x$i,int($a/$b)."+---\n";($a=$b)=($b,$a%$b)}
print" "x$g."$a\n"

example :
#perl fraction.pl
5
7
   1
0+---
    1
 1+---
     1
  2+---
     2

Game Maker Language (Script), 61 71
a=argument0;b=argument1;while b!=0{c+=string(a/b)a,b=b,a mod b}return c

Compile with all uninitialized variables as 0.

does this output anything? also, it seems to be wrong; you're appending a string to a number. did you try it?

@Doorknob You're right, I meant to give that to c.

It still doesn't output anything...

@Doorknob Yeah, it doesn't return anything, and I had some syntax errors. It should return the correct value now.

Razor Leaf on Firefox, 108 127
%r=(i,n,d)=>
    mn"#{n/d|0}"
    if i<8&&n%d
        mo"+"
        mfrac
            mn"1"
            me%r(i+1,d,n%d)
math%[a,b]=data;r(0,a,b)

The prompt really hurts there… Oh, you mean I get to pick? Okay, it’s a list. Anyways, good luck getting this to run.

Assuming the input numbers as co-prime, call this process function with numerator and denominator. It can go to any depth until it finds the continued form, no limit
Written in JAVA (238 characters)
String space = "";
private void process(int n, int d) {
    System.out.println(space+(n/d)+" + 1");
    space += "    ";
    System.out.println(space+"------");
    if((n % d)==1)
        System.out.println(space+d);
    else
        process(d,(n % d));
}

process(89,150);
0 + 1
    ------
    1 + 1
        ------
        1 + 1
            ------
            2 + 1
                ------
                5 + 1
                    ------
                    1 + 1
                        ------
                        1 + 1
                            ------
                            2

process(973,13421);
0 + 1
    ------
    13 + 1
        ------
        1 + 1
            ------
            3 + 1
                ------
                1 + 1
                    ------
                    5 + 1
                        ------
                        3 + 1
                            ------
                            1 + 1
                                ------
                                1 + 1
                                    ------
                                    4

K, 136
{-1@((!#j)#\:" "),'j:(,/{(x,"+ 1";(" ",(2*y)#"-"),"\t")}'[a;1+|!#a:$-1_i]),$*|i:*:'1_{(i;x 2;x[1]-(i:x[1]div x 2)*x@2)}\[{~0~*|x};1,x];}

.
k)f:{-1@((!#j)#\:" "),'j:(,/{(x,"+ 1";(" ",(2*y)#"-"),"\t")}'[a;1+|!#a:$-1_i]),$*|i:*:'1_{(i;x 2;x[1]-(i:x[1]div x 2)*x@2)}\[{~0~*|x};1,x];}
k)f[5 4]
1+ 1
  --
  4

k)f[5 3]
1+ 1
  ----
  1+ 1
    --
    2

k)f[5 7]
0+ 1
  ------
  1+ 1
    ----
    2+ 1
      --
      2

k)f[9 16]
0+ 1
  --------
  1+ 1
    ------
    1+ 1
      ----
      3+ 1
        --
        2

k)f[89 150]
0+ 1
  --------------
  1+ 1
    ------------
    1+ 1
      ----------
      2+ 1
        --------
        5+ 1
          ------
          1+ 1
            ----
            1+ 1
              --
              2

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

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


text:
Build a snowman!
It's getting to be that time of year, and I figured I might as well post the first winter-themed question :)
Your challenge is to build a snowman.
How, you ask? Well, you decide! You can do ASCII art, you can animate it, you can golf the code, you can make the code that generates the snowman itself a snowman, you can generate a colored image; be creative!
This is a popularity-contest, so the answer with the most upvotes at the end of December will win. (If an answer surpasses the winner in upvotes, then it will become the new winner.) The winning answer will get the magical green check mark!

Yeah, let us post more "draw a symbol, the unicode character is allowed and mark it as [tag:popularity-contest]". I learn to hate [tag:popularity-contest]

@JohannesKuhn I was really intending for some interesting answers, like animated colored snowmans or something, to come up. :( Maybe I should disallow the unicode character and delete my answer, but I really just posted it so that nobody else would :P

As it currently stands, you win your own contest with the fastest gun in the west.

The failings of the StackExchange code golf community are hardly good reason to hate a fun seasonal challenge. Plus, the real answers take longer to make, so naturally the mediocre answers will be some of the first to come in.

I'm voting to close this question as off-topic and too old to migrate because the winning condition indicates that the challenge concluded on December 31, 2013, nearly 4 years ago

JavaScript/HTML: 454 Characters
Thanks @Doorknob for the idea
Snowman Sitting in the Snow
Here it is running:
http://jsfiddle.net/au35H/1/
Code-golfed:

That's cute ^.^

Wow, very nice! This is the kind of thing I was looking for :-)

I just know someone is going to post this eventually, so 1 character in HTML:
☃

(That's a Unicode snowman; U+2603)
It's pretty hard to see, so here's 23 characters:

☃

Renders as this on my browser:

Or, I could be evil and use the deprecated and terrible font tag for 15 characters:
☃

It renders smaller for some reason.

(of course, these HTML files aren't valid, but latest Chrome (31.0.1650.57 as of writing) gladly accepts them)

If you ever need a unicode snowman, there's this site: http://unicodesnowmanforyou.com/ :)

The 15 character version can be shorten with 1 digit, as the font tag's size attribute handles values in range 1..7 only.

For heaven's sake, why does a unicode snowman even exist...

@Cruncher Why not? If you have 1,114,111 characters, you need to fill that space somehow. Why not add Klingon? Ohh, wait...

@JohannesKuhn klingon to me is more justifiable than a snowman. A snowman is just a picture. Idk. Why not have a statue of liberty? (Please don't tell me there is lol)

@Cruncher there's also the poor fellow U+26C4 SNOWMAN WITHOUT SNOW, and also: http://www.fileformat.info/info/unicode/char/1f5fd/index.htm :-)

@FireFly -____-

Stop upvoting this! :-P I just posted this so that nobody else would...it was not meant to be a real answer

@Doorknob would you like me to downvote to counteract upvotes? ^_^

Polyglot, 1 character
8

Sorry.

Works in PowerShell.

@Iszi works on anything that allows character 8 - eight :-)

@Tomas No, it works on anything that allows the character 8 and will print that character without any other syntax required.

Works in JavaScript... Gets my vote...

MSBuild
Save the following project file as snowman:
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="x">
  <Target Name="x">
    <Exec Command="start http://unicodesnowmanforyou.com"/>
  </Target>
</Project>

The task was to build a snowman, so:
msbuild snowman

This is a bit of a cheat as it is mostly reusing some existing code, but it's a slightly modified version of a C++ AMP realtime GPU path tracer I wrote.

Most of the interesting code is here but there's some utility code in a couple of other files for setting up D3D, setting up the window etc.
#include "app.h"

#include "d3d11device.h"

#include <vector>
#include <fstream>
#include <chrono>
#include <iostream>
#include <initializer_list>
#include <random>
#include <cassert>
#include <cmath>

#include <amp.h>
#include <amp_graphics.h>

#include <Xinput.h>

#include <amputils.h>

using namespace std;
using namespace renderer;
using namespace concurrency;
using namespace concurrency::direct3d;
using namespace concurrency::graphics;
using namespace concurrency::graphics::direct3d;
using namespace concurrency::fast_math;
using namespace DirectX;
using namespace amputils;

namespace {

template<typename T, size_t N>
size_t ArraySize(T (&)[N]) {
    return N;
}

vector<char> LoadFile(const char* filename) {
    ifstream file(filename, ios_base::binary);
    return vector<char>(istreambuf_iterator<char>(file), (istreambuf_iterator<char>()));
}

struct SimpleVertex
{
    float x, y, z;
};

class Sphere
{
public:
    Sphere(const Vector3& center_, float radius_) restrict(amp, cpu) : center(center_), radius(radius_) {}

    Vector3 GetCenter() const restrict(amp, cpu) { return center; }
    float GetRadius() const restrict(amp, cpu) { return radius; }

    // Used for sampling a light from a point
    Vector3 Sample(const Vector3& p, float u1, float u2, Vector3& normal) const restrict(amp, cpu);

    float Pdf(const Vector3& p, const Vector3& /*wi*/) const restrict(amp, cpu) {
        Vector3 pToCenter = center - p;
        float sinThetaMax2 = radius * radius / Dot(pToCenter, pToCenter);
        float cosThetaMax = sqrt(max(0.1f, 1.f - sinThetaMax2));
        return UniformConePdf(cosThetaMax);
    }

private:
    Vector3 center;
    float radius;
};

class DifferentialGeometry
{
public:
    DifferentialGeometry() restrict(amp, cpu) : p(0.0f), n(0.0f) {}
    DifferentialGeometry(const Vector3& p_, const Vector3& n_) restrict(amp, cpu) : p(p_), n(n_) {}

    const Vector3& GetPoint() const restrict(amp, cpu) { return p; }
    const Vector3& GetNormal() const restrict(amp, cpu) { return n; }

private:
    Vector3 p;
    Vector3 n;
};

bool IntersectP(const Ray& ray, const Sphere& sphere, float& t) restrict(amp, cpu)
{
    const auto v = ray.GetOrigin() - sphere.GetCenter();
    const auto a = Dot(ray.GetDirection(), ray.GetDirection());
    const auto minusB = -2.f * Dot(ray.GetDirection(), v);
    const auto c = Dot(v, v) - Square(sphere.GetRadius());
    const auto discrim = (Square(minusB) - 4.f * a * c);
    if (discrim < 0.f) {
        return false;
    }

    const auto sqrtDiscrim = sqrt(discrim);
    const auto tMax = minusB + sqrtDiscrim;
    if (tMax < 0.f) {
        return false;
    }

    const auto denominator = 1.f / (2.f * a);
    const auto tMin = minusB - sqrtDiscrim;
    t = (tMin < 0.f ? tMax : tMin) * denominator;
    return true;
}

bool Intersect(const Ray& ray, const Sphere& sphere, float& t, DifferentialGeometry& dg) restrict(amp, cpu)
{
    const auto v = ray.GetOrigin() - sphere.GetCenter();
    const auto a = Dot(ray.GetDirection(), ray.GetDirection());
    const auto minusB = -2.f * Dot(ray.GetDirection(), v);
    const auto c = Dot(v, v) - Square(sphere.GetRadius());
    const auto discrim = (Square(minusB) - 4.f * a * c);
    if (discrim < 0.f) {
        return false;
    }

    const auto sqrtDiscrim = sqrt(discrim);
    const auto tMax = minusB + sqrtDiscrim;
    if (tMax < 0.f) {
        return false;
    }

    const auto denominator = 1.f / (2.f * a);
    const auto tMin = minusB - sqrtDiscrim;
    t = (tMin < 0.f ? tMax : tMin) * denominator;
    Vector3 p = ray(t);
    dg = DifferentialGeometry(p, Normalize(p - sphere.GetCenter()));
    return true;
}

inline Vector3 Sphere::Sample(const Vector3& p, float u1, float u2, Vector3& normal) const restrict(amp, cpu) {
    Vector3 pToCenter = center - p;
    Vector3 wc = Normalize(pToCenter);
    Vector3 wcX(0.0f), wcY(0.0f);
    CoordinateSystem(wc, wcX, wcY);
    float sinThetaMax2 = radius * radius / Dot(pToCenter, pToCenter);
    float cosThetaMax = sqrt(max(0.1f, 1.f - sinThetaMax2));
    float tHit;
    DifferentialGeometry dg;
    Ray r(p, UniformSampleCone(u1, u2, cosThetaMax, wcX, wcY, wc));
    if (!Intersect(r, *this, tHit, dg))
        tHit = Dot(pToCenter, Normalize(r.GetDirection()));
    normal = dg.GetNormal();
    return dg.GetPoint();
}

class Primitive
{
public:
    Primitive(const Sphere& s_, const Vector3& color_) restrict(amp, cpu) : s(s_), color(color_) {}

    const Sphere& GetSphere() const restrict(amp, cpu) { return s; }
    const Vector3& GetColor() const restrict(amp, cpu) { return color; }

private:
    Sphere s;
    Vector3 color;
};

struct CameraSample
{
    CameraSample(float x_, float y_) restrict(amp, cpu) : x(x_), y(y_) {}
    float x, y;
};

class StratifiedSampler
{
public:
    explicit StratifiedSampler(int n) restrict(amp, cpu) : mN(n) {}

    int GetNumSamples() const restrict(amp, cpu) { return mN * mN; }
    CameraSample Sample2D(amputils::Rng& rng, int i) restrict(amp, cpu) {
        float dxy = 1.0f / mN;
        float xOff = static_cast<float>(i % mN);
        float yOff = static_cast<float>(i / mN);
        return CameraSample((xOff + rng.GetUniform()) * dxy, (yOff + rng.GetUniform()) * dxy);
    }

private:
    StratifiedSampler& operator=(const StratifiedSampler&);

    int mN;
};

class Camera
{
public:
    Camera(int filmWidth, int filmHeight)
        : mPos(0.0f, 0.0f, -20.0f),
          mYaw(0.0f),
          mPitch(0.0f),
          mWorldToCamera(XMMatrixLookAtLH(XMVectorReplicate(0.0f), XMVectorReplicate(1.0f), XMVectorSet(0.0f, 1.0f, 0.0f, 0.0f))),
          mCameraToWorld(XMMatrixInverse(nullptr, mWorldToCamera.GetXMMATRIX())),
          mProjection(XMMatrixPerspectiveFovLH(3.1415f * 0.333f, 1.0f, 1e-2f, 1e3f)),
          mInverseProjection(XMMatrixInverse(nullptr, mProjection.GetXMMATRIX())),
          mFilmWidth(filmWidth),
          mFilmHeight(filmHeight)
    {
        UpdateMatrices();
    }

    const Matrix4& GetWorldToCamera() const restrict(amp, cpu) { return mWorldToCamera; }
    const Matrix4& GetCameraToWorld() const restrict(amp, cpu) { return mCameraToWorld; }
    const Matrix4& GetProjection() const restrict(amp, cpu) { return mProjection; }
    const Matrix4& GetInverseProjection() const restrict(amp, cpu) { return mInverseProjection; }

    void RotateCam(float yaw, float pitch)
    {
        mYaw += yaw;
        mPitch = Clamp(mPitch + pitch, 3.14f * -0.45f, 3.14f * 0.45f);
        UpdateMatrices();
    }

    void TranslateCam(const Vector3& trans)
    {
        mPos += trans;
        UpdateMatrices();
    }

    Ray GenerateRay(int x, int y, int i, StratifiedSampler& samp, amputils::Rng& rng) const restrict(amp, cpu) {
        auto camSamp = samp.Sample2D(rng, i);
        const float fx = (camSamp.x + float(x)) / float(mFilmWidth);
        const float fy = (camSamp.y + float(y)) / float(mFilmHeight);
        const Vector4 rayFilm(2.0f * fx - 1.0f, 2.0f * fy - 1.0f, 0.0f, 1.0f);
        const Vector4 rayFilmCam = Project(rayFilm, GetInverseProjection());
        const Vector4 rayFilmWorld = Transform(rayFilmCam, GetCameraToWorld());
        const Vector4 rayStartWorld(mPos.x(), mPos.y(), mPos.z(), 1.0f);
        const Vector4 rayDirection(rayFilmWorld - rayStartWorld);
        return Ray(Vector3(rayStartWorld.e(0), rayStartWorld.e(1), rayStartWorld.e(2)), Vector3(rayDirection.e(0), rayDirection.e(1), rayDirection.e(2)));
    }

private:
    void UpdateMatrices()
    {
        XMMATRIX cam = XMMatrixLookAtLH(XMVectorSet(mPos.x(), mPos.y(), mPos.z(), 1.0f), XMVectorSet(mPos.x(), mPos.y(), mPos.z() + 1.0f, 1.0f), XMVectorSet(0.0f, 1.0f, 0.0f, 0.0f));
        XMMATRIX rot = XMMatrixMultiply(XMMatrixRotationY(mYaw), XMMatrixRotationX(mPitch));
        mWorldToCamera = XMMatrixMultiply(cam, rot);
        mCameraToWorld = XMMatrixInverse(nullptr, mWorldToCamera.GetXMMATRIX());
    }

    Vector3 mPos;
    float mYaw, mPitch;

    Matrix4 mWorldToCamera;
    Matrix4 mCameraToWorld;
    Matrix4 mProjection;
    Matrix4 mInverseProjection;

    int mFilmWidth, mFilmHeight;
};

class Scene;

class SceneView
{
public:
    int GetNumPrims() const restrict(amp, cpu) { return prims.extent.size(); }
    const Primitive& GetPrim(int i) const restrict(amp, cpu) { return prims[i]; }

    const Camera& GetCamera() const restrict(amp, cpu) { return camera; }

    const Primitive& GetLight() const restrict(amp, cpu) { return light; }

private:
    friend class Scene;
    explicit SceneView(const Camera& camera_, const vector<Primitive>& prims_, const Primitive& light_)
        : camera(camera_),
          prims(prims_.size(), prims_),
          light(light_)
    {
    }

    Camera camera;
    array_view<const Primitive> prims;
    Primitive light;
};

class Scene
{
public:
    explicit Scene(int filmWidth, int filmHeight, const initializer_list<Primitive>& prims_)
        : camera(filmWidth, filmHeight),
          prims(prims_.begin(), prims_.end()),
          light(Sphere(Vector3(50.0f, 50.0f, -50.0f), 5.0f), Vector3(0.75f, 0.75f, 0.67f))
    {
    }

    SceneView GetView() const
    {
        return SceneView(camera, prims, light);
    }

    Camera& GetCamera() { return camera; }
    const Camera& GetCamera() const { return camera; }

    const Primitive& GetLight() const { return light; }

    Primitive& GetPrimitive(int i) { return prims[i]; }

private:
    Camera camera;
    vector<Primitive> prims;
    Primitive light;
};

}

Scene MakeScene(int filmWidth, int filmHeight)
{
    auto prims = {
        Primitive(Sphere(Vector3(0.0f, 0.0f, 1100.0f), 1000.0f), Vector3(0.61f, 0.78f, 1.0f)),
        Primitive(Sphere(Vector3(0.0f, -1010.0f, 0.0f), 1000.0f), Vector3(0.85f, 0.85f, 0.85f)),
        Primitive(Sphere(Vector3(-2.0f, -6.5f, 2.0f), 4.0f), Vector3(0.85f, 0.85f, 0.85f)),
        Primitive(Sphere(Vector3(-2.0f, -1.5f, 2.0f), 3.0f), Vector3(0.85f, 0.85f, 0.85f)),
        Primitive(Sphere(Vector3(-2.0f, 2.8f, 2.0f), 2.0f), Vector3(0.85f, 0.85f, 0.85f)),
        Primitive(Sphere(Vector3(-2.0f, 2.8f, 0.0f), 0.2f), Vector3(0.05f, 0.05f, 0.05f)),
        Primitive(Sphere(Vector3(-2.5f, 3.5f, 0.3f), 0.2f), Vector3(0.05f, 0.05f, 0.05f)),
        Primitive(Sphere(Vector3(-1.5f, 3.5f, 0.3f), 0.2f), Vector3(0.05f, 0.05f, 0.05f))
    };
    return Scene(filmWidth, filmHeight, prims);
}

class App : public IApp {
public:
    App(void* hwnd, int width, int height);
    ~App();
    void Update(bool mouseButtons[2], int mouseX, int mouseY) override;

private:
    void UpdateControllerState();
    void UpdateTexture(unsigned t);

    Device mDevice;

    // No copy or assignment
    App(const App&);
    App operator=(const App&);

    ID3D11VertexShaderPtr mVs;
    ID3D11PixelShaderPtr mPs;

    accelerator_view mAcceleratorView;
    texture<float_4, 2> mAmpTex;
    ID3D11Texture2DPtr mD3dTex;
    ID3D11ShaderResourceViewPtr mTexView;
    ID3D11SamplerStatePtr mSamplerState;
    ID3D11InputLayoutPtr mInputLayout;
    ID3D11BufferPtr mQuadVertexBuffer;
    ID3D11BufferPtr mQuadIndexBuffer;

    chrono::time_point<chrono::high_resolution_clock> mLastFrameTime;

    Scene mScene;

    XINPUT_STATE mControllerState;

    vector<amputils::Rng::SeedValue> mRngSeeds;
};

App::App(void* hwnd, int width, int height) :
    mDevice(hwnd, width, height),
    mAcceleratorView(create_accelerator_view(mDevice.GetD3D11Device())),
    mAmpTex(width, height, mAcceleratorView),
    mD3dTex(get_texture(mAmpTex)),
    mLastFrameTime(chrono::high_resolution_clock::now()),
    mScene(MakeScene(width, height)),
    mRngSeeds(mAmpTex.extent.size())
{
    auto vs = LoadFile("simplevs.cso");
    mDevice.GetD3D11Device()->CreateVertexShader(vs.data(), vs.size(), nullptr, &mVs);

    auto ps = LoadFile("simpleps.cso");
    mDevice.GetD3D11Device()->CreatePixelShader(ps.data(), ps.size(), nullptr, &mPs);

    CD3D11_SHADER_RESOURCE_VIEW_DESC resViewDesc(mD3dTex, D3D11_SRV_DIMENSION_TEXTURE2D);
    mDevice.GetD3D11Device()->CreateShaderResourceView(mD3dTex, &resViewDesc, &mTexView);

    CD3D11_SAMPLER_DESC samplerDesc(D3D11_DEFAULT);
    mDevice.GetD3D11Device()->CreateSamplerState(&samplerDesc, &mSamplerState);

    D3D11_INPUT_ELEMENT_DESC elems[] = {
        { "SV_Position", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 }
    };
    mDevice.GetD3D11Device()->CreateInputLayout(elems, ArraySize(elems), vs.data(), vs.size(), &mInputLayout);

    SimpleVertex quadVerts[] = {
        { -1.0f, 1.0f, 0.0f },
        { 1.0f, 1.0f, 0.0f },
        { 1.0f, -1.0f, 0.0f },
        { -1.0f, -1.0f, 0.0f },
    };
    CD3D11_BUFFER_DESC vbDesc(sizeof(quadVerts), D3D11_BIND_VERTEX_BUFFER);
    D3D11_SUBRESOURCE_DATA vbData = { quadVerts, 0, 0 };
    mDevice.GetD3D11Device()->CreateBuffer(&vbDesc, &vbData, &mQuadVertexBuffer);

    uint16_t quadIndices[] = { 0, 1, 2, 2, 3, 0 };
    CD3D11_BUFFER_DESC ibDesc(sizeof(quadIndices), D3D11_BIND_INDEX_BUFFER);
    D3D11_SUBRESOURCE_DATA ibData = { quadIndices, 0, 0 };
    mDevice.GetD3D11Device()->CreateBuffer(&ibDesc, &ibData, &mQuadIndexBuffer);

    std::random_device rd;
    std::mt19937 gen(rd());
    std::uniform_int_distribution<unsigned int> dis;
    for_each(begin(mRngSeeds), end(mRngSeeds), [&gen, &dis](amputils::Rng::SeedValue& seedValue) {
        seedValue = amputils::Rng::SeedValue(dis(gen), dis(gen), dis(gen), dis(gen));
    });

    amputils::Rng rng(amputils::Rng::SeedValue(dis(gen), dis(gen), dis(gen), dis(gen)));
    StratifiedSampler sampler(4);
    for (int i = 0; i < sampler.GetNumSamples(); ++i) {
        auto samp = sampler.Sample2D(rng, i);
        cout << samp.x << ", " << samp.y << "\n";
    }
}

App::~App() {
}

bool IsShadowed(const Ray& ray, const SceneView& scene) restrict(amp, cpu)
{
    auto lightT = FLT_MAX;
    if (!IntersectP(ray, scene.GetLight().GetSphere(), lightT))
        return true;

    for (auto i = decltype(scene.GetNumPrims())(0); i < scene.GetNumPrims(); ++i)
    {
        const auto& sphere = scene.GetPrim(i).GetSphere();
        float t = FLT_MAX;
        if (IntersectP(ray, sphere, t) && t < lightT) {
            return true;
        }
    }
    return false;
}

template<int RecursionDepth>
inline Vector3 TraceRay(const Ray& ray, const SceneView& scene, Rng& rng, int sampIdx) restrict(amp, cpu)
{
    Vector3 color(0.1f, 0.1f, 0.25f);
    auto nearestT = FLT_MAX;
    DifferentialGeometry nearestDg;
    Vector3 nearestDiffuseColor(0.0f);

    for (auto i = decltype(scene.GetNumPrims())(0); i < scene.GetNumPrims(); ++i)
    {
        const auto& sphere = scene.GetPrim(i).GetSphere();
        float t = FLT_MAX;
        DifferentialGeometry dg;
        if (Intersect(ray, sphere, t, dg) && t < nearestT) {
            nearestT = t;
            nearestDg = dg;
            nearestDiffuseColor = scene.GetPrim(i).GetColor();
        }
    }

    if (nearestT < FLT_MAX) {
        // Direct lighting
        StratifiedSampler sampler(4);
        auto samp = sampler.Sample2D(rng, sampIdx);
        Vector3 lightNormal(0.0f);
        const auto lightPos = scene.GetLight().GetSphere().Sample(nearestDg.GetPoint(), samp.x, samp.y, lightNormal);
        const auto L = Normalize(lightPos - nearestDg.GetPoint());
        if (IsShadowed(Ray(nearestDg.GetPoint() + L * 1e-3f, L), scene))
            color = Vector3(0.0f);
        else
            color = nearestDiffuseColor * Dot(nearestDg.GetNormal(), L) * scene.GetLight().GetColor();

        // Indirect lighting
        auto indirectSamp = sampler.Sample2D(rng, sampIdx);
        auto indirectDirLocal = CosineSampleHemisphere(indirectSamp.x, indirectSamp.y);
        Vector3 normalZ = nearestDg.GetNormal();
        Vector3 normalX(0.0f), normalY(0.0f);
        CoordinateSystem(normalZ, normalX, normalY);
        auto indirectDirWorld = normalX * indirectDirLocal.x() + normalY * indirectDirLocal.y() + normalZ * indirectDirLocal.z();
        Ray indirectRay(nearestDg.GetPoint() + nearestDg.GetNormal() * 1e-3f, indirectDirWorld);
        auto indirectColor = TraceRay<RecursionDepth - 1>(indirectRay, scene, rng, sampIdx) * CosineHemispherePdf(Dot(indirectDirWorld, nearestDg.GetNormal()), 0.0f);
        color += indirectColor * nearestDiffuseColor;
    }

    return color;
}

template<>
inline Vector3 TraceRay<0>(const Ray& /*ray*/, const SceneView& /*scene*/, Rng& /*rng*/, int /*sampIdx*/) restrict(amp, cpu)
{
    return Vector3(0.0f);
}

const int Height = 512;
const int Width = 512;

inline float_4 RaytraceScene(int x, int y, const SceneView& scene, Rng& rng) restrict (amp, cpu)
{
    float_4 totalIrradiance = 0.0f;
    StratifiedSampler sampler(4);
    for (int samp = 0; samp < sampler.GetNumSamples(); ++samp)
    {
        auto ray = scene.GetCamera().GenerateRay(x, y, samp, sampler, rng);
        totalIrradiance += ToFloat4(TraceRay<4>(ray, scene, rng, samp));
    }
    totalIrradiance *= 1.0f / sampler.GetNumSamples();
    return totalIrradiance;
}

void App::UpdateTexture(unsigned t)
{
    auto sceneView = mScene.GetView();
    auto ampTexView = writeonly_texture_view<float_4, 2>(mAmpTex);
    auto rngSeedsView = array_view<const amputils::Rng::SeedValue, 2>(ampTexView.extent, mRngSeeds);
    parallel_for_each(mAcceleratorView, mAmpTex.extent, [ampTexView, sceneView, t, rngSeedsView](index<2> idx) restrict(amp) {
        //Rng::SeedValue rngSeed(rngSeedsView[idx].z1 + t, rngSeedsView[idx].z2 + t, rngSeedsView[idx].z3 + t, rngSeedsView[idx].z4 + t);
        Rng rng(rngSeedsView[idx]);
        ampTexView.set(idx, RaytraceScene(idx[1], idx[0], sceneView, rng));
    });
}

void App::UpdateControllerState()
{
    for (DWORD i = 0; i < 4; ++i)
    {
        // Simply get the state of the controller from XInput.
        ZeroMemory(&mControllerState, sizeof(mControllerState));
        DWORD dwResult = XInputGetState(i, &mControllerState);

        if (dwResult == ERROR_SUCCESS)
            return;
    }
}

float GetThumbstickAmount(const int rawVal)
{
    const int inputDeadzone = static_cast<int>(0.24f * float(0x7FFF)); // Default to 24% of the +/- 32767 range.
    const int deadzoneVal = abs(rawVal) < inputDeadzone ? 0 : rawVal + inputDeadzone * Sign(rawVal);
    return float(deadzoneVal) / float(0x7FFF - inputDeadzone);
}

void App::Update(bool /*mouseButtons*/[2], int /*mouseX*/, int /*mouseY*/)
{
    static const auto startTime = chrono::high_resolution_clock::now();
    auto frameTime = chrono::high_resolution_clock::now();
    auto frameMs = chrono::duration_cast<chrono::milliseconds>(frameTime - mLastFrameTime);
    //float frameS = chrono::duration_cast<chrono::milliseconds>(frameTime - startTime).count() * 1e-3f;
    mLastFrameTime = frameTime;

    UpdateControllerState();
    float xRot = GetThumbstickAmount(mControllerState.Gamepad.sThumbRX) * float(frameMs.count()) * -1e-3f;
    float yRot = GetThumbstickAmount(mControllerState.Gamepad.sThumbRY) * float(frameMs.count()) * 1e-3f;
    mScene.GetCamera().RotateCam(xRot, yRot);
    Vector4 camForward = mScene.GetCamera().GetCameraToWorld().GetRow(2);
    Vector4 camStrafe = mScene.GetCamera().GetCameraToWorld().GetRow(0);
    float forward = GetThumbstickAmount(mControllerState.Gamepad.sThumbLY) * float(frameMs.count()) * 5e-3f;
    float strafe = GetThumbstickAmount(mControllerState.Gamepad.sThumbLX) * float(frameMs.count()) * 5e-3f;
    Vector4 camTranslate = camForward * forward + camStrafe * strafe;
    mScene.GetCamera().TranslateCam(Vector3(camTranslate.x(), camTranslate.y(), camTranslate.z()));

    /*
    auto movingSpherePos = Vector3(sin(frameS), cos(frameS), cos(frameS)) * 5.0f;
    mScene.GetPrimitive(6) = Primitive(Sphere(movingSpherePos, 3.0f), Vector3(0.6f, 0.6f, 0.05f));
    */

    UpdateTexture(static_cast<unsigned>(frameTime.time_since_epoch().count()));

    mDevice.ClearDefaultRenderTarget();
    mDevice.SetDefaultRenderTarget();

    ID3D11DeviceContextPtr deviceContext;
    mDevice.GetD3D11Device()->GetImmediateContext(&deviceContext);

    deviceContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
    deviceContext->IASetInputLayout(mInputLayout);
    deviceContext->IASetIndexBuffer(mQuadIndexBuffer, DXGI_FORMAT_R16_UINT, 0);
    ID3D11Buffer* vbs[] = { mQuadVertexBuffer.GetInterfacePtr() };
    UINT strides[] = { sizeof(SimpleVertex) };
    UINT offsets[] = { 0 };
    deviceContext->IASetVertexBuffers(0, ArraySize(vbs), vbs, strides, offsets);
    deviceContext->VSSetShader(mVs, nullptr, 0);
    deviceContext->PSSetShader(mPs, nullptr, 0);
    ID3D11ShaderResourceView* srvs[] = { mTexView.GetInterfacePtr() };
    deviceContext->PSSetShaderResources(0, ArraySize(srvs), srvs);
    ID3D11SamplerState* samplers[] = { mSamplerState.GetInterfacePtr() };
    deviceContext->PSSetSamplers(0, ArraySize(samplers), samplers);
    deviceContext->DrawIndexed(6, 0, 0);
    ID3D11ShaderResourceView* emptySrvs[] = { nullptr };
    deviceContext->PSSetShaderResources(0, ArraySize(emptySrvs), emptySrvs);

    mDevice.Present();

    cout << frameMs.count() << endl;
}

unique_ptr<IApp> CreateApp(void* hwnd, int width, int height) {
    return unique_ptr<IApp>(new App(hwnd, width, height));
}

How can anyone not love this?!

Befunge 93
>"  )__:__(  @"v
v"@'--( : )--'"<
>"   )^_^(   @"v
v"@   _[_]_   "<
>"     _     @"v
@    v_v#!-"@":<
     >$ 91+,:!v
       >,: !#v_^
^            <

Ouput:
     _
   _[_]_
   (^_^)
'--( : )--'
  (__:__)

Change one character for infinite snowmen:
>"  )__:__(  @"v
v"@'--( : )--'"<
>"   )^_^(   @"v
v"@   _[_]_   "<
>"     _     @"v
@    v_v#!-"@":<
     >$ 91+,:!v
       >,: !#v_^
v            <

How it works: stores the characters in the snowman on the stack. @ symbolizes a new line. Then, loops through all the characters; if it is an @, print a new line: 91+,, otherwise, print the character. Then, it checks if the end has been reached. If it has, it exits the loop: #v_^.

Ascii art versions
          >")__:__(  @"v
          v            <
          >            v
       vv"@'--( : )--'"<vv
         v              v_
        >"   )"     "^"   v
      v"@   ""("   "^""_" <
      >"   "              v
        v     "_[_]_"     <<
        >>                v
          v               <
  _       >"  ":"@  ":  ::v       _
 | |     v    ::    :"  _"<      | |
 | |=====>                 v=====| |
  =======v   "@"    +0     <=======|
         >>               v
          v               <
         %v<   o     o    <v
        %v<    0     0     &%
        %>                  v
        v    "@"     :      <
        >>                 v
         v +0+0:,+19$<_v#!-<
    _____>0+!#v_v#+0!:,<@@@@ _____
    @@@@@@@$0 <@>0+0+0+0+0+ ^@@@@@

Outputs the exact same thing. Can also be changed to infinite snowman:
          >")__:__(  @"v
          v            <
          >            v
       vv"@'--( : )--'"<vv
         v              v_
        >"   )"     "^"   v
      v"@   ""("   "^""_" <
      >"   "              v
        v     "_[_]_"     <<
        >>                v
          v               <
  _       >"  ":"@  ":  ::v       _
 | |     v    ::    :"  _"<      | |
 | |=====>                 v=====| |
  =======v   "@"    +0     <=======|
         >>               v
          v               <
         %v<   o     o    <v
        %v<    0     0     &%
        %>                  v
        v    "@"     :      <
        >>                 v
         v +0+0:,+19$<_v#!-<
    _____>0+!#v_v#+0!:,<@@@@ _____
    @@@@@@v$0 <@>0+0+0+0+0+ ^@@@@@

My favorite part is v_v#!, the code that branches for the @ character.

I love the ASCII art versions :D

@Doorknob I spent hours on it. I kept coding it wrong and had to debug. I thought that it does not look too much like a snowman (I'm not good at ascii art), but I just had to try.


text:
Christmas Countdown
In the spirit of the holidays, and as someone already started the winter theme(Build a snowman!) I propose a new challenge.
Print the number of days, hours, minutes, and seconds until Christmas(midnight(00:00:00) December 25th) on a stand alone window(not a console) in any unambiguous format you see fit, and continually update it as these values change.
Input - nothing, must read system time.
Shortest code wins :) The strings "Days", "Hours", "Minutes", "Seconds", and "Until Christmas" are free code. You can also flavour them up if you like. Flavouring them up is sheerly for the purpose of producing a nice output. You can not flavour strings for the purpose of making a magic number to save code.

What exactly do you mean by "flavour them up"? Are "days", "hours", "minutes", "seconds", and "until Christmas" required in the output, or just free options? How much "flavouring" of those strings is free?

No console?? Console coders revolt! Just kidding. Nice idea. Happy holidays.

@Iszi They are not required. I just gave them free so that if people want to make an actual nice output they won't lose so many characters.

@DarrenStone my primary reasoning for this, is so that the countdown isn't just a barrage of printouts. That's ugly :)

Isn't Christmas midnight is the end of Christmas?

No, typically midnight is the zeroth instant of the new day. "Midnight Christmas" is when Christmas begins.

Related

Are string delimiters for those strings free too?

Ruby with Shoes, 96 - 33 = 63
Shoes.app{p=para
animate{p.text="0 days 0 hours 0 minutes #{1387951200-Time.new.to_f} seconds"}}

Well, you never said we couldn't. ;)

Updates once every frame.
The magic number 1387951200 is Christmas - Dec 25, 2013 00:00.
Sample IRB session for where I got the numbers:
irb(main):211:0> "0 days 0 hours 0 minutes  seconds".size
=> 33
irb(main):212:0> Time.new(2013,12,25,00,00,00).to_i
=> 1387951200
irb(main):213:0>

Dec 25, 2013 00:00 is midnight.

@Cruncher Ah, okay then. Editing out lots of the useless text then

Mathematica 167 - 44 = 123
The following continually updates a table showing the days, hours, minutes and seconds (in thousandths) until the beginning of Christmas day.
I am unsure how to count discount for the free strings.
Dynamic[Grid[Join[{{"Countdown", "until Christmas"}},
{DateDifference[Date[], {2013, 12, 25, 0, 0, 0}, {"Day", "Hour", "Minute", "Second"}],
Clock[{1, 1}, 1]}[[1]] /. d_String :> d <> "s"]] ]

A quick and dirty solution: 104-19 = 85 chars
Dynamic@{DateDifference[Date[], {2013, 12, 25, 0, 0, 0}, {"Day", "Hour", "Minute",
 "Second"}], Clock[{1, 1}, 1]}[[1]]

{{17, "Day"}, {10, "Hour"}, {59, "Minute"}, {51.4011, "Second"}}

"Countdown to Christmas: Days" This can be free, "Day", "Hour", "Minute", "Second" can be as well.

Thanks for the clarification. Btw, spaces outside of strings are not obligatory. They are inserted only for legibility.

Why are there "-" in front of the numbers? It may be confusing, and look like we're passed christmas already. Would they be fixed by changing the order in DateDifference?

I removed them and improved the formatting, paying the price in characters added.

PowerShell: 279
Character count does not take into account any freebies. @Cruncher - please adjust accordingly.
Golfed
($t=($a='New-Object Windows.Forms')+".Label"|iex).Text=($i={((New-TimeSpan -en 12/25|Out-String)-split"`n")[2..6]});$t.Height=99;($x=iex $a".Form").Controls.Add($t);$x.Text='Time Until Christmas';($s=iex $a".Timer").add_tick({$t.Text=&$i;$x.Refresh()});$s.Start();$x.ShowDialog()

This ain't the prettiest thing, either as code or as a window, but it works.
One nice bit is that this isn't just good for 2013 - it'll work in any year, from 00:00 on January 1 until 00:00 on December 25th.
Warning: The window may become unresponsive - it will continue to update, but you might not be able to move or close it.

Un-golfed with comments
(
    # $t will be the label that displays our countdown clock on the form.
    $t=(
        # $a is used as a shortcut to address the Forms class later.
        $a='New-Object Windows.Forms'
    # Tack ".Label" onto the end with iex to finish making $t.
    )+".Label"|iex

# Set the text for our label.
).Text=(
    # $i will be a script block shortcut for later.
    $i={
        (
            (
                # Get the current "Time until Christmas", and output it as a string.
                New-TimeSpan -en 12/25|Out-String
            # Break the string into newline-delimeted array.
            )-split"`n"
        # Only output elements 2..6 - Days, Hours, Minutes, Seconds, Milliseconds.
        )[2..6]
    }
);

# Make sure the label is tall enough to show all the info.
$t.Height=99;

(
    # Use iex and $a as shortcut to make $x a "New-Object Windows.Forms.Form".
    $x=iex $a".Form"

# Add the label to the form.
).Controls.Add($t);

# Put 'Time Until Christmas' in the title bar for flavor.
$x.Text='Time Until Christmas';

(
    # Use iex and $a as shortcut to make $s a "New-Object Windows.Forms.Timer".
    $s=iex $a".Timer"

# Tell the timer what to do when it ticks.
).add_tick(
    {
        # Use the $i script block to update $t.Text.
        $t.Text=&$i;
        # Reload the form so the updated text displays.
        $x.Refresh()
    }
);

# Start the timer.
$s.Start();

# Show the form.
$x.ShowDialog();

# Variable cleanup - omit from golfed code.
rv t,a,x,i,s

Python 136
I'm sure someone can do this better - I've never used Tkinter before. In particular I bet the l.pack() and l["text"] can are avoidable.

Golfed
from Tkinter import*
from datetime import datetime as d
r=Tk()
l=Label(r)
l.pack()
while 1:
    l["text"]=d(2013,12,25)-d.now()
    r.update()

R
Here is a solution for R using GTK+ via the gWidgets package. This is pretty ugly code since I am not familiar with the gWidgets/GTK+ package at all.
Code
Here is the code:
library(gWidgets)
options(guiToolkit="RGtk2")

# FUNCTION compute the hours minutes and seconds from time in seconds
fnHMS = function(timeInSec) {
  hours = timeInSec %/% 3600
  minutes = (timeInSec %% 3600) %/% 60
  seconds = (timeInSec %% 3600) %% 60
  return(list(hours = hours, minutes = minutes, seconds = seconds))
}

# test the function
fnHMS(1478843)

# container for the label and the button widget
christmasCountdownContainer = gwindow('Christmas Countdown!!', visible = TRUE)
christmasCountdownGroup = ggroup(horizontal = FALSE,
                                 container = christmasCountdownContainer)
ccWidget1 = glabel(sprintf('%4.0f hours, %4.0f minutes, %4.0f seconds till Christmas!!',
                           (liHMS <- fnHMS(as.double(difftime(as.POSIXct(strptime('25-12-2013 00:00:01',
                                      format = '%d-%m-%Y %H:%M:%S')),
                  Sys.time(), units = 'secs'))))[[1]], liHMS[[2]], liHMS[[3]]),
                            container = christmasCountdownGroup)

ccWidget2 = gbutton("Update!", handler = function(h, ...) {
  # retrieve the old value of the ccWidget1
  oldValue = svalue(ccWidget1)
  liHMS = fnHMS(as.double(difftime(as.POSIXct(strptime('25-12-2013 00:00:01',
                                                       format = '%d-%m-%Y %H:%M:%S')),
                                   Sys.time(), units = 'secs')))
  svalue(ccWidget1) = sprintf('%4.0f hours, %4.0f minutes, %4.0f seconds till Christmas!!',
                              liHMS[[1]], liHMS[[2]], liHMS[[3]])
  }, container = christmasCountdownGroup)

Output
Here is what the output looks like:

It has to continually update - that means automatically

Dyalog APL, 61
{⎕SM[1;]←1 1,⍨⊂⍕(1 4⍴2↓2013 12 24 23 59 59 1000-⎕TS)⍪'Days' 'Hours' 'Minutes' 'Seconds'⋄∇1}1

C# 128
Golfed
using D=System.DateTime;using System.Windows.Forms;class C{static void Main(){MessageBox.Show(""+(new D(2013, 12, 25)-D.Now));}}

Ungolfed
using D=System.DateTime;
using System.Windows.Forms;
class C
{
    static void Main()
    {
        MessageBox.Show(""+(new D(2013,12,25)-D.Now));
    }
}

This doesn't continually count down does it? Also, Welcome to codegolf!

Thanks, glad to be here! I guess I misunderstood, this would only update when it is rerun. I'll edit and repost soon

Python 2, 115
from datetime import datetime as d
n=d.now()
print str(24-n.day),str(23-n.hour),str(59-n.minute),str(60-n.second)

This counts newlines as 2 characters.