text:
Help Sam understand chess
For this challenge, you will be writing a program or function which outputs (or prints) (in a reasonable format, i.e single string or an array of lines) a chess board which indicates all the possible moves of a piece given an empty board.

There are 5 chess pieces (for this challenge a pawn may be ignored):

Bishop (Moves diagonally any number of squares)
Rook (Moves orthogonally any number of squares)
Queen (Moves diagonally or orthogonally any number of squares)
KNight (Moves in an L shape, i.e. two in one dimension, and one in the other)
King (Moves one step orthogonally or diagonally)

Your submission will take in three inputs: the row of the chess piece, the column of the chess piece, and the type of piece (as a character or integer).
Say we call drawBoard(4,4,'N') for the Knight using 0-indexing, the output will be as follows:
........
........
...M.M..
..M...M.
....N...
..M...M.
...M.M..
........

where the '.' and 'M' can be replaced accordingly with printable ascii characters of your choice.
Sample outputs as follows for other piece types. (Note all of these are called with input of 4,4 and are 0-indexed).
King:
........
........
........
...mmm..
...mKm..
...mmm..
........
........

Rook:
....m...
....m...
....m...
....m...
mmmmRmmm
....m...
....m...
....m...

Sam does not mind 1-based indexing, or even indexing following chess algebraic notation. However, your code must be as small as possible so Sam has enough space to think about his chess with the code next to him.

Sam has also realized that outputs will be accepted regardless of trailing or preceding whitespace (before and after input and each line)

I would advise either changing the os to .s, or changing them to spaces and adding a border. It's kinda unreadable at the moment.

related http://codegolf.stackexchange.com/questions/69014/fairy-chess-leaper-movement-patterns

@El'endiaStarman done

Are spaces to the right of the output ok?

sure, may I asky why? @LevelRiverSt

@RohanJhunjhunwala I was thinking of using modular aritmetic for the bishops moves but decided against it. For example, in a 64 character string representation of a board (ignoring newlines) with a bishop standing at x=4, y=0, all the squares it can move to have either x%9=4 or x%7=4. Unfortunately this also allows for the bishop to wrap around if he walks of the board, which is not permitted in chess. A solution is to pad the end of each line to, say 16, with spaces (and a newline) and increase to x%15 and x%17 so that no wrapping occurs in the region of interest. But I abandoned the idea.

related http://codegolf.stackexchange.com/questions/89647/chess-conversion#89647

Ruby, 125
anonymous function, prints to stdout.
RevB: golfed, but a bug fix brought it back to the same length as before.
->x,y,z{72.times{|i|v=y-i/9;u=x-i%=9
e=u*u+v*v
$><<(i<8?e<1?z:[r=0==v*u,b=u*u==v*v,b|r,3>e,5==e]["RBQKN"=~/#{z}/]??*:?.:$/)}}

Prints each of the 64 squares + 8 newlines = 72 characters individually.
Relies on e, the square of the Euclidean distance between the current square and the given coordinates for checking king moves and knight moves (and also for printing the piece value z when the Euclidean distance is zero.)
Ungolfed in test program
f=->x,y,z{                         #x,y,character
  72.times{|i|                     #8 rows of (8 chars + newline) = 72 chars
    v=y-i/9;                       #vertical diff between y coord and current square
    u=x-i%=9                       #horizontal diff between x coord and current square. note i%=8
    e=u*u+v*v                      #square of euclidean distance
    $><<(                          #$> is stdout. send to it....
      i<8?                         #if not the newline column,
        e<1?z:                       #if the euclidean distance is 0, print the symbol for the piece, else
        [r=0==v*u,                   #TRUE if v or u is 0 (rook)
        b=u*u==v*v,                  #TRUE if abs(u)==abs(v) (bishop)
        b|r,                         #TRUE if either of the above are true (queen)
        3>e,                         #TRUE if e == 1 or 2 (king)
        5==e                         #TRUE if e == 5 (knight)
        ]["RBQKN"=~/#{z}/]??*:?.:    #select value from array corresponding to piece and print * or . accordingly
      $/                           #if newline column, print a newline
    )
  }
}

x=gets.to_i
y=gets.to_i
z=gets.chomp
f[x,y,z]

JavaScript (ES6), 137 130 bytes

f=
(x,y,p)=>`${1e8}`.repeat(8).replace(/./g,c=>+c?(i=x*x--,z=y,`
`):i+(j=z*z--)?`.*`[+!{K:i+j>3,N:i+j-5,R:i*j,B:b=i-j,Q:b*i*j}[p]]:p)
;

<input id=x type=number placeholder=X><input id=y type=number placeholder=Y><select id=p><option value=>Piece<option value=B>Bishop<option value=K>King<option value=N>Knight<option value=Q>Queen<option value=R>Rook</select>

Note: Outputs one leading newline.
Explanation: Builds and scans though the string 100000000100000000100000000100000000100000000100000000100000000100000000. Each 1 indicates a new line where the relative coordinate x is decremented and the relative coordinate z is reset. Each 0 indicates a new square where the relative coordinate z is decremented. (y is reserved to reset z.) Then uses the fact that many of the moves can be categorised by the squares i and j of the relative coordinates (before they were decremented):

(initial square) i + j == 0
B: i == j
K: i + j < 3
N: i + j == 5
Q: i == j || !i || !j
R: !i || !j

Because - is shorter than == it's golfier to compute the negation and invert it later. (This lets me use the cute '.*'[] expression although it's actually the same length as a boring ?: expression.) * is also golfier than &&.

How about using 0 and 1 as we can replace . and M with other ASCII characters?

@ShieruAsakoto Sorry, I'm not following you; have you commented on the wrong answer or something?

Oh sorry, I meant the '.*' part could be omitted and output 0 and 1 in place of . and *

@ShieruAsakoto Thanks, I see what you meant now, but I think I probably chose those characters to make the output look nice and I can't see myself switching even though it would save 6 bytes.

Java 8 lambda, 473 435 289 characters
Looks like this:
(R,C,f)->{String b="";for(int r=0,c,d,D;r<8;r++){for(c=0;c<8;c++){d=R-r<0?r-R:R-r;D=C-c<0?c-C:C-c;b+=R==r&&C==c?f:((f=='R'||f=='Q')&&(R==r||C==c))||((f=='B'||f=='Q')&&d==D)||(f=='K'&&((R==r&&D==1||C==c&&d==1)||(d==D&&d==1)))||(f=='N'&&(d==2&&D==1||d==1&&D==2))?"M":".";}b+="\n";}return b;}

Or ungolfed into a class:
public class Q89429 {

    static String chessMoves(int row, int column, char figure) {
        String board = "";

        for (int r = 0, c, deltaRow, deltaColumn; r < 8; r++) {
            for (c = 0; c < 8; c++) {
                deltaRow = row - r < 0 ? r - row : row - r;
                deltaColumn = column - c < 0 ? c - column : column - c;
                board += row == r && column == c ?
                        figure :
                        ((figure == 'R' || figure == 'Q') && (row == r || column == c))
                        || ((figure == 'B' || figure == 'Q') && deltaRow == deltaColumn)
                        || (figure == 'K' && (
                                (row == r && deltaColumn == 1 || column == c && deltaRow == 1)
                                || (deltaRow == deltaColumn && deltaRow == 1)))
                        || (figure == 'N' && (deltaRow == 2 && deltaColumn == 1 || deltaRow == 1 && deltaColumn == 2))
                        ? "M" : ".";
            }
            board += "\n";
        }

        return board;
    }
}

This is a TriFunction. It returns the chess field as a printable String. I wanted to use streams, and it looks quite good. It's like a 2D iteration, may be shorter without the streams. Switched to classic loops and saved a lot!
It can definitely be shortened by using a ternary, I will do that now.
Updates
Saved 38 characters by using a ternary.
Saved 146 characters by using good old loops. We should all abandon streams ;)

for loops may be shorter

@RohanJhunjhunwala I also thought about that. Currently working on the ternary. After that I will switch to loops, just needed some practice in using streams :D

:D (11 more characters)

Ruby, 209 Bytes
->v,a,b{R=->x,y{x==a||y==b};B=->x,y{x-y==a-b||a-x==y-b};Q=->x,y{R.(x,y)||B.(x,y)};K=->x,y{((x-a).i+y-b).abs<2};N=->x,y{((a-x)*(b-y)).abs==2};(r=(0..7)).map{|x|r.map{|y|[x,y]==[a,b]?v: eval(v+".(x,y)??x:?o")}}}

This is a lambda that makes use of other lambdas, defined inside.

x86 machine code, 114 103 bytes
Input:

AL - ASCII piece type (N/B/R/Q/K)
BP - 0x88 index
DI - Buffer

Output:

DI - Last character + 1

Assembly source code:
    pusha
    mov di, offset disp_db - 3
    mov cx, 8
    mov bx, cx
    repne scasb
    mov dx, di
    sub dx, offset disp_db - 1
    pop si
    mov di, si

init_loop:
    mov ax, '.'
    mov cl, 8
    rep stosb
    mov al, 9
    mov cl, 7
    rep stosb
    inc ax
    stosb
    dec bx
    jnz init_loop

init_done:
    push di
    mov di, si

piece_loop:
    mov si, offset moves_knight - 2
    add si, dx
    lodsb
    add si, ax

vec_loop:
    lodsb
    cbw

sign_loop:
    mov bx, bp

dest_loop:
    add bx, ax
    test bl, 088h
    jnz vec_cont
    mov byte ptr [di + bx], '*'
    test dl, dl
    jp dest_loop

vec_cont:
    neg ax
    js sign_loop
    cmp al, 80h
    jnz vec_loop

done:
    popa
    mov [di + bp - 128], al
    ret

disp_db db "NBKRQ"

moves_knight db vec_knight - moves_knight - 1
moves_bishop db vec_bishop - moves_bishop - 1
moves_king   db vec_king   - moves_king   - 1
moves_rook   db vec_rook   - moves_rook   - 1
moves_queen  db vec_king   - moves_queen  - 1

vec_knight db 0Eh, 12h, 1Fh, 21h, 80h
vec_bishop db 0Fh, 11h, 80h
vec_king   db 0Fh, 11h
vec_rook   db 01h, 10h, 80h


text:
Lemon-Limify a String
Write a program or function that takes in a nonempty single-line string. You may assume it only contains printable ASCII excluding space.
Print or return an ASCII art lozenge shape similar to a lemon or lime made from the prefixes of the string.
Suppose the input string is n letters long. Then, such a shape consists of 2n − 1 columns of ASCII art stitched together, each consisting of 2n − 1 lines. Counting from 1, the k-th column is f(k) = min(k, 2n − k) characters wide, and contains f(k) copies of the first f(k) characters of input, centered vertically, with single blank lines separating the copies.
For example, if the input is Lemon, the output should be:
          Lemon
      Lemo     Lemo
   Lem    Lemon    Lem
 Le   Lemo     Lemo   Le
L  Lem    Lemon    Lem  L
 Le   Lemo     Lemo   Le
   Lem    Lemon    Lem
      Lemo     Lemo
          Lemon

If the input is lime the output should be:
      lime
   lim    lim
 li   lime   li
l  lim    lim  l
 li   lime   li
   lim    lim
      lime

And the same pattern is followed for other inputs:
a

a

Be

 Be
B  B
 Be

/\

 /\
/  /
 /\

cat

   cat
 ca   ca
c  cat  c
 ca   ca
   cat

|||

   |||
 ||   ||
|  |||  |
 ||   ||
   |||

.__.

      .__.
   .__    .__
 ._   .__.   ._
.  .__    .__  .
 ._   .__.   ._
   .__    .__
      .__.

$tring

               $tring
          $trin      $trin
      $tri     $tring     $tri
   $tr    $trin      $trin    $tr
 $t   $tri     $tring     $tri   $t
$  $tr    $trin      $trin    $tr  $
 $t   $tri     $tring     $tri   $t
   $tr    $trin      $trin    $tr
      $tri     $tring     $tri
          $trin      $trin
               $tring

Lines in the output may have trailing spaces and there may be one optional trailing newline.
The shortest code in bytes wins.

I was surprised that you only used prefixes - I was expecting prefixes on the left and suffixes on the right!

(Actually from a coding POV I would have preferred suffixes throughout but you can't have your cake and eat it.)

Define "shape similar to a lemon or lime"

@PeterTaylor The shape shown by the examples. Is there honestly an input string you can't infer the output for?

I shouldn't have to infer anything: the question should have a specification.

Matlab, 140 136 128 124 bytes
Basically first starts with the middle section, and then prepends/appends the shortened/modified versions step by step.
a=input('');v=ones(nnz(a)*2-1,1)*a;v(2:2:end,:)=0;b=v;for k=a;v=v(2:end,1:end-1);v(end+1,:)=0;b=[v,b,v,''];end;b(~flip(b))=0

Thanks for 8 bytes @LuisMendo!
E.g. for MATLAB we get:
               MATLAB
          MATLA      MATLA
      MATL     MATLAB     MATL
   MAT    MATLA      MATLA    MAT
 MA   MATL     MATLAB     MATL   MA
M  MAT    MATLA      MATLA    MAT  M
 MA   MATL     MATLAB     MATL   MA
   MAT    MATLA      MATLA    MAT
      MATL     MATLAB     MATL
          MATLA      MATLA
               MATLAB

Oh, cool idea! Unfortunately my old version does not have flip :/

I tested your 124-byte code on R2015b and I confirm it works

Thank you!

MATL, 44 bytes
I took some inspiration from @flawr's answer (although the algorithm is not the same)
GtnEq:!g*2Mo*XKG"K1YS3LZ)OX@:Y(PO5MY(XKwyhhc

Input is a string with single quotes.
Try it online!

Python 2, 121 110 bytes
s=input()
n=len(s)
r=range(1,n)+range(n,0,-1)
for y in r:print''.join(s[:(x+y-n&(x+y>n))*x]or' '*x for x in r)

116 bytes if using raw_input. The program essentially does a mask based on L1-norm/Manhattan distance from the centre, as well as the parity of this distance compared to the parity of the input length.
(Thanks to @Lynn for -9 bytes and paving the way for 2 more)

One thing that pops out is that you could compact the first two lines to l=len(input()), no?

@Frank s is used at the end of the long line, so unfortunately that's not possible

Python 2 can get 112 or 116 bytes using a slightly different choice for R.

Ah, I didn't catch that one, sorry.

@Lynn Oh wow, that choice or R does make the code a lot neater!

Can you show the output, as in flawr's answer using MATLAB?

JavaScript (ES6), 132 bytes
s=>{x=' '.repeat(l=s.length);for(n=r='';n++<l;r=r?t+`
${r}
`+t:t)for(i=l,t='';i;t=t?w+t+w:w)w=(i<n|n+i&1?x:s).slice(0,i--);return r}

Test

var solution =

s=>{
  x=' '.repeat(l=s.length);
  for(n=r='';n++<l;r=r?t+`\n${r}\n`+t:t)
    for(i=l,t='';i;t=t?w+t+w:w)
      w=(i<n|n+i&1?x:s).slice(0,i--);
  return r
}

result.textContent = solution('Lemon');
<input type="text" id="input" value="Lemon" oninput="result.textContent=solution(this.value)" />

Pyth, 32 bytes
jsMCm.[tylztsmC*\ dd*;ld+J._zt_J

Demonstration

Jelly, 32 26 bytes
³L_+«0ị“~ ”«³ḣ
JµṖ;Ṛç@þ`j⁷

Try it online!
EDIT: Dennis saved 6 bytes. Thanks!

Haskell, 109 bytes
f s|n<-length s,r<-[1..n]++[n-1,n-2..1]=unlines[do x<-r;min(" ~"!!mod((x+y+n)*min(n-x-y)0)2)<$>take x s|y<-r]

JavaScript, 187 178 bytes
A bitwise approach. Function m defines a mask by starting at 2 ** length, e.g. 00100 in binary, and defining m(n) = m(n-1) << 1 | m(n-1) >> 1 for the first half. Interestingly the second half can be defined as m(n) = m(n-1) << 1 & m(n-1) >> 1. (though the program instead opts to define m(n) = m(2 * length - 1) for the second half) From here these masks can be used to determine whether a word or space should appear by checking 2 ** column & m(row). Of course in JavaScript it's shorter to write 2 ** something with 1 << something...
note: written while tired. May Almost surely does have mistakes.
s=>{m=n=>n?n>l?m(2*l-n):(p=m(n-1))>>1|p<<1:1<<l
for(r=0;r/2<=(l=s.length-1);r++){for(i=1,o="";i/2-1<l;i++)o+=(1<l?2*l+2-i:i)
console.log(o)}}

Brachylog, 46 bytes
{a₀⟨{;Ṣ}j₎l⟩}ᶠL&l;Ṣj₍ẹa₁ᶠ;Lz{czzcᵐ}ᵐ⟨kc↔⟩zcᵐ~ṇ

Try it online!
Terrible byte count and probably worse approach (not to mention Brachylog isn't exactly designed for ASCII art), but I wasted enough time on it to post it anyways.
              L    The variable L
{           }ᶠ     is a list containing every possible
 a₀                prefix of
                   the input
    {;Ṣ}           paired with a space
        j          and concatenated with itself
   ⟨     ₎l⟩       a number of times equal to its length.

          ᶠ    A list containing every possible
        a₁     suffix of
   Ṣ           a space
    j          concatenated with itself
  ;  ₍         a number of times equal to
 l             the length of
&              the input
      ẹ        then split back up into its elements
               is an important list which doesn't actually get a name.

                         That list
;Lz                      zipped with L
   {     }ᵐ              with each pair being
    c                    concatenated,
     z                   zipped with cycling,
      z                  zipped back,
        ᵐ                and subjected to each of its elements being
       c                 concatenated itself,
           ⟨kc↔⟩         then palindromized
                z        and zipped yet again
                 cᵐ      with every line concatenated once more
                   ~ṇ    and finally joined on newlines
                         is the output.

Just about the only clever part of any of this is the use of a₁ to generate the vertical spaces largest-first while a₀ generates the word prefixes smallest-first, and zz to expand single spaces into blocks of space matching the widths of the prefixes.

TSQL, 259 bytes
Golfed:
DECLARE @ VARCHAR(30)='TSQL'

,@o VARCHAR(max),@i INT=0,@j INT,@t VARCHAR(max)SET @j=LEN(@)z:WHILE @i<LEN(@)SELECT @o=x+ISNULL(@o+x,''),@i+=1FROM(SELECT LEFT(IIF((@j-@i)%2=1,@,SPACE(99)),LEN(@)-@i)x)z SELECT @j-=1,@t=@o+ISNULL(CHAR(10)+@t+CHAR(10)+@o,''),@o=null,@i=0IF @j>0GOTO z PRINT @t

Ungolfed:
DECLARE @ VARCHAR(30)='TSQL'

,@o VARCHAR(max),@i INT=0,@j INT,@t VARCHAR(max)SET @j=LEN(@)
z:
WHILE @i<LEN(@)
  SELECT @o=x+ISNULL(@o+x,''),@i+=1
  FROM(SELECT LEFT(IIF((@j-@i)%2=1,@,SPACE(99)),LEN(@)-@i)x)z
SELECT @j-=1,@t=@o+ISNULL(CHAR(10)+@t+CHAR(10)+@o,''),@o=null,@i=0
IF @j>0 GOTO z

PRINT @t

Fiddle

J, 67 bytes
[:;"1@|:(#-h){.&.>"0 1]((<#)#&.>,:&''@]<@{"{~2|[)~[:+/~h=.|@i:@<:@#

Try it online!
I may try to improve this further tomorrow.

PowerShell, 116 bytes
($r=0..($n=($a=$args).count-1)+$n..0|gu)|%{$y=$_;-join($r|%{($a[0..$_],(' '*($_+1)))[($_+$y+$n)%2-or($_+$y)-lt$n]})}

Try it online!
Unrolled:
$a=$args
$n=$a.count-1
$range=0..$n+$n..0|Get-Unique
$range|%{
    $y=$_
    $line=-join(
        $range|%{
            $word=$a[0..$_]
            $space=' '*($_+1)
            $switch=($_+$y+$n)%2-or($_+$y)-lt$n
            ($word,$space)[$switch]
        }
    )
    $line
}

J, 49 bytes
3 :';"{((]<@{.y''''&[~2&|@+<:>)"+/e&-)|i:1-e=.#y'

Try it online!
How it works
3 :';"{((]<@{.y''''&[~2&|@+<:>)"+/e&-)|i:1-e=.#y'

3 :'...'       Explicit function definition; right arg(y) = given string
|i:1-e=.#y     e = length of y; create array of [e-1 .. 0 .. e-1]

((]<@{.y''&[~2&|@+<:>)"+/e&-)  Create boxed lemon shape:
                         e&-   Create array of [1 .. e .. 1]
 (                   )"+/      Outer product with [e-1 .. 0 .. e-1]
                               (left item = a, right item = b)
             2&|@+<:>          (a+b)%2 <= (a>b)
       y''&[~                  If above is true, use '' (empty string)
                               otherwise use y
  ]  {.                        Take first b chars from above
                               (fill with blanks if needed)
   <@                          Box it

;"{      Unbox and concatenate each row from the table (outer product)
         Result is the matrix of chars, giving the lemon shape

3 :';"1((]<@{.y#~><2|+)"0/#@y-])|i:1-#y' seems to work

C, 167 bytes
This program expects the input text to be passed as the first parameter to the program (via command line or however else) and will write the output to stdout.
int i,j,k,l,v;main(h,s)char**s;{h=strlen(s[1]);l=h*2;for(;++i<l;puts(""))for(j=0;++j<l,v=j<h?j:l-j;)for(k=0;k++<v;putchar((i+j+h%2)%2&&v>h-(i<h?i:l-i)?s[1][k-1]:32));}

This is my first attempt at code golf here as it seemed like a reasonable challenge, so it can probably be golfed more than I was able to just due to how I did it.
Explanation
/* Static variables
   i - "Row" number
   j - "Column" number
   k - String character counter
   l - Double length of the input string
   v - Inverted column distance from center */
int i,j,k,l,v;

/* Main parameters
   h - (argc) Input string length
   s - argv */
main(h, s)
char**s;
{
  /* Assign the input string length and double length */

  h = strlen(s[1]);
  l = h * 2;

  /* Display content */

    /* Loop over rows l - 1 times and put a newline after each */
  for (; ++i < l; puts(""))
      /* Loop over columns l - 1 times and set the inverted column
         distance each time */
    for (j = 0; ++j < l, v = ((j < h) ? j : l - j);)
        /* Loop over characters up to the inverted column distance from the
           center (this generates the pattern of output lengths needed) */
      for (k = 0; k++ < v;)
        putchar(
            /* Check for if the current row + column (with an offset based on
               the input parity) parity is even or odd, creating the needed
               checkerboard pattern */
          (i + j + h % 2) % 2 &&
            /* If the inverted column distance from the center is more than the
               row distance from the center, then the cell is inside the
               circular shape */
          v > (h - ((i < h) ? i : l - i)) ?
              /* Display the requested character (minus one for 0 based) */
            s[1][k-1] :
            32 /* Otherwise display a space (ASCII 32) */
        );
}

It is significant enough to note the usage of (n < m) ? n : (m * 2) - n in the program at least twice to get the inverted distance from a center position m on a range of m * 2 with the input n. If there is a shorter way to do that then it could be golfed down some more easily as that algorithm is important for how this program works.

158 bytes

C, 137 bytes
x,y,w;main(l,v)char**v;{for(y=l=strlen(v[1]);-l<--y;putchar(10))for(x=l;-l<--x;printf("%*.*s",w,w,x+y+l&1&&w>abs(y)?v[1]:""))w=l-abs(x);}

Breakdown:
This draws every element of the 2n-1 x 2n-1 grid, with a mask function deciding whether the current element should be blank space or the input word (the mask checks for a diamond shape and checkerboard pattern).
x,y,w;
main(l,v)char**v;{
    for(y=l=strlen(v[1]);-l<--y;/*...*/)    // row loop (count down to save bytes)
        for(x=l;-l<--x;/*...*/)             // column loop
            w=l-abs(x);                     // calculate current word's width
            printf("%*.*s",                 // print...
                w,w,                        // ...with min & max width...
                x+y+l&1&&w>abs(y)           // Check mask:
                    ?v[1]                   //  ...word
                    :"")                    //  ...or blank space
        putchar(10)                         // Newline
}

131 bytes

05AB1E, 27 26 bytes
ηεN>иygð×©.ýIgN-<®и.ø}ûøJ»

Try it online or verify all test cases.
Explanation:
η           # Get a list of prefixes of the (implicit) input-String
 ε          # Map each prefix `y` to:
  N>        #  Get the (0-based) map-index, and increase it by 1 to make it 1-based
    и       #  Repeat the current substring that many times as list
  yg        #  Push prefix `y` again, and pop and push its length
    ð×      #  Create a string of that many spaces
      ©     #  Store this spaces-string in variable `®` (without popping)
       .ý   #  Intersperse the earlier list with this spaces-string
  Ig        #  Push the input, and then pop and push its length
    N-      #  Subtract the (0-based) map-index
      <     #  And decrease it by 1 more
       ®и   #  Repeat spaces-string `®` that many times as list
         .ø #  Surround the earlier list with this list as both leading and trailing portion
 }û         # After the map: palindromize (abc → abcba) the entire list of lists
   ø        # Zip/transpose; swapping rows/columns
    J       # Join each inner list together to a single string
     »      # And join those strings by newlines
            # (after which the result is output implicitly)

JavaScript (Node.js), 120 118 109 105 bytes
x=>(l=x.length,g=(F,i=1,w=F(i))=>i<l?w+g(F,i+1)+w:w)(y=>g(a=>a+y+l&a+y>l?x.slice(0,a):" ".repeat(a))+`
`)

Try it online!
A bunch of bytes are shaved thanks to the similar structures of the nesting functions. I was confident that this golf could save some bytes but not that much.
x=>(                   // Main function:
 l=x.length,           //  l = Length of x
 g=(                   //  Nesting function:
  F,                   //   Output-generating function
  i=1,                 //   Counter (initially 1)
  w=F(i)               //   The output at that counter value
 )=>
  i<l                  //   If not the center line/block:
  ?w+g(F,i+1)+w        //    Sandwich next iteration with output
  :w                   //   Otherwise: Return the output
)(                     //  Call the nesting function with
 y=>                   //  Outer nest: Generating lines
  g(                   //   Call the nesting function with
   a=>                 //   Inner nest: Generating blocks
    a+y+l&a+y>l        //    If the position should not be space:
    ?x.slice(0,a)      //     Output the first a characters of x
    :" ".repeat(a)     //    Otherwise: Output a spaces
  )+"\n"               //   Append the line with a newline
)

Original 118-byte answers:
F=(x,i=1,t=x.length,w=(G=(j,A,B,c=i+j+t&1&i+j>t?A:B)=>j<t?c+G(j+1,A+x[j],B+' ')+c:c)(0,'','')+`
`)=>i<t?w+F(x,i+1)+w:w

Try it online!
F=(x,i=1,t=x.length,w=(G=(j,c=i+j+t&1&i+j>t?x.slice(0,j):" ".repeat(j))=>j<t?c+G(j+1)+c:c)(1)+`
`)=>i<t?w+F(x,i+1)+w:w

Try it online!

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:
Is it a Proth number?
A Proth number, named after François Proth, is a number that can be expressed as
$$N = k \times 2^n + 1$$
Where \$k\$ is an odd positive integer and \$n\$ is a positive integer such that \$2^n > k\$. Let's use a more concrete example. Take 3. 3 is a Proth number because it can be written as
$$ 3 = (1 \times 2^1) + 1 $$
and \$2^1 > 1\$ is satisfied. 5 Is also a Proth number because it can be written as
$$ 5 = (1 \times 2^2) + 1 $$
and \$2^2 > 1\$ is satisfied. However, 7 is not a Proth number because the only way to write it in the form \$N = k \times 2^n + 1\$ is
$$ 7 = (3 \times 2^1) + 1 $$
and \$2^1 > 3\$ is not satisfied.
Your challenge is fairly simple: you must write a program or function that, given a positive integer, determines if it is a Proth number or not. You may take input in any reasonable format, and should output a truthy value if it is a Proth number and a falsy value if it is not. If your language has any "Proth-number detecting" functions, you may use them.
Test IO
Here are the first 46 Proth numbers up to 1000. (A080075)
3, 5, 9, 13, 17, 25, 33, 41, 49, 57, 65, 81, 97, 113, 129, 145, 161, 177, 193, 209, 225, 241, 257, 289, 321, 353, 385, 417, 449, 481, 513, 545, 577, 609, 641, 673, 705, 737, 769, 801, 833, 865, 897, 929, 961, 993

Every other valid input should give a falsy value.
As usual, this is code-golf, so standard loopholes apply, and the shortest answer in bytes wins!

Number theory fun-fact side-note:
The largest known prime that is not a Mersenne Prime is \$19249 \times 2^{13018586} + 1\$, which just so happens to also be a Proth number!

Jelly, 5 bytes
’&C²>

Try it online! or verify all test cases.
Let \$\newcommand{\&}[]{\text{ & }}j\$ be a strictly positive integer. \$j + 1\$ toggles all trailing set bits of \$j\$ and the adjacent unset bit. For example, \$10011_{2} + 1 = 10100_{2}\$.
Since \${\sim}j = -(j + 1) = -j - 1\$, \$-j = {\sim}j + 1\$, so \$-n\$ applies the above to the bitwise NOT of \$j\$ (which toggles all bits), thus toggling all bits before the last \$1\$.
By taking \$j \& (-j)\$ (the bitwise AND of \$j\$ and \$-j\$), all bits before and after the last set bit are nullified (since unequal in \$j\$ and \$-j\$), thus yielding the highest power of \$2\$ that divides \$j\$ evenly.
For input \$N\$, we want to apply the above to \$N - 1\$ to find \$2^{n}\$, the highest power of \$2\$ that divides \$N - 1\$. If \$m = N - 1\$, \$-m = -(N - 1) = 1 - N\$, so \$(N - 1) \& (1 - N)\$ yields \$2^{n}\$.
All that's left to test is if \$2^{n} > k\$. If \$k > 0\$, this is true if and only if \$(2^{n})^{2} > k2^{n}\$, which is true itself if and only if \$(2^{n})^{2} \ge k2^{n} + 1 = N\$.
Finally, if \$(2^{n})^{2} = N = k2^{n} + 1\$, \$2^{n}\$ must be odd (\$1\$) so the parities of both sides can match, implying that \$k = 0\$ and \$N = 1\$. In this case \$(N - 1) \& (1 - N) = 0 \& 0 = 0\$ and \$((N - 1) \& (1 - N))^{2} = 0 < 1 = N\$.
Therefore, \$((N - 1) \& (1 - N))^{2} > N\$ is true if and only if \$N\$ is a Proth number.
How it works
’&C²>  Main link. Argument: N

’      Decrement; yield N - 1.
  C    Complement; yield 1 - N.
 &     Take the bitwise AND of both results.
   ²   Square the bitwise AND.
    >  Compare the square to N.

woah. thats incredible

Python, 22 bytes
lambda N:N-1&1-N>N**.5

This is a port of my Jelly answer. Test it on Ideone.
How it works
Let \$\newcommand{\&}[]{\text{ & }}j\$ be a strictly positive integer. \$j + 1\$ toggles all trailing set bits of \$j\$ and the adjacent unset bit. For example, \$10011_{2} + 1 = 10100_{2}\$.
Since \${\sim}j = -(j + 1) = -j - 1\$, \$-j = {\sim}j + 1\$, so \$-n\$ applies the above to the bitwise NOT of \$j\$ (which toggles all bits), thus toggling all bits before the last \$1\$.
By taking \$j \& (-j)\$ (the bitwise AND of \$j\$ and \$-j\$), all bits before and after the last set bit are nullified (since unequal in \$j\$ and \$-j\$), thus yielding the highest power of \$2\$ that divides \$j\$ evenly.
For input \$N\$, we want to apply the above to \$N - 1\$ to find \$2^{n}\$, the highest power of \$2\$ that divides \$N - 1\$. If \$m = N - 1\$, \$-m = -(N - 1) = 1 - N\$, so \$(N - 1) \& (1 - N)\$ yields \$2^{n}\$.
All that's left to test is if \$2^{n} > k\$. If \$k > 0\$, this is true if and only if \$(2^{n})^{2} > k2^{n}\$, which is true itself if and only if \$(2^{n})^{2} \ge k2^{n} + 1 = N\$.
Finally, if \$(2^{n})^{2} = N = k2^{n} + 1\$, \$2^{n}\$ must be odd (\$1\$) so the parities of both sides can match, implying that \$k = 0\$ and \$N = 1\$. In this case \$(N - 1) \& (1 - N) = 0 \& 0 = 0\$ and \$((N - 1) \& (1 - N))^{2} = 0 < 1 = N\$.
Therefore, \$((N - 1) \& (1 - N))^{2} > N\$ is true if and only if \$N\$ is a Proth number.
Ignoring floating point inaccuracies, this is equivalent to the code N-1&1-N>N**.5 in the implementation.

I frequent Math.SE, and my eyes really wish for beautiful LaTeX on this site instead of looking like a 90s site...

This one's my favorite.

Mathematica, 50 48 45 40 38 35 31 29 bytes
Mathematica generally sucks when it comes to code golf, but sometimes there's a built-in that makes things look really nice.
1<#<4^IntegerExponent[#-1,2]&

A test:
Reap[Do[If[f[i],Sow[i]],{i,1,1000}]][[2,1]]

{3, 5, 9, 13, 17, 25, 33, 41, 49, 57, 65, 81, 97, 113, 129, 145, 161, 177, 193, 209, 225, 241, 257, 289, 321, 353, 385, 417, 449, 481, 513, 545, 577, 609, 641, 673, 705, 737, 769, 801, 833, 865, 897, 929, 961, 993}

Edit: Actually, if I steal Dennis's bitwise AND idea, I can get it down to 23 22 20 bytes.
Mathematica, 23 22 20 bytes (thanks A Simmons)
BitAnd[#-1,1-#]^2>#&

Welcome to Programming Puzzles and Code Golf! :)

No need to begin with g=, a pure function is fine!

Oh, sweet. Fixed it now.

By the way, your test can be significantly simplified to Select[Range@1000,f].

Python 2, 23 bytes
lambda n:(~-n&1-n)**2>n

05AB1E, 14 10 bytes
Thanks to Emigna for saving 4 bytes!
Code:
<©Ó¬oD®s/›

Uses the CP-1252 encoding. Try it online!.
Explanation:
For the explanation, let's use the number 241. We first decrement the number by one with <. That results into 240. Now, we calculate the prime factors (with duplicates) using Ò. The prime factors are:
[2, 2, 2, 2, 3, 5]

We split them into two parts. Using 2Q·0K, we get the list of two's:
[2, 2, 2, 2]

With ®2K, we get the list of the remaining numbers:
[3, 5]

Finally, take the product of both. [2, 2, 2, 2] results into 16. The product of [3, 5] results into 15.
This test case is truthy since 16 > 15.

<©Ó¬oD®s/› or <DÓ0èoDŠ/› for 10.

@Emigna That is genius! Thanks :).

Brain-Flak, 460 350 270 266 264 188 176 bytes
Try it online!
({}[()])(((<>()))){{}([(((({}<(({}){})>){}){})<>[({})(())])](<>)){({}())<>}{}<>{}{}<>(({})){{}{}<>(<(())>)}{}}(<{}{}>)<>{({}[()])<>(({}()[({})])){{}(<({}({}))>)}{}<>}{}<>({}<>)

Explanation
The program goes through powers of two and four until it finds a power of two greater than N-1.  When it finds it it checks for the divisibility of N-1 by the power of two using modulo and outputs the result
({}[()])      #Subtract one from input
(((<>())))    #Put three ones on the other stack
{
 {}           #Pop the crap off the top
 ([(
  ((({}<(({}){})>){}){}) #Multiply the top by four and the bottom by two
  <>[({})(())])](<>)){({}())<>}{}<>{}{}<>(({})){{}{}<>(<(())>)}{} #Check if the power of four is greater than N-1
}
(<{}{}>) #Remove the power of 4
<>{({}[()])<>(({}()[({})])){{}(<({}({}))>)}{}<>}{}<>({}<{}><>) #Modulo N-1 by the power of two

This program is not stack clean.  If you add an extra 4 bytes you can make it stack clean:
({}[()])(((<>()))){{}([(((({}<(({}){})>){}){})<>[({})(())])](<>)){({}())<>}{}<>{}{}<>(({})){{}{}<>(<(())>)}{}}(<{}{}>)<>{({}[()])<>(({}()[({})])){{}(<({}({}))>)}{}<>}{}<>({}<{}><>)

Regex (ECMAScript), 48 43 41 bytes
Neil's and H.PWiz's regexes (both also ECMAScript flavour) are beautiful in their own right. There is another way to do it, which by a pretty neat coincidence was 1 byte more than Neil's, and now with H.PWiz's suggested golfing (thanks!), is 1 byte more less than H.PWiz's.
Warning: Despite this regex's small size, it contains a major spoiler. I highly recommend learning how to solve unary mathematical problems in ECMAScript regex by figuring out the initial mathematical insights independently. It's been a fascinating journey for me, and I don't want to spoil it for anybody who might potentially want to try it themselves, especially those with an interest in number theory. See this earlier post for a list of consecutively spoiler-tagged recommended problems to solve one by one.
So do not read any further if you don't want some advanced unary regex magic spoiled for you. If you do want to take a shot at figuring out this magic yourself, I highly recommend starting by solving some problems in ECMAScript regex as outlined in that post linked above.
So, this regex works quite simply: It starts by subtracting one. Then it finds the largest odd factor, k. Then we divide by k (using the division algorithm briefly explained in a spoiler-tagged paragraph of my factorial numbers regex post). We sneakily do a simultaneous assertion that the resultant quotient is greater than k. If the division matches, we have a Proth number; if not, we don't.
I was able to drop 2 bytes from this regex (43 → 41) using a trick found by Grimmy that can futher shorten division in the case that the quotient is guaranteed to be greater than or equal to the divisor.

 ^x(?=(x(xx)*)\1*$)((\1x*)(?=\1\4*$)x)\3*$

Try it online!

 # Match Proth numbers in the domain ^x*$
 ^
 x                         # tail = tail - 1
 (?=(x(xx)*)\1*$)          # \1 = largest odd factor of tail

 # Calculate tail / \1, but require that the quotient, \3, be > \1
 # (and the quotient is implicitly a power of 2, because the divisor
 # is the largest odd factor).
 (                         # \3 = tail / \1, asserting that \3 > \1
     (\1x*)                # \4 = \3-1
     (?=\1\4*$)            # We can skip the test for divisibility by \1-1
                           # (and avoid capturing it) because we've already
                           # asserted that the quotient is larger than the
                           # divisor.
     x
 )
 \3*$

O_o wow, only 48 bytes

Neil's is more similar to mine than to Dennis'

MATL, 9 bytes
qtYF1)EW<

Truthy output is 1.  Falsy is 0 or empty output. (The only inputs that produce empty output are 1 and 2; the rest produce either 0 or 1).
Try it online!
Explanation
Let x denote the input. Let y be the largest power of 2 that divides x−1, and z = (x−1)/y. Note that z is automatically odd. Then x is a Proth number if and only if y > z, or equivalently if y2 > x−1.
q    % Input x implicitly. Subtract 1
t    % Duplicate
YF   % Exponents of prime factorization of x-1
1)   % First entry: exponent of 2. Errors for x equal to 1 or 2
E    % Duplicate
W    % 2 raised to that. This is y squared
<    % Is x-1 less than y squared? Implicitly display

Haskell, 55 46 bytes
f x=length [x|k<-[1,3..x],n<-[1..x],k*2^n+1==x,2^n>k]>0

Edit:
Thanks to nimi, now 46 bytes
f x=or[k*2^n+1==x|k<-[1,3..x],n<-[1..x],2^n>k]

Welcome to Programming Puzzles & Code Golf!

Thanks man! Been a lurker here for a while. Big fan btw, jelly is super cool. Wish I could learn but alas, I don't really understand

A general tip: if you're just interested in the length of a list created by a comprehension, you can use sum[1| ... ]. Here we can go further and move the equality test in front of the | and check with or if any of them is true: f x=or[k*2^n+1==x|k<-...,n<-...,2^n>k].

Wow. Great tips. I'll definitely revise.

If you're interested in learning Jelly, check out the wiki or join the Jelly room.

Brachylog, 28 bytes
>N>0,2:N^P:K*+?,P>K:2%1,N:K=

Try it online!
Verify all testcases at once.
(Slightly modified.)
Explanation
Brachylog, being a derivative of Prolog, is very good at proving things.
Here, we prove these things:
>N>0,2:N^P:K*+?,P>K:2%1,N:K=

>N>0                           input > N > 0
     2:N^P                     2^N = P
         P:K*+?                P*K+1 = input
                P>K            P > K
                  K:2%1        K%2 = 1
                        N:K=   [N:K] has a solution

Julia, 16 bytes
!x=~-x&-~-x>x^.5

Credits to @Dennis for the answer and some golfing tips!

That doesn't work. In Julia, & has the same precedence as *.

Oh right. Fixed :P I should really test my code.

You can use -~-x instead of (1-x). Also, there's √x instead of x^.5, but it doesn't save any bytes.

R, 52 50 bytes
x=scan()-1;n=0;while(!x%%2){x=x/2;n=n+1};2^(2*n)>x

The program begins by dividing N-1 (called here P and x) by 2 as long as possible in order to find the 2^npart of the equation, leaving k=(N-1)/2^n, and then computes wether or not k is inferior to 2^n, using the fact that 2^n>x/2^n <=> (2^n)²>x <=> 2^2n>x

You can pull the P= at the beginning, and change the end to 2^n>x and save like 5 or 6 bytes

Regex (ECMAScript), 40 38 bytes
-2 bytes thanks to Deadcode
^x(?=((xx)+?)(\1\1)*$)(?!(\1x\2*)\4*$)

Try it online!
Commented version:
# Subtract 1 from the input N
^x

# Assert N is even.
# Capture \1 = biggest power of 2 that divides N.
# Capture \2 = 2.
(?=((xx)+?)(\1\1)*$)

# Assert no odd number > \1 divides N
(?!(\1x\2*)\4*$)

Wow, this is very cool. So many different ways to do this problem!

38 bytes: ^x(?=((xx)+?)(\1\1)*$)(?!(\1x\2*)\4*$) (Try it online)

J, 10 bytes
%:<<:AND-.

Based on @Dennis' bitwise solution.
Takes an input n and returns 1 if it is Proth number else 0.
Usage
   f =: %:<<:AND-.
   f 16
0
   f 17
1
   (#~f"0) >: i. 100  NB. Filter the numbers [1, 100]
3 5 9 13 17 25 33 41 49 57 65 81 97

Explanation
%:<<:AND-.  Input: n
        -.  Complement. Compute 1-n
   <:       Decrement. Compute n-1
     AND    Bitwise-and between 1-n and n-1
%:          Square root of n
  <         Compare sqrt(n) < ((1-n) & (n-1))

Huh. I didn't know about AND. cool!

Retina 0.8.2, 47 bytes
\d+
$*
+`(1+)\1
$+0
01
1
+`.10(0*1)$
1$1
^10*1$

Try it online! Explanation: Given a Proth number \$ k · 2^n + 1 \$, you can derive two new Proth numbers \$ (2k±1) · 2^{n + 1} + 1 \$. We can run this in reverse until we obtain a Proth number where \$ k = 1 \$. This is readily performed by transforming the binary representation.
\d+
$*

Convert to unary.
+`(1+)\1
$+0
01
1

Convert to binary.
+`.10(0*1)$
1$1

Repeatedly run the Proth generation formula in reverse.
^10*1$

Match the base case of the Proth generation formula.
Edit: I think it's actually possible to match a Proth number directly against a unary number with a single regex. This currently takes me 47 bytes, 7 bytes more than my current Retina code for checking whether a unary number is a Proth number:
^.(?=(.+?)(\1\1)*$)(?=((.*)\4.)\3*$).*(?!\1)\3$

ECMAScript Regex, 42 bytes
^x(?=(x(xx)*)\1*$)(?=(x+?)((\3\3)*$))\4\1x

Try it online! (Using Retina)
I essentially subtract 1, divide by the largest possible odd number k, then check that at least k+1 is left over.
It turns out that my regex is very similar to the one Neil gives at the end of his answer. I use x(xx)* instead of (x*)\2x. And I use a shorter method to check k < 2^n

Wow, this is awesome! Very nicely done. Note that you can make it a little bit faster by changing (\3\3)*)$ to (\3\3)*$)

Nice job with that Retina code. I didn't know about $= and $.=. It can be improved even better.

@Deadcode If you're going to nitpick the header and footer, then have some further improvements.

@Neil That looks like good golf, but unfortunately it seems to have a bug. Try single numbers. They don't work.

@Deadcode Sorry, I hadn't realised that single numbers were part of the "spec".

Brain-Flak, 128 bytes
({<{({}[()]<(([{}]())<>{})<>>)}{}>{{}(<>)}{}}<><(())>){([()]{}<(({}){})>)}{}([({}[{}(())])](<>)){({}())<>}{}{((<{}>))<>{}}{}<>{}

Try it online!
I used a very different algorithm than the older Brain-Flak solution.
Basically, I divide by 2 (rounding up) until I hit an even number. Then I just compare the result of the last division with the two to the power of the number of times I divided.
Explanation:
({
  # (n+1)/2 to the other stack, n mod 2 to this stack
  <{({}[()]<(([{}]())<>{})<>>)}{}>
  # if 1 (n was odd) jump to the other stack and count the one
  {{}(<>)}{}
#end and push the sum -1, with a one under it
}<>[(())])
#use the one to get a power of two
{([()]{}<(({}){})>)}{}
#compare the power of two with the remainder after all the divisions
([({}[{}(())])](<>)){({}())<>}{}{((<{}>))<>{}}{}<>{}

Bitwise Fuckery, 56 bytes
,-@|~+&[>+>+<<-]>%>[<|[<+>-]>-]<<[>+<-]|+[-(>.<)>-(.>)<]

Try it online!
Uses the latest version of the language, in which I finally fixed the [] and () loops.
Inputs via char code. Outputs a null byte if the input is not a Proth number, outputs a non-null byte otherwise. Add the -n flag to output an an integer.
How it works
Bitwise Fuckery is, unsurprisingly, an extension of brainfuck with bitwise commands, an "if zero" loop and a second tape. As demonstrated by Dennis, bitwise operations are helpful in this challenge, so I thought I'd fix up the language and give it a go.
Bitwise Fuckery's second tape has the same tape head as the first tape, and certain commands operate on the two values under the tape head on each tape. I've marked the tape heads with (...) in the explanation.
I'll work through the program with an example input of 5 (that's the char code of the character, not the character 5)
,	# Take a byte of input
	#   Tapes: [( 5)  0   0 ...] [( 0)  0   0 ...]
-	# Decrement it
	#   Tapes: [( 4)  0   0 ...] [( 0)  0   0 ...]
@	# Swap tapes
	#   Tapes: [( 0)  0   0 ...] [( 4)  0   0 ...]
|	# Bitwise OR, copying across
	#   Tapes: [( 4)  0   0 ...] [( 4)  0   0 ...]
~+	# Bitwise NOT and increment
	#   Tapes: [(-4)  0   0 ...] [( 4)  0   0 ...]
&	# Bitwise AND
	#   Tapes: [( 4)  0   0 ...] [( 4)  0   0 ...]

[>+>+	# Copy the first cell into cells 2 and 3
 <<-]	#   Tapes: [( 0)  4   4 ...] [( 4)  0   0 ...]

>	# Move along one cell
	#   Tapes: [  0 ( 4)  4 ...] [  4 ( 0)  0 ...]
%>	# Swap the cells under the tape head and move
	#   Tapes: [  0   0 ( 4)...] [  4   4 ( 0)...]

[	# Square the value under the tape head:
 <|	# Move left and Bitwise XOR
	#   Tapes: [  0 ( 4)  4 ...] [  4 ( 4)  0 ...]
 [<+>-]	# Copy into the first cell
	#   Tapes: [  4 ( 0)  4 ...] [  4 ( 4)  0 ...]
 >-	# Move right and decrement
	#   Tapes: [  4   0 ( 3)...] [  4   4 ( 0)...]
]	# Repeat while the tape head is non-zero
	#   Tapes: [ 16   0 ( 0)...] [  4   4 ( 0)...]

<<	# Move to the first cell
	#   Tapes: [(16)  0   0 ...] [( 4)  4   0 ...]
[>+<-]	# Copy into the second cell
	#   Tapes: [( 0) 16   0 ...] [( 4)  4   0 ...]
|+	# Logical OR and increment, restoring N to the tape
	#   Tapes: [( 5) 16   0 ...] [( 4)  4   0 ...]

[	# Check that N is less than the second cell
 -	# Decrement N
	#   Tapes: [( 4) 16   0 ...] [( 4)  4   0 ...]
 (	# If zero:
  >.<	#  Output the value in the second cell
	#    Tapes: [( 4) 16   0 ...] [( 4)  4   0 ...]
 )
 >-	# Move right and decrement
	#    Tapes: [  4 (15)  0 ...] [  4 ( 4)  0 ...]
 (	# If zero:
  .>	#   Output and move right
	#    Tapes: [  4  15 ( 0)...] [  4   4 ( 0)...]
 )
 <	# Move left
	#    Tapes: [  4 (15)  0 ...] [  4 ( 4)  0 ...]
]

Pyt, 7 bytes
Đ⁻Đ~∧²<

Try it online!
Port of Dennis's Jelly answer

Maple, 100 bytes (including spaces)
IsProth:=proc(X)local n:=0;local x:=X-1;while x mod 2<>1 do x:=x/2;n:=n+1;end do;is(2^n>x);end proc:

Nicely spaced for readbility:
IsProth := proc( X )
    local n := 0;
    local x := X - 1;
    while x mod 2 <> 1 do
        x := x / 2;
        n := n + 1;
    end do;
    is( 2^n > x );
end proc:

Same idea as several others; divide X by 2 until X is no longer evenly divisible by 2, then check the criteria 2^n > x.

Java 1.7, 49 43 bytes
Another 6 bytes the dust thanks to @charlie.
boolean g(int p){return p--<(p&-p)*(p&-p);}

Try it! (ideone)
Two ways, equally long. As with most answers here, credits go to @Dennis of course for the expression.
Taking the root of the righthand side of the expression:
boolean f(int p){return(p-1&(1-p))>Math.sqrt(p);}

Applying power of two to the lefthand side of the expression:
boolean g(int p){return Math.pow(p-1&(1-p),2)>p;}

Can shave off a single byte if a positive numeric value is allowed to represent 'truthy', and a negative value 'falsy':
double g(int p){return Math.pow(p-1&(1-p),2)-p;}

Unfortunately because of 'Narrowing Primitive Conversion' one cannot simply write this in Java and get correct results:
((p - 1 & (1 - p))^2) > p;

And any attempt to widen 'p' will lead to a compile error because bitwise operators are not supported on i.e. floats or doubles :(

f = 47: boolean f(int p){return Math.sqrt(p--)<(p&-p);}

g = 43: boolean g(int p){return p--<(p&-p)*(p&-p);}

Nice one! I knew there had to be a way to get rid of the Math.* calls; just couldn't figure out how! Thanks!

C (gcc), 29 30 bytes
z;f(x){return--x<(z=x&-x)*z;}

Try it online!

Hy, 37 bytes
(defn f[n](>(**(&(- n 1)(- 1 n))2)n))

Try it online!
Port of @Dennis' answer.

Japt, 12 10 9 bytes
É&1-U)>Uq

Try it online!
Port of Dennis' Jelly answer again. - 1 thanks to @Shaggy.

-1 can be É.

x86 Machine Code, 15 bytes
4F 89 F8 F7 D8 21 F8 0F AF C0 39 C7 19 C0 C3

These bytes define a function that takes the input argument (an unsigned integer) in the EDI register, following the standard System V calling convention for x86 systems, and it returns the result in the EAX register, like all x86 calling conventions.
In assembler mnemonics:
4F          dec   edi            ; input -= 1
89 F8       mov   eax, edi       ; \ temp
F7 D8       neg   eax            ; |      =
21 F8       and   eax, edi       ; /        (input & -input)
0F AF C0    imul  eax, eax       ; temp *= temp
39 C7       cmp   edi, eax       ; set CF if (input < temp)
19 C0       sbb   eax, eax       ; EAX = -CF
C3          ret                  ; return with result in EAX
                                 ;  (-1 for Proth number; 0 otherwise)

Try it online!
It's a pretty straightforward solution—and conceptually similar to MegaTom's C version. In fact, you could write this in C as something like the following:
unsigned IsProthNumber(unsigned input)
{
    --input;
    unsigned temp  = (input & -input);
    temp          *= temp;
    return (input < temp) ? -1 : 0;
}

but the machine code above is better golfed than what you'll get out of a C compiler, even when it's set to optimize for size.
The only "cheat" here is returning -1 as a "truthy" value and 0 as a "falsy" value. This trick allows the use of the 2-byte SBB instruction as opposed to the 3-byte SETB instruction.

-2 bytes for return value via carry flag, and another -1 byte for dropping the ret when the compiler inlines it

Thunno, \$ 12 \log_{256}(96) \approx \$ 9.88 bytes
zt1-s1_A&2^q

Attempt This Online! or generate all values up to 100.
Port of Dennis's Jelly answer
Explanation
zt1-s1_A&2^q  # Implicit input
zt            # Triplicate
  1-s         # Decrement and swap
     1_       # Subtract from 1
       A&     # Bitwise AND
         2^   # Squared
           q  # Is greater than the input?

Javascript ES7, 16 bytes
x=>x--<(-x&x)**2

Port of my Julia answer, which is a port of @Dennis's Jelly answer.
Thanks @Charlie for 2 bytes saved!

n=x=>x-1&1-x>x**.5; n(3) gives me 0 (actually it gives me 0 regardless of input)

What browser? It may be just that.

Chrome 52. Firefox 48 gives the same answer for n=x=>x-1&1-x>Math.pow(x,0.5); n(3)

Ok - it's the operator precedence. It has to be (x-1&1-x) as without it the operator precedence is actually: (x-1)&((1-x)>x**.5)

@eithedog fixed

Replace = with - and you got a Cheddar program to check proth numbers!

-1 byte: x=>x--**.5<(x&-x) or x=>x**.5<(--x&-x)

-1 byte: x=>x--<(-x&x)**2

Cjam, 11 bytes
Like many of us, piggybacking off of Dennis's excellent solution:
qi_(_W*&2#<

Try it online

C (137 bytes)
int P(int N){int x=1,n=0,k=1,e=1,P=0;for(;e;n++){for(x=1,k=1;x&&x<N;k+=2){x=2<<n;x=x>k?x*k+1:0;if(x>N&&k==1)e=0;}if(x==N)P=1;}return P;}

Only came to read the answers after I tried it.
Considering N=k*2^n+1 with the conditional of k<2^n (k=1,3,5.. and n=1,2,3..
With n=1 we have one k available to test. As we increase n we get a few more k's to test like so:
n=1 ; k=1
n=2 ; k=1 k=3
n=3 ; k=1 k=3 k=5 k=7
...
Iterating through those possibilities we can be sure N is not a Prouth number if for a given n the k=1 number obtained is larger than N and no other iteration was a match.
So my code basically "brute-forces" its way into finding N.
After reading the other answers and realizing you can factor N-1 with 2 to find n and then make the conditional of k<2^n, I think my code could be smaller and more efficient using this method.
It was worth a try!
Tested all numbers given and a few "non-Prouth" numbers. Function returns 1 if the number is a Prouth number and 0 if it's not.

C# (.NET Core), 17 bytes
x=>x--<(x=x&-x)*x

Try it online!
Port of MegaTom's C answer.
I attempted a LINQ based solution, but this was too good.

ink, 60 bytes
=p(n)
~n-=n>1
~temp x=1
-(k){n%2:{n<x}->->}
~x+=x
~n=n/2
->k

Try it online!
Based on @DSkoog's Maple answer - it wasn't the first of its kind to be posted, but it was the first of its kind that I saw.
Ungolfed
= is_proth(number) =

/* It's easy to check if a number is one less than a Proth number.
   We take the number and divide it by 2 until we can't.
   Once we can't, we've found the smallest possible "k".
   If we also keep track of how many times we divided, we have our corresponding "2^n"
   All we have to do then is compare those
*/

~ number -= (number > 1)            // So, we first subtract one. Except this implementation won't ever halt for 0, so we don't subtract if the input is 1 (this is fine since the desired outputs for inputs 1 and 2 are the same)
~ temp power_of_two = 1             // We declare a variable to store our "2^n"
- (check)
  {
  - number % 2:                     // Once we can't divide by 2 anymore, we've found the smallest possible "k"
    {number < power_of_two}         // At that point, we print whether it's smaller than the "2^n" we found
    ->->                            // And then we return to where we were called from
  }

  ~ number = number / 2             // We keep dividing by 2 until we can't.
  ~ power_of_two += power_of_two    // and update our "2^n" as we go
-> check

Stax, 6 bytes
öZç♫Δ¼

Run and debug it

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:
Sort the months of the year
Write a function or program that takes string inputs, fully-spelled, English month names in title case: January, February, March, etc. (null/CR/LF terminated OK, delimited with some non-alpha character if you so choose) and either

compares two inputs, returning a Truthy value if the second input is greater (in month order) than the first. Equal values result in a Falsey value
or sorts an arbitrary sequence (list, delimited string, etc.) of them in chronological order

(The crux of the challenge is defining a method/expression that gives the correct lexicographical sort. Some languages might have a shorter answer with one or the other)
You cannot use any internal time parsing methods (e.g. strptime) to translate the month name into a number or a pre-canned mapping of month names. Use properties of the strings themselves, a parsimonious look-up table you define, or something clever.
Example
Functioning examples, though the first is prohibited by the rules...
import datetime
def is_later_month(a, b):
    '''
    Example of prohibited code because it relies on language
    features about how to parse month names
    '''
    return datetime.strptime(a, '%B') < datetime.strptime(b, '%B')

The below versions are OK though, because we code that info
months = {
    'January':  1, 'February':  2, 'March':      3,
    'April':    4, 'May':       5, 'June':       6,
    'July':     7, 'August':    8, 'September':  9,
    'October': 10, 'November': 11, 'December':  12,
}
def is_later_month(a, b):
    """
    Returns True/False when comparing two months.
    """
    return months[a] < months[b]

Or you could do a sorting function
months = {'as above...'}
def sort_months(l):
    """
    Sorts list and returns it. Different input and output than the above,
    but equally valid. Sorting versus comparing might be shorter in your
    favorite language.
    """
    return sorted(l, key=lambda x: months[x])

Example tests
assert is_later_month('January', 'February')
assert is_later_month('January', 'December')
assert is_later_month('November', 'December')
assert not is_later_month('July', 'July')
assert not is_later_month('October', 'September')

You cannot use any internal time parsing methods (e.g. strptime) to translate the month name into a number. This is a bit unclear. Can we use a language's predefined literal that contains the months' names?

I'll delete my answer then. But it's still not clear what is allowed and what is not.

The problem is you can't anticipate all those potential tricks, such as predefined arrays. Perhaps a better option would have been to use a less common set of strings, such as made-up names. But it's too late now for that I guess

Is what I'm expressing clear? If Python had a builtin months that was a list of all Month names, I'd want to forbid months[x] < months[y] as an answer. The list of month names has some more peculiar features (varying length, commonality) that make the challenge easier/harder over randomly generated strings.

Yes, I think it's clear. I just fear that there may be other similar cases that you haven't explicitly ruled out (but I don't know which ones)

Can someone please provide (as a comment here) an example of a solution that violates the rule:
"You cannot use any internal time parsing methods (e.g. strptime) to translate the month name into a number or a pre-canned mapping of month names." ?

@Bevo there's one in the question above (marked "prohibited", using strptime). The "spirit of the rules" are that the month names are to be treated as arbitrary strings with an arbitrary order. Any a priori knowledge that a language might have about that string:order mapping is prohibited.

Jelly, 19 bytes
11ị“bMAanlseovc”iµÞ

This is a monadic link that takes a list as argument and sorts it. Try it online!
Background
Jelly uses modular, 1-based indexing. If we repeat the months names often enough to obtain 11 characters, we get the following array.
J a n u a r y J a n u
F e b r u a r y F e b
M a r c h M a r c h M
A p r i l A p r i l A
M a y M a y M a y M a
J u n e J u n e J u n
J u l y J u l y J u l
A u g u s t A u g u s
S e p t e m b e r S e
O c t o b e r O c t o
N o v e m b e r N o v
D e c e m b e r D e c

In the 11th (last) column, all characters are different, so we can use them to identify the order of the months.
How it works
11ị“bMAanlseovc”iµÞ  Monadic link. Argument: A (array of months)

                 µ   Combine the preceding chain into a link.
                  Þ  Sort A by that link.
11ị                    Select the 11th character of the month's name.
   “bMAanlseovc”       Find the index of that character in "bMAanlseovc".
                       For 'u' ("January"), this returns 0 (not found).

Just curious, how are you ranking the month with "bMAanlseovc"? Index of first character match?

I've added an explanation.

Wow, that's really clever!

x86 machine code, 26 25 bytes
Hexdump:
ff 32 8b 01 34 c0 68 30 5f 43 01 59 f7 e1 91 5a
80 f2 c0 f7 e2 3b c8 d6 c3

Assembly code:
    push dword ptr [edx];
    mov eax, [ecx];
    xor al, 0xc0;
    push 0x01435f30;
    pop ecx;
    mul ecx;
    xchg eax, ecx;
    pop edx;
    xor dl, 0xc0;
    mul edx;
    cmp ecx, eax;
    _emit 0xd6;
    ret;

The following hash function happens to put the month names in the proper order (found by brute force):
(x ^ 0xc0) * 0x01435f30

It is applied to the first 4 bytes (32 bits) of the input string, arranged in little-endian order. Then comparing the result and using SALC to set the result register (al):

-1 (true) if the months are in order
0 (false) if the second month precedes the first month (or they are the same)

I'm impressed. A very short piece of code without using code-golf specific language.

Jelly, 15 bytes
Oḅ32 354*%991µÞ

No online interpreter link here because this is one slow submission. The program uses the hashing function 354^(input interpreted as base 32 int) % 991 as the sort key, which happens to give outputs in the right order. The program won't finish any time soon because the results of the exponentiation are giant - for "September", a number with 0.24 quadrillion digits needs to be calculated!
Jelly explanation:
              Þ         Sort by...
             µ          Monadic link consisting of...

O                       Convert month string to code points
 ḅ32                    Take base 32
     354*               Perform 354 to the power of the result
         %991           Take modulo 991

Python proof of concept script - note the use of pow for modular exponentiation, which is much more efficient:
import random

def base_convert(string, base):
    total = 0

    for c in string:
        total = total * base + ord(c)

    return total

def month_hash(month):
    return pow(354, base_convert(month, 32), 991)

months = ["January", "February", "March", "April", "May", "June", "July",
    "August", "September", "October", "November", "December"]
random.shuffle(months)

print(months)
print(sorted(months, key=month_hash))

"No online interpreter link here because this is one slow submission." In which case, you may as well sort the months by hand. ;-)

Maybe you could PR a feature request to optimize pow/mod...

@NickT That's an excellent idea, but unfortunately with the way the interpreter's set up (with each operator defined separately), that might be a little tricky. And Jelly doesn't work well with operators that have more than two arguments, so defining a separate operator wouldn't quite work either...

Not a separate operator or anything, just some deeper introspection to see if a power operation is followed by modular division. Sounds easy? :P

Python, 64 61 57 bytes
lambda x,y,g='bMAanlseovc'.find:g((x*4)[10])<g((y*4)[10])

The lambda takes two months as input and compares them. Test it on Ideone.
Thanks to @ljeabmreosn for golfing off 3 bytes and paving the way for 3 more!

At last, you reveal the secret behind the black magic you used to quickly calculate the correct month in your Jelly answer!

Would changing s[10%len(s)] to (4*s)[10] work?

@ljeabmreosn That works indeed. Thanks!

Haven't seen the abuse of default arguments in a lambda yet :P

Python, 81 71 bytes
lambda x,y,m='anebarprayunulugepctovec':m.index(x[1:3])<m.index(y[1:3])

https://repl.it/CluN/1
Compares the index in m of the second and third letters of two months.
83 byte version to sort a list of months:
lambda x:sorted(x,key=lambda i:'JanFebMarAprMayJunJulAugSepOctNovDec'.index(i[:3]))

Julia 1.0, 28 bytes
~m=hash("lWbAj"*m)
m^n=~m<~n

Try it online!
This solution prepends a string to each month before calculating the hash. The magic values in this and the other solutions were found by brute force.
Simple hash, 29 bytes
~m=hash(m)%69675331
m^n=~m<~n

Try it online!
String repetition + modulo, 29 bytes
~m=hash(m^69)%22670
m*n=~m<~n

Try it online!

Haskell, 74 bytes
My first code golf, yay! The general idea of this one is inspired by the top answer in Jelly, and the fact that when the month names are cycled, the 11th character is always unique.
e s=head.drop 10$cycle s;a#b=elem(e b)$tail$dropWhile(/=e a)"ubMAanlseovc"

Here is an ungolfed version to see how it works:
order :: String
order = "ubMAanlseovc"

eleventhChar :: String -> Char
eleventhChar
  = head . drop 10 $ cycle

inOrder :: String -> String -> Bool
inOrder m1 m2
  = elem (eleventhChar m2) (tail $ dropWhile (/= eleventhChar m1) order)

The e function represents the eleventhChar function (sadly can't strip off 4 bytes due to the monomorphism restriction I think) and the # infix function corresponds to the inOrder function.
A neat little solution, but there may be ways of shaving off more bytes (I found some just while writing this!)

You could shorten e s=head.drop 10$cycle s like you did in your explanation by using . instead of $: e=head.drop 10.cycle. However using the list index operator !! is even shorter: e=(!!10).cycle

Great suggestions. Sometimes you just overlook these things. Thanks a lot. Will edit it shortly.

Ruby, 58 bytes
Uses the month sorting trick from @atlasologist's answer.
->a{a.sort_by{|i|"anebarprayunulugepctovec".index i[1,2]}}

The comparison function is a bit longer, at 63 bytes
->a,b{m=->i{"anebarprayunulugepctovec".index i[1,2]};m[a]<m[b]}

J, 66 65 bytes
Uses the fact that f(m) = 2*(ord(m[0])+ord(m[-1]))//len(m) is a valid function in the limited domain of the 12 months:
>/@:('7/HEäWa<+0'&i.@(3 :'u:<.(#>y)%~+:+/3&u:({.>y),({:>y)')"0)"1

Usage:
   bigger =: >/@:('7/HEäWa<+0'&i.@(3 :'u:<.(#>y)%~+:+/3&u:({.>y),({:>y)')"0)"1
   bigger ('May'; 'March')
1
   bigger ('May'; 'June')
0

(By no means is this the best idea, but I didn't want steal anyone's ranking trick!)
Here is a shorter version using @atlasologist's method:
J, 63 bytes
m=:[:}.3{.]
[:>/(12 2$'anebarprayunulugepctovec')i.([:m[),:[:m]

Usage:
   bigger =: [:>/(12 2$'anebarprayunulugepctovec')i.([:m[),:[:m]
   'January' bigger 'May'
0
   'June' bigger 'May'
1

And a much shorter version using @Dennis's clever method:
J, 34 bytes
>&:('ubMAanlseov'&i.@:{.@:(10&|.))

ARM machine language on Linux 44 40 bytes
e28fc001     add ip, pc, #1
e12fff1c     bx ip
6803         ldr r3, [r0, #0]
6808         ldr r0, [r1, #0]
4a05         ldr r2, [pc, #20]
f08303dd     eor.w r3, r3, #221
f08000dd     eor.w r0, r0, #221
4353         muls r3, r2
4350         muls r0, r2
4283         cmp r3, r0
bfac         ite ge
2000         movge r0, #0
2001         movlt r0, #1
4770         bx lr
2f68f24c

I used a different hash function than anatolyg's solution and tried to use thumb instructions to save a few bytes (though I blew 8 bytes entering thumb mode).
You can try this out on a Raspberry Pi or Android device with GNURoot.
int main(int argc,char**argv){
return ((int(*)(char*,char*))"\
\1\xc0\x8f\xe2\
\x1c\xff\x2f\xe1\
\3\x68\x8\x68\
\5\x4a\x83\xf0\
\xdd\3\x80\xf0\
\xdd\x43\x53\x43\
\x50\x4a\x83\x42\
\xac\bf\0\x20\
\1\x20\x70\x47\
\x4c\xf2\x68\x2f\
")(argv[1],argv[2]);}

To run enter something like
$ ./foo January February; echo $?

The current version now handles the equality case (and others) correctly.

I think you don't need code that explicitly switches into Thumb mode. From what I remember, you only need to tell the linker your procedure is in thumb mode, and the linker will set the LSB in your procedure's address to 1, so the processor will switch to Thumb mode automatically when your code is called.

Also, what does bfac do?

@anatolyg ite ge conditionally executes the next instruction (movge r0, #0) if r3 >= r0, otherwise the instruction following that is executed (movlt r0, #1). I think there is room to knock off a couple of bytes here but I haven't had time to work on this :-)

Java, 133 123
Golfed:
boolean f(String a,String b){return h(a)<h(b);}int h(String s){return"anebarprayunulugepctovec".indexOf(s.substring(1,3));}

I was searching for a clever technique like in the assembler answer, but it was taking too long to figure out so I went with the same technique everyone else used.
Ungolfed:
import java.util.Random;

public class SortTheMonthsOfTheYear {

  public static void main(String[] args) {
    // @formatter:off
    String[] MONTHS = new String[] {
        "January", "February", "March",
        "April",   "May",      "June",
        "July",    "August",   "September",
        "October", "November", "December"
    };
    // @formatter:on

    Random r = new Random();
    for (int i = 0; i < 100; ++i) {
      int m1 = r.nextInt(MONTHS.length);
      int m2 = r.nextInt(MONTHS.length);
      System.out.println("Input: " + MONTHS[m1] + " < " + MONTHS[m2]);
      System.out.println("Expected: " + (m1 < m2));
      System.out.println("Actual:   " + new SortTheMonthsOfTheYear().f(MONTHS[m1], MONTHS[m2]));
      System.out.println();
    }
  }

  // Begin golf
  boolean f(String a, String b) {
    return h(a) < h(b);
  }

  int h(String s) {
    return "anebarprayunulugepctovec".indexOf(s.substring(1, 3));
  }
  // End golf

}

You could use substring instead if charAt

@anatolyg thanks, I am not sure how that one escaped me. I was also able to remove "" + since there are no raw chars anymore.

Haskell, 118 characters
data M=Ju|Fr|Mc|Ai|My|Je|Jy|Au|St|Oo|Ne|De deriving(Ord,Eq,Read)
r=read.([head,last]<*>).lines.take 4
a#b=(r a::M)<r b

Uses the fact that each month name is unique in its first and fourth characters (or 3rd for May) to define a data type that can be automatically parsed and compared by the language.  The 'r' function converts a string by grabbing the first four characters (or fewer), then just picking the first and last.  Then 'a#b' is an operator to compare the values:
*Main> "June" # "March"
False
*Main> "June" # "July"
True
*Main> "January" # "July"
True
*Main> "January" # "November"
True
*Main> "December" # "November"
False

Could probably be done in a more efficient way, but I wanted to try doing it using a useful data type to represent the months.

Python 83 82 bytes
lambda x,y,m=(lambda a:'2&9<@FD6A?L%'.find(chr(sum(map(ord,a[:3]))%77))):m(x)<m(y)

Test: https://repl.it/repls/TimelyDecimalBrowsers
Gets the sum of the first 3 chars and creates a single char to search.

PowerShell, 96 88 63 bytes
$input|Sort{'anebarprayunulugepctovec'.IndexOf((-join$_[1,2]))}

e.g.
PS C:\Code> 'February', 'January', 'December', 'April' | .\monthsort.ps1
January
February
April
December

Now does the second challenge of sorting a list into order; previous versions did the comparison of two month test:
v2.
$l,$r=$args|%{-join$_[1,2]};($d='anebarprayunulugepctovec').indexof($l)-lt$d.IndexOf($r)

v1.
$l,$r=$args|%{-join$_[1,2]};$r-match('an|eb|ar|pr|ay|un|ul|ug|ep|ct|ov|ec'-split$l)[1].Trim('|')

e.g.

PS C:\code> .\Test-MonthsInOrder.ps1 January February
True

Based on the second two characters in the month name.

Perl 6, 55 bytes
*.sort({index 'anebarprayunulugepctovec',.substr(1,2)})

It would require a few more bytes for the comparison versions:
{[<] @_».&{index 'anebarprayunulugepctovec',.substr(1,2)}}
{[<] .map: {index 'anebarprayunulugepctovec',.substr(1,2)}}

Test:
#! /usr/bin/env perl6
use v6.c;
use Test;

my @months = <
  January February March April May June July
  August September October November December
>;

my &month-sort = *.sort({index 'anebarprayunulugepctovec',.substr(1,2)});

plan 100;

for ^100 {
  # ｢.pick(*)｣ returns all elements in random order
  is-deeply month-sort(@months.pick(*)), @months.List;
}

awk, 73 bytes
function __(_){return index("=anebarprayunulugepctovec",substr(_,2,2))/2}

The full function, for any awk and any locale setting, 73 bytes
echo -n 'function __(_){return index("=anebarprayunulugepctovec",substr(_,2,2))/2}' |
gwc -lcm
      0      73      73

The core components only, 50 bytes
echo -n   'index("=anebarprayunulugepctovec",substr(_,2,2))/2' |
gwc -lcm
      0      50      50

This is better than the shorter trick involving the 11th letter, because that one requires all inputs to be full length names. this one works for both 3-letter abbreviated ones and their full length counterparts

Bash, 101 bytes
this is function like is_later
f(){ s=ubMAanlseovc a=$1$1$1 b=$2$2$2 c=${a:10:1} d=${b:10:1} e=${s%$c*} f=${s%$d*};((${#e}<${#f}));}

test
$ f January December && echo later || echo not later
not later

k4, 29
{x@<"ubMAanlseovc"?(*|11#)'x}

A port of @Dennis's Jelly answer.
This is the sorter, not the comparator; interestingly, the comparator is trivially implementable by the same algorithm, and only one byte longer:
{(<)."ubMAanlseovc"?(*|11#)'x}

Bash + coreutils, 94 bytes93 bytes
s(){ x=FMAyulgSOND;for y;{ rev<<<${y:0:3}|tr -d -C $x|tr $x C-M;echo B$y;}|sort|cut -f2 -dB;}

This is an attempt to come up with a transform that sorts lexicographically.  If you look closely at the transform key FMAyulgSOND you can see the months February through December (January becomes empty after the transform; it's pulled to top by use of 'B' as the separator).  Reversing, truncating, and removing non-keyed letters allow this trick to be pulled off.
90 bytes using C Locale
s(){ x=FMAyulgSOND;for y;{ rev<<<${y:0:3}|tr -d -C $x|tr $x C-M;echo \␉$y;}|sort|cut -f2;}

...where ␉ is the tab character.
80 bytes using C Locale
s(){ x=anebarprayunulugepctovec;for y;{ echo ${x%${y:1:2}*}\␉$y;}|sort|cut -f2;}

...using @atlasolog's method.  Bound to be a way to use this approach to work with more locales.
Test/Usage
s December November October September August July June May April March February January

outputs:
January
February
March
April
May
June
July
August
September
October
November
December

Javascript, 118 bytes
u=p=>{p=p.split` `.sort();c=[];for(i=0;i<12;i++){c.push(p["4 3 7 0 8 6 5 1 11 10 9 2".split` `[i]]);}return c.join` `}

Could be golfed more, probobly by getting rid of c and using array.map, but this is what I have for now...

for(i=0;i<12;)c.push(p[[4,3,7,0,8,6,5,1,11,10,9,2][i++]]);

Thunno, \$ 29 \log_{256}(96) \approx \$ 23.87 bytes
De11AH"bMAanlseovc"AhEZZz:.AK

Attempt This Online!
Port of Dennis's Jelly answer.
Explanation
De          # Duplicate and map over the list
  11AH      # Get the 11th item of the string (1-indexed, modular)
      "..." # Push the string of each month's 11th letter
Ah          # Get the index in this string (January returns -1)
  E         # End map
   ZZ       # Zip with the original list
     z:     # Sort this list
       .AK  # And get the last item of each
            # Implicit output


text:
Make a (somewhat) self-referential string
You want to make a string where the (1-indexed) character at index n is n. When n is less than 10, this is easy: "123456789". When n is 12, for example, it becomes impossible, since numbers greater than 9 (in base 10) take up more than one character. We can compromise by dividing the string into two-character substrings: "020406081012". Now the index of the end of each substring n is n.
This can be generalized for any d-digit number. Here's an explanation for the "0991021" part of the string for a three-digit number:
Index:     ... * 97  98  99*100 101 102*103 ...
               *           *           *
               *---+---+---*---+---+---*---+
Character: ... * 0 | 9 | 9 * 1 | 0 | 2 * 1 | ...
               *---+---+---*---+---+---*---+

If you haven't figured it out yet, you are to write a program/function that takes a string or integer and output its self-referential string as specified above. You can also output an array of single-digit numbers, chars, or single-character strings.
The given integer will always be positive and divisible by its length (e.g. 126 is divisible by 3; 4928 is divisible by 4). Your program should theoretically work for an arbitrarily large input, but you can assume it is smaller than your language's maximum integer and/or string length.
Some observations if you still don't get it: The length of the output will always be the input itself, and the numbers that appear in the output will be divisible by the number of digits in the input.
This is code-golf, so shortest answer in bytes wins.
Test cases
1    => 1
9    => 123456789
10   => 0204060810
105  => 003006009012015018021024027030033036039042045048051054057060063066069072075078081084087090093096099102105
1004 => 00040008001200160020002400280032003600400044004800520056006000640068007200760080008400880092009601000104010801120116012001240128013201360140014401480152015601600164016801720176018001840188019201960200020402080212021602200224022802320236024002440248025202560260026402680272027602800284028802920296030003040308031203160320032403280332033603400344034803520356036003640368037203760380038403880392039604000404040804120416042004240428043204360440044404480452045604600464046804720476048004840488049204960500050405080512051605200524052805320536054005440548055205560560056405680572057605800584058805920596060006040608061206160620062406280632063606400644064806520656066006640668067206760680068406880692069607000704070807120716072007240728073207360740074407480752075607600764076807720776078007840788079207960800080408080812081608200824082808320836084008440848085208560860086408680872087608800884088808920896090009040908091209160920092409280932093609400944094809520956096009640968097209760980098409880992099610001004

Jelly, 12 bytes
VRUmLDUz0ZFU

I/O is in form of digit arrays. Try it online! or verify all test cases.
How it works
VRUmLDUz0ZFU  Main link. Argument: A (digit array)

V             Eval; turn the digits in A into an integer n.
 R            Range; yield [1, ..., n].
  U           Upend; reverse to yield [n, ..., 1].
    L         Yield the length (l) of A.
   m          Modular; keep every l-th integer in A.
     D        Decimal; convert each kept integer into the array of its digits.
      U       Upend; reverse the digits of each integer.
       z0     Zip/transpose with fill value 0.
         Z    Zip again.
              This right-pads all digit arrays with zeroes.
          F   Flatten the resulting 2D array.
           U  Upend/reverse it.

Look 'ma, no Unicode!

Yet it looks like some angry driver.

C, 64 bytes
l,i;main(n){for(scanf("%d%n",&n,&l);i<n;)printf("%0*d",l,i+=l);}

Takes a single integer as input on stdin.

JavaScript (ES6), 83 bytes
n=>[...Array(n/(l=`${n}`.length))].map((_,i)=>`${+`1e${l}`+l*++i}`.slice(1)).join``

Yes, that's a nested template string. 79 bytes in ES7:
n=>[...Array(n/(l=`${n}`.length))].map((_,i)=>`${10**l+l*++i}`.slice(1)).join``

MATL, 15 14 bytes
VntG3$:10YA!1e

Try it online!
V        % Implicitly input number, n. Convert to string
n        % Length of that string, s
t        % Duplicate s
G        % Push n again
3$:      % 3-input range (s,s,n): generates [s, 2*s, ... ] up to <=n
10YA     % Convert each number to base 10. This gives a 2D array of char, with each
         % number on a row, left-padded with zeros if needed
!1e      % Reshape into a string, reading in row-major order. Implicitly display

05AB1E, 15 bytes
Code:
LD¹gÖÏvy0¹g×0ñ?

Explanation:
L                # Get the array [1, ..., input].
 D               # Duplicate this array.
  ¹g             # Get the length of the first input.
    Ö            # Check if it's divisible by input length.
     Ï           # Keep those elements.
      vy         # For each...
         ¹g      # Get the length of the first input.
        0  ×     # String multiply that with "0".
            0ñ   # Merge with the number.
              ?  # Pop and print without a newline.

The merging is done like this:
From these:
000
 12

It results into this:
012

Uses the CP-1252 encoding. Try it online!.

Cool! Didn't know that ñ worked like that.

@Emigna Yeah, but it looks rather a bit long. I should probably make a builtin for that builtin :P.

A builtin for padding would be really useful as well.

Python 2, 78 70 68 64 63 bytes
Actually basing on the idea of Destructible Watermelon makes it even smaller (using input is even better)(filling the string backward saves 4 bytes)(no () at while):
n,s=input(),''
l=len(`n`)
while n:s=`n`.zfill(l)+s;n-=l
print s

Here is the old 70 byte approach (Saving 8 bytes by using backquotes instead of str and dropping the square brackets around generator thanks to Dennis):
def f(n):l=len(`n`);print"".join(`x`.zfill(l)for x in range(l,n+l,l))

I forgot about zfill... darn.

You can use `x` instead of str(x). Also, you don't need the [] around the generator.

You outgolfed me again... serous times call for serious measures: I'm gonna have to change to python 2

goddamnit you did it again!

You don't need the parens in while(n).

Python 2, 63 bytes
def f(n):l=len(`n`);print'%%0%dd'%l*(n/l)%tuple(range(l,n+1,l))

Test it on Ideone.

Dat format string °_°

JavaScript (ES6), 66
Recursive, input n as a string (not a number) and limiting the output string size to 2GB (that is above the string limit of most javascript engines)
f=(n,i=1e9,s='',l=n.length)=>s[n-1]?s:f(n,i+=l,s+(i+'').slice(-l))

Test

f=(n,i=1e9,s='',l=n.length)=>s[n-1]?s:f(n,i+=l,s+(i+'').slice(-l))

function test() {
  var v=I.value;
  Alert.textContent=v % v.length ?
    'Warning: input value is not divisible by its string length':'\n';
  Result.textContent=f(v);
}

test()
<input type=number id=I value=105 oninput='test()' max=500000>

R, 66 64 62 bytes
edit:
x=nchar(n<-scan());paste0(str_pad(1:(n/x)*x,x,,0),collapse="")
first golf attempt...

Hi, and welcome to PPCG! Nice first post!

2sable, 13 bytes
Code:
g©÷F®N>*0®×0ñ

Uses the CP-1252 encoding.

why didn't you name this 05AB1F? :3

@ConorO'Brien I actually thought about that, but then the names would look really similar and confusing :p.

you mean 15AB1E

Python 3 2, 79 74 69 65 68 67 bytes
Thanks Dennis!
def f(n):i=l=len(`n`);s='';exec n/l*"s+=`i`.zfill(l);i+=l;";print s

byte count increase from bad output method

Shouldnt it be len(x) instead of f and then save bytes by assigning it to a variable?

I don't think so.. what do you mean. Also, I would have outgolfed you with python 2, but some stupid stuff it happening right now ._.

You seem to have switched to Python 2. Also, per consensus on meta, using backspace to overwrite part of the output is only allowed in ASCII art challenges.

In Python 2, / performs integers division foe.integer arguments.

Bash, 31 22 bytes
seq -ws '' ${#1}{,} $1

Test it on Ideone.
Thanks to @izabera for golfing off 6 bytes!

Brachylog, 53 45 42 37 28 bytes

lB,?ybeN:B%0,N:ef:{,"0":"9"y:?m.}acAl:Br-:"0"rjb:Acw\
lB,?ybeN:B%0,10:B^:N+:ef:{,"0":"9"y:?m.}acbw\
lB,?ybeN:B%0,10:B^:N+:ef:{:16+:@Prm.}acbw\
lB,?ybeN:B%0,10:B^:N+:efbe:16+:@Prmw\
lB,?ybeN:B%0,10:B^:N+:efbew\

Try it online!

Ruby, 52 48 + n flag = 49 bytes
((l= ~/$/)..$_.to_i).step(l){|j|$><<"%0#{l}d"%j}

Maybe you don’t need to chop if you assume input is passed without a trailing newline? I’m not sure if that’d work. Or how about assuming there always is one, and writing l=~-size?

@Lynn calling size like that doesn't work for me. Oh well, I remembered a trick I had used in an earlier answer that's shorter anyways

Javascript - 76
n=>eval('c="";for(a=b=(""+n).length;a<=n;a+=b)c+=`${+`1e${b}`+a}`.slice(1)')

or 71 if allowing for string arguments:
n=>eval('c="";for(a=b=n.length;a<=n;a+=b)c+=`${+`1e${b}`+a}`.slice(1)')

Thanks to @user81655!
Ungolfed:
function x(n)
{
   c = "", a = b = (""+n).length;
   while(a<=n)
   {
       c=c+"0".repeat(b-(""+a).length)+a
       a+=b;
   }
   return c;
}

much place for improvement, but i'm tired right now

Nice! I found a few improvements that could be made (76 bytes): n=>eval('c="";for(a=b=(""+n).length;a<=n;a+=b)c+=\${+`1e${b}`+a}`.slice(1)'). The main bits are using a forloop and Neil's1e${b}` trick.

@user81655 - it gives me Uncaught SyntaxError: Invalid or unexpected token. Haven't debugged yet as I'm just awake :D

Hmmm. It might be hidden characters which are sometimes added to SO comments. Try writing it out.

zsh, 28 bytes
printf %0$#1d {$#1..$1..$#1}

zsh + seq, 2120 bytes
This is pretty much the same answer as Dennis but in 20 bytes because zsh
seq -ws '' $#1{,} $1

R, 149 142 138 bytes
x=rep(0,n);a=strtoi;b=nchar;for(i in 1:(n=scan()))if(!i%%b(a(n)))x[i:(i-b(a(i))+1)]=strsplit(paste(a(i)),"")[[1]][b(a(i)):1];cat(x,sep="")

Leaving nchar in the code gives a program with the same number of bytes than replacing it with b, but having random letters wandering around in the code makes it more... mysterious
Ungolfed :
Each nchar(strtoi(something)) permits to compute the number of numerals in a given number.
n=scan()   #Takes the integer
x=rep(0,n) #Creates a vector of the length of this integer, full of zeros

for(i in 1:n)
    if(!i%%b(strtoi(n)))         #Divisibility check
        x[i:(i-nchar(as.integer(i))+1)]=strsplit(paste(a(i)),"")[[1]][nchar(as.integer(i)):1];
        #This part replace the zeros from a given position (the index that is divisible) by the numerals of this position, backward.

cat(x,sep="")

The strsplit function outputs a list of vectors containing the splitten elements. That's why you have to reach the 1st element of the list, and then the ith element of the vector, writing strsplit[[1]][i]

try using str_pad()

@hedgedandlevered : well, this function needs a package (i.e. it cannot be run with vanilla R), and I don't want to use such while PPCG-ing

Haskell, 51 bytes
f n|k<-length$show n=[k,2*k..n]>>=tail.show.(+10^k)

Perl, 40 bytes
39 bytes code + 1 for -n.
$}=y///c;printf"%0$}d",$i+=$}while$i<$_

Usage
echo -n 9 | perl -ne '$}=y///c;printf"%0$}d",$i+=$}while$i<$_'
123456789
echo -n 10 | perl -ne '$}=y///c;printf"%0$}d",$i+=$}while$i<$_'
0204060810
echo -n 102 | perl -ne '$}=y///c;printf"%0$}d",$i+=$}while$i<$_'
003006009012015018021024027030033036039042045048051054057060063066069072075078081084087090093096099102
echo -n 1000 | perl -ne '$}=y///c;printf"%0$}d",$i+=$}while$i<$_'
0004000800120016002000240028003200360040004400480052005600600064006800720076008000840088009200960100010401080112011601200124012801320136014001440148015201560160016401680172017601800184018801920196020002040208021202160220022402280232023602400244024802520256026002640268027202760280028402880292029603000304030803120316032003240328033203360340034403480352035603600364036803720376038003840388039203960400040404080412041604200424042804320436044004440448045204560460046404680472047604800484048804920496050005040508051205160520052405280532053605400544054805520556056005640568057205760580058405880592059606000604060806120616062006240628063206360640064406480652065606600664066806720676068006840688069206960700070407080712071607200724072807320736074007440748075207560760076407680772077607800784078807920796080008040808081208160820082408280832083608400844084808520856086008640868087208760880088408880892089609000904090809120916092009240928093209360940094409480952095609600964096809720976098009840988099209961000

k4, 27
{,/"0"^(-c)$$c*1+!_x%c:#$x}

Not really golfed at all, just a straight-forward implementation of the spec.
                        $ / string
                       #  / count
                     c:   / assign to c
                   x%     / divide x by
                  _       / floor
                 !        / range (0-based)
               1+         / convert to 1-based
             c*           / multiply by count
            $             / string
       (-c)               / negative count
           $              / pad (negative width -> right-aligned)
   "0"^                   / fill blanks with zeros
 ,/                       / raze (list of string -> string)

SQF - 164
Using the function-as-a-file format:
#define Q String""
l=(ceil log _this)+1;s='';for[{a=l},{a<=_this},{a=a+l}]do{c=([a]joinQ)splitQ;reverse c;c=(c+['0'])select[0,l];reverse c;s=format[s+'%1',c joinQ]}

Call as INTEGER call NAME_OF_COMPILED_FUNCTION

Actually, 30 bytes
;╝R╛$l;)*@#"%0{}d"f╗`#╜%`MΣ╛@H

Try it online!
I'm not happy with the length of this code, but I'm not sure that it can be made much shorter (if at all).
Explanation:
;╝R╛$l;)*@#"%0{}d"f╗`#╜%`MΣ╛@H
;╝                              duplicate input, push a copy to reg1
  R                             range(1, input+1)
   ╛$l                          push input from reg1, stringify, length
      ;)                        duplicate and move copy to bottom of stack
        *                       multiply range by length of input
         @#                     swap range with length, make length a 1-element list
           "%0{}d"f             "%0{}d".format(length) (old-style Python format string for zero-padding integers to length of input)
                   ╗            save format string in reg0
                    `#╜%`M      for each value in range:
                     #            make it a 1-element list
                      ╜%          format using the format string
                          Σ     concatenate
                           ╛@H  take only the first (input) characters in the resulting string

PowerShell, 77 bytes
$x="$($args[0])";$l=$x.Length;-join(1..($x/$l)|%{"$($_*$l)".PadLeft($l,'0')})

Uses string interpolation to shorten string casts. The parts before the second semicolon shorten the names of reused things. Then, every integer up to the input - and only those that are multiples of the input's length - are padded to be as long as the input string and finally joined into one.

PHP, 83 78 bytes
<?$a=$argv[1];$i=$y=strlen($a);while($y<=$a){printf('%0'.$i.'d', $y);$y+=$i;}

Tips are more then welcome. Manage to golf it myself by one byte by changing it from a for loop to a while loop.
This code assumes that this is being execute from the command line and that $argv[1] is the int.
Thanks to:
@AlexGittemeier
His suggestion (see comments) golfed this by 5 bytes to 78 bytes.

You can change echo sprintf(...) -> printf(...)

CJam, 19 bytes
q_,:V\i,%{V+sV0e[}/

Try it online. No one has posted in CJam yet, so this is the script I used for the test cases.
Explanation
q_,:V  e# Store the length of the input as V
\i,    e# Push the range from 0 to the input
%      e# Keep only every V'th number in the array
{      e# Do this for each number:
  V+   e# Add V to get the right number of leading zeroes
  s    e# Convert to string for left padding
  V    e# Push V, the length to bring each string to, and...
  0    e# The character to add to the left
  e[   e# Left pad
}/

Perl 6, 69 59 46 bytes
{my \a=.chars;(a,2*a...$_).fmt("%0"~a~"s","")}

You can use fmt on the list instead of map, sprintf and [~]. 42 bytes