text:
Smallest positive integer not yet appeared so that the sum of the first n elements is divisible by n
Task
Given positive integer n, output a(n) where a is the sequence defined below:
a(n) is the smallest positive integer not yet appeared so that the sum of the first n elements in the sequence is divisible by n.
Example

a(1) is 1 because it is the smallest positive integer that has not appeared in the sequence, and 1 is divisible by 1.
a(10) is 16 because look at the first nine elements: 1,3,2,6,8,4,11,5,14. They sum up to 54, so for the first ten elements to sum up to a multiple of 10, a(10) would need to have a remainder of 6 when divided by 10. 6 has already appeared, so a(10) is 16 instead.

Testcases
n     a(n)
1     1
2     3
3     2
4     6
5     8
6     4
7     11
8     5
9     14
10    16
11    7
12    19
13    21
14    9
15    24
16    10
17    27
18    29
19    12
20    32
100   62
1000  1618
10000 16180

a(n) from n=1 to n=10000

References

OEIS A019444

What values of n and a(n) must we support?

@RohanJhunjhunwala Theoretically every positive number.

so bignum mandatory?

@RohanJhunjhunwala I said theoretically, meaning it is not mandatory.

so less than 2^31 -1 is ok?

I only ask so I can use int in Java (and S.I.L.O.S)

@RohanJhunjhunwala Yes.

Strangely related.

Python 2, 43 bytes
r=.5+5**.5/2
lambda n:[n/r+1,n*r][n%r<1]//1

Outputs floats. Uses the relation

a(n) = A002251(n-1) + 1

to Wythoff pairs. Takes from the upper or lower Beatty sequence by multiplying or dividing by the golden ratio and converting to an integer.

I think the precision is fine up to 2**32.

Then it does not work outside the boundary.

@LeakyNun I thought you said up to 2^31 -1 is ok?

What does it return for 2^31-1?

@LeakyNun It gives 6949403065.0.

My arbitrary precision version gives 3474701531.

Can you try 2^31-2?

@LeakyNun Oops, I ran the wrong value. 2^31-1 gives 3474701531.0 and 2**31-2 gives 3474701529.0. Here are 10 nearby values if you want to compare.

Python 3, 102 bytes
Definitely not the shortest solution (not familiar with code golf) but I was bored so here it is in Python. I'm sure you could make it smaller with lambdas/filter.
def a(n,s=[]):
    for j in range(1,n+1):
        i=1
        while i in s or(sum(s)+i)%j:i+=1
        s+=[i]
    return s[-1]

Use a while loop for the second nested loop. Your solution currently does not theoretically support higher integers.

Rather than using 4 spaces, you can use a tab or one space.

You can also use space for the first level and then tab for the second level.

Make sure to include your byte count.

You ca put the opposite of the if condition as the while condition, and then append the item to the array outside the while loop.

@LeakyNun Very true. Thanks for all the suggestions :)

You can put i+=1 on the same line as the while condition

You can remove the whitespace after or

You can save a few bytes by defining s in your def; i.e. def a(n,s=[]): (saves 4 spaces and a newline, but adds one comma.)

OCaml, 163 bytes
open List
let a x=let rec h m s=let rec n m s c=if fold_left(+)c(s)mod m<>0||mem c s then n m s(c+1)else c in if m=x then hd s else h(m+1)((n(m+1)s 2)::s) in h 1[1]

Online interpreter
Usage
>> open List
>> let a x=let rec h m s=let rec n m s c=if fold_left(+)c(s)mod m<>0||mem c s then n m s(c+1)else c in if m=x then hd s else h(m+1)((n(m+1)s 2)::s)in h 1[1];;
<< val a : int -> int = <fun>
>> a(100);;
<< int = 62

where >> is STDIN and << is STDOUT.

Can you remove the whitespace after the last in?

I'm guessing you meant before? Thanks for editing in the demo!

Yes, I meant before

Actually, 17 bytes
This uses xnor's algorithm. Golfing suggestions welcome. Try it online!
,;;φ(/u(φ*1φ(%<I≈

Here's a 31-byte version that uses the function definition, but with the oddity that, at first, the function returns the sequence a(n)-1, so the result needs to be incremented at the end. Try it online!
[]╗,`1";#╜+;l@Σ%@╜í+uY"£╓╖`n╜Nu

Ungolfing:
First algorithm

,;;                 Take the input, duplicate it twice
          1φ(%<I    If input mod phi less than 1
       (φ*          then input * phi
   φ(/u             else input / phi + 1
                ≈   int() the result

Second algorithm

[]╗    Push a list to register 0 (call this res from now on)
,      Take input
`1     Start function, push 1
  "      Start string
  ;      Duplicate i
  #╜+;   res + list(i), duplicate
  l      len(new list)
  @Σ     sum(new list)
  %      sum % len
  @╜í    Rotate i to top, check if i in res
  +uY    (sum%len) + (i in res) + 1, negate (1 if i fits conditions, else 0)
  "£     End string, turn into a function
╓      Push first (1) values where f(x) is truthy, starting with f(0)
╖`     Append result to the list in register 0, end function
n      Run function (input) times
╜Nu    Return res[-1]+1

Pyth - 23 21 18 bytes
Can probably streamline the generation process with more lambdas or other tricks, but this is my first answer in more than a month.
eem=+Yf!|}TY%+TsYh

Try it online here.

R, 99 bytes
f=function(n){a=n
b=c()
while(0<(a=a-1))b=c(f(a),b)
while(a<-a+1)if(!(sum(b)+a)%%n&!a%in%b)break
a}

Simple algorithm. Runs from n-1 to 1 and gathers all of those numbers in the sequence. Then it moves up from 1 -- checking membership and whether it divides appropriately.

JavaScript (ES6), 69 bytes
n=>{for(a=[],s=i=0;i++<n;a[j]=1,s+=j)for(j=i-s%i;a[j];)j+=i;return j}

At each stage just checks all the numbers with the appropriate remainder until it finds one that it hasn't seen before, then marks it seen and updates the total.

Python 3, 96 bytes
n=int(input())
a=[]
for L in range(1,n+1):
 t=L-sum(a)%L
 while t in a:t+=L
 a+=[t]
print(a[-1])

Ideone it!

Behaviour, 64 bytes
c=&[(~!a{})(l=c:a-1s=0\(~(l<=s+=1)~!(l+s>&a+b)%a)l+s)]f=&(!c)%-1

Test with:
f:1
f:2
f:10

Calculates the list recursively and doesn't even work for n > 300, but you know, there was an attempt.
Ungolfed and commented:
// There are two functions, the first is recursive and creates the entire list
createList = &
  [
    (~!a; {})    // Base case, n==0 return empty list
    (
      list = createList:a-1 // create the list for n-1
      smallest = 0          // initialize the variable to find the smallest
                            // Repeat the following Sequencer until success
      \(
        // Increments smallest and check if it is NOT on the list
        ~(list <= smallest+=1)

        // sum up the list with the smallest found
        sum = list+smallest > &a+b

        // is the sum divided by n remainder 0
        ~!sum%a
      )
      // returns the list with the smallest
      list + smallest
    )
  ]
// The second function just execute the first and return its last item
f = &(!createList)%-1


text:
Code golf ABC's: The ASCII Box Challenge
Given two positive integers, 'a' and 'b', output an ascii-art "box" that is a characters wide and b characters tall. For example, with '4' and '6':
****
*  *
*  *
*  *
*  *
****

Simple right? Here's the twist: The border of the box must be the characters of "a" and "b" alternating. This starts at the top left corner, and continues in a clockwise spiral. For example, the previous example with 4 and 6 should be
4646
6  4
4  6
6  4
4  6
6464

A and B may be two-digit numbers. For example, the inputs "10" and "3" should output this:
1031031031
1        0
3013013013

In order to keep the output relatively small, you do not have to support three or more digit numbers. Also, since inputs are restricted to positive integers, '0' is an invalid input, which you do not have to handle.
Here are some more test cases:
Input: (3, 5)
Output:

353
5 5
3 3
5 5
353

Input: (1, 1)
Output:

1

Input: (4, 4)
Output:

4444
4  4
4  4
4444

Input: (27, 1)
Output:

271271271271271271271271271

Input: (1, 17)
Output:

1
1
7
1
1
7
1
1
7
1
1
7
1
1
7
1
1

Input: (12, 34):
Output:

123412341234
4          1
3          2
2          3
1          4
4          1
3          2
2          3
1          4
4          1
3          2
2          3
1          4
4          1
3          2
2          3
1          4
4          1
3          2
2          3
1          4
4          1
3          2
2          3
1          4
4          1
3          2
2          3
1          4
4          1
3          2
2          3
1          4
432143214321

You may take input and output in any reasonable format, and standard loopholes are banned. Since this is code-golf, the shortest answer in bytes wins!

Related

Must I start the pattern from the top left hand corner clockwise?

@LeakyNun Yes, that is necessary.

If a is 1 is it the left wall or the right wall?

@LeakyNun I'm not sure if it makes any difference. Either way, I added a test case with a = 1

do i have to print the box?

Isn't the first example wrong? (3,5) should be 3 wide and 5 tall

@Brian Yes, you're right. Sorry about that, fixed now.

Is a leading newline ok?

Pyth, 65 51 bytes

juXGhHX@GhHeH@jkQ~hZ{s[+L]0UhQ+R]thQUeQ+L]teQ_UhQ+R]0_UeQ)m*;hQeQ
AQjuXGhHX@GhHeH@jkQ~hZ{s[,L0G,RtGH_,LtHG_,R0H)m*;GH

Try it online!

C#, 301 bytes
I'm sure there is a lot more golfing that can be done here but I'm just happy I got a solution that worked.
I found a bug where the bottom line was in the wrong order, damnit!
a=>b=>{var s=new string[b];int i=4,c=b-2,k=a;var t="";for(;i++<2*(a+b);)t+=t.EndsWith(a+"")?b:a;s[0]=t.Substring(0,a);if(b>2){for(i=0;++i<b-1;)s[i]=(a<2?t.Substring(1,c):t.Substring(2*a+c))[c-i]+(a>1?new string(' ',a-2)+t.Substring(a,c)[i-1]:"");for(;--k>=0;)s[b-1]+=t.Substring(a+c,a)[k];}return s;};

Old version: 280 bytes
a=>b=>{var s=new string[b];int i=4,c=b-2;var t="";for(;i++<2*(a+b);)t+=t.EndsWith(a+"")?b:a;s[0]=t.Substring(0,a);if(b>2){for(i=0;++i<b-1;)s[i]=(a<2?t.Substring(1,c):t.Substring(2*a+c))[c-i]+(a>1?new string(' ',a-2)+t.Substring(a,c)[i-1]:"");s[b-1]=t.Substring(a+c,a);}return s;};

Python 2, 199 bytes
w,h=input()
s=(`w`+`h`)*w*h
r=[s[:w]]+[[" "for i in[0]*w]for j in[0]*(h-2)]+[s[w+h-2:2*w+h-2][::-1]]*(h>1)
for y in range(1,h-1):r[y][w-1],r[y][0]=s[w+y-1],s[w+h+w-2-y]
print"\n".join(map("".join,r))

JavaScript, 213 212 202
c=>a=>{for(a=$=a,c=_=c,l=c*a*2,b=0,s=Array(l+1).join(c+""+a),O=W=s.substr(0,a),W=W.substr(0,a-2).replace(/./g," ");--_;)O+="\n"+s[l-c+_]+W+s[$++];return O+"\n"+[...s.substr(l-a-c+1,a)].reverse().join``}

Surely has room for improvement.
Edit: Saved a byte thanks to TheLethalCoder

I think \${c}${a}`.repeat(l+1)` might save you a byte.

Oh, and isn't' W=W.substr(0,a-2).replace(/./g," ") the same as W=" ".repeat(a-2)? (Does your code actually work for a=1?)

Ruby, 128 bytes
->w,h{s="%d%d"%[w,h]*q=w+h;a=[s[0,w]];(h-2).times{|i|a<<(s[2*q-5-i].ljust(w-1)+s[w+i,1])[-w,w]};puts a,h>1?(s[q-2,w].reverse):p}

Outputs trailing newline if height is 1.
Ideone link: https://ideone.com/96WYHt

You can do [w,h]*"" instead of "%d%d"%[w,h] for 4 bytes, and you don't need the parentheses around s[q-2,w].reverse, but then you'll need a space after the :, so -1 byte.

C, 311 bytes
char s[5];sprintf(s,"%d%d",a, b);int z=strlen(s);int i=0;while(i<a){printf("%c",s[i++%z]);}if(b>2){i=1;while(i<b-1){char r=s[(a+i-1)%z];char l=s[(2*a+2*b-i-4)%z];if(a>1){printf("\n%c%*c",l,a-1,r);}else{printf("\n%c",l);}i++;}}printf("\n");if(b>1){i=0;while(i<a){printf("%c",s[(2*a+b-i-3)%z]);i++;}printf("\n");}

Uses automatically included libraries stdio.h and string.h.

JavaScript (ES6), 171 bytes
(w,h)=>[...Array(h)].map((_,i)=>i?++i<h?(w>1?s[p+p+1-i]+` `.repeat(w-2):``)+s[w+i-2]:[...s.substr(p,w)].reverse().join``:s.slice(0,w),s=`${w}${h}`.repeat(p=w+h-2)).join`\n`

Where \n represents the literal newline character. Creates a repeated digit string, then decides what to concatenate based on which row we're on; top row is just the initial slice of the repeated digit string, bottom row (if any) is a reversed slice from the middle of the string, while intervening rows are built up using characters taken from other parts of the string.

You can use currying by changing (w,h)=> to w=>h=> to save a byte

TSQL, 291 bytes
Golfed:
DECLARE @ INT=5,@2 INT=4

,@t INT,@z varchar(max)SELECT @t=iif(@*@2=1,1,(@+@2)*2-4),@z=left(replicate(concat(@,@2),99),@t)v:PRINT iif(len(@z)=@t,left(@z,@),iif(len(@z)>@,right(@z,1)+isnull(space(@-2)+left(@z,1),''),reverse(@z)))SET @z=iif(len(@z)=@t,stuff(@z,1,@,''),substring(@z,2,abs(len(@z)-2)))IF @<=len(@z)goto v

Ungolfed:
DECLARE @ INT=5,@2 INT=4

,@t INT,@z varchar(max)
SELECT @t=iif(@*@2=1,1,(@+@2)*2-4),@z=left(replicate(concat(@,@2),99),@t)

v:
  PRINT
    iif(len(@z)=@t,left(@z,@),iif(len(@z)>@,right(@z,1)
      +isnull(space(@-2)+left(@z,1),''),reverse(@z)))
  SET @z=iif(len(@z)=@t,stuff(@z,1,@,''),substring(@z,2,abs(len(@z)-2)))
IF @<=len(@z)goto v

Fiddle

Python 3, 155 148 bytes
Golfed off 7 more bytes:
p=print
def f(w,h):
 s=((str(w)+str(h))*w*h)[:2*w+2*h-4or 1];p(s[:w])
 for i in range(h-2):p(['',s[-i-1]][w>1]+' '*(w-2)+s[w+i])
 p(s[1-h:1-h-w:-1])

Substituted 2*w+2*h-4or 1 for max(1,2*w+2*h-4) and
['',s[-i-1]][w>1] for (s[-i-1]if w>1else'').
Prior version:
p=print
def f(w,h):
 s=((str(w)+str(h))*w*h)[:max(1,2*w+2*h-4)];p(s[:w])
 for i in range(h-2):p((s[-i-1]if w>1else'')+' '*(w-2)+s[w+i])
 p(s[1-h:1-h-w:-1])

source: Stack Exchange

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

sort: votes


text:
Is this square symmetrical?
Write a program or function that takes in a 4×4 text grid consisting of exactly 4 A's, 4 B's, 4 C's, and 4 D's, such as:
ACDC
BBCA
BADD
ABCD

The ABCD's may be in any arrangement but there will always be 4 of each. You can assume the input is valid. If desired you can also assume it has a trailing newline and/or that it comes as one line in reading order, e.g. ACDCBBCABADDABCD. You may also replace the characters ABCD with 0123 or 1234 respectively, if desired (but that's all).
Output a truthy value if the text grid has any form of reflective or rotational symmetry. Specifically:

If there is a central horizontal line of symmetry. e.g.
BACD
BACD
BACD \___ bottom mirrors top
BACD /

If there is a central vertical line of symmetry. e.g.
BCCB
DAAD
CAAC
BDDB
  \/___ right mirrors left

If there is a diagonal line of symmetry (in either direction). e.g.
     ___ diagonally mirrored
    /
ABDC
BACD
DCAB
CDBA
    \___ diagonally mirrored

If there is 90° rotational symmetry. e.g.
BDAB
ACCD    same if rotated 90 degrees (or 180 or 270)
DCCA
BADB

If there is 180° rotational symmetry. e.g.
DBCA
BDCA    same if rotated 180 degrees
ACDB
ACBD

(Note that translational symmetry doesn't come into play here.)
Output a falsy value if the grid doesn't have one of the symmetries mentioned above. e.g. the very first example grid.
The shortest code in bytes wins.

Can we take a list of four strings as input?

@MartinEnder Yes, alright.

I just read that and thought "nope" lol

Had you thought to tile the square then you could have taken translational symmetry into account too.

May I take input as an enclosed array? I.e. a single element, whose value is a 4×4 table?

@Adám No. No more input formats. I feel I shouldn't really have allowed Martin's.

@HelkaHomba Can you put up test cases in an easy-to-copy format?

CJam, 16 bytes
{{z_W%_}4*;])e=}

An unnamed block which expects the input as a list of four strings on top of the stack and leaves a 0 (falsy) for asymmetric inputs and a positive integer (truthy) for symmetric inputs.
Test it here. Or run a full test suite.
Explanation
The symmetries of the square are the elements of the dihedral group of order 8 (which are just the 4 rotations of the square and the same 4 rotations of some reflected version of the square). It's not possible to generate this group from repeated application of a single permutation. But two reflections always give some rotation. Hence, the entire group can be generated by alternating between two reflections four times. (We just need to make sure that the two reflections give the 90 degree or 270 degree rotation, not 0 or 180.)
The challenge asks whether the input square is equal to any of the other 7 symmetries. So this answer just generates all of them and then checks whether the input is among the others.
{      e# Run this block 4 times.
  z_   e# Transpose the grid and duplicate it. (This is one type of reflection.)
  W%_  e# Reverse the lines and duplicate it. (This is another type of
       e# reflection. Together they rotate the grid by 90 degrees.)
}4*    e# The last element will be the original grid again.
;      e# Discard one copy of that original grid.
]      e# Wrap all symmetries in a list.
)      e# Pull off the original grid.
e=     e# Count how many times it appears among the other symmetries.

To see how the repeated application of z and W% generates all symmetries, have a look at this "diagram":
     0123
     4567
     89ab
     cdef

     original

 z   048c       W%       37bf
-->  159d  ----------->  26ae
     26ae                159d
     37bf                048c

     diag. refl.         rot. 90 degrees ccw

 z   3210       W%       fedc
-->  7654  ----------->  ba98
     ba98                7654
     fedc                3210

     vert. refl.        rot. 180 degrees

 z   fb73       W%       c840
-->  ea62  ----------->  d951
     d951                ea62
     c840                fb73

     antidiag. refl.     rot. 270 degrees ccw

 z   cdef       W%       0123
-->  89ab  ----------->  4567
     4567                89ab
     0123                cdef

     horiz. refl.        original

Wow, can you explain this? Do you have a built-in for all rotations/flips?

@Adám I'll add a full explanation in a bit, but z is transpose and W% reverses the lines, so I'm just generating all symmetries by repeated application of those.

There is, of course, nothing special about the first value, but sadly the more purist approach of counting whether you get 8 distinct values costs one char more.

Pyth, 11 bytes
<7.u?%Y2CN_

Test suite
This uses Martin's transpose and reverse technique, but with a twist. While other solutions have explicitly generated all 8 symmetries, then counted the number of appearances of the original, this program uses Pyth's .u function.
The .u function is the "Apply until repeat is found". In this case, we alternately transpose and reverse until a repetition happens, then accumulate the results into a list. Then, I remove the last 7 values, so there will only be a value remaining if there were no symmetries, and the first repetition happened after all 8 reflections and repetitions were generated.
Explanation:
<7.u?%Y2CN_
<7.u?%Y2CN_NQ    Implicit variables
                 Q = eval(input())
  .u        Q    Starting with Q, apply the following until a repeat occurs,
                 then accumulate all values into a list.
    ?%Y2         If the iteration number is odd
        CN       Transpose
          _N     Else reverse
<7               Remove the last 7 results

05AB1E, 13 bytes
4Fø€JÂD}\\)¹å

Explanation
Uses the method expertly explained by Martin in his CJam answer.
4F     }       # 4 times do:
  ø€J          # zip and join each
     ÂD        # bifurcate, duplicate
        \\     # delete the top 2 items on the stack
          )    # wrap stack in list
           ¹å  # check if input is in that list

Try it online

Dyalog APL, 37 19 17 bytes
@ngn reduced it by 20 bytes!
8>≢(∪⊢,⌽¨,⍉¨)⍣≡⊂⎕

TryAPL online!

⍉¨ instead of ⌽∘⍉¨ works too.

@ngn Done. Thanks. See you tomorrow.

Perl, 61 60 bytes
Includes +3 for -p0a
Give input square on STDIN, prints 0 for no symmetry, otherwise some positive number
./symmetry.pl
DBCA
BDCA
ACDB
ACBD
^D

symmetry.pl:
#!/usr/bin/perl -p0a
s,.,chop$F[$i++/($j-4?1:4)%4],eg;$\+=$$_++;++$j<8&&redo}{

Brachylog, 38 36 bytes
@eL:1fbeL
(L;?:raL)(.;L$\.;L$/.;Lr.)

Try it online!
This expects a list of strings as input. This prints either true. or false..
Explanation

Main predicate:
@eL    Split each line into a list of chars ; call that list of lists L
:1f    Find all symmetries
b      Remove the first one (the identity)
eL     L is an element of that list of symmetries

Predicate 1: Output is one of the 8 symmetries of the input.
(
    L             L = Input
;             Or
    ?:raL         L = reverse all lines of the input
)
(
    .             Output = L
;             Or
    L$\.          Output = transpose of L
;             Or
    L$/.          Output = antitranspose of L
;             Or
    Lr.           Output = reverse of L
)

TSQL, 229 225 bytes
Be aware TSQL has no build-in for rotating, so this is part the code.
Returning -1 for true 0 for false
Golfed:
DECLARE @1 char(16)='BCCBDAADCAACBDDB'

DECLARE @i INT=0,@ char(16)=0WHILE @i<16SELECT
@=substring(@1,@i*4%16+@i/4+1,1)+@,@i+=1SELECT~count(*)/2FROM (SELECT
left(x,8)a,right(x,4)b,substring(x,9,4)c
FROM(values(@1),(@))x(x))x
WHERE a in(reverse(b+c),b+c,reverse(c+b))

Ungolfed:
DECLARE @1 char(16)='BCCBDAADCAACBDDB'

DECLARE @i INT=0,@ char(16)=0
WHILE @i<16
  SELECT @=substring(@1,@i*4%16+@i/4+1,1)+@,@i+=1
SELECT~count(*)/2
FROM
  (SELECT left(x,8)a,right(x,4)b,substring(x,9,4)c
   FROM(values(@1),(@))x(x))x
WHERE a in(reverse(b+c),b+c,reverse(c+b))

Fiddle

Python 2, 154 146 bytes
Checks if any of the necessary transformations is equivalent to the original using numpy arrays. Input is taken as a list of four strings.
from numpy import*
A=array(map(list,input()))
R=rot90
T=transpose(A)
print any([all(A==Z)for Z in(A[:,::-1],A[::-1],R(A),R(A,2),R(A,3),T,R(T,2))])

Try it online
Taking input as a single string is one char longer, with A=array(list(input())).reshape(4,4). A[:,::-1] is the same as fliplr(A). A[::-1] is the same as flipud(A).

Maybe use map(list,input()) instead of [list(r)for r in input()]

@Cyoce Thanks. Idk how I missed that.

any takes a generator expression, so you can save a few bytes by dropping the outer pair of square brackets.

@TheBikingViking I had already tried that. If you pass a generator, then it returns a generator, making the print statement not work. Try forking my online code and running it that way to see.

Ah, ok. I didn't realise that it would break the print.

Python 3, 99 bytes
def f(x):
 t=x;c=[]
 for i in range(7):*t,=[map(''.join,zip(*t)),t[::-1]][i%2];c+=t,
 return x in c

A function that takes input, via argument, of a list of strings and returns True or False as relevant.
This uses the same approach as @MartinEnder's answer.
How it works
def f(x)                Function with input list of strings x
 t=x;c=[]               Initilaise temporary square t and combination list c
 for i in range(7):...  For i in range [0,6]:
 [...][i%2]              If i is even:
 zip(*t)                  transpose(t)
 *t,=map(''.join,...)     t = t with each line concatenated (such that t is in the same
                          format as x)
                         Else:
 *t,=t[::-1]              t = reverse(t)
 c+=t,                   Append t to c
 return x in c           Return True if x is in c else return False

Try it on Ideone

JavaScript (ES6), 131 bytes
s=>[...`0101010`].map(c=>+c?``+b.reverse():`${b=b.map((s,i)=>s.replace(/./g,(_,j)=>b[j][i]))}`,b=a=s.match(/..../g)).includes(``+a)

17 bytes could be removed if you pass an array of 4 strings directly. I tried bit-twiddling (input in "0123301223011230" format) but that took me 199 bytes:
s=>[...'0101010'].map(c=>r=+c?r<<24&255<<24|r<<8&255<<16|r>>8&255<<8|r>>>24:r&0xc0300c03|r<<6&806093568|r<<12&3075<<16|r<<18&3<<24|r>>6&0xc0300c|r>>12&49200|r>>18&192,r=n=parseInt(s,4)|0).includes(n)

all_licenses: 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/


text:
Right and tfeL truncatable primes
A right-truncatable prime is a prime where every prefix is a prime (in base 10).  A left-truncatable prime is exactly the opposite, where every postfix is a prime (primes that start with 0 aren't allowed).  Both of these sequences are finite (There are only 83 Right-truncatables, while there are 4260 Left-truncatables).
You need to write a program that accepts a single number as input, and produces the nth right-truncatable prime.  However, when the program is read arranged backwards, it should produce the nth left-truncatable prime.
To arrange a program backwards, we split the program into words, then reverse the order of the words.  A word can consist of any number of characters.
For example, if the following was your program:
hello world
1234567890

The following would all be allowed as possible backwards arrangements:
Splitting on each character:
0987654321
dlrow olleh

Splitting on whitespace:
1234567890
world hello

Splitting arbitrarily (pipes added for clarity):
hel|lo w|orld
1|23456|7|8|90

908723456orld
1lo whel

When arranging your program backwards, all whitespace must be considered and reversed, just like any other character.
Forward test inputs:
1:  2
2:  3
21: 379
60: 239933
83: 73939133

Backward test inputs:
1:    2
2:    3
39:   647
187:  29173
4260: 357686312646216567629137

Programs should be able to run in a reasonable amount of time (less than a minute)
This is a code-golf, so the program with the fewest bytes wins!

no.  The atom after lo w is orld\n1.  The newline doesn't end the atom

Ah, thanks. Got it now. Removing my two previous comments to avoid confusion

Jelly, 26 23 bytes
Forward
Ñ¶p9¶7ÆR2ĿV€$ÆPÐf$ÐĿFị@

Try it online!
Words
Ñ ¶ p 9 ¶ 7ÆR2ĿV€$ÆPÐf$ÐĿFị@
Backward
7ÆR2ĿV€$ÆPÐf$ÐĿFị@¶9p¶Ñ

Try it online!
Words
7ÆR2ĿV€$ÆPÐf$ÐĿFị@ ¶ 9 p ¶ Ñ
How it works
All Jelly programs consist of links (Jelly's take on functions), which are separated by linefeeds or pilcrows (¶). The last of them is the main link; it is called automatically when the program is run.
The forward program works as follows.
Ñ                   Helper link. Unused.

p9                  Helper link. Take the Cartesian product with [1, ..., 9].

7ÆR2ĿV€$ÆPÐf$ÐĿFị@  Main link. Argument: n

7ÆR                 Yield all primes up to 7.
             ÐĿ
            $ÐĿ     Combine the two quicklinks to the left into a monadic chain,
                    and call it repeatedly until the results are no longer unique.
                    Return the array of all intermediate results.
       $              Combine the two links to the left into a monadic chain.
   2Ŀ               Call the helper link on line 2.
     Ṿ€                 Eval each array in the product. This casts to string
                        before evaluating, thus concatenating both numbers.
        ÆPÐf        Filter by primality; keep only primes.
               F    Flatten the resulting array.
                ị@  Retrieve the element at index n.

The backward program does almost exactly the same; there are only two differences.

The main link is now Ñ, which simply calls the link below it (wrapping around), i.e., the main link of the forward program.
9p instead of p9 return the reversed Cartesian product.

Python 2, 143 139 bytes
I=1
a={2}
def f(s):
 for d in'123456789':u=d[I:]+s+d*I;z=int(u);z+=z<3;z%91>0<2==pow(2,z,z)>a.add(z)<f(u)
f('')
lambda n:sorted(a)[~-n]
I=0

Consists of five parts:

I=1
A newline
a={2}…[~-n]
A newline
I=0

So reversal is just flipping the value of I.
Explanation
The function f performs a recursive search for either left-truncatable primes (LTPs) or right-truncatable primes (RTPs), depending on the value of the global I. These values get added to the set a. Then, lambda n:sorted(a)[~-n] returns the n-th one.
Let’s define a leaf as either an LTP, an RTP, some non-zero digit + an LTP, or an RTP + some non-zero digit. These are all the values that f could ever want to check for primality.
I designed a Fermat pseudoprime test that works for all leaves:

(63973 is a Carmichael number.)
If this test returns true, then z should be added to the set a and we should recurse on str(z). The responsible bit of code is:

z+=z<3;z%91>0<2==pow(2,z,z)>a.add(z)<f(u)

First, we wish to deal with the case z == 2. We do so by simply dodging it here and hard-coding 2 when we initially define a! (EDIT: And nothing harmful happens if we also catch z == 1.) So we can assume that z ≥ 3 now.
I’ve translated some “and”s into a short-circuiting chained comparison: the first three comparisons have to succeed before a.add(z) and f(u) are ever evaluated. Here are all their roles:

z%91>0 encodes our first condition. (63973 is divisible by 91, which is not a leaf itself, so that’s how we recognize it.)
0<2 is always true, but chaining is shorter than and.
2==pow(2,z,z) encodes our second condition.
pow(2,z,z)>a.add(z) triggers the addition, and is always true, since set.add returns None, and integers are always greater than None.
a.add(z)<f(u) triggers the recursion. Its truth value is unimportant.

Acknowledgements

Dennis saved four bytes (u=[d+s,s+d][I] → u=d[I:]+s+d*I; z==2 → z<3 and the mod 91 trick). Thanks!


text:
Show off your tree analysing toolbox
As a programmer or computer scientist one might encounter quite a lot of trees - of course not the woody growing-in-the-wrong-direction kind, but the nice, pure mathematical kind:
  *<- root (also a node)
 /|\<- edge
* * *<- inner node
|  / \
* *   *<- leaf (also a node)
  |
  *

Naturally over time we all have put together our own small handy toolbox to analyse such trees as we encounter them, right?
Now is the time to show it off!

Task
The toolbox must include the following functions:

size: The number of nodes in the tree.
depth: The number of edges on the longest path from the root to any leaf.
breadth: The number of leaves.
degree: The maximum number of child nodes for any node.

You have to submit a program or function for each of the tools, however they might share subroutines (e.g. parsing) which then have to be submitted only once. Note that those subroutines need to be full programs or functions too.

Input Format
The trees can be given in any reasonable format capturing the structure, e.g. the tree
  *
 / \
*   *

could be represented through parentheses (()()), lists of lists [[],[]], or data structures with a constructor T[T[],T[]].
However not through linearisation [2,0,0] or a format like (size, depth, breath, degree, whatever-else-is-needed-to-make-this-format-unique-for-every-tree).
Generally speaking, your tree format should not contain numbers.
Output Format
A natural number for each of the properties described above.
Scoring
Lowest code in bytes for the 4 functions in every language wins, thus I will not accept an answer.
Feel free to provide additional tree tools like fold, isBinaryTree, preLinearise, postLinearize, or whatever you like. Of course those don't have to be included in the byte count.
Examples
First the tree is given in the sample formats from above, then the results of the functions as (size, depth, breadth, degree).
()
[]
T[]
(1,0,1,0)

(()())
[[],[]]
T[T[],T[]]
(3,1,2,2)

((())()((())()))
[[[]],[],[[[]],[]]]
T[T[T[]],T[],T[T[T[]],T[]]]
(8,3,4,3)

((()())((())()((())()))(()())(()))
[[[],[]],[[[]],[],[[[]],[]]],[[],[]],[[]]]
T[T[T[],T[]],T[T[T[]],T[],T[T[T[]],T[]]],T[T[],T[]],T[T[]]]
(17,4,9,4)

((((((((()))))))))
[[[[[[[[[]]]]]]]]]
T[T[T[T[T[T[T[T[T[]]]]]]]]]
(9,8,1,1)

(((((((()()))((()()))))((((()()))((()()))))))((((((()()))((()()))))((((()()))((()())))))))
[[[[[[[[],[]]],[[[],[]]]]],[[[[[],[]]],[[[],[]]]]]]],[[[[[[[],[]]],[[[],[]]]]],[[[[[],[]]],[[[],[]]]]]]]]
T[T[T[T[T[T[T[T[],T[]]],T[T[T[],T[]]]]],T[T[T[T[T[],T[]]],T[T[T[],T[]]]]]]],T[T[T[T[T[T[T[],T[]]],T[T[T[],T[]]]]],T[T[T[T[T[],T[]]],T[T[T[],T[]]]]]]]]
(45,7,16,2)

What counts as a subroutine here? Does it need to be a complete function, and to count the bytes for calling it, or can it just be a snippet of code that is inserted into more than one task's solution?

A subroutine has to be a complete function or program. I suspect the "snippet of code" option could get out of hand easily.

Yes I can imagine - that's the main reason I wanted to get it clarified as early as possible :)

It's worth editing to make the exact requirement clear before answers start coming in.

Ruby, 122 110 bytes
f=->s{->t{t.to_s.scan(s).size}}
s=f[?[]
d=->t{[-1,*t.map(&d)].max+1}
b=f['[]']
g=->t{([t.size]+t.map(&g)).max}

Inspired by Neil's JavaScript solution. d and g are just translations from his JS to Ruby. For s and b I'm using string conversion tricks.
Shaved a few bytes off of s and b by adding the helper f, and a few more byte off of d and g thanks to Jordan.

Welcome to PPCG! Nice first answer!

In s you can use count(?[) instead of scan.... In d you can save a byte with [-1,*t.map(&d)], and the same in g. And in g you can use size instead of length.

Nice! I also found a way to save a few bytes on s and b with some higher-level function magic.

Don't forget you can replace ([t.length]+t.map(&g)).max with [t.size,*t.map(&g)].max for 3 bytes.

Python, 136 bytes
f=lambda z,c:lambda t:eval(t,{'T':lambda*a:a and eval(z)or c})
s,d,b,g=map(f,['sum(a)+1','max(a)+1','sum(a)','max(len(a),*a)'],[1,0]*2)

The input format is the 'T[]' format but with parens instead of brackets and passed as a string. It's the longest submission so far, but I thought the approach is pretty cute.

tinylisp, 248 bytes
(d X(q((m n)(i(l m n)n m))))(d F(q(()g(c(q(T))(c(c(q i)(c(q T)g))())))))(d S(F(s(S(h T))(s 0(S(t T))))1))(d H(F(X(s 1(s 0(H(h T))))(H(t T)))0))(d B(F(s(B(h T))(s 0(i(t T)(B(t T))0)))1))(d C(F(s 1(s 0(C(t T))))0))(d D(F(X(C T)(X(D(h T))(D(t T))))0))

Fun fact: 49% of that program is parentheses.
tinylisp is a minimalistic version of Lisp, containing only 10 built-in functions and macros. Because Lisp is awesome, it is nonetheless very powerful, and well-suited to manipulating abstract data structures like trees.
The program defines functions S, H (for "height"), B, and D, as well as a max function X and a number-of-children function C. It uses the (()()) form of trees, with the added requirement that each tree must be quoted to be treated as data rather than code: (q (()())). Example run:
tl> (d tree (q ((())()((())()))))
tree
tl> (S tree)
8
tl> (H tree)
3
tl> (B tree)
4
tl> (D tree)
3

Here's an ungolfed version, with a couple extra utility functions defined to make things clearer. For reference, the built-ins used are define, quote, if, less than, cons, subtract, head, and tail. (Yes, addition has to be implemented from subtraction.)
(d lambda (q (() args args)))

(d add
 (lambda (a b)
  (s a (s 0 b))))

(d max
 (lambda (a b)
  (i (l a b) b a)))

(d size
 (lambda (tree)
  (i tree
   (add (size (h tree)) (size (t tree)))
   1)))

(d depth
 (lambda (tree)
  (i tree
   (max (add 1 (depth (h tree))) (depth (t tree)))
   0)))

(d breadth
 (lambda (tree)
  (i tree
   (add
    (breadth (h tree))
    (i (t tree)
     (breadth (t tree))
     0))
   1)))

(d children
 (lambda (tree)
  (i tree
   (add 1 (children (t tree)))
   0)))

(d degree
 (lambda (tree)
  (i tree
   (max (children tree) (max (degree (h tree)) (degree (t tree))))
   0))))

This is pretty horrible Lisp style, since there's no tail recursion, but hey--it's code golf. ;^)

JavaScript (ES6), 131 bytes
s=a=>a.reduce((r,e)=>r+s(e),1)
d=a=>Math.max(...a.map(d),-1)+1
b=a=>a.reduce((r,e)=>r+b(e),+!a[0])
g=a=>Math.max(...a.map(g),a.length)

Since all the functions are recursive, I've given them one letter names to save bytes: size, depth, breadth and degree. Takes input using the [,] format.

Perl 5 - 130 bytes
sub z{$_[0]=~y/<//c}
sub d{$_=$_[0];{s/><//&&redo}-1+z$_}
sub b{()=$_[0]=~/<>/g}
sub g{(grep{$_[0]=~/<(<(?1)*>){$_}>/}0..z$_)[-1]}

These take input as a string using angle brackets (e.g. <<><>>). z (size) and b (breadth) count the substrings for either all nodes or leafs, d (depth) collapses adjacent nodes until there's no branching then gets the size, and g (degree) uses a recursive regex to test for the presence of nodes of each degree up to the size then returns the largest found.

C#, 380, 357 bytes
I've just noticed I forgot to remove some of my test code, so 23 bytes shaved off...
This is my first submission on PPCG and I'm not sure if the format is entirely correct especially because I'm using C#, but here are my four functions:
int d(string t){int l=-1,p=0;t.Max(m=>p=p<(l+=m=='('?1:-1)?l:p);return p;}
int s(string t){return t.Count(c=>c=='(');}
int f(string t){int q=0,w=d(t)+2;int[]l=new int[w],i=new int[w];t.Max(m=>l[q]=m=='('?l[q++]+1:(0*(i[q]=l[q]>i[q]?l[q]:i[q])*(q--)));return i.Max();}
int b(string t){var f='(';int l=0;t.Max(m=>l+=(f=='('&m==')')?(f=m)*0+1:(f=m)*0);return l;}

d: Depth
s: Size:
f: Degree
b: Breadth
The functions use () as input
I'm using LINQ's Max function to iterate through the items in the string array. I'm not using the functionality of Max, I only use it because it's the shortest iterative function; I could just as well have used Min. There's no recursion and all is done in linear time.
A slightly more readable version of my code, but the LINQ is still a bit cryptic:
    /*Depth: Increment counter on open bracket and
     decrement on closed bracket;
     return highest number reached*/
    int d(string t)
    {
        int l = -1, p = 0;
        t.Max(m => p = p < (l += m == '(' ? 1 : -1) ? l : p);
        return p;
    }

    int s(string t)//Size: Count the number of open brackets
    {
        return t.Count(c => c == '(');
    }

    int f(string t)//Degree, this one took me hours to figure out
    {
        int q = 0, w = d(t) + 2;
        int[] l = new int[w], i = new int[w];
        t.Max(m => l[q] = m == '(' ? l[q++] + 1 : (0 * (i[q] = l[q] > i[q] ? l[q] : i[q]) * (q--)));
        return i.Max();
    }

    int b(string t)//Breadth
    {
        var f = '(';
        int l = 0;
        t.Max(m => l += (f == '(' & m == ')') ? (f = m) * 0 + 1 : (f = m) * 0);
        return l;
    }

Mathematica, 77 bytes
s=LeafCount
d=Depth@#-2&
b=Length@Level[#,{-2}]&
g=Max[Length@#,##&@@#]&//@#&

Take any Mathematica expression as input.

Standard ML, 149 bytes
val m=Int.max
val% =foldl
fun f?(T%)= ?(map(f?)%)
val s=f(%op+1)
val d=f(fn t=>1+ %m~1t)
val b=f(fn[]=>1|t=> %op+0t)
val g=f(fn t=>m(length t,%m 0t))

Try it on Tutorialspoint. Uses the constructor notation (e.g. T[T[],T[]]) with the following data structure declaration: datatype tree = T of tree list
Ungolfed:
fun fold f (T xs) = f (map (fold f) xs)

val size    = fold (foldl op+ 1)
val depth   = fold (fn t => 1 + foldl Int.max ~1 t)
val breadth = fold (fn nil => 1 | t => foldl op+ 0 t)
val degree  = fold (fn t => Int.max(length t, foldl Int.max 0 t))


text:
Quick Golf: The Gold Leader
Challenge
Using data from the API here, output the names of the three countries with the most Olympic gold medals at the 2016 Rio Olympic Games (i.e. the first element of the returned list).
For example, at the time of posting (18:23 UTC+1, Monday, 15th August), the USA, the UK and China have the most gold medals, so the output would be:
United States
Great Britain
China

The country names must be separated by newlines and you may have a leading or trailing newlines.
Once the Olympics have finished, the program does not have to work as expected.
URL shorteners are disallowed but JSON parsing libraries are allowed.
This is code golf, so the shortest code in bytes wins.
I'm going to keep trying to get an Olympics themed challenge in here
Leaderboard

var QUESTION_ID=89919,OVERRIDE_USER=30525;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

Would you say this is a... mini-golf?

@Deusovi Ba-dum crash

I really want somebody to post a Java solution so that I can see if my C solution beats it…

@Dave You've got a Java solution now :D

@βετѧΛєҫαγ dang! beats mine by 45 bytes. Thought I had a chance there…

"The UK ... so output ... Great Britain"

@trichoplax In fairness team GB should probably be called team UK, but even then there's a bunch of others included too. I guess "Team UK+BOT+CD-CI-BVI-B" was judged to be too confusing (yes I just looked that up on Wikipedia).

@Dave Challenge accepted

Does the output have to be exactly as shown there, or can it be akin to "United States", Great Britain", "China" (with newlines, but with the quotation marks / comma)

@DylanMeeus It has to be exactly as shown

@βετѧΛєҫαγ Cheers :-)

@Dave NI Athletes can choose to either represent Team GB or Team Ireland. If NI Athletes were required to join Team GB, then it would be Team UK.

bash + w3m + grep + cut, 65 59 58 54 bytes
w3m medalbot.com/api/v1/medals|grep -m3 m|cut -d\" -f4

6 bytes less thanks to @Joe's suggestions.
1 byte less thanks to @YOU.
4 bytes less thanks to @manatwork's suggestion that the medalbot API seems to work without www. subdomain too.

Change cut -d '"' to cut -d\" to save two bytes. If you use w3m instead of curl -s you can save 4 more.

you can change _n to m

@YOU: Not really because that way it'll return more lines than expected, i.e. "id": "germany", id": "colombia" etc.

if they cant be 1 to 3rd it will be fine, you have -m3 guard.

@YOU: I guess this is true for the current score and it seems that it will be OK for the 2016 Olympics (except if they change United States to United States of America :P). I'll change it.

C (+sockets), 433 429 280 276 270 259 bytes
#define H"medalbot.com"
char**p,B[999],*b=B;main(f){connect(f=socket(2,1,getaddrinfo("www."H,"80",0,&p)),p[4],16);send(f,"GET http://"H"/api/v1/medals HTTP/1.1\r\nHost:"H"\r\n\r\n",69);read(f,b,998);for(f=3;f--;puts(p))b=strchr(p=strstr(++b,"_n")+9,34),*b=0;}

So it turns out that C isn't great at downloading resources from the internet and parsing them as JSON. Who knew?
This code is (naturally) super lax with error checking, so I guess if medalbot.com wanted to send malicious data they'd be able to trigger buffer overflows, etc. Also the latest code expects certain values for the constants (e.g. AF_INET = 2) which will probably be the case everywhere, but it's not guaranteed.
Here's the original code which isn't so fragile (but still isn't very robust or safe):
#include<netdb.h>
#define H"medalbot.com"
char*b,*B,d[999];struct addrinfo*p,h;main(f){h.ai_socktype=SOCK_STREAM;getaddrinfo("www."H,"80",&h,&p);f=socket(p->ai_family,p->ai_socktype,p->ai_protocol);connect(f,p->ai_addr,p->ai_addrlen);send(f,"GET http://"H"/api/v1/medals HTTP/1.1\r\nHost: "H":80\r\nConnection: close\r\n\r\n",92,0);recv(f,d,998,0);for(f=0,b=d;f<3;++f)B=strstr(b,"_n")+9,b=strchr(B,'}'),*strchr(B,'"')=0,puts(B);}

Breakdown:
                            // No imports needed whatsoever!
#define H"medalbot.com"     // Re-use the host in multiple places
char**p,                    // This is actually a "struct addrinfo*"
    B[999],                 // The download buffer (global to init with 0)
    *b=B;                   // A mutable pointer to the buffer

main(f){
    // Hope for the best: try the first suggested address with no fallback:
    // (medalbot.com runs on Heroku which has dynamic IPs, so we must look up the
    // IP each time using getaddrinfo)
    f=socket(2,1,getaddrinfo("www."H,"80",0,&p));
                            // 2 = AF_INET
                            // 1 = SOCK_STREAM
                            //     (may not match getaddrinfo, but works anyway)
                            // 0 = IP protocol (getaddrinfo returns 0 on success)
    connect(f,p[4],16);     // struct addrinfo contains a "struct sockaddr" pointer
                            // which is aligned at 32 bytes (4*8)

    // Send the HTTP request (not quite standard, but works. 69 bytes long)
    send(f,"GET http://"H"/api/v1/medals HTTP/1.1\r\nHost:"H"\r\n\r\n",69);
    // (omit flags arg in send and hope 0 will be assumed)

    read(f,b,998);          // Get first 998 bytes of response; same as recv(...,0)

    // Loop through the top 3 & print country names:
    // (p is re-used as a char* now)
    for(f=3;f--;puts(p))        // Loop and print:
        p=strstr(++b,"_n")+9,   //  Find "country_name": "
        b=strchr(p,34),         //  Jump to closing "
        *b=0;                   //  Set the closing " to \0
}

This isn't very nice for the server since we don't send Connection: close\r\n as part of the HTTP request. It also omits the Accept header since medalbot.com doesn't seem to be using compression in any case, and misses the space after Host: (again, the server seems to be OK with this). It doesn't seem as though anything else can be removed though.

Once the olympics end, the most likely behaviour for this program is to segfault trying to read memory location 9. Unless an evil hacker takes over the domain, in which case the most likely behaviour is for it to set some byte to 0 in the address info structs, which probably isn't too dangerous actually. But who can tell with these evil hackers?

Yeah, it's a pest with those hackers. Good thing we're on a website on which hackers of any kind are unlikely to ever turn up...

That was quite the leap!

@NonlinearFruit yeah it's amazing how many characters can be saved when you throw caution to the wind and use implementation-defined numbers directly in the code! This has become an exercise into "what is the craziest, most dangerous, most likely to break — but currently functional — way to download text in C?"

Let's just hope that little Bobby Tables doesn't have any relatives competing this year.

Readability is also one of the first casualties of cod golf. . .

PowerShell v4+, 88 69 bytes
(ConvertFrom-Json(iwr medalbot.com/api/v1/medals))[0..2].country_name

Uses iwr (the alias for Invoke-WebRequest) to grab the API.  We feed that as the input parameter to the ConvertFrom-Json built-in that pulls the JSON text into a custom object array. We encapsulate that object array in parens, take the first three elements [0..2], and take the .country_name of each thereof.
Requires at least v4+ for the multiple-object-properties, else we'd need to use something like |Select "country_name" instead. Requires at least v3+ for the ConvertFrom-Json built-in.
PS C:\Tools\Scripts\golfing> .\olympics-gold-leader.ps1
United States
Great Britain
China

You can drop http://www. and PS doesn't mind about http:// or the site about www.. My PS (5.1.14393) also doesn't even seem to care about the .content.

@NickT Thanks for the golfs. I didn't realize that ConvertFrom-Json didn't explicitly need only the .content portion of the web request, but it works on my setup as well.

R, 98, 112, 108 bytes
golfed 4 thanks to @miff
a=jsonlite::fromJSON(readLines("http://www.medalbot.com/api/v1/medals"))
cat(a$c[order(-a$g)[1:3]],sep="\n")

First line imports data using a JSON library. Second line grabs the relevant country names. It sorts the countries by gold medals in increasing order, reverses the indices, and takes the first 3, printing them.

I think that you can replace rev(order(a$g)) with order(-a$g) to save 4 bytes

JavaScript (ES6), 122 Bytes
fetch`http://www.medalbot.com/api/v1/medals`.then(a=>a.json()).then(b=>alert(b.slice(0,3).map(c=>c.country_name).join`\n`))

Due to a browser safety issue, this code must be run on medalbot.com. It does not however take advantage of that and could potentially be run elsewhere. Also note that I inserted the \n character, but am only counting is as one, because I could replace it with one
Node.js (ES6), 173 Bytes
require("http").get("http://www.medalbot.com/api/v1/medals",s=>s.on("data",d=>t+=d,t="").on("end",q=>console.log(JSON.parse(t).slice(0,3).map(a=>a.country_name).join`\n`)))

This would have been so much shorter if the API returned the data all in one stretch, but since it returns in two sections, I must concatenate the parts and combine them, and then parse them.
Node.js (ES6) + Request, 138 Bytes
require("request")("http://www.medalbot.com/api/v1/medals",(e,r,b)=>console.log(JSON.parse(b).slice(0,3).map(a=>a.country_name).join`\n`))

Better, but still not as good as the browser version. Thanks fetch API! Request is a popular HTTP client library used to simplify requests, and you can see that take effect here.

Which of these works in any browser? Can you put the shortest of those at the top of your answer (for the leaderboard)

The top one of these works in most modern browsers, and is also the shortest. The other two are in Node.js a way of writing JavaScript on the server (plus other things).

@βετѧΛєҫαγ Take note that it doesn't work in any version of IE or Safari

I see, I was getting hung up on the CORS problem

bash + w3m + jq, 83 59 bytes
w3m medalbot.com/api/v1/medals|jq -r '.[:3][].country_name'

Thanks to Jordan for three bytes.
Thanks to YOU for 24 more bytes! Turns out the data is sorted. Wow. :D

You can omit .| and index the result of sort_by directly, and you can save another byte by using [:3][] instead of [0,1,2]. All together: sort_by(-.gold_count)[:3][].country_name.

w3m medalbot.com/api/v1/medals|jq -r '.[:3][].country_name'

Java 8, 261 258 bytes
This uses a lambda to save a couple bytes and the net library to get the webpage. Other than that is just Java.
()->{try{for(int i=0;i<3;System.out.println(new java.util.Scanner(new java.net.URL("http://www.medalbot.com/api/v1/medals").openConnection().getInputStream()).useDelimiter("\\A").next().split("\n")[i++*9+3].replaceAll(".* \"|\",","")));}catch(Exception e){}}

Here is my (old) POJO for testing (and golfing):
class QuickGolf {
  static void f(h x){x.g();}
  static interface h{ void g(); }
  static void main(String[] args){
    f(
      ()->{try{for(int i=0;i<3;i++){System.out.println(new java.util.Scanner(new java.net.URL("http://www.medalbot.com/api/v1/medals").openConnection().getInputStream()).useDelimiter("\\A").next().split("\n")[i*9+3].substring(21).replace("\",",""));}}catch(Exception e){}}
    );
  }
}

Update

-3 [16-08-17] Move print statement into for loop
-5 [16-08-16] Improved regex replace
-9 [16-08-16] Removed java.net import

Eep. I need to save some bytes…

I'm catching up! Now just 15 bytes behind!

Well, I was ahead for a few hours at least. It works against me, but you can probably save some more bytes by having the loop count down from 3 instead of up.

@Dave I tried having the boolean break condition just bei but Java doesn't convert boolean to int or visa versa, if that was what you were thinking. Also you had me pretty nervous with that last edit.

JavaScript + jQuery, 114 100 bytes
$.get("www.medalbot.com/api/v1/medals",a=>alert(a[0][c='country_name']+'\n'+a[1][c]+'\n'+a[2][c]))

For the reason of Cross Origin Requests, this must be run from the medalbot.com domain (with jQuery).
History

-14 bytes thanks to @YetiCGN
-2 bytes thanks to Yay295

Or run chrome without web security {    chrome.exe --disable-web-security    }

save 2 bytes $.get("www.medalbot.com/api/v1/medals",a=>alert(a[0][c='country_name']+'\n'+a[1][c]+'\n'+a[2][c]))

Python 3, 202, 164 bytes.
Python 3 does not do short url/json handling. :/
Didn't realize the API already sorts by gold count
from urllib.request import*
import json
print('\n'.join(x['country_name']for x in json.loads(urlopen('http://www.medalbot.com/api/v1/medals').read().decode())[:3]))

MATL, 67 bytes
'http://www.medalbot.com/api/v1/medals'Xi'(?<="c.+e": ")[^"]+'XX3:)

This doesn't work online because function Xi (urlread) is disallowed.
Example run:
>> matl
 > 'http://www.medalbot.com/api/v1/medals'Xi'(?<="c.+e": ")[^"]+'XX3:)
 >
United States
Great Britain
China

Explanation
This reads the contents as a string and then applies the regex '(?<="c.+e": ")[^"]+' to extract country names. The regex uses look-behind with "c.+e" instead of "country_name" to reduce code length.
'http://www.medalbot.com/api/v1/medals'   % Push string representing the URL
Xi                                        % Read URL contents as a string
'(?<="c.+e": ")[^"]+'                     % String for regex matching
XX                                        % Apply regex
3:)                                       % Get first 3 results

Python 2, 120 113 bytes
from urllib import*
for x in list(urlopen("http://www.medalbot.com/api/v1/medals"))[3:26:9]:
    print x[21:-4]

Thanks @Nick T and @Value Ink

from urllib import* and using just urlopen later saves 1 byte. Also, you should be able to take the print statement and put it right after the colon, saving you from the indentation.

If you feed the urlopen object to list(), does that do the same thing as .readlines()?

PHP, 205 139 124 116 111 109 bytes
I just wanted to use the new spaceship operator for PHP 7 once (EDIT: It's superfluous, as sorting isn't required):
<?$d=json_decode(file_get_contents('http://www.medalbot.com/api/v1/medals'),1);usort($d,function($a,$b){$g='gold_count';return$b[$g]<=>$a[$g];});$c='country_name';foreach([0,1,2]as$i){echo$d[$i][$c]."\n";}

If we omit the unneccesary sorting step and assume the API delivers the data already sorted by gold_count descending (as it would seem), we can shorten this further:
while($i<3)echo json_decode(file_get_contents('http://medalbot.com/api/v1/medals'))[+$i++]->country_name."
";

Note: The line break within the string is intentional to save a byte from \n
History

Ommitted some quotes and braces that will throw notice's, removed the $c variable for country_name index. Thanks to @manatwork for these tipps to save even more characters.
Thanks to @jeroen for pointing out the shorter while loop, also switched to object access to go from 124 to 116
Saved 5 more bytes by calling the API within the loop. Granted, it takes longer and clobbers the API, but it's Code Golf. Needs PHP 5.5 to work because of array dereferencing.
Saved 2 more bytes by removing the short open tag, as per this meta answer

Thanks! I just saw all the other entries sorting and thought I missed something.

Why are you putting "country_name" in a variable? And anyway, as error_reporting's default value not displays notices, you can omit the double quotes. And the medalbot API seems to work without www. subdomain too. Then you not need the braces around echo.

Thanks a bunch! Well, it was late ... The $c variable is a leftover from a previous optimization that I threw away when I switched to the for loop. I guess clean coding (notice-free) is too deeply ingrained still so I don't even consider these optimizations you pointed out. So, thanks again!

replacing the foreach with the following forloop: for(;$i<3;)echo$d[+$i++][country_name]." " reduces it with 5 bytes. Last space being an enter offcourse. Or just as a while loop while($i<3)

Ruby, 97 79 + -rnet/http (11) = 90 bytes
Uses a modification of the regex pattern from Luis Mendo's MATL answer, further optimized by @Jordan, since Ruby doesn't support quantifiers in lookbehinds.
-18 bytes from @Jordan.
puts Net::HTTP.get("www.medalbot.com","/api/v1/medals").scan(/"c.+"(.+)"/)[0,3]

You can omit .map(&:last) entirely for 12 bytes, and omit the leading / in /api for one more.

Also, a shorter regex that seems to work fine: /"cou.+"(.+)"/

Or: /y_.+"(.+)"/.

@Jordan omitting the leading / causes errors on my Ruby version. Or it might be the network I'm on? Whatever. I went with a slightly different regex than the one you suggested but same length.

Interesting. FWIW I'm using 2.3.1.

Mathematica 96 66 bytes
@alephalpha found a way to work directly from the file (without saving it), thereby saving 30 bytes!
Import["http://www.medalbot.com/api/v1/medals","RawJSON"][[;;3,2]]

Import imports the file as a Raw JSON file.
[[;;3,2]]takes rows 1-3, second entry (country name).

Import["http://www.medalbot.com/api/v1/medals","RawJSON"][[;;3,2]]

PowerShell, 60
(iwr medalbot.com/api/v1/medals|convertfrom-json)[0..2]|% c*

Same basic idea as TimmyD (didn't see their answer before I posted), but quite a bit shorter :-)

How the devil does that |% c* parsing work? I mean, it does, I just tried it, but that's some weird syntax (it even highlights in my ISE as an error).

@TimmyD: ForEach-Object has a parameter set that expands a single property, or calls a method with arguments: ForEach-Object [-MemberName] <String>. The -MemberName parameter supports wildcards, so in this case it expands the only member matching that wildcard: country_name. Saves quite a few characters, too ;-)

BASH + w3m + core utils, 70 bytes
w3m www.medalbot.com/api/v1/medals|grep -m3 tr|cut -f6- -d\ |tr -d \",

Looks like the output comes sorted already. Just need to throw out all of the extra text.

CJam (57 bytes)
"http://www.medalbot.com/api/v1/medals"gN/3>9%3<{'"/3=N}%

Online demo not available because it fetches content from the web. This cheats by not actually parsing JSON, but assuming that the structure won't change. (But then so do most of the existing answers, in different ways).

Java 8 386 384 459 bytes
2 bytes saved from @Easterly Irk
My first code golf submission so I'm sure there's a way to save plenty of bytes, but oh well :)
It uses Gson to read the JSON
Requires:
import java.util.*;
import java.io.*;

Golfed code:
void p()throws Exception{List a=new com.google.gson.Gson().fromJson(new InputStreamReader((InputStream)((new java.net.URL("http://www.medalbot.com/api/v1/medals").openConnection())).getContent()),new com.google.gson.reflect.TypeToken<List>(){}.getType());a.sort((b,c)->c.gold_count.compareTo(b.gold_count));for(int i=0;i<3;)System.out.println(a.get(i++).country_name);}class A{String country_name;Integer gold_count;}

Ungolfed Code:
void p() throws Exception {
    List a = new com.google.gson.Gson().fromJson(new InputStreamReader((InputStream)((new java.net.URL("http://www.medalbot.com/api/v1/medals").openConnection())).getContent()),new com.google.gson.reflect.TypeToken<List>(){}.getType());
    a.sort((b, c) -> c.gold_count.compareTo(b.gold_count));
    for(int i=0; i<3;)
        System.out.println(a.get(i++).country_name);
}

class A {
    String country_name;
    Integer gold_count;
}

Can you remove the space in "g = new Gson()"?

Wait, doesn't this need some imports to compile?

import statements need to be added to byte count?

how do you calculate imports?

Don't know what the exact rules are for Java, since I haven't posted any here before, but the usual rule is that you have to count everything which is needed to make the code valid (and from quickly looking up the Java hints page I can see various suggestions about how to minimise the import code, so I guess it must be counted). But then again, I'm also trying to get my C answer to win against Java in this question, so I'm pretty biased :D

You have to count import java.net.*;import java . . . since this requires those libraries in order to run.

fixed it...those damn imports added in almost 80 bytes :/

Python 2, 117 bytes
from requests import *
for x in get('http://www.medalbot.com/api/v1/medals').json()[:3]:
    print(x['country_name'])

Welcome to PPCG! You can save a few bytes by removing the space between import and *, and by moving the print to directly after the colon on line 2. We generally use #s instead of ** before and after for our headers.

We typically require submitters to include any third-party libraries required in the answer header. Since requests isn't a standard library module, this answer's language should be "Python 2 + requests".

R, 97 95 bytes
t=rjson::fromJSON(f="http://www.medalbot.com/api/v1/medals")
for(i in 1:3)cat(t[[c(i,2)]],"\n")

Little improvement over user5957401's answer, no sorting required, and shorter library name.
Also my first attempt at golfing ;)

You can, as in every language, omit the "www." part of the domain and save 4 more bytes if your library follows the ensuing redirect.

Clojure, 122 bytes
(fn[](mapv #(println(%"country_name"))(take 3(read-string(.replace(slurp"http://www.medalbot.com/api/v1/medals")":""")))))

No JSON library used :). Reads string from the URL, replaces colons with empty string and evals the string which results into Clojure map. Takes first 3 elements and maps eagerly function which prints country_name property of each elements.

Kotlin (Script), 125 121 119 bytes
java.net.URL("http://medalbot.com/api/v1/medals").readText().lines().filter{'m' in it}.take(3).map{println(it.split('"')[3])}

Runnable with kotlinc -script <filename> or through IDEA as *.kts file.
now, if we make a VERY big assumption about the format, including numbers of lines, we can trim it to:
java.net.URL("http://medalbot.com/api/v1/medals").readText().lines().slice(setOf(3,12,21)).map{println(it.split('"')[3])}

or even
java.net.URL("http://medalbot.com/api/v1/medals").readText().lines().slice(3..21 step 9).map{println(it.split('"')[3])}

Thanks to folks at Kotlin slack team for helping me trim a couple dozens of bytes!

3 symbols shorter than Clojure and JS? I'll take that.

Javascript 167 bytes
x=new XMLHttpRequest();x.open("GET","http://www.medalbot.com/api/v1/medals",false);x.send()
i=-3;while(i++)console.log(JSON.parse(x.responseText)[i+2]["country_name"])


text:
Is it a wordinian?
What is the shortest way to see if an input is a wordinian using any programming language?
A wordinian is a word that contains words of length 1 to the original word's length. For example,

bin
'I' is a word
  'in' is a word
  'bin' is a word

Or,

stage
'a' is a word
  'ta' is a word (yes it is)
  'age' is a word
  'stag' is a word
  'stage' is a word

Input
Your code should take a word and a dictionary as inputs, in any reasonable format.
Output
The output should be a value to indicate true or false, to tell us if the word is a wordinian.
For more info on wordinians click here.
Here is a list of words that I will be using as inputs and subwords. Also, in response to @xnor, it has to contain subwords of each length, not a chain of subwords. Note that only one word will be used as an input.

@FryAmTheEggman I can't put a whole dictionary on here. What if it's any word that exists?

I'd recommend passing in a dictionary as input.  That way, its easy to come up with test cases (as you can make your own small dictionary)

Does it just have to contain subwords of each length, or do they have to be a chain where each subword adds one letter to the previous?

@FryAmTheEggman I edited my question to supply a list of all words.

@xnor I updated the question to answer your question.

@trichoplax Ok thanks. Also, will something like this list work?

@trichoplax Actually, I think this list should work: https://raw.githubusercontent.com/dwyl/english-words/master/words.txt
I updated my question to include the new list.

@trichoplax The new list contains about 479k words. I think that should be enough. How can this question get reopened though?

@trichoplax Ok thanks for all your help!

@JacquesMarais This challenge is clear to me, but I'd definitely include some test cases!

@trichoplax Ok I use the ENABLE2K list now, thanks. So you mean a to take the whole list as an input and find the wordinians, instead of taking one word as an input?

@JacquesMarais the concept is to take a word and a dictionary, and return true if the word is a wordinian (according to the dictionary)

@NathanMerrill I don't think I understand you correctly now. So you use one word and check through the dictionary to see if the word is a wordinian?

Yep.  Aka, if your dictionary was ["bin","i"], then "bin" wouldn't be a wordinian because "in" isn't in the dictionary.  The function call would be func("bin",["bin","i"])

Oh, ok, I see @NathanMerrill. Thanks, I'll use that instead. But how can implement that into the question?

I've edited to suggest how you might word it, rather than trying to discuss it in comments too much. This is just a suggestion so feel free to reverse the edit or amend it to suit your intention.

What do you mean by "contains"? From the examples it seems to be "contains a substring" rather than "contains a subsequence", but it would be good to make that explicit.

Can I assume the length of the word and the dictionary (and all entries in the dictionary) have length of at least 1?

Does the output have to be a value? Or can it be something else (such as an array) according to our definition of truthy/falsy?

@JacquesMarais UrbanDictionary hardly counts as a valid source for the English language.

Three of the ten answers beat the accepted answer in bytes.  This is a code-golf, and as such the shortest answer should be the accepted answer.  Was there a different winning criterion?

@JacquesMarais No problem!  For the future, if you want to select the answer with the highest votes us here at PPCG call that a Popularity-Contest.

Pyth, 20 16 15 13 11 bytes
Thanks to Leaky Nun for saving 4 bytes!  Unfortunately, I changed the entire method afterwards, but it still helped.
gl{lM}#zQlz

Expects input as dictionary followed by word.  Outputs True or False.
Try it here!
Explanation:
        lz   Collects the length of the word  input
g             and compares it to:
 l             The length of the following:
     # Q        Select all words from the dictionary that
    } z         are contained within the input word.
  lM            Map them to their respective lengths, and
 {              then remove any duplicates.

This does not function if the empty string "" is a valid word.

.E can be replaced with s

m}kH can be replaced with }RH

I would just give you the golfed code

Python, 52 bytes
lambda w,d:len({len(x)for x in d if x in w})==len(w)

An anonymous function that takes a word w and dictionary d. It takes the words in d that are substrings of w, makes a set of their lengths, and then checks that there as many distinct lengths as there are letters in w.

Ugh I just wrote the exact same thing except I had W instead of x and [ instead of {. +1

@Dopapp It wouldn't work if you used [ instead of {. {...} is a set comprehension (The same as set([...])).

@mbomb007, oh right, a set would be needed

@xnor Sorry for not selecting this answer, but as it's a code golf, I have to select the shortest...

Python 3, 108 bytes
lambda w,d,r=range:all(any(i in d for i in j)for j in[[w[i:i+s]for i in r(len(w)+1-s)]for s in r(1,len(w))])

An anonymous function that takes input, via argument, of a word w as a string and a dictionary d as a list of strings and returns True or False.
How it works
The first step is a list comprehension that generates a list of lists of all substrings of w excluding w, grouped by length. For example, for 'stage', the list [['s', 't', 'a', 'g', 'e'], ['st', 'ta', 'ag', 'ge'], ['sta', 'tag', 'age'], ['stag', 'tage']] is generated. This is achieved by looping over all valid start indices i for each substring length s, and slicing every s-length substring using w[i:i+s]. For each list in this list, the presence of each substring in the dictionary is checked; calling any returns a hit if at least one match for a given length is found. Finally, calling all checks if a match has been found for all substring lengths, and the result of this is returned.
Try it on Ideone

Ruby, 44 bytes

7 Bytes off thanks to @NotThatCharles and his set operator tricks!
2 bytes off thanks to @Jordan with the Ruby 2.3 safe navigation operator trick w[x]&.size :)

->w,d{[*1..w.size]-d.map{|x|w[x]&.size}==[]}

It's an anonymous functions which takes a word w and a dictionary (array of words) d. Creates two arrays: The first containing the numbers 1 up to and including the length of w; The second array is d with each word mapped to their size if they are a substring of w, otherwise nil. Then it does set substraction to check whether the second array contains all element of the first array.

With the "safe navigation operator" in Ruby 2.3 you can save a couple bytes: w[x]&.size==i instead of x.size==i&&w[x].

Oh wow, thanks @Jordan. Didn't know that one, awesome :)

you can save another few bytes in your anonymous function (and maybe the full program) by dropping the uniq and -[p] and using set subtraction instead: [*1..w.size]-d.map{...}==[]

@NotthatCharles That's brilliant! Thanks :)

PowerShell v3+ v2+, 127 110 70 65 bytes
param($a,$d)($d|?{$a-match$_}|select length -U).count-eq$a.length

(I see now that my approach is similar to @xnor's, though I developed it independently)
Takes input word $a and dictionary $d, expecting $d as an array (see examples below). Loops through the entirety of $d and performs a Where-Object to pull out the entries where the current word $_ is a regex -match against the input word $a (i.e., is the current word a substring of the input word).
We collect all of those substring words and pipe them to Select-Object on the length parameter and the -Unique constraint. That will pull out the unique lengths of each substring. For example, for input word comb, this will be an array of (4,2) for ('comb','om').
We take the .count of that resultant array and compare it against the input word's .length. If it's equal to, that means that every substring length is in the dictionary, so $TRUE, otherwise we're missing at least one, so $FALSE. That Boolean value is left on the pipeline and output is implicit.
NB - This should work in v2+, since the -in operator is no longer present, but I've not tested that version.
Examples
PS C:\Tools\Scripts\golfing> .\is-it-a-wordinian.ps1 'stage' (gc .\words.txt)
True

PS C:\Tools\Scripts\golfing> .\is-it-a-wordinian.ps1 'metal' (gc .\words.txt)
True

PS C:\Tools\Scripts\golfing> .\is-it-a-wordinian.ps1 'comb' (gc .\words.txt)
False

Perl, 86 bytes
Requires -E at no extra cost.
chop(($s,@d)=<>);for$=(1..($x=length$s)){$-+=!!grep$s=~/$_/,grep$===y///c,@d}say$-==$x

Accepts all input via STDIN. First input is target word, rest of input is dictionary. Prints 1 on success, empty string on failure.
Usage
perl -E 'chomp(($s,@d)=<>);for$=(1..($x=length$s)){$-+=!!grep$s=~/$_/,grep$===y///c,@d}say$-==$x' <<< 'stage
a
ta
age
stag
stage'
1
perl -E 'chomp(($s,@d)=<>);for$=(1..($x=length$s)){$-+=!!grep$s=~/$_/,grep$===y///c,@d}say$-==$x' <<< 'stage
a
at
age
stag
stage'

perl -E 'chomp(($s,@d)=<>);for$=(1..($x=length$s)){$-+=!!grep$s=~/$_/,grep$===y///c,@d}say$-==$x' <<< 'bin
i
in
bin'
1

Mathematica, 90 bytes
Sort[MemberQ[DictionaryWordQ/@StringPartition[#,t,1],True]~Table~{t,StringLength@#}][[1]]&

Uses Mathematica's builtin DictionaryWordQ.
Taking input d as dictionary is 5 bytes shorter, but much slower for long lists:
m=MemberQ;Sort[m[d~m~#&/@StringPartition[#,t,1],True]~Table~{t,StringLength@#}][[1]]&

MATL, 15 bytes
1 byte saved using an idea from @xnor's answer.
XXgc32>!suz1Gn=

Outputs 1 or 0 for truthy or falsy.
Try it online!
XX      % Take the two inputs implicitly. Apply the second as a regex into the
        % first. Since the second input is a cell array, each of its contents is
        % applied separately as a regex. So for each dictionary word ("sub-word")
        % this outputs the sub-word if found in the original word, or else an
        % empty array. Gives a cell array of cells of strings
g       % Remove one level of nestedness
c       % Convert to char. This concatenates all found sub-words as rows of a 2D
        % char array, padding with spaces as needed
32>!s   % For each row, count how many non-space characters there are. This is
        % the length of each sub-word
uz      % Number of distinct non-zero elements
1Gn     % Push length of the original word
=       % Are they equal? Implicitly display

Perl, 42 41 bytes
Includes +2 for -p0
Give word followed by the dictionary on STDIN:
(echo stage; cat dictionary.txt) | ./wordinian.pl

(When testing on unix make sure dictionary.txt uses \n as line terminator, not \r\n)
wordinian.pl:
#!/usr/bin/perl -p0
s%\G.%!/^.*(.{$+[0]})\H*
\1
/%eg;$_=!//

JavaScript (Firefox 30-57), 68 bytes
(w,a)=>new Set((for(x of a)if(~w.search(x))x.length)).size==w.length

Using a generator comprehension avoids creating an intermediate array. 73 byte ES6 version:
(w,a)=>new Set(a.filter(x=>~w.search(x)).map(x=>x.length)).size==w.length

05AB1E, 8 bytes
ŒÃ€gZLåP

Word as first input, dictionary-list as second input.
Try it online or verify a few more test cases.
Explanation:
Œ         # Get all possible substrings of the (implicit) input-string
 Ã        # Only keep the ones which are also in the (implicit) dictionary-list
  €g      # Get the length of each remaining string
    Z     # Push the maximum length (without popping the list)
     L    # Pop and push a list in the range [1, maximum-length]
      å   # Check for each value if it's in the list of lengths
       P  # And check if this is truthy for all
          # (then output the result implicitly as result)

Kotlin, 51 bytes
{w,d->w.indices.all{w.windowed(it+1).any{it in d}}}

Try it online!

SQF, 147 bytes
Using the function-as-a-file format:
params["w","d"];a=[];c=count w;for"i"from 1 to c do{a=a+[""];for"j"from 0 to c-i do{q=w select[j,i];if(q in d)then{a set[i-1,q]}}};c==count(a-[""])

Call as: ["WORD", DICTIONARY] call NAME_OF_COMPILED_FUNCTION
Ungolfed:
//name parameters
params["w", "d"];
a = []; c = count w;
//for each length of subword
for "i" from 1 to c do {
    //add entry to the `a`
    a = a + [""];
    //for each starting position for that length
    for "j" from 0 to c - i do {
        //get subword
        q = w select [j, i];
        //check if in dictionary
        if(q in d) then {
            //set the entry to the wubword
            a set [i - 1, q]
        }
    }
};
//check if length of word is equal to number of subwords
c == count (a - [""])


text:
Dense Number Sequence
OEIS: A167171
A dense number is a number that has exactly as many prime divisors as non-prime divisors (including 1 and itself as divisors). Equivalently, it is either a prime or a product of two distinct primes. The first 100 dense numbers are:
2, 3, 5, 6, 7, 10, 11, 13, 14, 15, 17, 19, 21, 22, 23, 26, 29, 31, 33, 34, 35, 37, 38, 39, 41, 43, 46, 47, 51, 53, 55, 57, 58, 59, 61, 62, 65, 67, 69, 71, 73, 74, 77, 79, 82, 83, 85, 86, 87, 89, 91, 93, 94, 95, 97, 101, 103, 106, 107, 109, 111, 113, 115, 118, 119, 122, 123, 127, 129, 131, 133, 134, 137, 139, 141, 142, 143, 145, 146, 149, 151, 155, 157, 158, 159, 161, 163, 166, 167, 173, 177, 178, 179, 181, 183, 185, 187, 191, 193, 194

Given a nonnegative integer n, output dense(n). n may be 0-indexed or 1-indexed.
Reference implementation (Sage)
import itertools

def dense_numbers():
    n = 1
    while True:
        prime_divisors = [x for x in divisors(n) if x.is_prime()]
        non_prime_divisors = [x for x in divisors(n) if not x.is_prime()]
        if len(prime_divisors) == len(non_prime_divisors):
            yield n
        n += 1

N = 20

print itertools.islice(dense_numbers(), N, N+1).next()

Try it online

So many prime number sequences... I didn't know so many existed

@βετѧΛєҫαγ There are also primes called Sexy Primes ( ͡° ͜ʖ ͡°).

@Adnan Oh myy ;D

What is the maximum value for n?

@R.Kap As high as your language of choice can go.

Jelly, 9 bytes
ÆE²Sḍ2µ#Ṫ

Reads from STDIN and uses 1-based indexing. Try it online!
How it works
ÆE²Sḍ2µ#Ṫ  Main link. No arguments. Implicit argument: 0

      µ#   Read an integer n from STDIN and execute the chain to the left for
           k = 0, 1, 2, ... until n of them return a truthy value.
           Return the array of matches.
ÆE           Compute the exponents of k's prime factorization.
  ²          Square each exponent.
   S         Compute the sum of all squares.
    ḍ2       Test if 2 is divisible by the result (true iff  the sum is 1 or 2).
        Ṫ  Tail; extract the last (n-th) matching value of k.

05AB1E, 12 11 bytes
1-indexed
µ             # while counter != input
 NÑ           # get divisors of current number
   p          # check if prime
    D         # duplicate
     O        # sum one copy
      s_O     # invert and sum the other copy
         Q½   # if equal increase counter

Try it online

Actually, 12 bytes
All credits to Dennis for his algorithm.
`w♂N;*2%Y`╓N

Try it online!
`w♂N;*2%Y`╓N

`        `     define a function
 w             prime factorization in exponent form:
               18 = (2^1)*(3^2) becomes [[2,1],[3,2]]
  ♂N           get the last element (exponent) of each sublist
    ;*         dot-product with self; equivalent to squaring
               each item and then taking the sum
      2%Y      test divisibility by 2
          ╓    first (input) solutions to the above function
           N   get the last element.

Brachylog, 17 bytes
:1yt.
1<.=$p#dl<3

Try it online!
Predicate 0 (main predicate)
:1yt.
:1y     Find the first (input) solutions of predicate 1
   t    Last element
    .   Unify with output

Predicate 1 (auxiliary predicate)
1<.=$p#dl<3
1<.            1 < output
  .=           assign a value to output
  . $p#d       output's prime factorization contains no duplicate
        l      and the length
         <3    is less than three

Husk, 13 bytes
!fö`¦2ṁo□LgpN

Try it online!
Explanation
!fö`¦2ṁo□LgpN
            N List of natural numbers
 fö           filtered by the following 4 functions:
          gp  prime factorization, grouped into equal runs
      ṁo□L    get length of each run, square and sum
   `¦2        is 2 divisible by the sum?
!             nth element in filtered list

Divisible by 2 can just be less than 3

for some reason, <3 still requires an extra increment → at the end, maintaining the same byte count. @JoKing

ah, i guess <3 includes 1, which throws off the indexing

Vyxal rG, 56 bitsv2, 7 bytes
λ∆ǐ²∑2Ḋ;ȯ

Try it Online!
port of jelly

R, 93 Bytes
dense=function(n){a=b=0;for(i in which(!n%%1:n))if(which(!i%%2:i)+1==i)a=a+1 else b=b+1;a==b}

It has a tendency to throw a warning. Its not really a problem. Allowing the warning saves me 5 bytes.
Ungolfed
dense=function(n){
     a=b=0                                #Initializing
     factors = which(!n%%1:n)             #Finds all factors
     for(i in factors)                    #Loops through factors
         prime = which(!i%%2:i)+1==i      #Tests if current factor is prime. If it is -- the first term in this vector will be TRUE. Otherwise, it will be false.
           if (prime) a=a+1 else b=b+1    #If first term is true, add 1 to a. Else add one to b.
      return(a==b)                        #Test equality of a and b.
}

Can't you use the += operator to save 2 bytes?

Sadly, R doesn't have any useful incrementation operators like += or a++. Sometimes there can be shorter ways (taking advantage of loop structure mostly), but I don't know of one here.

Python, 79 bytes
f=lambda n,k=2:n<1or-~f(n-(sum((k%i<1)+2*(k%i**2<1)for i in range(2,k))<3),k+1)

Uses 1-based indexing. Test it on Ideone.

PHP, 118 Bytes
for($i=1;!$o=$s[$argn];$r[2]?:$t+=2*$$i=1,$t?:$s[]=$i)for($t=0,$r=[],$n=++$i;$n;$n--)$i%$n?:$t+=${$r[]=$n}?:-1;echo$o;

Try it online!

Axiom, 102 bytes
f(n:PI):PI==(i:=1;repeat(i:=i+1;a:=divisors(i);2*#[x for x in a|prime?(x)]=#a=>(n=1=>break;n:=n-1));i)

ungolf and result
-- 1 base Indexed: return the n_th number i that has 2*#divisorsPrimeOf(i)=#divisors(i)
ff(n:PI):PI==
     i:=1
     repeat
        i:=i+1
        a:=divisors(i)
        2*#[x for x in a|prime?(x)]=#a=>(n=1=>break;n:=n-1)
     i

(3) -> [f(i)  for i in 1..23]
   (3)  [2,3,5,6,7,10,11,13,14,15,17,19,21,22,23,26,29,31,33,34,35,37,38]
                                               Type: List PositiveInteger