text:
Connect-n time!
https://en.wikipedia.org/wiki/Connect_Four
Does anyone remember the 2 player game connect 4? For those who don't it was a 6x7 board that stands vertical on a surface. The goal of connect 4 is to, well connect 4! The connection is counted if it is horizontal, diagonal, or vertical. You place your pieces on the board by inserting a piece at the top of a column where it falls to the bottom of that column. Our rules change 3 things in connect 4.

Change #1 Winning is defined as the player with the most points. You get points by connecting 4 like in the rules - more on that later.
Change #2 You have 3 players each round.
Change #3 The board size is 9x9.

Scoring:
Score is based on how many you get in a row. If you have a 4 in a row group you get 1 point. If you have a 5 in a row group you get 2 points, 6 in a row 3 and so on.
Examples:
Note o and x are replaced with # and ~ respectively, for better contrast
Example of empty board: (all examples are 2 player standard size board)
   a b c d e f g
6 | | | | | | | |
5 | | | | | | | |
4 | | | | | | | |
3 | | | | | | | |
2 | | | | | | | |
1 |_|_|_|_|_|_|_|

If we drop a piece in coll d, it will land in location1d.
   a b c d e f g
6 | | | | | | | |
5 | | | | | | | |
4 | | | | | | | |
3 | | | | | | | |
2 | | | | | | | |
1 |_|_|_|#|_|_|_|

If we now drop a piece in coll d again, it will land in location 2d. Here are examples of 4 in a row positions:
   a b c d e f g
6 | | | | | | | |
5 | | | | | | | |
4 | | | |~| | | |
3 | | |~|#| | | |
2 | |~|#|~| |#| |
1 |~|#|~|#|_|#|_|

In this case x gets 1 point diagonally (1a 2b 3c 4d).
  a b c d e f g
6 | | | | | | | |
5 | | | | | | | |
4 | | | |#| | | |
3 | | | |#| | | |
2 | | | |#| | | |
1 |_|~|_|#|~|_|~|

In this case, o gets 1 point vertically (1d 2d 3d 4d).
   a b c d e f g
6 | | | | | | | |
5 | | | | | | | |
4 | | | | | | | |
3 | | | | | | | |
2 | | |#|#|#|#| |
1 |_|_|~|~|~|~|~|

In this case o gets 2 points horizontally (1c 1d 1e 1f 1g) and x gets 1 point horizontally (2c 2d 2e 2f).
   a b c d e f g
6 | | |#| | | | |
5 | | |#| | | | |
4 | | |#| | | | |
3 | | |#| | |~| |
2 |~| |#| | |#|~|
1 |~|_|#|~| |~|~|

This time x gets 3 points for a 6 in a row (1c 2c 3c 4c 5c 6c).
Input / Output
You will have access to the board via a 2d array. Each location will be represented with an int representing a player id. You will also have your player id passed to your function. You make your move by returning which coll you want to drop your piece into. Each round 3 players will be chosen to play. At the end of the game, all players will have played an even amount of games.
For the moment 100k rounds will be run (note this takes a long time, you may want to reduce it for fast turnaround testing). Overall the winner is the player with the most wins.
The controller can be found here: https://github.com/JJ-Atkinson/Connect-n/tree/master.
Writing a bot:
To write a bot you must extend the Player class. Player is abstract and has one method to implement, int makeMove(void). In makeMove you will decide which coll you would like to drop your piece into. If you chose an invalid coll (e.g. coll does not exist, coll is filled already), your turn will be skipped. In the Player class you have many useful helper methods. A listing of the most important ones follows:

boolean ensureValidMove(int coll): Return true if the coll is on the board and the coll is not filled yet.
int[] getBoardSize(): Return a int array where [0] is the number of columns, and [1] is the number of rows.
int[][] getBoard(): Return a copy of the board. You should access it like this: [coll number][row number from bottom].
To find the rest, look at the Player class.
EMPTY_CELL: The value of an empty cell

Since this will be multi-threaded, I have also included a random function if you need it.
Debugging your bot:
I have included some things in the controller to make it simpler to debug a bot. The first one is Runner#SHOW_STATISTICS. If this is enabled, you will see a printout of player groups played, including a count of bot wins. Example:
OnePlayBot, PackingBot, BuggyBot,
OnePlayBot -> 6
PackingBot -> 5
BuggyBot -> 3
Draw -> 1

You can also make a custom game with the connectn.game.CustomGame class, you can see the scores and winner of each round. You can even add yourself to the mix with UserBot.
Adding your bot:
To add your bot to the lineup, go to the PlayerFactory static block and add the following line:
playerCreator.put(MyBot.class, MyBot::new);

Other things to note:

The simulations are multi-threaded. If you want to turn that off, go to Runner#runGames() and comment this line (.parallel()).
To change the number of games, set Runner#MINIMUM_NUMBER_OF_GAMES to your liking.

Added later:

Communication among bots is disallowed.

Related: Play Connect 4!
================================
Scoreboard: (100 000 games)
MaxGayne -> 22662
RowBot -> 17884
OnePlayBot -> 10354
JealousBot -> 10140
Progressive -> 7965
Draw -> 7553
StraightForwardBot -> 7542
RandomBot -> 6700
PackingBot -> 5317
BasicBlockBot -> 1282
BuggyBot -> 1114
FairDiceRoll -> 853
Steve -> 634

================================

Can you add functionality to determine which turn the game is on?

Already done, check the Player class to see all methods available.

"a square 6x7" that's not a square

Giving players the ability to "pass" by making an illegal move changes the dynamics a bit. Does the game end if everyone passes?

Yes, that is why is is very important to use ensureValidMove (unless your strategy is to pass this turn of course).

I'll come up with an answer for this this afternoon.

Can you add my bot?

Sure, I can't do it now because I'm not near the computer, but I will when I can.

Can I make more than 1?

Yep, you can. 'filler'

great. Now I have the idea but can't make it...

MaxGayne
This bot assigns a score to each position, based mainly on the length of connected parts. It looks 3 moves deep inspecting 3 best looking moves at each stage, and chooses the one with the maximum expected score.
package connectn.players;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

public class MaxGayne extends Player {
    private static final int PLAYERS = 3;

    private static class Result {
        protected final int[] score;
        protected int lastCol;

        public Result(int[] score, int lastCol) {
            super();
            this.score = score;
            this.lastCol = lastCol;
        }

        public Result() {
            this(new int[PLAYERS], -1);
        }

        public Result(Result other) {
            this(new int[PLAYERS], other.lastCol);
            System.arraycopy(other.score, 0, this.score, 0, PLAYERS);
        }

        public int getRelativeScore(int player) {
            int max = Integer.MIN_VALUE;
            for (int i = 0; i < PLAYERS; ++ i) {
                if (i != player && score[i] > max) {
                    max = score[i];
                }
            }
            return score[player] - max;
        }
    }

    private static class Board extends Result {
        private final int cols;
        private final int rows;
        private final int[] data;
        private final int[] used;

        public Board(int cols, int rows) {
            super();
            this.cols = cols;
            this.rows = rows;
            this.data = new int[cols * rows];
            Arrays.fill(this.data, -1);
            this.used = new int[cols];
        }

        public Board(Board other) {
            super(other);
            this.cols = other.cols;
            this.rows = other.rows;
            this.data = new int[cols * rows];
            System.arraycopy(other.data, 0, this.data, 0, this.data.length);
            this.used = new int[cols];
            System.arraycopy(other.used, 0, this.used, 0, this.used.length);
        }

        private void updatePartScore(int player, int length, int open, int factor) {
            switch (length) {
                case 1:
                    score[player] += factor * open;
                    break;
                case 2:
                    score[player] += factor * (100 + open * 10);
                    break;
                case 3:
                    score[player] += factor * (10_000 + open * 1_000);
                    break;
                default:
                    score[player] += factor * ((length - 3) * 1_000_000 + open * 100_000);
                    break;
            }
        }

        private void updateLineScore(int col, int row, int colOff, int rowOff, int length, int factor) {
            int open = 0;
            int player = -1;
            int partLength = 0;
            for (int i = 0; i < length; ++ i) {
                int newPlayer = data[(col + i * colOff) * rows + row + i * rowOff];
                if (newPlayer < 0) {
                    if (player < 0) {
                        if (i == 0) {
                            open = 1;
                        }
                    } else {
                        updatePartScore(player, partLength, open + 1, factor);
                        open = 1;
                        player = newPlayer;
                        partLength = 0;
                    }
                } else {
                    if (newPlayer == player) {
                        ++ partLength;
                    } else {
                        if (player >= 0) {
                            updatePartScore(player, partLength, open, factor);
                            open = 0;
                        }
                        player = newPlayer;
                        partLength = 1;
                    }
                }
            }
            if (player >= 0) {
                updatePartScore(player, partLength, open, factor);
            }
        }

        private void updateIntersectionScore(int col, int row, int factor) {
            updateLineScore(col, 0, 0, 1, rows, factor);
            updateLineScore(0, row, 1, 0, cols, factor);
            if (row > col) {
                updateLineScore(0, row - col, 1, 1, Math.min(rows - row, cols), factor);
            } else {
                updateLineScore(col - row, 0, 1, 1, Math.min(cols - col, rows), factor);
            }
            if (row > cols - col - 1) {
                updateLineScore(cols - 1, row - (cols - col - 1), -1, 1, Math.min(rows - row, cols), factor);
            } else {
                updateLineScore(col + row, 0, -1, 1, Math.min(col + 1, rows), factor);
            }
        }

        private void updatePiece(int player, int col, int row) {
            updateIntersectionScore(col, row, -1);
            data[col * rows + row] = player;
            ++ used[col];
            lastCol = col;
            updateIntersectionScore(col, row, 1);
        }

        public Board updatePiece(int player, int col) {
            int row = used[col];
            if (row >= rows) {
                return null;
            } else {
                Board result = new Board(this);
                result.updatePiece(player, col, row);
                return result;
            }
        }

        private void updateBoard(int[][] board) {
            for (int col = 0; col < cols; ++ col) {
                for (int row = 0; row < rows; ++ row) {
                    int oldPlayer = data[col * rows + row];
                    int newPlayer = board[col][row] - 1;
                    if (newPlayer < 0) {
                        if (oldPlayer < 0) {
                            break;
                        } else {
                            throw new RuntimeException("[" + col + ", " + row + "] == "  + oldPlayer + " >= 0");
                        }
                    } else {
                        if (oldPlayer < 0) {
                            updatePiece(newPlayer, col, row);
                        } else if (newPlayer != oldPlayer) {
                            throw new RuntimeException("[" + col + ", " + row + "] == "  + oldPlayer + " >= " + newPlayer);
                        }
                    }
                }
            }
        }

        private Result bestMove(int depth, int player) {
            List<Board> boards = new ArrayList<>();
            for (int col = 0; col < cols; ++ col) {
                Board board = updatePiece(player, col);
                if (board != null) {
                    boards.add(board);
                }
            }
            if (boards.isEmpty()) {
                return null;
            }
            Collections.sort(boards, (o1, o2) -> Integer.compare(o2.getRelativeScore(player), o1.getRelativeScore(player)));
            if (depth <= 1) {
                return new Result(boards.get(0).score, boards.get(0).lastCol);
            }
            List<Result> results = new ArrayList<>();
            for (int i = 0; i < 3 && i < boards.size(); ++ i) {
                Board board = boards.get(i);
                Result result = board.bestMove(depth - 1, (player + 1) % PLAYERS);
                if (result == null) {
                    results.add(new Result(board.score, board.lastCol));
                } else {
                    results.add(new Result(result.score, board.lastCol));
                }
            }
            Collections.sort(results, (o1, o2) -> Integer.compare(o2.getRelativeScore(player), o1.getRelativeScore(player)));
            return results.get(0);
        }
    }

    private Board board = null;

    @Override
    public int makeMove() {
        if (board == null) {
            int[][] data = getBoard();
            board = new Board(data.length, data[0].length);
            board.updateBoard(data);
        } else {
            board.updateBoard(getBoard());
        }

        Result result = board.bestMove(3, getID() - 1);
        return result == null ? -1 : result.lastCol;
    }
}

Very, very nice! +1

Something I noticed while I was playing around with UserBot and your bot was that after some point MaxGayne will throw away turns (e.g. after 15 moves it skips every turn until the game ends).

The cause for this is probably a bug in CustomGame. It's using 0-based player ID's instead of 1-based like the main game. This simply breaks my bot. There are 2 more problems. javafx.util.Pair doesn't work in Eclipse because it's not considered as a part of the public API. And I have no idea where to look for sun.plugin.dom.exception.InvalidStateException. You probably meant java.lang.IllegalStateException.

That seems a little odd... Anyways as for Pair, that is as close as I can get to the data type I want without rolling my own, so unless eclipse won't compile, I think it's OK. As for #3, you are right, my autocomplete in IntelliJ isn't always right. (most of the time it is, that's why I didn't check)

@JAtkin Actually, the Pair problem really prevents compiling in Eclipse, unless you know the workaround.

RowBot
Looks in all directions and determines the optimal column. Tries to connect his pieces, while not letting his opponents do the same.
package connectn.players;

import connectn.game.Game;
import java.util.ArrayList;
import java.util.List;

public class RowBot extends Player {

    @Override
    public int makeMove() {
        int[][] board = getBoard();
        int best = -1;
        int bestScore = -10;
        for (int col = 0; col < board.length; col++) {
            if (ensureValidMove(col)) {
                int score = score(board, col, false);
                score -= score(board, col, true);
                if (score > bestScore) {
                    bestScore = score;
                    best = col;
                }
            }
        }
        return best;
    }

    private int score(int[][] board, int col, boolean simulateMode) {
        int me = getID();
        int row = getLowestEmptyRow(board, col);
        List<Score> scores = new ArrayList<>();
        if (!simulateMode) {
            scores.add(getScoreVertical(board, col, row));
        } else {
            row += 1;
        }
        scores.addAll(getScoreHorizontal(board, col, row));
        scores.addAll(getScoreDiagonal(board, col, row));
        int score = 0;
        for (Score s : scores) {
            if (s.player == me) {
                score += s.points > 2 ? 100 : s.points * 5;
            } else if (s.player != Game.EMPTY_CELL) {
                score += s.points > 2 ? 50 : 0;
            } else {
                score += 1;
            }
        }
        return score;
    }

    private Score getScoreVertical(int[][] board, int col, int row) {
        return getScore(board, col, row, 0, -1);
    }

    private List<Score> getScoreHorizontal(int[][] board, int col, int row) {
        List<Score> scores = new ArrayList<>();

        Score left = getScore(board, col, row, -1, 0);
        Score right = getScore(board, col, row, 1, 0);
        if (left.player == right.player) {
            left.points += right.points;
            scores.add(left);
        } else {
            scores.add(left);
            scores.add(right);
        }
        return scores;
    }

    private List<Score> getScoreDiagonal(int[][] board, int col, int row) {
        List<Score> scores = new ArrayList<>();

        Score leftB = getScore(board, col, row, -1, -1);
        Score rightU = getScore(board, col, row, 1, 1);
        Score leftBottomToRightUp = leftB;
        if (leftB.player == rightU.player) {
            leftBottomToRightUp.points += rightU.points;
        } else if (leftB.points < rightU.points || leftB.player == Game.EMPTY_CELL) {
            leftBottomToRightUp = rightU;
        }

        Score leftU = getScore(board, col, row, -1, 1);
        Score rightB = getScore(board, col, row, 1, -1);
        Score rightBottomToLeftUp = leftU;
        if (leftU.player == rightB.player) {
            rightBottomToLeftUp.points += rightB.points;
        } else if (leftU.points < rightB.points || leftU.player == Game.EMPTY_CELL) {
            rightBottomToLeftUp = rightB;
        }

        if (leftBottomToRightUp.player == rightBottomToLeftUp.player) {
            leftBottomToRightUp.points += rightBottomToLeftUp.points;
            scores.add(leftBottomToRightUp);
        } else {
            scores.add(leftBottomToRightUp);
            scores.add(rightBottomToLeftUp);
        }
        return scores;
    }

    private Score getScore(int[][] board, int initCol, int initRow, int colOffset, int rowOffset) {
        Score score = new Score();
        outerLoop: for (int c = initCol + colOffset;; c += colOffset) {
            for (int r = initRow + rowOffset;; r += rowOffset) {
                if (outside(c, r) || board[c][r] == Game.EMPTY_CELL) {
                    break outerLoop;
                }
                if (score.player == Game.EMPTY_CELL) {
                    score.player = board[c][r];
                }

                if (score.player == board[c][r]) {
                    score.points++;
                } else {
                    break outerLoop;
                }

                if (rowOffset == 0) {
                    break;
                }
            }
            if (colOffset == 0) {
                break;
            }
        }
        return score;
    }

    private boolean outside(int col, int row) {
        return !boardContains(col, row);
    }

    private int getLowestEmptyRow(int[][] board, int col) {
        int[] rows = board[col];
        for (int row = 0; row < rows.length; row++) {
            if (rows[row] == Game.EMPTY_CELL){
                return row;
            }
        }
        return -1;
    }

    private class Score {
        private int player = Game.EMPTY_CELL;
        private int points = 0;
    }
}

OnePlayBot
This bot has only one play - place its piece in the leftmost cell that is valid. Oddly enough it does pretty good ;)
static class OnePlayBot extends Player {
    @Override
    int makeMove() {
        int attemptedMove = 0;

        for (int i = 0; i < getBoardSize()[0]; i++)
            if (ensureValidMove(i)) {
                attemptedMove = i;
                break;
            }

        return attemptedMove;
    }
}

FairDiceRoll
Always returns 4.
static class FairDiceRoll extends Player {
    private int lastMove = 0;
    @Override
    int makeMove() {
        return 4;
    }
}

BasicBlockBot
A simple (and naive) block bot. He doesn't know you can make a 4 in a row horizontally or diagonally!
static class BasicBlockBot extends Player {
    @Override
    int makeMove() {
        List<Integer> inARows = detectInARows();
        double chanceOfBlock = 0.5;

        if (inARows.isEmpty())
            chanceOfBlock = 0;

        if (random() < chanceOfBlock) {
            return inARows.get((int)Math.round(random() * (inARows.size() - 1)));
        } else {
            return (int)Math.round(random() * getBoardSize()[0]);
        }
    }

    /**
     * Very limited - just detects vertical in a rows
     *
     * @return A list of colls that have 4 in a row vertical
     */
    private List<Integer> detectInARows() {
        List<Integer> ret = new ArrayList<>();
        int[][] board = getBoard();

        for (int i = 0; i < board.length; i++) {
            for (int j = 0; j < board[i].length; j++) {
                int currId = board[i][j];
                if (currId != -1 && is4InARowVertical(i, j, board)) {
                    ret.add(i);
                }
            }
        }

        return ret;
    }

    private boolean is4InARowVertical(int coll, int row, int[][] board) {
        int id = board[coll][row];

        for (int i = 0; i < 4; i++) {
            int y = row + i;
            if (!boardContains(coll,y) || board[coll][y] != id)
                return false;
        }
        return true;
    }

}

RandomBot
Just put a piece anywhere that is valid.
static class RandomBot extends Player {
    @Override
    int makeMove() {
        int attemptedMove = (int)Math.round(random() * getBoardSize()[0]);
        while (!ensureValidMove(attemptedMove))
            attemptedMove = (int)Math.round(random() * getBoardSize()[0]);

        return attemptedMove;
    }
}

Progressive
Progressive is... progressive. He likes looking at everything, and some! (I'm not sure of the methodology of this. It worked against a friend, once.) And, for some reason, it works decently.
static class Progressive extends Player{
    @Override
    int makeMove(){
        int move = 0;
        boolean statusBroken = false;
        for(int n=getBoardSize()[0];n>2;n-=2){
            for(int i=0;i<getBoardSize()[0];i+=n){
                if(ensureValidMove(i)){
                    move = i;
                    statusBroken = true;
                    break;
                }
                if(statusBroken) break;
            }
        }
        return move;
    }
}

@JAtkin Sorry, I had an older version of the code.

@JAtkin I rejected your edit.  You should allow them to fix their code in their post.  If you want to fix it for your controller, that's fine (I'd personally still leave a note), but outright modification of somebody's code on SE isn't allowed.

StraightForwardBot
Similar to the OnePlayBot but takes into account the last move and plays the next column over that is valid.
static class StraightForwardBot extends Player {
    private int lastMove = 0;

    @Override
    int makeMove() {
        for (int i = lastMove + 1; i < getBoardSize()[0]; i++) {
            if (ensureValidMove(i)) {
                lastMove = i;
                return i;
            }
        }
        for (int i = 0; i < lastMove; i++) {
            if (ensureValidMove(i)) {
                lastMove = i;
                return i;
            }
        }
        return 0;
    }
}

JealousBot
This bot hates the other player. And he doesn't like that he drops pieces on the board. So he tries to be the last one who have drop a piece in a column.
public class JealousBot extends Player {

    @Override
    public int makeMove() {
        int move = 0;
        boolean madeMove = false;
        int[] boardSize = getBoardSize();
        int id = getID();
        int[][] board = getBoard();

        if(getTurn()!=0) {
            for(int col = 0; col<boardSize[0]; col++) {
                for(int row = 0; row<boardSize[1]; row++) {
                    if(ensureValidMove(col)) {
                        if(board[col][row]!=EMPTY_CELL && board[col][row]!=id) {
                            move = col;
                            madeMove = true;
                            break;
                        }
                    }
                }
                if(madeMove) break;
            }

            if(!madeMove) {
                int temp = (int)Math.round(random()*boardSize[0]);
                while(madeMove!=true) {
                    temp = (int)Math.round(random()*boardSize[0]);
                    if(ensureValidMove(temp)) {
                        madeMove = true;
                    }
                }
                move = temp;
            }
        } else {
            move = (int)Math.round(random()*boardSize[0]);
        }

        return move;
    }
}

It's my first time on CodeGolf, so I hope this answer will be good enough. I couldn't test it yet, so please excuse me if there are any mistakes.
EDIT : Added a line to break the second for.
EDIT 2 : Figured out why the while was infinite. It is now complete and can be used!

Welcome to PPCG, you made me laugh with this answer, that's great ! Just be care with your conditions. I think the board is filled with -1 values by default, so if(board[col][row]!=null && board[col][row]!=id) Should be changed to if(board[col][row]!=-1..... Check in game.Game.genBoard() in OP's github if you wanna be sure. I don't know either if your random() will do what you want, maybe use (int)Math.random()*col?

@Katenkyo Thank you very much, I'm happy if it made you laughed! The random() method is in the Player class! So I think it will work =) But yeah, I wasn't confident in my conditions. I didn't find how it is defined in OP's code, but I'll check again. Thank you very much!

The Player class define random() as public double random() {return ThreadLocalRandom.current().nextDouble();}. I don't know precisely how it works, but I assume it returns a value between 0 and 1, so would may need to do (int)random()*col :)

@Katenkyo Oh, I thought it did that already... My bad. I'll edit it when I have found the right value for an empty cell in the board, thank you again!

@Katenkyo You are correct, nextDouble returns a number between 0 and 1. I included it because the simulations are run in parallel, and Math.random() is not thread safe.

@Keker Yes, a empty location is set to -1. I'll update the challenge and code do make it more clear.

@JAtkin Strange thing, my "while" is apparently infinite... But I just don't know why. Or maybe the random is taking too much time? Edit: Thank you for your comment =) But I didn't really looked at it very well, so it's not your fault

You can now use EMPTY_CELL if you need to find an empty cell.

@JAtkin I fixed this bot, it is now working! Sorry to have made so much edit.

It's fine, though I was scratching my head wondering why the controller was taking so long ;)

BuggyBot
A sample bot for you to beat (FYI: it's not hard ;)
static class BuggyBot extends Player {
    @Override
    int makeMove() {
        return getBoardSize()[1] - 1;
    }
}

PackingBot
This bot isn't aiming for points directly. He tries to pack a maximum of tokens until the board is filled. He understood that simply going up again and again is stupid, so he will randomly put tokens around his "domain".
He should be able to get some points in all directions, but will not be the best !
(Not tested)
package connectn.players;

static class PackingBot extends Player
{
    @Override
    int makeMove()
    {
        int move = 0;
        int[] sizes = getBoardSize();
        if(getTurn()==0)
            return sizes[0]/2+sizes[0]%2;

        int[][] board = getBoard();
        int[] flatBoard =new int[sizes[0]];
        //Creating a flat mapping of my tokens
        for(int i=0;i<sizes[0];i++)
            for (int j=0;j<sizes[1];j++)
                if(board[i][j]!=getID())
                    flatBoard[i]++;

        int max=0;
        int range=0;
        for(int i=0;i<flatBoard.length;i++)
        {
            if(flatBoard[i]!=0)
                range++;
            if(flatBoard[i]>flatBoard[max])
                max=i;
        }

        int sens = (Math.random()>0.5)?1:-1;
        move=((int)(Math.random()*(range+1)*sens))+max;

        while(!ensureValidMove(move))
        {
            move=(move+1*sens)%sizes[0];
            if(move<0)
                move=sizes[0]-1;
        }
        return move;
    }

}

Steve
package connectn.players;

import java.util.Random;
import java.util.concurrent.ThreadLocalRandom;

import connectn.game.Game;

public class Steve extends Player {
    @Override
    public int makeMove() {
        Random r=ThreadLocalRandom.current();
        int attemptedMove = 0;
        int[][]board=getBoard();
        int ec=Game.EMPTY_CELL;
        for(int c=0;c<board.length;c++){
            int j=board[c].length-1;
            for(;j>=0;j--){
                if(board[c][j]!=ec)break;
            }

            if(j>2+r.nextInt(3)&&r.nextDouble()<0.8)return c;
        }
        int k=-2+board.length/2+r.nextInt(5);
        if(ensureValidMove(k))return k;
        for (int i = 0; i < getBoardSize()[0]; i++)
            if (ensureValidMove(i)) {
                attemptedMove = i;
                break;
            }

        return attemptedMove;
    }
}

Steve is having a hard time, he scores under BasicBlockBot.


text:
How long ago was this?
The Rules

Each submission must be a full program.

The program must take input as two comma-separated dates in the form YYYY-MM-DD, and print the number of days that has passed since the second date to STDOUT as if today was the first date (if the second date would be in the future, output a negative number) plus an optional trailing newline, and nothing else. Assume both dates are in the Gregorian calendar.

The program must not write anything to STDERR.
Note that there must be an interpreter so the submission can be tested.

Submissions are scored in bytes, in an appropriate (pre-existing) encoding, usually (but not necessarily) UTF-8. Some languages, like Folders, are a bit tricky to score - if in doubt, please ask on Meta.

This is code-golf, so shortest code wins

Examples
Input:
2015-12-03,2015-12-01
Output:
2
Input:
2015-12-03,2014-12-01
Output:
367
Input:
2015-12-03,2013-12-03
Output:
730

Related

Are we allowed to use external libraries? Ones that are common in a given ecosystem but are not part of the standard lib? (For example, no one uses the JDK's Date APIs but JodaTime instead, even though it is technically an external library).

I assume everything uses UTC, since in my timezone the difference between 2015-11-01T00:00:00 and 2015-11-02T00:00:00 was only ~0.96 days (23 hours) due to daylight savings. You didn't mention anything about rounding fractional days, so you might want to clarify this in the question. (I think a lot of datetime libraries default to using local time.)

What is the case for leap years?

@TheCoffeeCup they must be handled

Why the specific and awkward input format?

How is it awkward? It is standard date format  seperated by commas.. @Adám

@ev3commander Using commas to separate is very artificial for array languages. Is this a parsing challenge or a calculation challenge?

What if my language doesn't support reading date from the system? Can I take it from stdin?

TeaScript, 24 bytes
((a=D.parse)×-a(y©/864e5

Uses Date.parse to parse the date, then get's the difference and divides.
Try it online
Explanation && Ungolfed
((a=D.parse)(x)-a(y))/864e5

               // Implicit: x is first date
               // y is second date
(
 (a=D.parse)   // Assign Date.parse to 'a'
 (x)           // Run Date.parse with first date
 -a(y)         // Subtract Date.parse run with second date
)/864e5        // Divide by 86,400,000

Bash + GNU utilities, 37
tr , \\n|date -f- +%s|dc -e??-86400/p

tr replaces the comma with a newline.  date reads the newline separated dates and outputs the number of seconds since the Unix epoch that the passed-in date represents.  These numbers are then put on the dc stack.  Then its a simple matter of subtraction and divide by (24*60*60).  In this case, dc stack-based RPN arithmetic evaluation is better than bc or bash $( ), mostly because the subraction-before-division needs no parentheses.
Input via STDIN:
$ echo 2015-12-3,2015-12-1 | ./longago.sh
2
$ echo 2015-12-3,2014-12-1 | ./longago.sh
367
$ echo 2015-12-3,2013-12-3 | ./longago.sh
730
$

Julia, 67 bytes
print(Int(-diff(map(i->Date(i,"y-m-d"),split(readline(),",")))[1]))

Ungolfed:
# Read a line from STDIN
r = readline()

# Split it into two character dates
s = split(r, ",")

# Convert each to a Date object
d = map(i -> Date(i, "y-m-d"), s)

# Compute the difference in dates (first-second)
f = diff(d)[1]

# Convert the Base.Date.Day object to an integer
# Negate to get second-first
i = Int(-f)

# Print to STDOUT
print(i)

Instead of -diff(d)[1] you can use -(d...) to save a couple of bytes. What Julia version are you using by the way? On 1.2, I had to explicitly import Dates and I also can't just convert days to integers like this.

This answer was posted in 2015, so it was probably Julia 0.3 or 0.4 at the latest.

Scala, 166 139 120 116 92 bytes
print(args(0).replace('-','/').split(",").map(java.util.Date.parse(_)/86400000).reduce(_-_))

Usage: scala [source filename].scala [date1],[date2]
Note: The third version (120 bytes) and on uses a deprecated API. It still compiles and works fine.
Note2: Thanks to the commenters below for the great advice!

Since the trailing new line is optional you could use print instead of println.

You can remove the Object A extends App{...} part and save it as a.scala and run it with scala a.scala 2015-12-3,2015-12-1 ;)

@MartijnR Genius! Thanks!!

Ruby, 69 66 65 57 55 bytes
a=->l{Time.gm *$F[l,3]};p (a[0]-a[3]).div 86400

47 bytes + 8 bytes for command line option. Thanks to Dane Anderson, saved 2 bytes.
57 bytes
p (Time.gm(*$F[0,3])-Time.gm(*$F[3,3])).div 86400

49 bytes code + 8 bytes for command line option. Saved 8 bytes with manatwork's suggestion.
65 bytes
a,b=gets.split(?,).map{|i|Time.gm *i.split(?-)};p (a-b).div 86400

66 bytes
a,b=gets.split(?,).map{|i|Time.new *i.split(?-)};p (a-b).div 86400

69 bytes
a,b=gets.split(',').map{|i|Time.new *i.split('-')};p (a-b).to_i/86400

Test it online
Ungolfed
a = -> l {
  Time.gm *$F[l,3]       # Anonymous method to parse time
}
p (a[0]-a[3]).div 86400  # Subtracts two times and divides by 24*60*60

Usage:
ruby -naF[,-] -e 'a=->l{Time.gm *$F[l,3]};p (a[0]-a[3]).div 86400' <<< '2015-12-3,2013-12-3'

=> 730

Three little chars: ',' → ?,, '-' → ?-, to_i/ → div .

Using some command line options may reduce it more: ruby -naF[,-] -e 'p (Time.new(*$F[0,3])-Time.new(*$F[3,3])).div 86400' <<< '2015-10-11,2015-07-11' is 59 characters as I count it.

@manatwork Not sure if that is allowed.

The rule is that the minimum necessity needed to pass the code (in case of Ruby -e) is free, everything else has to be included in the count. There are different opinions on what exactly is that everything else. For example some members include the option separator space character and quotes around parameter values. In my view should only be counted what actually gets passed to the interpreter, extra characters required by shell syntax not. But can't remember any voice raised to disallow the use of options.

@manatwork Got it. Updated the answer.

almost not worth mentioning, but you can shave a byte by moving the repeated code into a proc: t=->l{Time.gm(*$F[l,3])};p (t[0]-t[3]).div 86400

@DaneAndersen, it certainly worth. And with your proc another character can be spared by removing the parenthesis around Time.gm's parameter. Good catch. I only tried to use proc in an earlier phase when it was not yet feasible.

Javascript ES6, 63 bytes
Tested in chrome.
alert(((p=Date.parse)((a=prompt().split`,`)[0])-p(a[1]))/864e5)

comma-seperated from the question

@ev3commander Yes, I just fixed that.

I wonder why it works on Chrome but not on Firefox.

@CᴏɴᴏʀO'Bʀɪᴇɴ I've never actually tested this in firefox.

@SuperJedi224 Huh. Firefox gives Invalid date, whilst chrome happily proceeds.

I'd mark this Chrome-specific as it only seems to work in chrome. I think the compliant way would be to use Date.parse and replace the - with /

works fine in chrome

Weird, I get an NaN error as the return from the alert, and the console says undefined in the console. (Thats on MS Edge). Chrome works fine though like everyone else is saying.

Most browsers require the date to be padded so 2015-12-03 will work but 2015-12-3 will not (except in Chrome). The question does say that the date will be in the format YYYY-MM-DD so if the input really did follow that it would be cross-browser compatible, however the examples seem to say otherwise. Anyway, you could use Date.parse instead of new Date to save 2 bytes: alert((p((a=prompt(p=Date.parse).split`,`)[0])-p(a[1]))/864e5)

@user81655 Uncaught TypeError: p is not a function. Attempting alternate restructure. Edit: Okay, I found a way that works.

Oops, my bad! Try this one (62 bytes): alert((a=prompt(p=Date.parse).split`,`,p(a[0])-p(a[1]))/864e5)

@user81655 Sorry for the confusion. Now it says 2015-12-03 instead of 2015-12-3

Japt, 41 bytes
A=K$.parse)(($B=Uq',  g0)-$A($Bg1))/864e5

So far this is the best I can get it as all the variables and $ and parenthesis really kill the byte count.
Try it online
Explanation
             // Implicit: U is set to input
A=K$.parse)  // Set variable A to date parsing function
(($B=Uq',    // Set B to input split by ,
  g0)        // Get the first date and parse
-            // Subtract...
$A(          // Parse this date...
   $Bg1      // Get's second date
))/864e5     // Divides by 86,400,000

MATLAB, 41 31 bytes
disp(-diff(datenum(input(''))))
{'2015-12-03', '2014-12-22'}
   346

Input must be a comma-separated cell array. datenum converts the input cell into a 2x1 numeric array with the time stamp. diff takes the difference between the two.

Old solution, 41 bytes:
disp(-diff(datenum(strsplit(input('')))))

Input must be a comma-separated string:
disp(-diff(datenum(strsplit(input('')))))
'2015-12-03, 2014-12-22'
   346

The curious ways of programming. This works because of MATLAB's implicit casting between datatypes.
The output from strsplit(input('')) is a cell of strings. You cannot use diff on a cell, but fortunately, datenum works, and it actually casts the cell input back to a 2x1 numeric array, making diff possible to use.
You can specify a whole lot of delimiters in strsplit, but comma is the default one. Also, the default input to datenum is on the format yyyy-mm-dd. For those reasons, a lot of specifications such as: datenum(s,'yyyy-mm-dd') are avoided, saving a whole lot of bytes.
For the record, this would be 21 bytes if I could use a function:
@(s)-diff(datenum(s))

How could I forget about diff... Might as well just delete my submission, because it's essentially the same, but with 2 calls to datenum instead.

Great choice of input format!

PHP, 63 64 77 bytes
Found that the classic approach is shorter than the OOP one:
$x=fgetcsv(STDIN);$s=strtotime;echo($s($x[0])-$s($x[1]))/86400;

Reads the comma separated string from STDIN.

The straight forward OOP way (77 bytes):
$x=fgetcsv(STDIN);echo(new DateTime($x[0]))->diff(new DateTime($x[1]))->days;

Edits

Saved 13 bytes by using strtotime instead of DateTime.
Saved 1 byte by storing strtotime in a variable. Thanks to Blackhole.

-3 bytes: move the assignments to their first usage in parentheses (-1 byte each) and You can use <?= instead of echo.

Excel, 25 bytes
=LEFT(A1,10)-RIGHT(A1,10)

Excel automatically handles the strings as dates.

Python 2, 109 113 bytes
import datetime as d
j=[d.date(*[int(k) for k in g.split('-')]) for g in raw_input().split(',')]
print j[0]-j[1]

The spaces between )s and fors are not needed.

VBA, 69 bytes
Function x(s)
g=Split(s, ",")
x=CDate(g(0))-CDate(g(1))
End Function

psql, 75 bytes
(74 characters code + 1 character command line option)
\prompt i
select split_part(:'i',',',1)::date-split_part(:'i',',',2)::date

psql is PostgreSQL's interactive terminal. To respect the “Each submission must be a full program.” rule, the code reads the input itself.
Sample run:
bash-4.3$ psql -tf how-long-was-this.sql <<< '2015-12-3,2013-12-3'
      730

PowerShell v2+, 50 44 Bytes
$a,$b=$args-split','|%{date $_};($a-$b).Days

Takes input argument as a string, splits it on the comma, then pipes the array via a built-in alias date short for Get-Date to convert our strings into .NET datetime format. Those two dates then get stored simultaneously into $a and $b. We then use an overloaded-subtraction-operator to subtract the second from the first, and output the .Days thereof.
Golfed 6 bytes thanks to TessellatingHeckler.
Technically non-competing, as it doesn't have an online interpreter available, since the FOSS implementation of PowerShell, Pash, is around PowerShell v0.5. It doesn't support -split yet, let alone the complex .NET date functionality.

MATL, 5 bytes
iPYOd

This is the same as StewieGriffin's answer, except I used flip then diff rather than diff then negating the result.
Full explanation, with corresponding Matlab functions:
i   %// input(''), get input
P   %// flip, flips the array
YO  %// datenum, converts date string into an integer
d   %// diff, finds the difference between dates

Note: Whilst MATL was only released on December 12, after this challenge was posted, I came up with this answer on December 9 using a pre-release MATL compiler, which is almost identical to the released compiler, this code is the same.

Also, this is in no way an endorsement of the popular Apple portable music device :P

I should have used o for the datenum function :-D

That would have been amazing!

Does this handle leap years?

If the pre-release compiler is not public, this is invalid.

(I'm pretty sure this should be CW anyway because it's "the same as StewieGriffin's answer")

@ev3commander most answers on PPCG are the same as other answers, especially in cases like this where 4 commands suffice.

@David But you used a variant of the same language, etc...

This is invalid because of your first comment

Override header: invalid

Japt, 13 bytes
£ÐXÃr- zHÑ7e5

Try it

JavaScript, 58 53 bytes thanks to @targumon!
n=>(new Date((a=n.split`,`)[0])-new Date(a[1]))/864e5

Older version:
n=>(new Date((a=n.split(','))[0])-new Date(a[1]))/86400000

My submissions seem to have a reputation of being boring.

Let's push it down to 53 bytes:
n=>(new Date((a=n.split\,`)[0])-new Date(a[1]))/864e5`

Jolf, 33 bytes
Only works in Chrome. Noncompeting, since language updates postdate question. I'll add a more thorough explanation later.
$S=$viGi', mDN~DH r}/m4SmeP"864"5

“Explanation”
$S=$viGi', mDN~DH r}
$S=$                 sets S equal to
    viGi',           take string input and reassign it to the comma-split input
           mD      } map with this function
             N~DH r  return the time of the date of H (element)

/m4SmeP"864"5
/             divide
 m4S           subtraction applied to S (S[0] - S[1])
    meP"864"5  and 864 * 10 ^ 5 (thanks to Super Jedi for his nice constant)
              implicit output

How about you put "noncompeting" in your header?

MATLAB, 59 bytes
s=strsplit(input(''),',');disp(datenum(s{1})-datenum(s{2}))

Very straightforward approach: input has to be given as a string from the command window. The input string is then split and the number of days between the dates (and nothing else) is calculated from the serial date numbers.
I'm quite sure there is a way to avoid the need for calling datenum twice though...

jq, 50 bytes
(49 characters code + 1 character command line option)
./","|map(.+"T0:0:0Z"|fromdate)|(.[0]-.[1])/86400

Sample run:
bash-4.3$ ~/bin/jq -R './","|map(.+"T0:0:0Z"|fromdate)|(.[0]-.[1])/86400' <<< '2015-12-3,2013-12-3'
730

On-line test (Passing -R through URL is not supported – so input passed as string "2015-12-3,2013-12-3".)

T-SQL + SQLCMD, 51 bytes
PRINT DATEDIFF(D,RIGHT('$(i)',10),LEFT('$(i)',10))

Tested with SQL Server 2008R2.  The $(i) is replaced with the input provided as a command line argument.
Sample run:
sqlcmd -i script.sql -v i="2015-12-08,2016-01-01"
-24

Perl, 91 86 + 2 for np flags, 88 bytes
use Date::Calc qw(Delta_Days);($a,$b)=split(/,/);$_=Delta_Days(split(/-/,$b),split(/-/,$a))
use Date::Parse;$_=str2time((split(/,/,$_))[0])-str2time((split(/,/,$_))[1]);$_/=86400

Example
$ echo 2015-12-3,2015-12-1 | perl -npe 'use Date::Parse;$_=str2time((split(/,/,$_))[0])-str2time((split(/,/,$_))[1]);$_/=86400'
2

Mathematica, 61 bytes
Print@First[#-#2&@@DateObject/@InputString[]~StringSplit~","]

Basic date subtraction.

Mathematica, 56 bytes
Print@#&@@-DateDifference@@InputString[]~StringSplit~","

Most (all?) date functions will try to parse string inputs into dates automatically.

C# .NET, 148 bytes
using System;class P{static void Main(string[]a){Console.Write((DateTime.Parse(a[0].Substring(11,10))-DateTime.Parse(a[0].Substring(0,10))).Days);}}

Try Online

C (gcc), 225 199 bytes
-25 bytes thanks to ceilingcat! Replacing an array of numbers with a string of wide-characters is some proper black-magic
-1 byte by adding an additional character to the start of the string, allowing for indexing with [m] instead of [m-1]
a,b,d,e,f;i(m,y){return(a=y-1)*365+a/4-a/100+a/400+L"\0\37;Zx\x97µÔóđİŎ"[m]+(m>1&(y%100*!(y%4)||y%400<1));}main(c){scanf("%d-%d-%d,%d-%d-%d",&a,&b,&c,&d,&e,&f);printf("%d",i(b,a)-i(e,d)+c-f);}

Try it online!
Perhaps the code could be shortened by using <time.h>, but not using it makes for a fun challenge.
The difference between dates is calculated using a golfed version of this code.
Un-golfed:
a,b,d,e,f;
i(m,y){
    return(a=y-1)*365 /*Num days in y-1 years*/
        +a/4-a/100+a/400 /*Add previous years' leap days*/
        +L" \0\37;Zx\x97µÔóđİŎ"[m] /*Add days this year until month*/
        +(m>1&(y%100*!(y%4)||y%400<1)); /*Add this year's leap day*/
}
main(c){
    scanf("%d-%d-%d,%d-%d-%d",&a,&b,&c,&d,&e,&f);
    printf("%d",i(b,a)-i(e,d)+c-f);
}

source: Stack Exchange

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/

sort: votes


text:
Make a numeric list converter
Don't you hate it when you want to copy-paste a list of numbers (vector, array ...), from one program to another, but the format you have the numbers on doesn't match the format you need it on?
For instance, in MATLAB you may have a space separated list like this:
[1 2 3 4 5]    (you can also have it comma separated, but that's not the point)

In Python you would need to insert commas to make that list a valid input, so you'd have to convert it to
[1, 2, 3, 4, 5]

to make it work. In C++ you might want something like:
{16,2,77,29}

and so on.
To simplify everyone's life, let's create a list converter, that takes a list on any format*, and outputs a list on another specified format.
The valid brackets are:
[list]
{list}
(list)
<list>
list      (no surrounding brackets)

The valid delimiters are:
a,b,c
a;b;c
a b c
a,  b,  c       <-- Several spaces. Must only be supported as input.
a;     b; c     <-- Several spaces. Must only be supported as input.
a   b   c       <-- Several spaces. Must only be supported as input.

Note, the input can have any number of spaces between the numbers, but the output can choose to have zero spaces (if , or ; is used as delimiter), or a single space (if it's space-delimited).
In addition to the input list, there will be a string (or two characters) that defines the output format. The format string will first be the opening bracket type (only), [, (, <, { or  (the last one is a single space used when there is no surrounding bracket). The bracket type will be followed by the delimiter type, ,, ; or  (the last one is a single space). The two input format characters must be taken as a single argument (string or two consecutive characters) in the order described above.
Some examples of format strings:
[,    <-- Output format:   [a,b,c]
{;    <-- Output format:   {a;b;c}
      <-- Two spaces, output list has format:   a b c

Rules:

The output can't have leading spaces
The output can have trailing spaces and a newline

The output should only  be the list of numbers, not ans = or similar

The input will be a list of integer or decimal numbers (both positive and negative (and zero)), and a string of two characters

If the input consist of only integers, the output list should have only integers. If the input list consist of integers and decimal numbers, all output numbers can be decimal numbers. (It's optional to keep the integers as integers)
The maximum number of digits after the decimal point that must be supported are 3.
The input will be two arguments. I.e. the numbers are in one argument, and the format string is a single argument.

The code can be a program or function
The input can be function argument or STDIN

Some examples:
1 2 3 4
[,
[1,2,3,4]

<1;  2;  3>
 ;    <-- Space + semicolon
1;2;3
not valid:  1.000;2.000;3.000   (Input is only integers => Output must be integers)

{-1.3, 3.4, 4, 5.55555555}
[,
[-1.300,3.400,4.000,5.556]  (5.555 is also valid. Rounding is optional)
also valid: [-1.3,3.4,4,5.55555555]

The shortest code in bytes win. As always, the winner will be selected one week from the day the challenge was posted. Answers that are posted later can still win if they are shorter than the current winner.

Leaderboard
The Stack Snippet at the bottom of this post generates the catalog from the answers a) as a list of shortest solution per language and b) as an overall leaderboard.
To make sure that your answer shows up, please start your answer with a headline, using the following Markdown template:
## Language Name, N bytes

where N is the size of your submission. If you improve your score, you can keep old scores in the headline, by striking them through. For instance:
## Ruby, <s>104</s> <s>101</s> 96 bytes

If there you want to include multiple numbers in your header (e.g. because your score is the sum of two files or you want to list interpreter flag penalties separately), make sure that the actual score is the last number in the header:
## Perl, 43 + 2 (-p flag) = 45 bytes

You can also make the language name a link which will then show up in the snippet:
## [><>](http://esolangs.org/wiki/Fish), 121 bytes

var QUESTION_ID=66345,OVERRIDE_USER=44713;function answersUrl(e){return"https://api.stackexchange.com/2.2/questions/"+QUESTION_ID+"/answers?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+ANSWER_FILTER}function commentUrl(e,s){return"https://api.stackexchange.com/2.2/answers/"+s.join(";")+"/comments?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+COMMENT_FILTER}function getAnswers(){jQuery.ajax({url:answersUrl(answer_page++),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){answers.push.apply(answers,e.items),answers_hash=[],answer_ids=[],e.items.forEach(function(e){e.comments=[];var s=+e.share_link.match(/\d+/);answer_ids.push(s),answers_hash[s]=e}),e.has_more||(more_answers=!1),comment_page=1,getComments()}})}function getComments(){jQuery.ajax({url:commentUrl(comment_page++,answer_ids),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){e.items.forEach(function(e){e.owner.user_id===OVERRIDE_USER&&answers_hash[e.post_id].comments.push(e)}),e.has_more?getComments():more_answers?getAnswers():process()}})}function getAuthorName(e){return e.owner.display_name}function process(){var e=[];answers.forEach(function(s){var r=s.body;s.comments.forEach(function(e){OVERRIDE_REG.test(e.body)&&(r="
"+e.body.replace(OVERRIDE_REG,"")+"
")});var a=r.match(SCORE_REG);a&&e.push({user:getAuthorName(s),size:+a[2],language:a[1],link:s.share_link})}),e.sort(function(e,s){var r=e.size,a=s.size;return r-a});var s={},r=1,a=null,n=1;e.forEach(function(e){e.size!=a&&(n=r),a=e.size,++r;var t=jQuery("#answer-template").html();t=t.replace("{{PLACE}}",n+".").replace("{{NAME}}",e.user).replace("{{LANGUAGE}}",e.language).replace("{{SIZE}}",e.size).replace("{{LINK}}",e.link),t=jQuery(t),jQuery("#answers").append(t);var o=e.language;/s.lang?1:e.lang<s.lang?-1:0});for(var c=0;c<t.length;++c){var i=jQuery("#language-template").html(),o=t[c];i=i.replace("{{LANGUAGE}}",o.lang).replace("{{NAME}}",o.user).replace("{{SIZE}}",o.size).replace("{{LINK}}",o.link),i=jQuery(i),jQuery("#languages").append(i)}}var ANSWER_FILTER="!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe",COMMENT_FILTER="!)Q2B_A2kjfAiU78X(md6BoYk",answers=[],answers_hash,answer_ids,answer_page=1,more_answers=!0,comment_page;getAnswers();var SCORE_REG=/<h\d>\s*([^\n,]*[^\s,]),.*?(\d+)(?=[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/,OVERRIDE_REG=/^Override\s*header:\s*/i;
body{text-align:left!important}#answer-list,#language-list{padding:10px;width:290px;float:left}table thead{font-weight:700}table td{padding:5px}
 <link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b">

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

{{PLACE}}	{{NAME}}	{{LANGUAGE}}	{{SIZE}}	Link

{{LANGUAGE}}	{{NAME}}	{{SIZE}}	Link

Is trailing and leading whitespace permitted?

@overactor, see the first two rules. Leading whitespace is not OK, trailing is OK.

Can we take input in the opposite order? (delimiters first, list second)

@MartinBüttner, yes. It's not specified that it has to be list first, so you may choose.

J uses _ to denote negative elements. :(

Can the order of input arguments be chosen at will?

CJam, 27 bytes
l)l_5ms`-SerS%*\S-_o_'(#(f-

Try it here.
Explanation
l      e# Read the format string.
)      e# Extract the separator.
l_     e# Read the list.
5ms`   e# Get a string that contains -.0123456789.
-      e# Get the characters in the list that are not in the string.
Ser    e# Replace those characters with spaces.
S%     e# Split by those characters, with duplicates removed.
*      e# Join with the separator.
\S-    e# Remove spaces (if any) from the left bracket.
_o     e# Output a copy of that character before the stack.
_'(#   e# Find '( in the left bracket string.
(      e# Get -1 if '( is the first character, and -2 if it doesn't exist.
f-     e# Subtract the number from every character in the left bracket string,
          making a right bracket.

JavaScript (ES6), 75 82
As an anonymous function
Edit: 2 byte saved thx @user81655 (and 5 more just reviewing it)
(l,[a,b])=>a.trim()+l.match(/[-\d.]+/g).join(b)+']})> '['[{(< '.indexOf(a)]

Test snippet

F=(l,[a,b])=>a.trim()+l.match(/[-\d.]+/g).join(b)+']})> '['[{(< '.indexOf(a)]

// Test
console.log=x=>O.innerHTML+=x+'\n'
// default test suite
t=[['1 2 3 4','[,'],['<1;  2;  3>',' ;'],['{-1.3, 3.4, 4, 5.55555555}','[,']]
t.forEach(t=>console.log(t[0]+' *'+t[1]+'* '+F(t[0],t[1])))
function test() { console.log(P1.value+' *'+P2.value+'* '+F(P1.value,P2.value)) }
#P1 { width: 10em }
#P2 { width: 2em }
P1<input id=P1>
P2<input id=P2>
<button onclick="test()">-></button>

CJam, 35 34 bytes
l(S-l"{[<(,}]>);":BSerS%@*1$B5/~er

Test it here.
Expects the format on the first line and the list on the second.
Explanation
l   e# Read the format line.
(   e# Pull off the first character, which is the opening bracket.
S-  e# Set complement with a space, which leaves brackets unchanged and turns a space
    e# into an empty string.
l   e# Read the list.
"{[<(,}]>);":B
    e# Push this string which contains all the characters in the list we want to ignore.
Ser e# Replace each occurrence of one of them with a space.
S%  e# Split the string around runs of spaces, to get the numbers.
@   e# Pull up the the delimiter string.
*   e# Join the numbers in the list with that character.
1$  e# Copy the opening bracket (which may be an empty string).
B5/ e# Push B again and split it into chunks of 5: ["{[<(," "}]>);"]
~   e# Unwrap the array to leave both chunks on the stack.
er  e# Use them for transliteration, to turn the opening bracket into a closing one.

Pyth, 33 bytes
rjjezrXwJ"<>[]  {}(),;"d7@c6JChz6

Try it online: Demonstration or Test Suite
Explanation:
J"<>[]  {}(),;"  assign this string to J

rjjezrXwJd7@c6JChz6   implicit: z = first input string, e.g. "[;"
       w              read another string from input (the list of numbers)
      X Jd            replace every char of ^ that appears in J with a space
     r    7           parse ^ (the string of numbers and spaces) into a list
  jez                 put z[1] (the separator symbol) between the numbers
            c6J       split J into 6 pieces ["<>", "[]", "  ", "{}", "()", ",;"]
               Chz    ASCII-value of z[0] (opening bracket symbol)
           @          take the correspondent (mod 6) brackets from the list
 j                    and put the numbers between these brackets
r                 7   remove leading and trailing spaces

Can you add an explanation of how it works?

@Shel Here you are.

PowerShell, 108 100 95 85 Bytes
$i,$z=$args;($z[0]+($i-split'[^\d.-]+'-ne''-join$z[1])+' }) >]'[($z[0]-32)%6]).Trim()

(see revision history for previous versions)
Golfed another 15 bytes by removing $b and $s variables and changing parens on the inner string.
This takes input as two strings and stores them into $i and $z, then we construct a new output string. The inner parens -splits $i with a regex to select only numeric digits, then -joins back together with the requested delimiter. We concatenate that with the first character of the delimiter input (e.g., [) and close it with indexing into a string based on the ASCII value of the first character and some formulation trickery. The outer .Trim() removes any leading or trailing spaces.

I think you could replace your closing bracket expression "]})>"["[{(< ".IndexOf($b[0])] with something like ' }) >]'[($b[0]-32)%6]. The ($b[0]-32)%6 gives you 0,2,4,5,1 for opening bracket characters, which you can use to index into the closing bracket string ' }) >]'. There might be a shorter "formula", but this seems good enough.

@DankoDurbić Excellent! I was trying to come up with some math to select on the correct output character based on ASCII values, but I couldn't find the right formula. I kept getting tripped up by () being right next to each other, but the other brackets have a character between, so I went with indexing. Thanks!

Using String.Replace() instead of the -replace operator would buy you another 2 bytes (no need to escape or define a character class with [])

@MathiasR.Jessen Unless I'm missing something here, the .Replace('[]{}()<>;,',' ') won't catch individual characters but instead try to match the symbolic whole, which doesn't exist. We'd need to use Regex.Replace, which involves a [regex]:: .NET call and would instead lengthen the code.

@TessellatingHeckler Thanks! I golfed another byte using -ne'' instead of |?{$_}.

Neat, I didn't know you could -ne on an array.

Python 2, 96 bytes
import re
lambda(a,(b,c)):(b+c.join(re.findall('[-\d\.]+',a))+'])>} '['[(<{ '.index(b)]).strip()

Call as:
f(('{-1.3, 3.4, ,4, 5.55555555}','[,'))

Output:
[-1.3,3.4,4,5.55555555]

JavaScript (ES6), 82 92 116 92 bytes
(a,b)=>(c=a.match(/-?\d+(\.\d+)?/g).join(b[1]),d=b[0],d<"'"?c:d+c+"]}>)"["[{<(".indexOf(d)])

An anonymous function, run it like this
((a,b)=>(c=a.match(/-?\d+(\.\d+)?/g).join(b[1]),d=b[0],d<"'"?c:d+c+"]}>)"["[{<(".indexOf(d)]))("{1;  2;3;   4}","<;")

This can probably be golfed way further..
Ungolfed
(a,b)=>(                             // "{1;  2;3;   4}", "<;"
    c=a.match(/-?\d+(\.\d+)?/g)      // regex to match decimals
    .join(b[1]),                     // c -> "1;2;3;4"
    d=b[0],                          // d -> "<"
    d<"'" ?                          // if d is smaller than ' then ...
        c :                          // return just "1;2;3;4"
        d + c +                      // "<" + "1;2;3;4" + ...
        "]}>)" [ "[{<(".indexOf(d) ] // "]}>)"[2] -> ">"
)

I think you have to take a as a string, not a list.

Totally misunderstood this: The input will be a list of integer or decimal numbers (both positive and negative (and zero)), and a string of two characters. Fixed it, thanks

Mathematica, 108 bytes
Mathematica is generally clumsy with string inputs unless the string is meant to be interpreted as a text.
c=Characters;t_~f~p_:=({b,s}=c@p;b<>Riffle[StringCases[t,NumberString],s]<>(b/.Thread[c@"[ {<(" -> c@"] }>)"]))

Explanation
StringCases[t,NumberString]returns the list of number strings.
Riffleinserts the separators between the numbers.
/.Thread[c@"[ {<(" -> c@"] }>)"]) replaces the left "bracket" with the right bracket.
<> is the infix form of StringJoin.  It glues together the substrings.

Bash + GNU Utilities, 90
b=${2:0:1}
echo $b`sed "s/[][{}()<>]//g;s/[,; ]\+/${2:1}/g"<<<"$1"``tr '[{(<' ']})>'<<<$b`

Matlab, 85 bytes
@(s,x)[x(1) strjoin(regexp(s,'-?\d+\.?\d*','match'),x(2)) x(1)+(x(1)~=32)+(x(1)~=40)]

Example use:
>> @(s,x)[x(1) strjoin(regexp(s,'-?\d+\.?\d*','match'),x(2)) x(1)+(x(1)~=32)+(x(1)~=40)]
ans =
    @(s,x)[x(1),strjoin(regexp(s,'-?\d+\.?\d*','match'),x(2)),x(1)+(x(1)~=32)+(x(1)~=40)]

>> ans('1 2.4 -3 -444.555 5', '[,')
ans =
[1,2.4,-3,-444.555,5]

Julia, 95 bytes
f(l,s)=(x=s[1]<33?"":s[1:1])*join(matchall(r"[\d.-]+",l),s[2])*string(x>""?s[1]+(s[1]<41?1:2):x)

This is a function f that accepts two strings and returns a string.
Ungolfed:
function f{T<:AbstractString}(l::T, s::T)
    # Extract the numbers from the input list
    n = matchall(r"[\d.-]+", l)

    # Join them back into a string separated by given separator
    j = join(n, s[2])

    # Set the opening bracket type as the empty string unless
    # the given bracket type is not a space
    x = s[1] < 33 ? "" : s[1:1]

    # Get the closing bracket type by adding 1 or 2 to the ASCII
    # value of the opening bracket unless it's an empty string
    c = string(x > "" ? s[1] + (s[1] < 41 ? 1 : 2) : x)

    # Put it all together and return
    return x * j * c
end

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


text:
Point in convex hull (2D)
Background
The convex hull of a finite number of points is the smallest convex polygon that contains all of the points, either as vertices or on the interior. For more information, see this question on PGM which defines it very well.
Input
N+1 2-D coordinates (N >= 3) passed through STDIN (with other usual golf inputs allowed too) in the following format (the number of decimals can vary but you can assume it remains "reasonable" and each number can be represented as a float):
0.00;0.00000
1;0.00
0.000;1.0000
-1.00;1.000000

Output
A truthy value printed to STDOUT (or equivalent) if the first point in the list ((0.00;0.00000) in the example above) is in the convex hull of the other N points, and a falsy value otherwise.
This is code-golf, so the shortest solution in bytes wins.

Border cases: you can return any value (but don't crash) if the point lies on the border of the convex hull (i.e. on a side or on a vertex on the outer frontier of the hull), since it is a zero probability event (under any reasonable probability).
Forbidden: anything (language, operator, data structure, built-in or package) that exists only to solve geometric problems (e.g. Mathematica's ConvexHull). General purpose mathematical tools (vectors, matrices, complex numbers etc.) are allowed.

Tests

Should return TRUE: spiralTest1-TRUE, squareTest1-TRUE
Should return FALSE: spiralTest2-FALSE, squareTest2-FALSE

What is an "ad hoc data structure"?

"elementary functions/operators" is much too vague.

@DavidCarraher: something like a Polygon, or a Triangle, or a Segment (anything that exists only to solve geometric problems).

@quintopia: any builtin that solves the convex hull problem is forbidden (what would be the point).

@xnor: tried to clarify.

@AlexandreHalm Your edit helped a lot. I think "elementary" isn't the right word. I thought it would eliminate general-purpose built-ins like sort or round. I think it's clearer to just say nothing specifically made for geometry is allowed. What, though, about a function to add two lists as vectors? Or a function to find the argument (angle) of a complex number?

@xnor: good question. What would you suggest?

@AlexandreHalm I think it's too fuzzy to delineate between generic geometric operations and generic list/complex operations. Maybe just ban things specifically having to do with complex hull, polygons, and geometric inclusion? That might still be too vague. Another solution is to just allow anything and let Mathematica do what it wants.

Are the input points guaranteed to be "on" the hull, or could some of them be meaningless since they're "inside" as well? (Or, phrased another way, do the input points form a convex polygon)

This is why the Diamonds request people please use the Sandbox before posting new challenges.

@TimmyD: the points are random (i.e. they don't necessarily form a convex polygon). It wouldn't be fun otherwise

@AlexandreHalm Is it ok to call a linear programming algorithm (eg. boot::simplex in R), or does linear algebra count as geometric?

@han: linear algebra and complex numbers are indeed a bit tricky. Let's say both are fine (I'll edit the question to clarify this). Just no "pure" geometry.

J, 40 39 34 bytes
3 :'(o.1)<(>./-<./)12 o.y*+{.y'@:-

An anonymous dyadic function, taking a point, p, as one of its arguments, and a list of points, P, as the other argument (it doesn't matter which argument is which), and returning 0 or 1, if p is outside or inside the convex hull of P, respectively.
The point p, and the points in P, are taken as complex numbers.
Example
  is_inside =: 3 :'(o.1)<(>./-<./)12 o.y*+{.y'@:-

  0.5j0.5  is_inside  0j0 0j1 1j0 1j1
1
  1.5j0.5  is_inside  0j0 0j1 1j0 1j1
0

or...
Python 2, function, 121 103, full program, 162
Python 3, 149 bytes
import sys,cmath as C
p,q,*P=[complex(*eval(l.replace(*";,")))for l in sys.stdin]
A=[C.phase((r-p)/(q-p+(q==p)))for r in P]
print(max(A)-min(A)>C.pi)

Takes input, in the same format as the original post, through STDIN, and prints a boolean value indicating whether p is in the convex hull of P

Explanation
The program tests whether the difference between the maximum and minimum (signed) angles between any point r in P, p, and a fixed arbitrary point q in P (we just use the first point in P), is less than 180°.
In other words, it tests whether all the points in P are contained in an angle of 180° or less, around p.
p is in the convex hull of P if and only if this condition is false.

At the cost of a few more bytes, we can use a similar method that doesn't require us to explicitly calculate angles:
Note that the above condition is equivalent to saying that p is outside the convex hull of P if and only if there exists a line l through p, such that all the points in P are on the same side of l.
If such a line exists, then there's also such a line that is incident to one (or more) of the points in P (we can rotate l until it touches one of the points in P.)
To (tentatively) find this line, we start by letting l be the line through p and the first point in P.
We then iterate over the rest of the points in P; if one of the points is to the left of l (we assume some directionality throughout, left or right doesn't really matter,) we replace l with the line passing through p and that point, and continue.
After we iterated over all of P, if (and only if) p is outside the convex hull, then all the points in P should be to the right of (or on) l.
We check that using a second pass over the points in P.
Python 2, 172 bytes
import sys
P=[eval(l.replace(*";,"))for l in sys.stdin]
x,y=P.pop(0)
C=lambda(a,b),(c,d):(a-x)*(d-y)-(b-y)*(c-x)>0
l=reduce(lambda*x:x[C(*x)],P)
print any(C(l,q)for q in P)

Alternatively, to do the same thing in a single pass, let to-the-left-of be a realtion between any two points, q and r, in P, such that q is to the left of r if q is to the left of the line passing through p and r.
Note that to-the-left-of is an order relation on P if and only if all the points in P are on the same side of some line passing through p, that is, if p is outside the convex hull of P.
The procedure described above finds the minimum point in P w.r.t. this order, i.e., the "leftmost" point in P.
Instead of performing two passes, we can find the maximum (i.e., the "rightmost" point), as well as the minimum, points in P w.r.t. the same order in a single pass, and verify that the minimum is to the left of the maximum, i.e., effectively, that to-the-left-of is transitive.
This would work well if p is outside the convex hull of P, in which case to-the-left-of is actually an order relation, but may break when p is inside the convex hull (for example, try to figure out what will happen if we ran this algorithm where the points in P are the vertices of a regular pentagon, running counter-clockwise, and p is its center.)
To accommodate, we slightly alter the algorithm:
We select a point q in P, and bisect P along the line passing through p and q (i.e., we partition P around q w.r.t. to-the-left-of.)
We now have a "left part" and a "right part" of P, each contained in a halfplane, so that to-the-left-of is an order relation on each; we find the minimum of the left part, and the maximum of the right part, and compare them as described above.
Of course, we don't have to physically bisect P, we can simply classify each point in P as we look for the minimum and maximum, in a single pass.
Python 2, 194 bytes
import sys
P=[eval(l.replace(*";,"))for l in sys.stdin]
x,y=P.pop(0)
C=lambda(a,b),(c,d):(a-x)*(d-y)-(b-y)*(c-x)>0
l=r=P[0]
for q in P:
 if C(P[0],q):l=q*C(l,q)or l
 elif C(q,r):r=q
print C(l,r)

any chance you could make your solutions (at least the Python one, I have no clue if J can do that) take input from STDIN? I find it would be easier to compare solutions with a level playing field. Assuming that input is already a preformatted set of complex numbers or points is a bit of a stretch IMO.

@AlexandreHalm Added full program.

You should split your solutions into one answer per language.

Octave, 82 72 bytes
d=dlmread(0,";");i=2:rows(d);~isna(glpk(i,[d(i,:)';~~i],[d(1,:)';1]))&&1

The idea is to check whether the linear program min { c'x : Ax=b, e'x=1, x >= 0 } has a solution, where e is a vector of all ones, columns of A are the coordinates of the point cloud, and b is the test point, and c is arbitrary.  In other words, we try to represent b as a convex combination of columns of A.
To run the script, use octave -f script.m <input.dat

R, 207 bytes
d=read.csv(file("stdin"),F,";")
q=function(i,j,k)abs(det(as.matrix(cbind(d[c(i,j,k),],1))))
t=function(i,j,k)q(i,j,k)==q(1,i,j)+q(1,i,k)+q(1,j,k)
any(apply(combn(2:nrow(d),3),2,function(v)t(v[1],v[2],v[3])))

The script takes its inputs from STDIN, e.g. Rscript script.R < inputFile.
It generates all triangles from the N last points (the last line, apply(combn(... ) and checks whether the first point is in the triangle using the t function.
t uses the area method to decide if U is in ABC: (writing (ABC) for the area of ABC) U is in ABC iff (ABC) == (ABU) + (ACU) + (BCU). Also, areas are calculated using the determinant formula (see here for a nice demo from Wolfram).
I suspect this solution is more prone to numerical errors than my other one, but it works on my test cases.

R, 282 bytes
d=read.csv(file("stdin"),F,";")
p=function(a,b)a[1]*b[1]+a[2]*b[2]
t=function(a,b,c){A=d[a,];
U=d[1,]-A
B=d[b,]-A
C=d[c,]-A
f=p(C,C)
g=p(B,C)
h=p(U,C)
i=p(B,B)
j=p(U,B)
k=f*i-g*g
u=i*h-g*j
v=f*j-g*h
min(u*k,v*k,k-u-v)>0}
any(apply(combn(2:nrow(d),3),2,function(v)t(v[1],v[2],v[3])))

The script takes its inputs from STDIN, e.g. Rscript script.R < inputFile.
It generates all triangles from the N last points (the last line, apply(combn(... ) and checks whether the first point is in the triangle using the t function.
t uses the barycentric method to decide if U is in ABC: (writing XY for the X to Y vector) since (AB,AC) is a basis for the plane (except for the degenerate cases where A,B,C are aligned), AU can be written as AU = u.AB + v.AC and U is in the triangle iff u > 0 && v > 0 && u+v < 1. See for instance here for a more detailed explanation and a nice interactive chart. NB: to save a few chars and avoid DIV0 errors, we only compute a shortcut to u and v and a modified test (min(u*k,v*k,k-u-v)>0).
The only mathematical operators used are +, -, *, min()>0.


text:
The alphanumeric spiral
The task is very simple, when given an input, output one of the following spirals:
Input = 1 gives a spiral with the letter A beginning in the top left corner:
A B C D E F
T U V W X G
S 5 6 7 Y H
R 4 9 8 Z I
Q 3 2 1 0 J
P O N M L K

Input = 2 gives a spiral with the letter A beginning in the top right corner:
P Q R S T A
O 3 4 5 U B
N 2 9 6 V C
M 1 8 7 W D
L 0 Z Y X E
K J I H G F

Input = 3 gives a spiral with the letter A beginning in the bottom right corner:
K L M N O P
J 0 1 2 3 Q
I Z 8 9 4 R
H Y 7 6 5 S
G X W V U T
F E D C B A

Input = 4 gives a spiral with the letter A beginning in the bottom left corner:
F G H I J K
E X Y Z 0 L
D W 7 8 1 M
C V 6 9 2 N
B U 5 4 3 O
A T S R Q P

As you can see, the spiral always goes clockwise and moves from the outside to the inside.
The rules are simple:

You need to provide a full program using STDIN and STDOUT, or the nearest equivalent if not possible.
Given an input (1, 2, 3, 4), output the related spiral.
Trailing whitespaces are allowed
Leading whitespaces are allowed when used consistently
You need to use uppercase letter for the output, lowercase letters are not allowed.
This is code-golf, so the program with the least amount of bytes wins!

Related . This kind of feels like a dupe but I can't find one :P

More closely related.

are the spaces necessary?

@Maltysen Yes, they are required.

CJam, 45 43 42 bytes
'[,65>A,+W%(s{W%z_,@s/(@.+}A*ri{W%z}*Sf*N*

Test it here.
Explanation
'[,65>  e# Push the upper-case alphabet.
A,+     e# Append the digits.
W%      e# Reverse everything.
(s      e# Pull off the 9 and turn it into a string.
{       e# Repeat this 10 times to roll the string up in a spiral...
  W%z   e#   Rotate the existing grid clockwise.
  _,    e#   Duplicate grid so far and get the number of rows.
  @s    e#   Pull up the list of characters and flatten it into one string.
  /     e#   Split the string into chunks of the size of the number of rows.
  (     e#   Pull off the first chunk.
  @.+   e#   Pull up the grid so far and prepend the chunk as a new column.
}A*     e# We now have the spiral as desired, with the A in the bottom left corner.
ri      e# Read input and convert to integer.
{       e# Repeat this code that often..
  W%z   e#   Rotate the spiral clockwise.
}*
Sf*     e# Join each line with spaces.
N*      e# Join the lines with linefeeds.

Japt, 53 bytes 58 59 60
Saved 5 bytes thanks to @ETHproductions
"FGHIJK EXYZ0L DW781M CV692N BU543O ATSRQP"¸zU ®¬¸} ·

This uses the rotate command which I never thought would be so useful
Explanation && Ungolfed
"FGHIJK EXYZ0L DW781M CV692N BU543O ATSRQP"qS zU m_q qS} qR

             // Implicit: U = input
"FGH...SRQP" // String, " " represent newlines
qS           // Split   " "
zU           // Rotate
m_           // Loop the lines
  q qS}      // Insert spaces
qR           // Join by newlines

Try it online

Strangely, when I try to run the program online, it balks and complains that it cannot find variable f.

@DavidCarraher I recommend trying on Firefox, that's the browser the interpreter seems to work best in

Yes, it works on Firefox. Nice.

Ooh, nice! Using a few Unicode shortcuts, you can cut the byte count by five: "FGHIJK EXYZ0L DW781M CV692N BU543O ATSRQP"¸zU ®¬¸} ·

@ETHproductions didn't see those before, thanks!

MATLAB, 61 89 bytes
b=[65:90 48:57];n=zeros(12,6);n(2:2:end)=rot90(b(37-spiral(6)),input('')-2);disp([n' ''])

I'll see if I can get it down a bit. Not sure though.
This creates an array of all letters from A to Z followed by 0 to 9, then takes a spiral and uses that to arrange the data in the correct order. The array is then rotated by the amount the user specifies and then printed out.
The output consistently uses leading spaces as allowed by the question (in fact at no extra byte cost, it could do trailing spaces instead). Here is an example:
 F G H I J K
 E X Y Z 0 L
 D W 7 8 1 M
 C V 6 9 2 N
 B U 5 4 3 O
 A T S R Q P

As I saw that spaces are required, this original code (for 61) is not valid because it doesn't add a space between each character. But I will add it here for reference.
b=['A':'Z' '0':'9'];disp(rot90(b(37-spiral(6)'),6-input('')))

and produces:
ABCDEF
TUVWXG
S567YH
R498ZI
Q3210J
PONMLK

Mathematica 156 bytes
Converts initial string of letters, "ABCDEFTUVWXGS567YHR498ZIQ3210JPONMLK", into an array.  Nest applies f to that array n-1times, where n is the input number.  f works by Transpose-ing the array followed by Reverseapplied to each row.  g converts the final array into a string.
s=StringJoin;r=Riffle;f=Nest[Reverse/@Transpose@#&,Partition[Characters@"ABCDEFTUVWXGS567YHR498ZIQ3210JPONMLK",6],#-1]&;
g@n_:=s@r[s/@(r[#," "]&/@f[n]),"\n"]

Example
g[4]

If the output could be given as an array, the function g would be unnecessary.
f[4]

{{"F", "G", "H", "I", "J", "K"}, {"E", "X", "Y", "Z", "0", "L"}, {"D",
     "W", "7", "8", "1", "M"}, {"C", "V", "6", "9", "2", "N"}, {"B",
    "U", "5", "4", "3", "O"}, {"A", "T", "S", "R", "Q", "P"}}

Infix form can be used in some areas.

JavaScript ES6, 165 172
Simple rotation, starting from a hardcoded string
Note 1 byte saved thx @user81655
p=prompt();alert("ABCDEF TUVWXG S567YH R498ZI Q3210J PONMLK".split` `.map((r,y,a)=>[...r].map((c,x)=>p<2?c:a[p<3?5-x:p<4?5-y:x][p<3?y:p<4?5-x:5-y]).join` `).join`
`)

Test snippet:

// Test: redefine alert to write inside the snippet
alert=x=>P.innerHTML=x

p=prompt();
alert(
  "ABCDEF TUVWXG S567YH R498ZI Q3210J PONMLK"
  .split` `
  .map(
    (r,y,a)=>
    [...r].map(
      (c,x)=>p<2?c:
      a
       [p<3?5-x:p<4?5-y:x]
       [p<3?y:p<4?5-x:5-y]
    ).join` `
  ).join`\n`
)

You can put newline characters themselves inside template strings \`is one byte shorter than`\n``.

@user81655 thx, even 1 byte counts, but it's so awfully long anyway

Ruby, 173 bytes
->i{_,r,o=->s{s.map{|i|i*' '}},->s{s.transpose.map{|i|i.reverse}},%W(ABCDEF TUVWXG S567YH R498ZI Q3210J PONMLK).map(&:chars);puts i<2?_[o]:i<3?_[t=r[o]]:i<4?_[r[t]]:_[r[r[t]]]}

Ungolfed:
-> i {
  _ = -> s { s.map{|i| i*' ' } }
  r = -> s { s.transpose.map{|i| i.reverse } }
  o = %W(ABCDEF TUVWXG S567YH R498ZI Q3210J PONMLK).map(&:chars)
  puts i<2?_[o]:i<3?_[t=r[o]]:i<4?_[r[t]]:_[r[r[t]]]
}

Usage:
->i{_,r,o=->s{s.map{|i|i*' '}},->s{s.transpose.map{|i|i.reverse}},%W(ABCDEF TUVWXG S567YH R498ZI Q3210J PONMLK).map(&:chars);puts i<2?_[o]:i<3?_[t=r[o]]:i<4?_[r[t]]:_[r[r[t]]]}[4]
F G H I J K
E X Y Z 0 L
D W 7 8 1 M
C V 6 9 2 N
B U 5 4 3 O
A T S R Q P

Python, 152 bytes
s=[r for r in "ABCDEF TUVWXG S567YH R498ZI Q3210J PONMLK".split(" ")]
for i in range(1,int(input())):s=zip(*list(s)[::-1])
for x in s:print(" ".join(x))

Pyth - 60 bytes
Hardcodes the string and uses matrix operations to get all the options.
jjL\ @[_CKc6"ABCDEFTUVWXGS567YHR498ZIQ3210JPONMLK"KC_K__MK)Q

Test Suite.

+<G6" instead of "ABCDEF saves 2 bytes.