text:
Stable Game of Life
Challenge:
Given a matrix (or 2d array) of 0s and 1s, output the number of steps it takes for Conway's game of life to reach a stable state, or -1 if it never reaches one.  A stable state is a state in which no cells are turned on or off each step.  The game must run in the  given matrix, with the top and bottom connected, and the sides connected. (i.e. given a 4x3 matrix it should run on a 4x3 torus)  The input matrix will not be larger than 15x15.
Note: If the matrix starts in a stable state, the output should be 0.
Samples:
Input:
[[0,0,0],
 [0,1,1],
 [0,1,0]]

Output:
2
Process: (this does not need to be displayed)
[[0,0,0],
 [0,1,1],
 [0,1,0]]

[[1,1,1],
 [1,1,1],
 [1,1,1]]

[[0,0,0],
 [0,0,0],
 [0,0,0]]

Input:
[[0,0,1,1],
 [0,1,1,1],
 [0,1,0,0],
 [0,1,1,1]]

Output:
2
Process:
[[0,0,1,1],
 [0,1,1,1],
 [0,1,0,0],
 [0,1,1,1]]

[[0,0,0,0],
 [0,1,0,1],
 [0,0,0,0],
 [0,1,0,1]]

[[0,0,0,0],
 [0,0,0,0],
 [0,0,0,0],
 [0,0,0,0]]

Input:
[[0,1,0,0],
 [0,1,0,0],
 [0,1,0,0],
 [0,0,0,0]]

Output:
-1
Process:
[[0,1,0,0],
 [0,1,0,0],
 [0,1,0,0],
 [0,0,0,0]]

[[0,0,0,0],
 [1,1,1,0],
 [0,0,0,0],
 [0,0,0,0]]

[[0,1,0,0],
 [0,1,0,0],
 [0,1,0,0],
 [0,0,0,0]]

repeating forever
Input:
[[0,0,0,0],
 [0,0,0,1],
 [0,1,1,1],
 [0,0,1,0]]

Output:
4
Process:
[[0,0,0,0],
 [0,0,0,1],
 [0,1,1,1],
 [0,0,1,0]]

[[0,0,0,0],
 [1,0,0,1],
 [1,1,0,1],
 [0,1,1,1]]

[[0,1,0,0],
 [0,1,1,1],
 [0,0,0,0],
 [0,1,0,1]]

[[0,1,0,1],
 [1,1,1,0],
 [0,1,0,1],
 [1,0,1,0]]

[[0,0,0,0],
 [0,0,0,0],
 [0,0,0,0],
 [0,0,0,0]]

Input:
[[0,0,0,0],
 [0,1,1,0],
 [0,1,1,0],
 [0,0,0,0]]

Output:
0
Process:
The beginning state is stable.
Rules of the Game of Life
If a cell that is off (0) is next to exactly three on (1) cells, it is turned on. Otherwise, it is left off. If a cell that is on is next to 2 or 3 on squares, it says on.  Otherwise, it is turned off.

So what should be output if the pattern repeats forever?

I belive it says to output -1 in the question.

Possible input formats? Any bounds on matrix sizes? If not, what if we have a 100x100 matrix? Also, you should probably put a summary of the Game of Life rules in the question so it's self-contained.

Oh, I see. I misread one of the examples. Another question, though -- at what point should we assume it doesn't become stable? Because I'm sure there are plenty of patterns which become stable after hundreds or thousands of iterations. There's even a category for it: Methuselah

I'm pretty sure this challenge is essentially asking "solve the halting problem".

In small matrices like these, a pattern cannot take very long to become stable, so around 250 generations would probably be enough.

So there's a bound on the size?

Yeah, I added a 15x15 size limit to the question.

Is there a specific input format, and can I assume that the input is valid?

The input is a matrix consisting of 0s and 1s, and yes, you can assume the input is valid.

Are you saying "regard any matrix that hasn't stabilised by 250 generations as never stabilising", or do answers need to choose a number of generations that is provably sufficient to draw that conclusion? For example, 2^(15*15) is provably enough generations, as a given matrix always has the same successor and there are only this many possible matrices. I suspect there are much smaller upper bounds but I don't know how to prove one.

I'd recommend putting the rules before the examples, and including that each cell has 8 neighbours, for anyone unfamiliar with Conway's Game of Life.

As a counterexample to show 250 generations is not always enough: For a 15 by 14 matrix, a single glider in an otherwise empty arena will take 15144=840 generations to return to its original state. If the end of that long path is blocked by a 2 by 2 block, the glider will annihilate leaving a stable configuration. This will be a few rows short of the end of the path to avoid destroying the glider right at the start, but still well over 600 generations before stability.

Can I just do 2^(x*y) iterations, or is there a timing constraint?

@JanDvorak Doesn't looks like there's a timing constraint as the Mathematica answer is said to take ages for everything greater than 4x4

Is there a minimum size ? I'd like really to assume width and height >= 2 so the same value doesn't wrap around twice :-)

@poi830 Please clarify in the question the maximum number of generations required, or if a solution will only detect an infinite loop by reaching a previously held state. At the moment, it's unclear what you're asking.

Mathematica, 130 129 bytes
#&@@FirstPosition[Partition[CellularAutomaton[{224,{2,{{2,2,2},{2,1,2},{2,2,2}}},{1,1}},#,2^Length[Join@@#]],2,1],{x_,x_},0,1]-1&

I wouldn't recommend trying more than 4x4 inputs, because it's going to take forever (and a lot of memory).
Explanation
This simply simulates the Game of Life for 2N steps where N is the number of cells in the input. This guarantees that if the system settles into a stable state, we've reached it. Afterwards, we find the first pair of consecutive identical states in the simulated history.
Let's go through the code:
2^Length[Join@@#]

This computes 2N, since Join@@ is used to flatten a 2D list.
CellularAutomaton[{224,{2,{{2,2,2},{2,1,2},{2,2,2}}},{1,1}},#,...]

This simulates the Game of Life for 2N generations. The 3x3 matrix specifies the neighbourhood of a totalistic 2D automaton and 224 is the rule number of standard Game of Life. I've written about how to compute this number over here on Mathematica.SE.
Partition[...,2,1]

This gets all consecutive (overlapping) pairs of generations.
FirstPosition[...,{x_,x_},0,1]

This finds the first pair of identical generations, defaulting to 0 if none is found and limiting the search to depth 1. If such a pair is found, the result is returned in a list though. So we use:
#&@@...

To extract the first element from that list (the default value of 0, being atomic, is unaffected by this).
...-1

Finally we subtract one because the challenge expects 0-based indices and -1 for failure.

Lua, 531 509 488 487 464 424 405 404 Bytes
Who wants a massive submission? \o/
Edit: Improved it, but don't know how to golf it anymore, so... explanations are coming comments added :)
Saved ~60 bytes with the help of @KennyLau
small golfing cutting one more byte by renaming a into Y to prevent the inlined hexadecimal conversion
function f(m)c={}t=table.concat::z::c[#c+1]={}p=c[#c]Y={}for i=1,#m do k=m[i]p[#p+1]=t(k)Y[i]={}for j=1,#k
do v=m[i%#m+1]l=j%#k+1w=m[(i-2)%#m+1]h=(j-2)%#k+1Y[i][j]=v[l]+k[l]+w[l]+v[h]+v[j]+w[h]+w[j]+k[h]end
end s=''for i=1,#m do k=m[i]for j=1,k do
x=Y[i][j]k[j]=k[j]>0 and((x<2or x>3)and 0or 1)or (x==3 and 1or 0)end
s=s..t(k)end for i=1,#c do
if(s==t(c[i]))then return#c>i and-1or i-1
end end goto z end

Ungolfed
function f(m)                -- takes a 2D array of 0 and 1s as input
  c={}                       -- intialise c -> contains a copy of each generation
  t=table.concat             -- shorthand for the concatenating function
  ::z::                      -- label z, used to do an infinite loop
    c[#c+1]={}               -- initialise the first copy
    p=c[#c]                  -- initialise a pointer to this copy
    a={}                     -- initialise the 2D array of adjacency
    for i=1,#m               -- iterate over the lines of m
    do
      k=m[i]                 -- shorthand for the current line
      p[#p+1]=t(k])          -- saves the current line of m as a string
      a[i]={}                -- initialise the array of adjacency for the current line
      for j=1,#k             -- iterate over each row of m
      do
                             -- the following statements are used to wraps at borders
        v=m[i%#m+1]          -- wrap bottom to top
        l=j%#k+1             -- wrap right to left
        w=m[(i-2)%#m+1]      -- wrap top to bottom
        h=(j-2)%#k+1         -- wrap left to right

        a[i][j]= v[l]        -- living cells are 1 and deads are 0
                +k[l]        -- just add the values of adjacent cells
                +w[l]        -- to know the number of alive adjacent cells
                +v[h]
                +v[j]
                +w[h]
                +w[j]
                +k[h]
      end
    end

    s=''                     -- s will be the representation of the current generation
    for i=1,#m               -- iterate over each line
    do
      k=m[i]                 -- shorthand for the current line
      for j=1,#k             -- iterate over each row
      do
        x=a[i][j]            -- shorthand for the number of adjacent to the current cell
                             -- the next line change the state of the current cell
        k[j]=k[j]>0          -- if it is alive
                and((x<2     --   and it has less than 2 adjacent
                    or x>3)  --   or more than 3 adjacent
                  and 0      --     kill it
                  or 1)      --     else let it alive
                or           -- if it is dead
                  (x==3      --   and it has 3 adjacent
                  and 1      --     give life to it
                  or 0)      --     else let it dead
      end
      s=s..t(k)              -- save the representation of the current line
    end
    for i=1,#c               -- iterate over all the generation done until now
    do
      if(s==t(c[i]))         -- if the representation of the current generation
      then                   -- is equal to one we saved
        return#c>i           -- check if it is the latest generation
              and-1          -- if it isn't, it means we are in a loop -> return -1
              or i-1         -- if it is, we did 2 generations without changing
                             --  -> return the number of generation
      end
    end
  goto z                     -- if we reach that point, loop back to the label z
end

Test cases
Here's some test cases
function f(m)c={}t=table.concat::z::c[#c+1]={}p=c[#c]a={}for i=1,#m do k=m[i]p[#p+1]=t(k)a[i]={}for j=1,#k
do v=m[i%#m+1]l=j%#k+1w=m[(i-2)%#m+1]h=(j-2)%#k+1
a[i][j]=v[l]+k[l]+w[l]+v[h]+v[j]+w[h]+w[j]+k[h]end
end s=''for i=1,#m do k=m[i]for j=1,k do
x=a[i][j]k[j]=k[j]>0 and((x<2or x>3)and 0or 1)or (x==3 and 1or 0)end
s=s..t(k)end for i=1,#c do
if(s==t(c[i]))then return#c>i and-1or i-1
end end goto z end

print(f({{0,0,0},{0,1,1},{0,1,0}}))
print(f({{0,1,0,0},{0,1,0,0},{0,1,0,0},{0,0,0,0}}))
-- 53 generation, 15x15, takes 50-100 ms on a bad laptop
print(f({{0,0,0,0,1,1,0,1,0,0,0,0,1,0,0},
       {0,1,1,0,1,1,1,1,1,1,1,0,0,0,0},
       {0,1,1,1,0,1,0,1,0,0,0,0,1,0,0},
       {0,0,1,0,1,1,1,0,0,1,1,1,0,1,1},
       {1,1,0,0,1,1,1,0,1,1,0,0,0,1,0},
       {0,0,0,0,1,1,0,1,0,0,0,0,1,0,0},
       {0,1,1,0,1,1,1,1,1,1,1,0,0,0,0},
       {0,1,1,1,0,1,0,1,0,0,0,0,1,0,0},
       {0,0,1,0,1,1,1,0,0,1,1,1,0,1,1},
       {1,1,0,0,1,1,1,0,1,1,0,0,0,1,0},
       {0,0,1,0,1,1,1,0,0,1,1,1,0,1,1},
       {1,1,0,0,1,1,1,0,1,1,0,0,0,1,0},
       {0,0,0,0,1,1,0,1,0,0,0,0,1,0,0},
       {0,0,0,0,1,1,0,1,0,0,0,0,1,0,0},
       {0,1,1,0,1,1,1,1,1,1,1,0,0,0,0}}))
-- Glider on a 15x14 board
-- 840 distinct generation
-- loop afterward -> return -1
-- takes ~4-5 seconds on the same bad laptop
print(f({{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
       {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
       {0,0,0,0,1,0,0,0,0,0,0,0,0,0,0},
       {0,0,0,0,0,1,0,0,0,0,0,0,0,0,0},
       {0,0,0,1,1,1,0,0,0,0,0,0,0,0,0},
       {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
       {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
       {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
       {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
       {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
       {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
       {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
       {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
       {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}}))

Perl, 154 151 144 140 137 133 129 bytes
Includes +3 for -ap0
Run with the input as a line of groups of digits separated by space
life.pl <<< "0000 0001 0111 0010"

This is only really needed in case the input is immediately stable. In all other cases you can also more conveniently give it as seperate lines of digits:
life.pl
0000
0001
0111
0010
^D

Giving input this way would however give 1 instead of 0 for an immediately stable configuration.
life.pl:
#!/usr/bin/perl -ap0
map{@f=map$F[$_%@F]x3,$i-1..++$i;s%.%"0+($&+33)=~grep\$_,map{(//g)[@--1..@+]}\@f"%eeg}@Q=@F;$_=/@Q/?keys%n:$n{$_="@Q"}--||redo

Almost beating Mathematica on this one...
Only on older perl versions (where you could use a constant as a variable) does this 126 byte solution work:
#!/usr/bin/perl -p0a
map{@f=map$F[$_++%@F]x2,-1..1;s%.%"0+($&+33)=~grep\$_,map{(//g)[@--1..@+]}\@f"%eeg}@Q=@F;$_=/@Q/?keys%n:$n{$_="@Q"}--||redo

In case there are certain to be at least 2 rows this 123 byte solution works on all perl versions:
#!/usr/bin/perl -p0a
@F=@F[-$#F..!s%.%"0+($&+33)=~grep\$_,map{(//g,//g)[@--1..@+]}\@F[-1..1]"%eeg]for@Q=@F;$_=/@Q/?keys%n:$n{$_="@Q"}--||redo

Jelly, 26 25 bytes
ṙ-r1¤SZµ⁺_|=3
ÇÐĿ-LiṪÇ$$?

Try it online! or verify all test cases.
Larger test cases (from @Katenkyo's answer): 15×15 stable | 15×14 glider
How it works
ṙ-r1¤SZµ⁺_|=3  Helper link. Argument: G (grid)
               This link computes the next state of G.

    ¤          Evaluate the three links to the left as a niladic chain.
 -               Yield -1.
   1             Yield 1.
  r              Range; yield [-1, 0, 1].
ṛ              Rotate the rows of G -1, 0 and 1 units up.
     S         Compute the sum of the three resulting grids.
               Essentially, this adds the rows directly above and below each given
               row to that row.
      Z        Zip; transpose rows and columns.
       µ       Convert the preceding chain into a link and begin a new chain.
        ⁺      Apply the preceding chain once more.
               This zips back and adds the surrounding columns to each column.
         _     Subtract G from the result.
               Each cell now contains the number of lit cells that surround it.
          |    That the bitwise OR of the result and G.
               Notably, 3|0 = 3|1 = 2|1 = 3.
           =3  Compare each resulting number with 3.

ÇÐĿ-LiṪÇ$$?    Main link. Argument: G (grid)

ÇÐL            Repeatedly apply the helper link until the results are no longer
               unique. Collect all unique results in a list.
         $     Evaluate the two links to the left as a monadic chain:
        $        Evaluate the two links to the left as a monadic chain:
      Ṫ            Pop the last element of the list of grids.
       Ç           Apply the helper link to get the next iteration.
     i           Get the index of the grid to the right (the first non-unique one)
                 in the popped list of grids. This yields 0 iff the popped list
                 doesn't contain that grid, i.e., the grid reached a stable state.
          ?    If the index is non-zero:
   -             Return -1.
    L            Else, return the length of the popped list of grids.

Julia, 92 88 bytes
f(x,r...)=x∈r?(r[k=end]==x)k-1:f(sum(i->circshift(x,[i÷3,i%3]-1),0:8)-x|x.==3,r...,x)

Verification
julia> f(x,r...)=x∈r?(r[k=end]==x)k-1:f(sum(i->circshift(x,[i÷3,i%3]-1),0:8)-x|x.==3,r...,x)
f (generic function with 1 method)

julia> f([0 0 0;0 1 1;0 1 0])
2

julia> f([0 0 1 1;0 1 1 1;0 1 0 0;0 1 1 1])
2

julia> f([0 1 0 0;0 1 0 0;0 1 0 0;0 0 0 0])
-1

julia> f([0 0 0 0;0 0 0 1;0 1 1 1;0 0 1 0])
4

julia> f([0 0 0 0;0 1 1 0;0 1 1 0;0 0 0 0])
0

julia> f([0 0 0 0 1 1 0 1 0 0 0 0 1 0 0;0 1 1 0 1 1 1 1 1 1 1 0 0 0 0;0 1 1 1 0 1 0 1 0 0 0 0 1 0 0;0 0 1 0 1 1 1 0 0 1 1 1 0 1 1;1 1 0 0 1 1 1 0 1 1 0 0 0 1 0;0 0 0 0 1 1 0 1 0 0 0 0 1 0 0;0 1 1 0 1 1 1 1 1 1 1 0 0 0 0;0 1 1 1 0 1 0 1 0 0 0 0 1 0 0;0 0 1 0 1 1 1 0 0 1 1 1 0 1 1;1 1 0 0 1 1 1 0 1 1 0 0 0 1 0;0 0 1 0 1 1 1 0 0 1 1 1 0 1 1;1 1 0 0 1 1 1 0 1 1 0 0 0 1 0;0 0 0 0 1 1 0 1 0 0 0 0 1 0 0;0 0 0 0 1 1 0 1 0 0 0 0 1 0 0;0 1 1 0 1 1 1 1 1 1 1 0 0 0 0])
53

julia> f([0 0 0 0 0 0 0 0 0 0 0 0 0 0 0;0 0 0 0 0 0 0 0 0 0 0 0 0 0 0;0 0 0 0 1 0 0 0 0 0 0 0 0 0 0;0 0 0 0 0 1 0 0 0 0 0 0 0 0 0;0 0 0 1 1 1 0 0 0 0 0 0 0 0 0;0 0 0 0 0 0 0 0 0 0 0 0 0 0 0;0 0 0 0 0 0 0 0 0 0 0 0 0 0 0;0 0 0 0 0 0 0 0 0 0 0 0 0 0 0;0 0 0 0 0 0 0 0 0 0 0 0 0 0 0;0 0 0 0 0 0 0 0 0 0 0 0 0 0 0;0 0 0 0 0 0 0 0 0 0 0 0 0 0 0;0 0 0 0 0 0 0 0 0 0 0 0 0 0 0;0 0 0 0 0 0 0 0 0 0 0 0 0 0 0;0 0 0 0 0 0 0 0 0 0 0 0 0 0 0])
-1

ruby, 207 bytes
->a{r=[];(r<<a;a=(0...a.size).map{|i|(0...a[i].size).map{|j|n=0;(-1..1).map{|u|(-1..1).map{|v|n+=a[(i+u)%a.size][(j+v)%a[i].size]}};[n==3,n>2&&n<5][a[i][j]]?1:0}})while(!r.index(a));(a==r[-1])?r.index(a):-1}

I keep a history of each board, so if I get a board I have seen before I know one of two thing happened. first it could be that we have found a stable position, in which case it will be the most resent in our history. the other possibility is that we have a loop.

15x15 matrix means we have 2^225 possible boards, I highly doubt you can even memorize those matrices using the memory of all computer in the worlds (even if most games will probably end with less than 1000 boards).. Good luck addressing that in 64 bit machines.

@DarioOO Even a glider on a 15x14 board will need "only" 840 generation before looping back to its first state, so we can expect nearly everything to be under 1000 gens. Also, 1000 gens on a  15x15 using 32 bits integers result in a memory usage of 15*15*4*1000 -> 900 KB, good enough for cases where we'll need 10k+ gens :).

Python 3.8, 268 262 260 bytes
Had fun w a little convolution. Code stores prev generations as byte array. Cuts off at 1000 iterations for the sake of not chasing an infinite starting matrix, but can be easily changed to any number of iterations or removed.
note: There's a deprecation for scipy arrays coming in scipy 2.0.0 so this only works on previous versions.
import scipy as s
def g(b,n=0,L=[0]):
 if n>1e3:return-1
 b=s.array(b);j=b.tobytes()
 if j==L[-1]:return n-1
 if j in L: return-1
 L+=[j];f=[[1]*3]*3;f[1][1]=0
 x=s.ndimage.convolve(b,f,mode='wrap')
 b[x<2]=0;b[x>3]=0;b[x==3]=1
 n=g(b,n+1,L)
 return n

I'm sure there's more to shave off, please lmk!

Octave, 275 213 206 202 bytes
Implementation.
Saved 73 bytes thanks to the comment of @ceilingcat

Golfed version. Try it online!
function s=f(x);p=[];for s=0:1e3;if isequal(x,p);--s;return;end;[m,n]=size(y=p=x);for i=1:m;for j=1:n;z=x(i,j);s=sum(x(mod(i-2:i,m)+1,mod(j-2:j,n)+1)(:))-z;y(i,j)=s==2&z==1|s==3;end;end;x=y;end;s=-1;end

Ungolfed version. Try it online!
function steps = f(x)
  max_iterations = 1000;  % set a max limit to stop infinite loops
  prev_x = [];
  for steps = 0:max_iterations
    if isequal(x, prev_x)
      steps=steps-1;
      return
    end
    prev_x = x;
    x = next_generation(x);
  end
  steps = -1;  % did not reach a stable state within max_iterations
end

function y = next_generation(x)
  [m, n] = size(x);
  y = zeros(m, n);
  for i = 1:m
    for j = 1:n
      % count the number of live neighbors, taking into account the torus shape
      neighbors = x(mod(i-2:i, m)+1, mod(j-2:j, n)+1);
      num_live_neighbors = sum(neighbors(:)) - x(i, j);
      if x(i, j) == 1  % if the cell is alive
        y(i, j) = num_live_neighbors == 2 || num_live_neighbors == 3;
      else  % if the cell is dead
        y(i, j) = num_live_neighbors == 3;
      end
    end
  end
end

disp(f([0 0 0;0 1 1;0 1 0]))
disp(f([0 0 1 1;0 1 1 1;0 1 0 0;0 1 1 1]))
disp(f([0 1 0 0;0 1 0 0;0 1 0 0;0 0 0 0]))
disp(f([0 0 0 0;0 0 0 1;0 1 1 1;0 0 1 0]))
disp(f([0 0 0 0;0 1 1 0;0 1 1 0;0 0 0 0]))
disp(f([0 0 0 0 1 1 0 1 0 0 0 0 1 0 0;0 1 1 0 1 1 1 1 1 1 1 0 0 0 0;0 1 1 1 0 1 0 1 0 0 0 0 1 0 0;0 0 1 0 1 1 1 0 0 1 1 1 0 1 1;1 1 0 0 1 1 1 0 1 1 0 0 0 1 0;0 0 0 0 1 1 0 1 0 0 0 0 1 0 0;0 1 1 0 1 1 1 1 1 1 1 0 0 0 0;0 1 1 1 0 1 0 1 0 0 0 0 1 0 0;0 0 1 0 1 1 1 0 0 1 1 1 0 1 1;1 1 0 0 1 1 1 0 1 1 0 0 0 1 0;0 0 1 0 1 1 1 0 0 1 1 1 0 1 1;1 1 0 0 1 1 1 0 1 1 0 0 0 1 0;0 0 0 0 1 1 0 1 0 0 0 0 1 0 0;0 0 0 0 1 1 0 1 0 0 0 0 1 0 0;0 1 1 0 1 1 1 1 1 1 1 0 0 0 0]))
disp(f([0 0 0 0 0 0 0 0 0 0 0 0 0 0 0;0 0 0 0 0 0 0 0 0 0 0 0 0 0 0;0 0 0 0 1 0 0 0 0 0 0 0 0 0 0;0 0 0 0 0 1 0 0 0 0 0 0 0 0 0;0 0 0 1 1 1 0 0 0 0 0 0 0 0 0;0 0 0 0 0 0 0 0 0 0 0 0 0 0 0;0 0 0 0 0 0 0 0 0 0 0 0 0 0 0;0 0 0 0 0 0 0 0 0 0 0 0 0 0 0;0 0 0 0 0 0 0 0 0 0 0 0 0 0 0;0 0 0 0 0 0 0 0 0 0 0 0 0 0 0;0 0 0 0 0 0 0 0 0 0 0 0 0 0 0;0 0 0 0 0 0 0 0 0 0 0 0 0 0 0;0 0 0 0 0 0 0 0 0 0 0 0 0 0 0;0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]))


text:
Identify the Conic Section
Given 5 distinct points on a two-dimensional plane, determine the type of conic section formed by the points. The output shall be one of circle, hyperbola, ellipse, or parabola.
Rules

The points will be in general linear position, meaning that no three points are collinear, and thus the conic passing through them will be unique.
The coordinates of the 5 points will be decimal numbers between -10 and 10, inclusive.
The precision for the decimal/float values should be the precision of your language's native float/decimal type. If your language/data type is arbitrary-precision, you may use 12 digits after the decimal point as the maximum required precision, rounding toward zero (e.g. 1.0000000000005 == 1.000000000000).
Capitalization of the output does not matter.
Outputting ellipse when the conic section is actually a circle is not allowed. All circles are ellipses, but you must output the most specific one.

On floating point inaccuracies and precision:

I'm trying to make this as simple as possible, so that issues with floating point inaccuracies don't get in the way. The goal is, if the data type was "magical infinite precision value" instead of float/double, then everything would work perfectly. But, since "magical infinite precision value" doesn't exist, you write code that assumes that your values are infinite precision, and any issues that crop up as a result of floating point inaccuracies are features, not bugs.

Test Cases
(0, 0), (1, 5), (2, 3), (4, 8), (9, 2) => hyperbola
(1.2, 5.3), (4.1, 5.6), (9.1, 2.5), (0, 1), (4.2, 0) => ellipse
(5, 0), (4, 3), (3, 4), (0, 5), (0, -5) => circle
(1, 0), (0, 1), (2, 1), (3, 4), (4, 9) => parabola

For floats, outputs like circle seem to require checking float equality to distinguish from a very round ellipse. What precision should we assume here?

@xnor Native precision of your language/data type

@Mego Why not allow the integer version of the problem for all languages , but with a wider range, e.g. -10000 to 10000.

I agree with @orlp. My solution is failing on your circle problem because of precision while you could have just made an integer test case.

would it be fine if I used numpy.isclose because of inaccuracies?

are you sure test case four is correct? desmos: https://www.desmos.com/calculator/fmwrjau8fd

Also, 3 looks wrong too: https://www.desmos.com/calculator/tkx1wrkotd

A link to the wikipedia page on conic sections

@orlp Ah, I was messing up my calculations. I'll add a test case for the circle soon.

No need to worry about FP precision guys. Every ellipse is a circle so you can just output ellipse !

@feersum I should hope that it's obvious that doing that is not allowed.

@Maltysen The test cases have been corrected. numpy.isclose would not be acceptable (nor needed), because Python's floats are not arbitrary-precision, and thus you would use a == b for equality. If a and b are within 1 ULP of each other, they will compare equal, and thus should be treated as equal.

What do you mean within 1 ULP ?

@edc65 I mean within 1 unit in the last place. It's very simple: if a == b, then the difference between the values that a and b are trying to represent is less than 1 ULP.

I think you are understimating the problems with FP accuracy, and that leads to answer like this http://codegolf.stackexchange.com/a/77815/21348

@Mego Yeah, you are making some really unrealistic assumptions about floating point computations. It is true that each individual floating-point operation is accurate to within 1 ULP. However, when you compose several floating-point operations, the sub-ULP errors get magnified at each step, so that the final result may be much less accurate. For example, (1/49)*49 != 1.

@AndersKaseorg I'm trying to make this as simple as possible, so that issues with floating point inaccuracies don't get in the way. The goal is, if the data type was "magical infinite precision value" instead of float/double, then everything would work perfectly. But, since "magical infinite precision value" doesn't exist, you write code that assumes that your values are infinite precision, and any issues that crop up as a result of floating point inaccuracies are features, not bugs.

@Mego In that case, I don’t understand your objection to Maltysen’s answer. It seems to interpret the question the same way.

@AndersKaseorg It's less objecting and more confusion. See my comment.

Matlab, 154 bytes
p=input();c=null([p.^2 prod(p,2) p 1+p(:,1)*0]),s={'circle' 'ellipse' 'parabola' 'hyperbola'};s{3+sign(c(3)^2-4*c(1)*c(2))-~max(abs(c(3)),abs(c(1)-c(2)))}

Saved some bytes thanks to Suever's suggestions.
Takes input as [x1 y1;x2 y2;x3 y3; etc]. This used a Vandermonde matrix, and finds the basis of its null space, which will always be a single vector. Then it calculates the discriminant and uses it to make an index between 1 and 4 which is used to get the string.
Ungolfed:
p=input();
c=null([p.^2 prod(p')' p ones(length(p),1)]);
s={'circle' 'ellipse' 'parabola' 'hyperbola'};
s{3+sign(c(3)^2-4*c(1)*c(2))-~max(abs(c(3)),abs(c(1)-c(2)))}

The sign(...) part calculates the discriminant, giving 1 if it's positive (hyperbola), -1 if it's negative (ellipse), and 0 if it's 0 (parabola). The max(...) subtracts 1 away if it is a circle. Matlab arrays are one-indexed, so add 3 to give values 1, 2, 3, 4, and use that to index the array of conic section names.

Rather than comparing max() == 0 you can simplify to ~max()

Also instead of ones(length(p),1) you could do 1+p(:,1)*0

Cheers, the max() thing was silly of me, I did have comparisons there before and got lazy obviously! That way of getting the ones is very nice too.

JavaScript (ES6), 316 323 347
p=>[1,2,4].some(x=>(d=D(Q=[[x&1,x&2,x&4,0,0,0],...p.map(([x,y])=>[x*x,x*y,y*y,x,y,1])]))?[a,b,c]=Q.map((v,i)=>D(Q.map((r,j)=>(r=[...r],r[i]=x*!j,r)))/d):0,D=m=>m[1]?m[0].reduce((r,v,i)=>r+(i&1?-v:v)*D(m.slice(1).map(r=>r.filter((a,j)=>j-i))),0):m)&&(d=b*b-4*a*c)?d<0?!b&c==a?'Circle':'Ellipse':'Hyperbola':'Parabola'

Any language better suited for handling matrix and determinant should score better (APL, J, CJAM, Jelly)
References: General form of a conic, Five points determine a conic, System of linear equations, Determinant
In the cartesian plane, the general equation of a conic is
A*x*x + B*x*y + C*y*y + D*x + E*y + F = 0

having A or B or C not equal to 0 (otherwise it's a straight line)
A ... F are six unknowns to be found. With five pairs of (x,y) we can build a linear system with five equations, and scaling remove one dimension. That is, we can set one of A,B or C to 1 if it's not 0 (and we know that at least one is not 0).
I build and try to solve 3 systems: first trying A=1. If not solvable then B=1, then C. (There could be a better way, but that's my best at the time)
Having the values of A,B,C we can classify the conic looking at the discriminant d=B*B-4*A*C

d == 0 -> parabola
d > 0 -> hyperbola
d < 0 -> ellipse, particularly (A == C and B == 0) -> circle

Less golfed
F=p=>(
  // Recursive function to find determinant of a square matrix
  D=m=>m[1]
    ?m[0].reduce((r,v,i)=>r+(i&1?-v:v)*D(m.slice(1).map(r=>r.filter((a,j)=>j-i))),0)
    :m,
  // Try 3 linear systems, coefficients in Q
  // Five equation made from the paramaters in p
  // And a first equation with coefficient like k,0,0,0,0,0,1 (example for A)
  [1,2,4].some(
    x => (
      // matrix to calc the determinant, last coefficient is missing at this stage
      Q = [
        [x&1, x&2, x&4, 0,0,0] // first one is different
        // all other equations built from the params
        ,...p.map( ([x,y]) => [x*x, x*y, y*y, x, y, 1] )
      ],
      d = D(Q), // here d is the determinant
      d && ( // if solvable  then d != 0
        // add missing last coefficient to Q
        // must be != 0 for the first row, must be 0 for the other
        Q.map( r=> (r.push(x), x=0) ),
        // solve the system (Cramer's rule), I get all values for A...F but I just care of a,b,c
        [a,b,c] = Q.map((v,i)=>D(Q.map(r=>(r=[...r],r[i]=r.pop(),r))) / d),
        d = b*b - 4*a*c, // now reuse d for discriminant
        d = d<0 ? !b&c==a ? 'Circle' : 'Ellipse' // now reuse d for end result
        : d ? 'Hyperbola' : 'Parabola'
      ) // exit .some if not 0
    ), d // .some exit with true, the result is in d
  )
)

Test

F=p=>[1,2,4].some(x=>(d=D(Q=[[x&1,x&2,x&4,0,0,0],...p.map(([x,y])=>[x*x,x*y,y*y,x,y,1])]))?[a,b,c]=Q.map((v,i)=>D(Q.map((r,j)=>(r=[...r],r[i]=x*!j,r)))/d):0,D=m=>m[1]?m[0].reduce((r,v,i)=>r+(i&1?-v:v)*D(m.slice(1).map(r=>r.filter((a,j)=>j-i))),0):m)&&(d=b*b-4*a*c)?d<0?!b&c==a?'Circle':'Ellipse':'Hyperbola':'Parabola'

console.log=(...x)=>O.textContent+=x+'\n'

;[
 [[0, 0], [1, 5], [2, 3], [4, 8], [9, 2]]
,[[1.2, 5.3],[4.1, 5.6], [9.1, 2.5], [0, 1], [4.2, 0]]
,[[5, 0], [4, 3], [3, 4], [0, 5], [0, -5]]
,[[1, 0], [0, 1], [2, 1], [3, 4], [4, 9]]
].forEach(t=>console.log(t.join`|`+' => '+F(t)))

This is really nice! Excellent work!

Python - 234 bytes
import numpy as n
x=input()
d=[n.linalg.det(n.delete(n.array([[i*i,i*j,j*j,i,j,1]for i,j in x]),k,1))for k in range(6)]
t=d[1]**2-4*d[0]*d[2]
print"hyperbola"if t>0else"parabola"if t==0else"circle"if d[1]==0and d[0]==d[2]else"ellipse"

I never print circle or parabola because t and d[1] never hit exactly 0, but OP said that was okay.

C, 500
My JavaScript answer ported to C. Just to see if it can be done.
Usage: read 10 values from standard input

echo 1 0 0 1 2 1 3 4 4 9 | conic

Output:

Parabola

Test (ideone)
double D(m,k)double*m;{double t=0;for(int s=1,b=1,x=0;x<6;x++,b+=b)k&b||(t+=s*m[x]*(k+b>62?1:D(m+6,k+b)),s=-s);return t;}i,u,h;double m[36],*t=m+6,w[6],s[3],b,d;main(){for(;i++<5;*t++=d*d,*t++=d*b,*t++=b*b,*t++=d,*t++=b,*t++=1)scanf("%lf%lf",&d,&b);for(u=4;u;u/=2)for(m[0]=u&1,m[1]=u&2,m[2]=u&4,d=D(m,0),h=0;d&&h<3;h++){for(i=0;i<6;i++)w[i]=m[i*6+h],m[i*6+h]=i?0:u;s[h]=D(m,0)/d;for(;i--;)m[i*6+h]=w[i];}b=s[1];d=b*b-4*s[0]*s[2];puts(d?d<0?!b&(s[2]==s[0])?"Circle":"Ellipse":"Hyperbola":"Parabola");}

Less golfed
// Calc determinant of a matrix of side d
// In the golfed code, d is fix to 6
double D(m, d, k)
double*m;
{
    int s = 1, b = 1, x = 0;
    double t = 0;
    for (; x < d; x++, b += b)
        k&b || (
            t += s*m[x] *(k+b+1==1<<d? 1: D(  m + d, d, k + b)), s = -s
        );
    return t;
}

double m[36],d, *t = m + 6, w[6], s[3], a, b, c;
i,u,h;
main()
{
    for (; i++ < 5; )
    {
        scanf("%lf%lf", &a, &b);
        *t++ = a*a, *t++ = a*b, *t++ = b*b, *t++ = a, *t++ = b, *t++ = 1;
    }
    for (u = 4; u; u /= 2)
    {
        m[0] = u & 1, m[1] = u & 2, m[2] = u & 4;
        d = D(m, 6, 0);
        if (d)
            for (h = 0; h < 3; h++)
            {
                for (i = 0; i < 6; i++)
                    w[i] = m[i * 6 + h],
                    m[i * 6 + h] = i ? 0 : u;
                s[h] = D(m, 6, 0)/d;
                for (; i--; )
                    m[i * 6 + h] = w[i];
            }
    }
    a = s[0], b = s[1], c = s[2];
    d = b*b - 4 * a * c;
    puts(d ? d < 0 ? !b&(c == a) ? "Circle" : "Ellipse" : "Hyperbola" : "Parabola");
}

Sage, 247 bytes
def f(p):
 for i in[1,2,4]:
  z=[i&1,i&2,i&4,0,0,0]
  M=matrix([z]+[[x*x,x*y,y*y,x,y,1]for x,y in p])
  try:A,B,C=(M\vector(z))[:3]
  except:continue
  d=B*B-4*A*C
  return['parabola','hyperbola','circle','ellipse'][[d==0,d>0,d<0and B==0and A==C,d<0].index(1)]

Try it online
This function takes an iterable of (x,y) pairs as input, tries computing the discriminant of each of the 3 possible linear systems (A=1, B=1, and C=1), and outputs the type of conic section based on the values of the discriminant, A, B, and C.
There's probably some more golfing to be done, but I'm rusty with Sage and sleepy right now, so I'll work on it more in the morning.

source: Stack Exchange

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

sort: votes


text:
Create a pie chart
The challenge is simple:
Create a pie-chart based on a number of input values.
The input will be a list of positive numbers, decimal or integers, and the output will be a pie-chart where each of the input values are represented by separate colors, and a percentage value outside each of the areas.
Rules:

The colors must be visually distinguishable (the exact colors are optional)
There will be at least two, and maximum 10 input values
The radius of the circle must be in the range [100 300] pixels

Vector graphics are OK as long as the default output gives a radius of [100, 300] pixels

The percentage values shall be integers

There is no strict rule saying where the percentage value shall be placed, but it must be easily seen which area it belongs to
The distance between the closest character and the outer edge of the circle must be in the range [5, 40] pixels
The font is optional

The plot may or may not have black lines separating each region
Functions made for creating pie charts, for instance, MATLAB: pie, Python: matplotlib.pyplot.pie and Mathematica: PieChart are not allowed
Normal rounding rules (up if it's (1.00, 0.5], down if it's (0.5, 0.00))
If the percentage value of a slice is smaller than 0.5%, output 0%. The slice must still be included in the plot.
Please provide plots for examination (or a link to an interpreter). It's enough to show only the plot with 10 input values (to avoid very long answers)

Examples
Please use the example values below. You can convert the lists to an appropriate format using a numeric list converter, for instance this 27 byte one by jimmy23013.
x = [0.3, 1.2]

x = [3, 6, 2, 10]

x = [0.4387, 0.3816, 0.7655, 0.7952, 0.1869, 0.4898, 0.4456, 0.6463, 0.7094, 0.7547]

"The radius of the circle must be in the range [100 300] pixels." Are vector graphics allowed too?

@MartinBüttner, yes. That's OK, as long as the output from the program looks like it's between [100, 300] by default. Is that a sufficient answer?

R rounds 0.5 to 0. Is that a problem?

It's ok to round 0.5 to zero if that's default. But 0.50001 must be rounded to 1.

Mathematica, 186 183 164 bytes
Graphics[{Hue@#,Disk[{0,0},{1,1},a=2Pi{##}],Black,Text[ToString@Round[100(#2-#)]<>"%",5Through@{Cos,Sin}@Mean@a/4]}&@@@Partition[Accumulate[#/Tr@#]~Prepend~0,2,1]]&

Could be golfed further. Currently generates a Graphics object. Test cases:

JavaScript (ES6), 311 310 302 298 bytes
a=>{with(Math)document.write(`<svg height=300>`+a.map(n=>`<path fill=#${(p*4e3|0).toString(16)} d=M135,150L${c(o=100,v=0)}A${[o,o,0,(v=n/=s)+.5|0,0,c(o)]}Z /><text x=${(z=c(135,v/=2))[0]} y=${z[p+=n,1]}>${n*o+.5|0}%</text>`,c=r=>[sin(d=PI*2*(v+p))*r+135,cos(d)*r+150],p=s=0,a.map(n=>s+=n)).join``)}

Saved a byte with help from @Neil!
Explanation
Writes some SVG to the HTML of the current page. Builds the chart with centre point 135 x 150 of radius 100px and text at a radius of 135px from the centre.

var solution =

a=>{
  with(Math)
  document.write(       // write to HTML body
    `<svg height=300>`+ // create 300px x 300px SVG canvas (width defaults to 300px)
    a.map(n=>           // for each number

      // Get the hex colour by multiplying the current position by (roughly) 0xfff
      `<path fill=#${(p*4e3|0).toString(16)

      // Calculate the path of the pie slice
      } d=M135,150L${c(o=100,v=0)}A${[o,o,0,(v=n/=s)+.5|0,0,c(o)]

      // Text
      }Z /><text x=${(z=c(135,v/=2))[0]} y=${z[p+=n,1]}>${n*o+.5|0}%</text>`,

      // Returns [ x, y ] for a certain radius at position v around the pie
      c=r=>[sin(d=PI*2*(v+p))*r+135,cos(d)*r+150],
      p=s=0,             // p = current position around pie (0 - 1)
      a.map(n=>s+=n)     // s = sum of all numbers
    ).join``

    +`</svg>` // <- this is just here for the test, so multiple charts can be displayed
  )
}

// Test
;[
  [0.3, 1.2],
  [3, 6, 2, 10],
  [0.4387, 0.3816, 0.7655, 0.7952, 0.1869, 0.4898, 0.4456, 0.6463, 0.7094, 0.7547]
].map(c=>solution(c));

I think you can save a few bytes using with(Math)c=r=>[sin(d=PI*2*(v+p))*r+135,cos(d)*r+150].

Hmm, you might have to write with(Math)var solution = a=> etc.

Hmm, actually I can use with. I think I might have been in strict mode when I tried it last...

@Neil Got it in there, thanks. I'm pretty sure there's a fair bit more golfing that can be done on this, since I was rushing a bit when I wrote it.

Only saved 1 byte? I guess it's a start...

Python + PIL, 365 355
from math import*;from random import*
from PIL import Image,ImageDraw
L,a,r=256,0,0.8;l,p,c=L/2,L/6,(L,L,L);I=Image.new('RGB',(L,L),c);D=ImageDraw.Draw(I)
x=input()
for i in x:b=a+ceil(360.0*i/sum(x));D.pieslice((p,p,L-p,L-p),int(a),int(b),tuple(map(randrange,c)));t=(a+b)*0.00872;D.text((l+cos(t)*l*r,l+sin(t)*l*r),str(int((b-a)/3.6))+'%',0);a=b
I.show()

Result for the largest example list :

In Python 2, isn't eval(raw_input()) equivalent to Python 2's input()?

@cat yes it is !

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


text:
Build a triangle without any triangles
As a little kid, I liked to play with these toys a lot:

They probably intended for these to be used for art, but I always used them for math! Fractals, patterns, etc. One time, I was given this challenge:

Build a triangle without using any of the green triangle tiles.

This challenge stumped me for the longest time, until I stumbled upon a really beautiful and simple way to do it with just 3 trapezoids:
  /\
 /_/\
/__\_\

Now, take this triangle, and rotate it:
______
\ \__/
 \/ /
  \/

Using these two triangles, we can construct larger triangles out of them. Here is a triangle of height 2:
     /\
    /_/\
   /__\_\
  /\ \__/\
 /_/\/ /_/\
/__\_\/__\_\

And here are triangles of height 3-7:
#3
        /\
       /_/\
      /__\_\
     /\ \__/\
    /_/\/ /_/\
   /__\_\/__\_\
  /\ \__/\ \__/\
 /_/\/ /_/\/ /_/\
/__\_\/__\_\/__\_\

#4
           /\
          /_/\
         /__\_\
        /\ \__/\
       /_/\/ /_/\
      /__\_\/__\_\
     /\ \__/\ \__/\
    /_/\/ /_/\/ /_/\
   /__\_\/__\_\/__\_\
  /\ \__/\ \__/\ \__/\
 /_/\/ /_/\/ /_/\/ /_/\
/__\_\/__\_\/__\_\/__\_\

#5
              /\
             /_/\
            /__\_\
           /\ \__/\
          /_/\/ /_/\
         /__\_\/__\_\
        /\ \__/\ \__/\
       /_/\/ /_/\/ /_/\
      /__\_\/__\_\/__\_\
     /\ \__/\ \__/\ \__/\
    /_/\/ /_/\/ /_/\/ /_/\
   /__\_\/__\_\/__\_\/__\_\
  /\ \__/\ \__/\ \__/\ \__/\
 /_/\/ /_/\/ /_/\/ /_/\/ /_/\
/__\_\/__\_\/__\_\/__\_\/__\_\

#6
                 /\
                /_/\
               /__\_\
              /\ \__/\
             /_/\/ /_/\
            /__\_\/__\_\
           /\ \__/\ \__/\
          /_/\/ /_/\/ /_/\
         /__\_\/__\_\/__\_\
        /\ \__/\ \__/\ \__/\
       /_/\/ /_/\/ /_/\/ /_/\
      /__\_\/__\_\/__\_\/__\_\
     /\ \__/\ \__/\ \__/\ \__/\
    /_/\/ /_/\/ /_/\/ /_/\/ /_/\
   /__\_\/__\_\/__\_\/__\_\/__\_\
  /\ \__/\ \__/\ \__/\ \__/\ \__/\
 /_/\/ /_/\/ /_/\/ /_/\/ /_/\/ /_/\
/__\_\/__\_\/__\_\/__\_\/__\_\/__\_\

#7
                    /\
                   /_/\
                  /__\_\
                 /\ \__/\
                /_/\/ /_/\
               /__\_\/__\_\
              /\ \__/\ \__/\
             /_/\/ /_/\/ /_/\
            /__\_\/__\_\/__\_\
           /\ \__/\ \__/\ \__/\
          /_/\/ /_/\/ /_/\/ /_/\
         /__\_\/__\_\/__\_\/__\_\
        /\ \__/\ \__/\ \__/\ \__/\
       /_/\/ /_/\/ /_/\/ /_/\/ /_/\
      /__\_\/__\_\/__\_\/__\_\/__\_\
     /\ \__/\ \__/\ \__/\ \__/\ \__/\
    /_/\/ /_/\/ /_/\/ /_/\/ /_/\/ /_/\
   /__\_\/__\_\/__\_\/__\_\/__\_\/__\_\
  /\ \__/\ \__/\ \__/\ \__/\ \__/\ \__/\
 /_/\/ /_/\/ /_/\/ /_/\/ /_/\/ /_/\/ /_/\
/__\_\/__\_\/__\_\/__\_\/__\_\/__\_\/__\_\

The Challenge
Write a program or function that takes a number n and prints a triangle-less triangle of height n. Trailing spaces on each line is acceptable, and up to one trailing or leading newline is also acceptable. IO can be in any reasonable format. The input is guarenteed to be a positive integer, so you don't have to worry about negative numbers, decimals, non-numbers etc.
Shortest answer in bytes wins!

Try making more trapezoids out of the trapezoids. Lengths 2 and 3 are definitely possible (and by extension, all numbers of the form 2^a*3^b) (How do I know? Played with the same kind of blocks when I was a kid.)

@CatsAreFluffy Well, since you can make a trapezoid out of triangles, you can conclude that you can make trapezoids out of trapezoids. In fact, if you look at the triangles of height 3 and 7, you can kinda see the same pattern repeated with large trapezoids.

This challenge is really cool. I enjoyed figuring out how to do this in Retina.

@mbomb007 Glad to hear you enjoyed it! =D That's exactly why I write challenges.

This challenge fits perfectly on the screen with the mobile app. Was that intentional? :)

I wonder if there's a way to make the larger triangles without using any of the smaller triangles...

CJam, 47
ri_"/__\_\/_/\/ /\ \__"6/f**eeW%{_S.*s\~,\-<N}/

Explanation:
ri_       read the input, convert to integer and duplicate
"…"       push that string, containing the repeating pattern
           (3 lines in reverse order, concatenated)
6/        split into (3) lines of 6 characters
f*        multiply (repeat) each line n times
*         repeat the array of 3 lines n times
           at this point we have an array of 3*n strings with 6*n characters each
ee        enumerate the array (obtaining an array of [index string] pairs)
W%        reverse the array
           (so the lines are in correct order and indices in reverse order)
{…}/      for each [index string] pair
  _       duplicate the pair
  S.*     vectorized-multiply with " "
           this effectively replaces the index with a string of <index> spaces
  s       convert the pair to string, effectively concatenating the spaces
           with the string
  \       swap with the other copy of the [index string] pair
  ~,      dump the index and string on the stack and get the string length
  \-      subtract the index from it - this is the desired line length
  <       cut the concatenated string to that length
  N       add a newline

Try it online

Ruby, 79
->n{1.upto(n*=3){|i|puts (' '*(n-i)).ljust(n+i,'/__\_\/\ \__/_/\/ '[i%3*6,6])}}

A. (-4 bytes, -1 +1) changed from 0-indexed (.times) to 1-indexed (1.upto)
B. (-5 bytes) changed from array of three 6-char strings to selection of 6-char substring of 18-char string.
C. (-1 byte) m=n*3 -> n*=3
D. (-5 bytes) reduced all five double backslashes to single backslashes (partly made possible by reordering of string required for point A)
Ruby, 94
->n{(m=n*3).times{|i|puts (' '*(m-i-1)).ljust(m+i+1,[ '/\\ \\__','/_/\\/ ','/__\\_\\'][i%3])}}

explanation
The basic unit is a 3x6 diamond as follows (last character on each row duplicated for clarity:)
    /\ \__/
   /_/\/ /
  /__\_\/

All we need to do is display a suitable window of this pattern. Ruby's ljust allows you to pad with any string, not just spaces. Normally ljust would be used to pad a string of printable characters by adding spaces at the end, but here we use it in reverse: to pad a string of spaces by adding printable characters at the end.
ungolfed in test program
f=->n{
  (m=n*3).times{|i|                  #for each line of the triangle
    puts (' '*(m-i-1)).              #print m-i-1 spaces,
      ljust(m+i+1,[ '/\\ \\__',      #left justified and padded to total length m+i+1
                   '/_/\\/ ',        #by one of these three strings
                  '/__\\_\\'][i%3])
  }
}

f[gets.to_i]

@mbomb007 It's the first time I've had that complaint. As an engineer, I'm used to putting revisions on everything This is a fairly simple challenge and the improvements are quite trivial, so I've gone ahead and deleted the revision letters.I think leaving the original code up is good or at least does no harm, as it's easier to follow than the current version.

The code size usually uniquely identifies any revision, but the revision history is also available for anyone viewing the edit history.

Retina, 150 122 118 bytes
The output to this challenge looks awesome, by the way!
Input is in unary. The output contains a trailing linefeed. The code uses ISO 8859-1 encoding. Note the trailing space on the penultimate line.
(?=_\\¶.*1)
_\/__\
(?=/_/\\¶.*1)
/_/\/
(^|__)(?=/\\¶.*1)
$1/\ \__
ms}`(.*1*)1
/\¶/_/\¶/__\_\¶$1
m`^(?=(.*¶)*.)
$#1$*

Try it online
Explanation
If you want a more in-depth explanation, comment or message me in chat.
(?=_\\¶.*1)                     # Matches the start of the 3rd line of every triangle
/__\_\                          #   and prepends another layer if needed
(?=/_/\\¶.*1)                   # 2nd line of each triangle
/_/\/
(^|__)(?=/\\¶.*1)               # 1st line of each triangle
$1/\ \__
ms}`(.*1*)1                 # This and above in a multi-single-line loop.
/\¶/_/\¶/__\_\¶$1               #   This stage adds a flattened triangle on top
m`^(?=(.*¶)*.)                  # Prepend a space for every line following -1
$#1$*

Thanks to Martin for golfing 32 bytes off.

#Tarmo's ascii printing language, 46 bytes.
1  /\| /_/\|/__\_\2 \__|/ 0n{n-a-1{~}1a{2#1}$}

Just by looking to such odd programming languages like CJam, it's makes me bit dizzy how complex, unnatural and cryptic language can be, that I wanted to "boldly go where no man has gone before", and invent my own language. As a result I've created my own language for ascii patterns printing.
Basic idea is that you can define first patten and then printing - using same kind of character '1' or '2' or whatever number - you can define your own print pattern.
Once pattern is defined (Starts from number till number end) - next numbers will execute pattern printing.
For example
1  /\| /_/\|/__\_\01

Outputs like this:
  /\
 /_/\
/__\_\

Will define pattern 1 and then print it right away.
Pattern is defined everything separated with '|' character.
0 at the end - acts like pattern termination.
Special characters like '$' are reserved as line-feed, and '~' is reserved for spacing - half - of specific pattern.
1  /\| /_/\|/__\_\01$~11$~1~11

Will outputs text like this:
  /\
 /_/\
/__\_\
     /\
    /_/\
   /__\_\
        /\
       /_/\
      /__\_\

Next goes for-loops. That one needs to be easily visible - so I've retained {} brackets for for-loops, but variable names are auto-named - so first bracket will use 'a' variable, second 'b' and so on. Iteration will go always from 0 to specific number - and that number is defined before {} brackets.
'n' is reserved variable for whole function input.
So code:
1  /\| /_/\|/__\_\0n{1$}

Will outputs ( With n == 4 ):
  /\
 /_/\
/__\_\
  /\
 /_/\
/__\_\
  /\
 /_/\
/__\_\
  /\
 /_/\
/__\_\

And '#' is special modifier for trim lead whitespace.
And finally whole solution:
DrawPatterns.cs:
using System;
using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using Microsoft.CSharp;

class DrawPatterns
{
//Command line parameters - for example like this: "1  /\| /_/\|/__\_\2 \__|/ 0n{n-a-1{~}1a{2#1}$}" 3
    static Dictionary<char, String[]> patterns = new Dictionary<char,string[]>();

    static string Tabs(int n)
    {
        if( n < 0 ) n = 0;

        String r = "";

        for( int i = 0; i < n ; i++ )
            r += "    ";

        return r;
    }

    static int[] left = new int[10];
    static int top = Console.CursorTop;
    static int lastTop = Console.CursorTop;

    static public void DoPrint(char c, char modifier = ' ')
    {
        if (c == '$')
        {
            for (int i = 0; i < left.Length; i++)
                left[i] = 0;
            top = lastTop + 1;
            return;
        }

        if (!patterns.ContainsKey(c))
            return;

        if (modifier == '½' || modifier == '~')
        {
            int maxSize = patterns[c].Select(x => x.Length).Max();
            for( int i = 0; i < left.Length; i++ )
                left[i] += maxSize / 2;
            return;
        }

        int iLine = 0;
        foreach (var l in patterns[c])
        {
            Console.SetCursorPosition(left[iLine], top + iLine);
            if( top + iLine > lastTop )
                lastTop = top + iLine;

            String s = l;
            if (modifier == '#')
                s = s.TrimStart(' ');

            Console.WriteLine(s);
            left[iLine] += s.Length;
            iLine++;
        }
    }

    static void Main(string[] _args)
    {
        List<String> args = _args.ToList();
        String todo = "";
        String code = "";
        char nextVar = 'a';
        String lf = "\r\n";
        int align = 1;
        char lastModifier = ' ';
        int nextArg = 1;
        Dictionary<String, String> argValues = new Dictionary<string,string>();
        bool bDebug = false;

        if (args.Count != 0 && args[0].ToLower() == "-d")
        {
            bDebug = true;
            args.RemoveAt(0);
        }

        if (args.Count == 0)
        {
            Console.WriteLine("Usage: DrawPatterns.cs [options] \"script\" <arguments to script>");
            Console.WriteLine("[options] allowed:");
            Console.WriteLine("-d - debug");
            return;
        }

        String prog = args[0];

        for( int i = 0; i < prog.Length; i++ )
        {
            char c = prog[i];

            // Define pattern.
            if (c >= '0' && c <= '9' && !patterns.ContainsKey(c))
            {
                String p = Regex.Match(prog.Substring(i + 1), "[^0-9]*").Groups[0].Value;
                patterns[c] = p.Split('|');
                i += p.Length;
                if( prog[i + 1] == '0' ) i++;
                continue;
            }

            String procRemain = prog.Substring(i);
            // modifier specified, but pattern number is not provided - use first pattern.
            if( lastModifier != ' ' && ( c < '0' || c > '9' ) )
            {
                code += Tabs(align);
                code += "print('1' , '" + lastModifier + "');" + lf;
                lastModifier = ' ';
            }

            switch ( c )
            {
                case '{':
                    code += Tabs(align);
                    code += "for ( int " + nextVar + " = 0; " + nextVar + " < " + todo + " ; " + nextVar + "++ )" + lf;

                    //  Check for all variable names if they can be used in program.
                    foreach ( var m in Regex.Matches(todo, "[a-zA-Z_][a-zA-Z0-9_]*", RegexOptions.Singleline) )
                    {
                        String varName = m.ToString();

                        if( varName.Length == 1 && varName[0] <= nextVar )
                            // Already declared as a loop.
                            continue;

                        if( argValues.ContainsKey(varName ) )
                            continue;

                        if( nextArg >= args.Count )
                        {
                            Console.WriteLine("Insufficient parameters provided to script - argument '" + varName + "' value is needed");
                            return;
                        }

                        argValues[varName] = args[nextArg];
                        nextArg++;
                    }

                    code += Tabs(align);
                    code += "{" + lf;
                    nextVar++;
                    todo = "";
                    align++;
                    break;

                case '}':
                    align--;
                    code += Tabs(align);
                    code += "}" + lf;
                    break;

                default:
                    if (((c >= '0' && c <= '9') || c == '<' || c == '$') && todo == "")
                    {
                        code += Tabs(align);
                        code += "print('" + c + "' , '" + lastModifier + "');" + lf;
                        lastModifier = ' ';
                        continue;
                    }

                    if (c == '½' || c == '~' || c == '#')
                    {
                        lastModifier = c;
                        continue;
                    }

                    if( c == '\r' || c == '\n' )
                        continue;

                    todo += c;
                    break;
            }

        } //for

        String code2 = "";
        code2 += "using System;" + lf;
        code2 += "public class ExecClass { static void Exec( Action<char, char> print";

        object[] invokeArgs = new object[ argValues.Count+1];
        invokeArgs[0] = new Action<char, char>(DoPrint);
        int iValueIndex = 1;

        foreach ( var kv in argValues )
        {
            code2 += ",";
            code2 += "int " + kv.Key;
            invokeArgs[iValueIndex] = Int32.Parse(kv.Value);
            iValueIndex++;
        }

        code2 += ") {" + lf;
        code2 += code;
        code2 += "} };";

        if( bDebug )
        {
            int line = 1;
            String lineNumberedCode =Regex.Replace(code2, "^(.*)$",
                delegate(Match m) { return (line++).ToString("d2") + ": " + m.Value; },
                RegexOptions.Multiline
            );
            Console.WriteLine(lineNumberedCode);
            Console.WriteLine();
            Console.WriteLine();
        }

        left[0] = Console.CursorLeft;
        for( int i = 1; i < left.Length; i++ )
            left[i] = left[0];
        top = Console.CursorTop;

        try
        {
            var compileResult = new CSharpCodeProvider().CompileAssemblyFromSource( new CompilerParameters() { GenerateExecutable = false, GenerateInMemory = true }, code2);
            if (compileResult.Errors.HasErrors)
            {
                foreach (CompilerError ce in compileResult.Errors)
                {
                    if (ce.IsWarning) continue;
                    Console.WriteLine("{0}({1},{2}: error {3}: {4}", ce.FileName, ce.Line, ce.Column, ce.ErrorNumber, ce.ErrorText);
                }
                return;
            }

            var method = compileResult.CompiledAssembly.GetType("ExecClass").GetMethod("Exec", System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic);
            method.Invoke(null, invokeArgs);

        }
        catch (Exception ex)
        {
            Console.WriteLine(ex.Message);
        }

        Console.SetCursorPosition(1, lastTop);
        Console.WriteLine();
        Console.WriteLine();
    } //Main
}

With command line arguments like this:
-d "1  /| //|/___\2 _|/ 0n{n-a-1{½}1a{2#1}$}" 3
Will outputs this:
01: using System;
02: public class ExecClass { static void Exec( Action<char, char> print,int n) {
03:     for ( int a = 0; a < n ; a++ )
04:     {
05:         for ( int b = 0; b < n-a-1 ; b++ )
06:         {
07:             print('1' , '~');
08:         }
09:         print('1' , ' ');
10:         for ( int c = 0; c < a ; c++ )
11:         {
12:             print('2' , ' ');
13:             print('1' , '#');
14:         }
15:         print('$' , ' ');
16:     }
17: } };

        /\
       /_/\
      /__\_\
     /\ \__/\
    /_/\/ /_/\
   /__\_\/__\_\
  /\ \__/\ \__/\
 /_/\/ /_/\/ /_/\
/__\_\/__\_\/__\_\

That's really awesome! You should put that up on Github and encourage people to use it!

Language depends on problem domain, and I didn't know such problem existed before I've read it from here. I'll guess I've could code language earlier if I've hit similar problem already. :) Anyway, by harvesting this site I've understood that CJam is quite "normal" language in here. :)

Also, you need to post a link to the github or an interpreter for this language. If no interpreter exists, then this answer is not valid.

Is C# script ok for you: http://www.csscript.net/ ?
I guess it's runs in windows, should be theoretically portable to any os, but I haven't tested by myself.

JavaScript (ES6), 119 bytes
n=>`,/\\ \\__,/_/\\/ ,/__\\_\\`[r=`repeat`](n).split`,`.map((s,i)=>` `[r](n*3-i)+s[r](n).slice(0,i*2)).slice(1).join`\n`

Where \n represents the literal newline character. If a leading line with n*3 spaces and a newline is acceptable then the .slice(1) can be removed for a saving of 9 bytes.

Python 2, 118 bytes
def f(n,s=["/\\ \\__","/_/\\/ ","/__\\_\\"]):
 print'\n'.join(map(lambda x:' '*(n*3-x)+(n*s[x%3])[:x*2+2],range(n*3)))

Similar approach to Level River St's Ruby answer.
Try it online

Python 2, 142 bytes
def f(n,m):return f(n-1,m+3)+[' '*(m+x)+(y*n)[x*2:]for x,y in((2,' \\__/\\'),(1,'/ /_/\\'),(0,'/__\\_\\'))]if n else[]
print '\n'.join(f(n,0))

The principle is very similar to other answers: take three repeated strings and then layer them in such a way that you only need to trim some of them to get the triangle, then pad them on the left.

C++, 395 Bytes
First time code golf with a glorious size of 395 bytes in C++. In my case, it feels a little like a contest for obfuscation : D
#include <iostream>
#include <cstring>
#define A for (int k=0;k<((s-(i+1))*3+(2-j));k++) cout<<" ";
using namespace std; string t[3]={"/\\","/_/\\","/__\\_\\"};string r[2]={" \\__","/ "};int tr=3;int main(int,char**argv){int s=atoi(argv[1]);for(int i=0;i<s;i++){for(int j=0;j<tr;j++){A for(int l=1;l<=2*(i+1)-1;l++){if((l%2)==0&&(j<2)){cout<<r[j];}else if ((l%2)==1)cout<<t[j];}A cout<<endl;}}}

Pyth, 66 bytes
jmj+L**3-Qhd\ [+*2;j" \\__"*Jhd]"/\\"+;j"/ "*J]"/_/\\"*J"/__\\_\\"

Try it online!

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


text:
Substitution cipher
A substitution cipher is an encoding method where each letter in the alphabet is replaced with a fixed, different one; for example, given the following substitution map:
abcdefghijklmnopqrstuvwxyz
            ||
qwertyuiopasdfghjklzxcvbnm

The phrase "we all love cryptography" would be encoded as "vt qss sgct eknhzgukqhin".
The program will continuously read its input, one line at time; the first line will contain the substitution map, in the form of all 26 letters, in any order, without repetitions, missing letters or extraneous characters; it will be interpreted as "the first letter is the substitution for A, the second letter is the substitution for B [...] the 26th letter is the substitution for Z"; no output will be provided after reading it.
For each subsequent line, the program will output the encoded text corresponding to the line. Only letters will be encoded; numbers, symbols and whitespaces will be simply copied to the output.
For simplicity, all input (including the substitution map) will only contain lowercase characters.
Sample input:
qwertyuiopasdfghjklzxcvbnm
hello
bye!
i don't know.

Sample output:
itssg
wnt!
o rgf'z afgv.

As usual, the shortest solution wins.

Additional clarifications on input:

The program must read its input stream (I thought that was clear); command line parameters, files, named pipes, network sockets, quantum entanglement or extra sensorial perceptions are not allowed.
The input must include only the actual text to be processed; quotes, brackets, commas or any other symbol, if found, should simply be copied to the output as they are.
No additional characters should be required in the input. If your program requires the input text to be placed in quotes, brackets, commas or any other delimiter, then You Are Doing It Wrong (TM).
"Line" is defined as a string of characters followed by a newline; the actual implementation of "newline" if usually left to the OS, but if you need to go into its details, just use whatever you prefer.
An empty line is no special case; the program could either print an empty line or do nothing, but it should not print any actual text, crash, exit, destroy the operating system, set fire to the house, collapse the Sun in a black hole, summon demons from other planes of existence or replace your toothpaste with mayonnaise.
There is no requirement for the program to run interactively; it's free to suck all its input in and then print all its output; there is also not any time limit on its execution, although it would be definitely preferable for it to terminate before the heat death of the universe.

Exiting with crash (after producing the correct output) is allowed by default. Does your edit "should not crash" rule that out? Because in that case you may be breaking some already posted answers. Also, I suggest you remove the black-hole and toothpaste stuff, as it adds nothing to the challenge

@LuisMendo If the program exits with a crash after the input is exhausted and the correct output is procuced, then yes, it's ok.

I thought the input format was specified very clearly; I didn't know it's considered usual practice here to rearrange input as needed. However, I saw the question lose several points after some people complained about the rules on the input format, so clearly someone got quite upset on this. Sorry, I didn't mean any harm.

But please, when a question clearly specifies the input format for the required program, just don't go assuming you can change it at will... and then complain if your answer is rejected.

@Massimo Arbitrarily overriding the defaults by not allowing a function and requiring a cumbersome input format are both considered things to avoid. The rules are ultimately up to you, but don't be surprised to get downvotes if your the community believes your challenge needlessly restricts participation. Note that some languages simply cannot do IO loops.

@Massimo Furthermore, saying thing like "If your program requires the input text to be placed in quotes, brackets, commas or any other delimiter, then You Are Doing It Wrong (TM)" is needlessly confrontational and contrarian, as the community has discussed and decided to allow such things in general. Again, you can override them, but expect a poor reaction, as there seems to be no good reason. Perhaps you have experience with other golfing sites that do expect exact inputs, but that's not how we work around here. I suggest you stick around a bit and get a sense of the usual rules and culture.

You don't have to quit. Making good questions is hard, but you can still answer them. Also, I wonder why nobody's mentioned the sandbox, where you can post questions and get comments. So yeah, pull out your compiler/interpreter/whateverer and get golfing!

@CatsAreFluffy I seriously didn't mean any harm, nor I wanted to start discussions or flame wars; I simply posted a challenge question like there are many... starting an argument about I/O formats was exactly not what I was looking for. This is definitely not the experience I was expecting from this site.

Hi Massimo, sorry your first experience as a challenge author was so negative. As you've noticed, the community has grown accustomed to certain freedoms regarding I/O, submission format, etc. It's one of the not-so-obvious facets of this site that unfortunately adds another hurdle to writing a challenge. We have a Sandbox for Proposed Challenges where folks can post their challenge ideas and get (usually more constructive) feedback before going live. I certainly hope you'll stick around and continue to write challenges!

If you have any questions about how the site works, I encourage you to ask on Meta or join us in chat and we'll try to help however we can. Thanks for being a member of the community and again I hope you'll stay.

Convex, 4 6 5 bytes
Crossed out 4 is still regular 4 :(
Note: As @Dennis pointed out, the input format I was using was not up to spec. This version should comply with the new rules, though.
lqT@Ë

Try it online
Explanation:
l       Read a line from input
 q      Read the rest of the input
  T     Push lowercase alphabet ("abcdefghijklmnopqrstuvwxyz")
   @    Rotate the top 3 items on the stack.
    er  Transliterate
        Implied output

Thanks to @LuisMendo for pointing out an error in the program

Nicely done, especially with your own language! Now let's wait for Dennis to beat this with Jelly.

Struck out 4 is still regular 4 ;(

Added a link to http://codegolf.stackexchange.com/a/73584/48836 :P

Pyth, 7 bytes
V.zXNGz

Try it online!
How it works:
V.zXNGz
        G = "abcdefghijklmnopqrstuvwxyz"
        z = input()
V.z     for N in all_input():
   XNGz     N.translate(G,z)    <--- automatically printed

It looks like with the new rules invalidate your submission, unfortunately. Quotes can't be included in the input like yours does. Don't worry, the new rules affected me too :P

@GamrCorps Updated.

JavaScript ES6, 65 62 49 bytes
Saved 2 bytes thanks to Neil.
(a,i)=>a.replace(/./g,x=>i[x.charCodeAt()-97]||x)

Takes an string of lines a and a dictionary i.

Use [...s] instead of s.split\``.

@Neil Ah, yes, of course.

On second thoughts, s.replace(/./g,x=>...) might be shorter still.

@Neil That would make it four bytes longer, no?

@Neil Is that what you meant?

Well, I meant instead of the split/join, but that works too, if it's an acceptable input format.

@Neil It should be, as that's how the examples are given.

CJam, 12 8 bytes
4 bytes saved thanks to Dennis!
l_$q\@er

Try it online!
Explanation
l        e# read a line
_$       e# fancy way to obtain string "abc...z". Thanks to Dennis!
q        e# read the rest of input as a string with newlines
\@       e# swap, rotate
er       e# transliterate. Implicit display

@Dennis That's very clever!

sh + coreutils, 16 bytes
read s;tr a-z $s

15 bytes if input is from a terminal:
tr a-z `sed 1q`

That won't work. sed will close the stream. (At least it does on my machine.)

@Dennis Ugh, it works when you type it in at the terminal...

Oh, I hadn't thought about that possibility...

05AB1E, 5 bytes
Code:
[A¹‡,

Explanation:
[      # Start an infinite loop.
 A     # Push the lowercase alphabet.
  ¹    # Push the first input (substitution map).
   ‡   # Transliterate. Since the arity of this function is 3 and there are only 2 values
                        on the stack, it implicitly takes a line of input.
    ,  # Pop and print.

So this continually reads a line of input and prints a line of input after. Uses CP-1252 encoding. This is what I got with the console version:
D:\Golfing\05AB1E>C:\Python34\python.exe 05AB1E.py test.abe
qwertyuiopasdfghjklzxcvbnm
hello
itssg
welcome
vtsegdt
greetings, planet!
ukttzoful, hsqftz!

Trying this online might be a bit weird, since 05AB1E is trying to read another line of input, but there is none, so you need to kill it to receive output (doesn't work all the time). It might be a better idea to do this with the console version of 05AB1E. Try it online!.

JavaScript 89
for(i=prompt,x=i(),n='';p=i();n+=p.replace(/./g,m=>x[m.charCodeAt(0)-97])+"\n");
alert(n)

Ruby, 35 31 29 bytes
Credit to @QPaysTaxes for the $_ trick, I had assumed that reading more from the STDIN object $< would change that variable, but it doesn't.
gets
$><<$<.read.tr('a-z',$_)

String#tr is basically a cipher substitution function, making things quite simple.

Because you only use c once, you can replace it with gets. Also, I'm not sure if it would work, but you could try replacing {|l| with ->l{.

You can't use it with gets because you're looping through an iterable with map and gets gets data from STDIN each time it's called. Bonus points because $< is the STDIN stream, making things potentially even more hectic. As for the arrow notation, it doesn't save bytes, and IIRC a lambda defined that way needs & in front of the procedure to make it work?

Oops, you're right. I wasn't paying attention to the function. What you can do is save a byte by just calling gets -- not assigning -- then using $_. As for the lambda notation, I'm not sure. I've almost never used it.

Thanks for the tip! I was able to find more tricks to further save bytes as well.

MATL, 14 bytes
jXKx`jHY2KXEDT

The program exits with an error after producing the correct output (allowed by default).
Try it online

A single newline is not defined as EOI; if it's found in input, the program should simply not print anything and keep looping until input actually ends.

@Massimo Corrected

Python 3, 50 bytes
lambda s,k:s.translate(dict(zip(range(97,122),k)))

Or if we really have to implement an infinite loop:
Python 3, 70 bytes
t=dict(zip(range(97,122),input()))
while 1:print(input().translate(t))

I think you have to take a list of strings instead of one string as input.

Pyth, 34 Bytes 31 Bytes 29 Bytes 27 Bytes
Saved 3 5 7 bytes thanks to Kenny Lau
jmsm?&<JCk123>J96@hQ-J97kdt

Try it out!

You can use V instead of Fd (but you'll have to change the variable names afterwards) :)

You can also save 2 bytes by changing ?XpYpZ to p?XYZ.

An array of strings is not the proper input format.

Factor, 155 bytes
The logic is actually pretty simple, it's just constraining to the REPL requirement that costs.
[let "abcdefghijklmnopqrstuvwxyz" readln string>array bi@ zip :> T [ t ] [ T readln string>array [ dup T key? [ T at ] [ ] if ] map "" join print ] while ]

Readable single-function version (don't ever write code like this):
:: monolithic-repl ( -- )
    "abcdefghijklmnopqrstuvwxyz" readln string>array bi@ zip
  :> table
  [ t ]
  [ table readln string>array
    [ dup table key?
      [ table at ] [ ] if
    ] map
    "" join print
  ] while ;

Readable, Factored version:
:: cipher-print ( cipher-table -- )
  readln string>array
  [ dup cipher-table key? [ cipher-table at ] [ ] if ] map
  "" join print ;

: cipher-get ( -- cipher )
  "abcdefghijklmnopqrstuvwxyz" readln
  string>array bi@ zip ;

:: cipher-repl ( -- )
  cipher-get :> table
  [ t ] [ table cipher-print ] while ;

C++, 154 Bytes
#include <iostream.h>
#include "string.h"
using namespace std;

void encript_string() {
char en[26],in[1024];
string s=cin.getline();
strcpy(en,s.c_str());
while(1){
 s=cin.get_line();
 strcpy(in,s.c_str());
 int i=0,m=0;
 while(in[i] != 10) {
  m=in[i]-97;
  cout<<en[m];
 }
 cout<<"\n";
}
}

This is a snippet, which is not allowed by our rules. Submissions must be functions or full programs.

Why it displays in same line ?? (Removes new line character ?)

This answer isn't valid because you're missing necessary header includes like iostream and string.

I seem to be getting errors from this


text:
Find the area of a polygon
Given consecutive side lengths s1, s2, s3... s_n of an n-gon inscribed in a circle, find its area. You may assume that the polygon exists. In addition, the polygon will be convex and not self-intersecting, which is enough to guarantee uniqueness. Built-ins that specifically solve this challenge, as well as built-in functions that calculate the circumradius or circumcenter, are banned (this is different from a previous version of this challenge).
Input: The side lengths of the cyclic polygon; may be taken as parameters to a function, stdin, etc.
Output: The area of the polygon.
The answer should be accurate to 6 decimal places and must run within 20 seconds on a reasonable laptop.
This is code golf so shortest code wins!
Specific test cases:
[3, 4, 5] --> 6
[3, 4, 6] --> 5.332682251925386
[3, 4, 6, 7] --> 22.44994432064365
[5, 5, 5, 5] --> 25
[6, 6, 6, 6, 6] --> 61.93718642120281
[6.974973020933265, 2.2393294197257387, 5.158285083300981, 1.4845682771595603, 3.5957940796134173] --> 21.958390804292847
[7.353566082457831, 12.271766915518073, 8.453884922273897, 9.879017670784675, 9.493366404245332, 1.2050010402321778] --> 162.27641678140589

Test case generator:

function randPolygon(n) {
  var left = 2 * Math.PI;
  var angles = [];
  for (var i = 0; i < n - 1; ++i) {
    var r = Math.random() * left;
    angles.push(r);
    left -= r;
  }
  angles.push(left);
  var area = 0;
  var radius = 1 + Math.random() * 9;
  for (var i = 0; i < angles.length; ++i) area += radius * radius * Math.sin(angles[i]) / 2;
  var sideLens = angles.map(function(a) {
    return Math.sin(a / 2) * radius * 2;
  });

  document.querySelector("#radius").innerHTML = radius;
  document.querySelector("#angles").innerHTML = "[" + angles.join(", ") + "]";
  document.querySelector("#inp").innerHTML = "[" + sideLens.join(", ") + "]";
  document.querySelector("#out").innerHTML = area;

  draw(angles);
}

function draw(angles) {
  var canv = document.querySelector("#diagram"),
    ctx = canv.getContext("2d");
  var size = canv.width
  ctx.clearRect(0, 0, size, size);
  ctx.beginPath();
  ctx.arc(size / 2, size / 2, size / 2, 0, 2 * Math.PI, true);
  ctx.stroke();
  ctx.beginPath();
  ctx.moveTo(size, size / 2);
  var runningTotal = 0;
  for (var i = 0; i < angles.length; ++i) {
    runningTotal += angles[i];
    var x = Math.cos(runningTotal) * size / 2 + size / 2;
    var y = Math.sin(runningTotal) * size / 2 + size / 2;
    ctx.lineTo(x, y);
  }
  ctx.stroke();
}
document.querySelector("#gen").onclick = function() {
  randPolygon(parseInt(document.querySelector("#sideLens").value, 10));
}

These are to help you; they are not part of the input or output.

  Circumradius:

  Angles, in radians, of each sector (this are NOT the angles of the polygon):

  Input:

  Output:

  Diagram:

  <canvas id="diagram" width="200" height="200" style="border:1px solid black"></canvas>

Number of side lengths:
<input type="number" id="sideLens" step="1" min="3" value="3" />

<button id="gen">Generate test case</button>

I know an easy way to find its perimeter.

I know an easy way to find the number of sides

This problem is pretty easy given the circumradius, but without it it's incredibly difficult.

It's also easy if there are fewer than five sides, not that it matters in code golf.

Python 2, 195 191 bytes
from math import*
C=sorted(input());l,h=0,1/max(C)
while h-l>2e-16:m=(l+h)/2;a=[asin(c*m)for c in C[:-1]];f=pi-sum(a);l,h=[l,m,h][sin(f)/m>C[-1]:][:2]
print sum(sin(2*t)/l/l for t in a+[f])/8

Uses a binary search to find the inverse diameter, then calculates the area of each segment by the angle/radius.
It finds the radius by first summing all but the largest chord angle, and checking the remaining angle to the remaining chord. Those angles are then also used to compute the area of each segment. A segment's area can be negative, if it's angle is bigger than 180 degrees. We do a binary search over the inverse diameter so the domain is bounded and well-behaved.
Readable implementation:
def segment_angles(line_segments, invd):
    return [2*math.asin(c*invd) for c in line_segments]

def cyclic_ngon_area(line_segments):
    line_segments = list(sorted(line_segments))
    lo, hi = 0, 1/max(line_segments)
    while hi - lo > 2e-16:
        mid = (lo + hi) / 2
        angles = segment_angles(line_segments[:-1], mid)
        angles.append(2*math.pi - sum(angles))
        if math.sin(angles[-1]/2) / mid > line_segments[-1]:
            lo = mid
        else:
            hi = mid
    return sum([math.sin(a)/lo/lo/8 for a in angles])

Does this work if the center is outside the polygon? (For example, a triangle with side lengths 6, 7, 12). Sometimes the sqrt(4**2 - c**2/4) needs to be negative, when the angle is greater than pi.

@soktinpk I fixed my answer.

The code gives wrong results for the input [1000000, 1000000, 1999999]. The exact result for this test is 1999999*sqrt(3999999)/4 = 999999375.0000546875...

@HugoPfoertner I fixed it by squaring the initial hi estimate, at the cost of 3 bytes.

Squaring the perimeter does not eliminate the problem that arises in polygon degeneracy when the longest side approaches the sum of the smaller sides. Then the radius can be arbitrarily large. I have now described this in more detail in the explanation of my program. Try the example [0.25, 0.25, 0.499999]. Your program returns 0.0077512398... instead of the correct result ~= 0.000125. Test cases using Mathematica: Table [ResourceFunction["HeronFormula"][{1/4,1/4,1/2-1/10^n}]+0.,{n,1,9} ] -> {0.03, 0.0121886, 0.00394297, 0.00124969, 0.000395275, 0.000125, 0.0000395285, 0.0000125,3.95285*10^-6}

@HugoPfoertner Right, it's unbounded. I fixed my answer by instead doing a binary search over the inverse diameter, which lies in (0, 1/max(edges)]. There's still numerical precision loss, but it should give 6 significant digits of precision for reasonable-sized inputs.

@orlp: It's okay now; the specification of the OP is potentially ambiguous with "accurate to 6 decimal places". He probably had "6 significant digits" in mind. I suspect that he overlooked the possibility of degeneracy, otherwise the test examples would have included one or two with this property.

PARI/GP, 182 bytes
A(v)=n=#s=vecsort(v);g=1^s;h=sum(k=1,n-1,asin(s[k]/S=s[n]))<Pi/2;g[n]-=2*h;d=solve(D=S,S/(vecsum(s)/2/S-1),sum(k=1,n,g[k]*asin(s[k]/D))-Pi*!h);sum(k=1,n,g[k]*s[k]*sqrt(d^2-s[k]^2))/4

Using @alephalpha's hints that global variables can be used and his improved chained assignments, significantly shorter code is possible. Also an unnecessary factor 8 in calculation of Dmax was removed.
Version with comments
AreaCyclicPolygon(VectorofSidelenghts) =
{
  my( s = vecsort(VectorofSidelenghts), \\ allows access to longest side
                                        \\ and loop over shorter sides
      n = #s,
      S = s[n],    \\ assignment postponed into loop in golfed code
      g = vector(n,i,1), \\ Auxiliary vector of ones
      d,
      h = sum ( k=1, n-1, asin(s[k]/S)) < Pi/2, \\ determine whether the triangle
                                                   \\ with longest side makes an angle > Pi.
      Dmax = S/sqrt(vecsum(s)/2/S - 1) \\ upper limit of diameter from asymptotic
                                             \\ expansion showing 1/sqrt(eps) dependency.
                                             \\ In "golfed" version sqrt can be ommitted
                                             \\ drastically overestimating Dmax; solve still works
    );
  g[n] -= 2*h; \\ factor = -1 for largest triangle
               \\ when the polygon only occupies less than half of the circle
  d = solve ( D=s[n], Dmax,
              sum (k=1, n, g[k]*asin(s[k]/D)) - Pi*!h); \\ solve sum of angles equation
                                                        \\ including special case of
                                                        \\ large angle for longest side
  sum (k=1, n, g[k]*s[k]*sqrt(d^2 - s[k]^2))/4  \\ return value: use solution for d in sum
                                                \\ of triangle areas, again with potentially
                                                \\ negative contribution of triangle
                                                \\ with longest side
};

Examples
AreaCyclicPolygon([3,4,5])
 6.000000000000000000
AreaCyclicPolygon([3,4,6])
 5.3326822519253854377215978803358864040
AreaCyclicPolygon([0.25,0.25,0.499999])
 0.00012499968750010937502343751074219391159
AreaCyclicPolygon([5,5,5,5])
 25.000000000000000000000000000000000000
AreaCyclicPolygon([6,6,6,6,6])
 61.937186421202809219324431185989945578
AreaCyclicPolygon([1e6,1e6,2e6-1])
 999999375.00005468750292968783569307190

Note on estimating the maximum diameter
Regardless of whether the diameter (or equivalently the radius) is calculated using bisection or with a function for solving a non-linear equation (like PARI's solve here), a bracketing interval is required for the solution value. Trivially, the diameter cannot be smaller than the longest side. However, since the polygon can degenerate when the sum of the shorter sides approaches the longest side, the diameter of the polygon can become arbitrarily large. In order to estimate this diameter, it is sufficient to use a triangle as a model. From the well-known Heron formula for the area A one gets the radius
$$
r(a,b,c) = \frac{a b c}{\sqrt{(a+b-c) (a-b+c) (-a+b+c) (a+b+c)}}
$$
If one assumes a model triangle \$\left(\frac{1}{4},\frac{1}{4},\frac{1}{2}-\epsilon \right)\$ normalized to an approximate perimeter of 1 with a scaled length deficit \$\epsilon\$ of the longest side, then r becomes
$$
r = \frac{\frac{1}{2}-\epsilon }{16 \sqrt{\left(\frac{1}{2}-\epsilon \right)^2 (1-\epsilon ) \epsilon }}
$$
Assuming \$\epsilon\$ to be small, r can be expanded r in a series
$$
r = \frac{1}{16 \sqrt{\epsilon }}+\frac{\sqrt{\epsilon }}{32}+\frac{3 \epsilon ^{3/2}}{128}+O\left(\epsilon ^{5/2}\right)
$$
The leading term contains the singularity \$\frac{1}{\sqrt{\epsilon }}\$, which must be taken into account when calculating the upper bound. It doesn't matter whether you use the circumference or the longest side to scale back.
Whether one computes \$\epsilon\$ as
$$
\epsilon = \frac{a+b+c}{2 c}-1 = \frac{a+b-c}{2 c}
$$
which is the vecsum(s)/2/S - 1 in the program, or as
$$
\epsilon = 1-\frac{2 c}{a+b+c}
$$
makes no essential difference for small \$\epsilon\$.

Welcome to Code Golf, and nice answer!

Welcome to Code Golf! I'm really happy to see a new PARI/GP answer.
Using global variables is fine in code golf. So you don't need to use my. my(s=vecsort(v),n=#v,S=s[n],g=vector(n,i,1),d,h=sum(k=1,n-1,asin(s[k]/S))<Pi/2) can become S=s[n=#s=vecsort(v)];g=1^s;h=sum(k=1,n-1,asin(s[k]/S))<Pi/2.

Thank you for the hints. I don't know enough about the rules here. May I incorporate your suggestions into my code? As an editor in OEIS, I constantly look at PARI code and occasionally create code myself. But there we often have the opposite problem, that we criticize poorly readable code. But it's fun here and I plan to contribute from time to time.

Since my reputation is not yet high enough to make comments on other posts, I'll say this at this point: @orlp 's Python code returns an incorrect result with the input of my last test example, because the starting value for the upper bound "hi" is set much too low for this input. print (cyclic_ngon_area ([1000000, 1000000, 1999999])) -> 124019623218.91309. Setting the hi value correctly is more laborious and requires longer code.

@HugoPfoertner Sorry. When I said you can use global variables, I meant that you can use global variables in functions (instead of local variables declared by my), not that you can assume the input is stored in a global variable. You should still define a function that takes the input.

Octave, 89 bytes
r=sum(s=input(''));while sum(a=asin(s/2/r))<pi r*=1-1e-4;b=a;end;disp(sum(cos(b).*s/2*r))

Explanation
The angle a spanned by a segment of length s is 2*asin(s/2/r), given a circumradius r. Its area is cos(a)*s/2*r.
Algorithm

Set r to something too large, such as the perimeter.
If the cumulated angle is smaller than 2pi, reduce r and repeat step 2.
Calculate the area.

On average, how many iterations does this take for r to be set? (out of curiosity)

There is no way this has the required precision. You repeatedly multiply the radius by 0.9999 to reduce it, this makes it very easy to undershoot the required 6 decimals of precision.

@soktinpk around 15000 for r*=1-1e-4 and 150000 for r*=1-1e-5.

@RainerP. Those two values are the same.

@orlp you can increase precision by increasing the exponent in r*=1-1e-4 at the cost of run time.

This answer is not correct when the centre is outside the polygon, unless octave has a magical asin. After testing it online, it returns a complex answer for [6, 7, 12].

I'll let you keep this answer since you already posted it, but future answers must meet the required precision within 20 seconds, and this answer requires 1e-4 to be at least 1e-7, and then takes about 2 minutes to find an answer. Sorry, the question should have been clearer.

@orlp You are right, it's broken. I'll have to fix it.

@soktinpk it is generally not a good idea to make an exception for a specific answer.

@Cyoce But I don't want to make him/her delete it since it wasn't originally specified in the challenge. I'll let the answer stay up, but it won't be part of the "competition" and can't be accepted. (Rainer P. can also probably delete it himself if he wants since it may not gather many upvotes anyway).