text:
Triangulating Text
Write a program or function that takes in a string guaranteed to only contain printable ASCII characters except for space, and to be a positive triangular number (1, 3, 6, 10, 15, ...) in length.
Print or return the same string, but shaped into a triangle using spaces. Some examples will best show what I mean:
If the input is R then the output will be
R

If the input is cat then the output will be
 c
a t

If the input is monk3y then the output will be
  m
 o n
k 3 y

If the input is meanIngfu1 then the output will be
   m
  e a
 n I n
g f u 1

If the input is ^/\/|\/[]\ then the output will be
   ^
  / \
 / | \
/ [ ] \

If the input is
Thisrunofcharactersismeanttohavealengththatcanbeexpressedasatriangularnumber.Diditwork?Youtellme,Ican'tcountverywell,ok?

then the output will be
              T
             h i
            s r u
           n o f c
          h a r a c
         t e r s i s
        m e a n t t o
       h a v e a l e n
      g t h t h a t c a
     n b e e x p r e s s
    e d a s a t r i a n g
   u l a r n u m b e r . D
  i d i t w o r k ? Y o u t
 e l l m e , I c a n ' t c o
u n t v e r y w e l l , o k ?

Basically, newlines are inserted between the substrings of triangular length, spaces are added between all characters, and each line is indented with spaces to fit the triangle shape.
A single trailing newline and lines with trailing spaces are optionally allowed, but otherwise your output should exactly match these examples. The last line of the triangle should not have leading spaces.
The shortest code in bytes wins.

Is there an absolute max the length of the string can be?

@geokavel It should work for any length of string your language can normally handle.

Here's a Christmas tree for anyone who hasn't put theirs' up yet.             *//|/|o/|o|/o|o|/||o|o/o|||o|/o||o|||/||o|||o|/|o|||o||o\

potentially related

Pyth, 22 bytes
jua+L\ GjdHfTczsM._UzY

Try it online: Demonstration or Test Suite
Explanation:
jua+L\ GjdHfTczsM._UzY   implicit: z = input string
                   Uz    create the list [0, 1, ..., len(z)-1]
                 ._      all prefixes of this list: [[0], [0,1], [0,1,2], ...]
               sM        sum up each sublist: [0, 1, 3, 6, 10, ...]
             cz          split z at these indices
           fT            remove all the unnecessary empty strings
                         this gives us the list of strings of the triangle
 u                   Y   reduce this list, with the initial value G = []
   +L\ G                    prepend a space to each string in G
        jdH                 join the current string with spaces
  a                         and append it to G
j                        print each string on a separate line

Python, 81 bytes
def f(s,p=''):
 i=-int(len(2*s)**.5)
 if s:f(s[:i],p+' ');print p+' '.join(s[i:])

A recursive function. Goes from the end of s, chopping off and printing characters. The number of characters to take is computed from  the length of s. The function is set up to prints in reverse order of the recursive calls, which terminate when s is empty and then resolve back up the line. Each layer, the prefix p has an extra space added.
In Python 3, the if can be done via short circuiting, though this doesn't seem to save chars:
def f(s,p=''):i=-int(len(2*s)**.5);s and[f(s[:i],p+' '),print(p+' '.join(s[i:]))]

An equally-long alternative with inequality chaining:
def f(s,p=''):i=-int(len(2*s)**.5);''<s!=f(s[:i],p+' ')!=print(p+' '.join(s[i:]))

Both print and f return None, which is hard to use.

This is quite clever. By chopping off the string one row at a time, you still end up with a triangular length string to compute the number of leading spaces with.

Candy, 67 59 57 bytes
&iZ1-=yZ1+Z*2/>{0g}0=z@1i&{|.}bYR(" ";=)ZR(=a&{;}" ";)"\n";Y1-=ya1j
&1-8*1+r1-2/=y@1i&{|.}bYR(" ";=)ZR(=a&{;}" ";)"\n";Y1-=ya1j
&8*7-r1-2/=y@1i&{|.}bYR(" ";=)ZR(=a&{;}" ";)"\n";Y1-=ya1j
or:
          &
         8 *
        7 - r
       1 - 2 /
      = y @ 1 i
     & { | . } b
    Y R ( "   " ;
   = ) Z R ( = a &
  { ; } "   " ; ) "
 \ n " ; Y 1 - = y a
1 j

long form:
stackSz
digit8    # Y = (sqrt((numCh - 1) * 8 + 1) - 1) / 2   using pythagorean
mult      # Y = (sqrt(numCh * 8 - 7) - 1) / 2  equivalent but shorter
digit7
sub
root
digit1
sub
digit2
div
popA
YGetsA
label digit1
incrZ
stackSz   # bail if we're out of letters
if
  else
  retSub
endif
stack2
pushY     # print the leading spaces (" " x Y)
range1
while
  " " printChr
  popA
endwhile
pushZ
range1      # output this row of characters (Z of them)
while
  popA
  stack1
  stackSz
  if
    printChr    # bail on unbalanced tree
  endif
  " " printChr
endwhile
"\n" printChr
pushY
digit1
sub
popA
YGetsA
stack1
digit1 jumpSub   # loop using recursion

Yea, I felt Christmas-y.

Retina, 108 102 94 87 82 64 63 bytes
Thanks to Sp3000 for making me pursue my original approach, which brought the byte count from 108 down to 82.
Massive thanks to Kobi who found a much more elegant solution, which allowed me to save another 19 bytes on top of that.
S_`(?<=^(?<-1>.)*(?:(?<=\G(.)*).)+)
.
$0
m+`^(?=( *)\S.*\n\1)
<space>

Where <space> represents a single space character (which would otherwise be stripped by SE). For counting purposes, each line goes in a separate file and \n should be replaced with an actual linefeed character. For convenience, you can run the code as is from a single file with the -s flag.
Try it online.
Explanation
Well... as usual I can't give a full introduction to balancing groups here. For a primer see my Stack Overflow answer.
S_`(?<=^(?<-1>.)*(?:(?<=\G(.)*).)+)

The first stage is a Split stage, which splits the input into lines of increasing length. The _ indicates that empty chunks should be omitted from the splitting (which only affects the end, because there will be a match in the last position). The regex itself is entirely contained in a look-around so it won't match any characters, but only positions.
This part is based on Kobi's solution with some additional golfitude I found myself. Note that lookbehinds are matched right-to-left in .NET, so the following explanation should best be read bottom to top. I've also inserted another \G in the explanation for clarity, although that isn't necessary for the pattern to work.
(?<=
  ^         # And we ensure that we can reach the beginning of the stack by doing so.
            # The first time this is possible will be exactly when tri(m-1) == tri(n-1),
            # i.e. when m == n. Exactly what we want!
  (?<-1>.)* # Now we keep matching individual characters while popping from group <1>.
  \G        # We've now matched m characters, while pushing i-1 captures for each i
            # between 1 and m, inclusive. That is, group <1> contains tri(m-1) captures.
  (?:
    (?<=
      \G    # The \G anchor matches at the position of the last match.
      (.)*  # ...push one capture onto group <1> for each character between here
            # here and the last match.
    )       # Then we use a lookahead to...
    .       # In each iteration we match a single character.
  )+        # This group matches all the characters up to the last match (or the beginning
            # of the string). Call that number m.
)           # If the previous match was at position tri(n-1) then we want this match
            # to happen exactly n characters later.

I'm still admiring Kobi's work here. This is even more elegant than the prime testing regex. :)
Let's move on to the next stage:
.
$0

Simple: insert a space after every non-linefeed character.
m+`^(?=( *)\S.*\n\1)
<space>

This last stage indents all the lines correctly to form the triangle. The m is just the usual multiline mode to make ^ match the beginning of a line. The + tells Retina to repeat this stage until the string stops changing (which, in this case means that the regex no longer matches).
^      # Match the beginning of a line.
(?=    # A lookahead which checks if the matched line needs another space.
  ( *) # Capture the indent on the current line.
  \S   # Match a non-space character to ensure we've got the entire indent.
  .*\n # Match the remainder of the line, as well as the linefeed.
  \1   # Check that the next line has at least the same indent as this one.
)

So this matches the beginning of any line which doesn't have a bigger indent than the next. In any such position we insert a space. This process terminates, once the lines are arranged in a neat triangle, because that's the minimal layout where each line has a bigger indent than the next.

@_@ What the heck does it do?

@n̴̖̋h̷͉̃a̷̭̿h̸̡̅ẗ̵̨́d̷̰̀ĥ̷̳ Now with 100% more amazingness, courtesy of Kobi.

CJam, 27 26 bytes
Thanks to Sp3000 for saving 1 byte.
Lq{' @f+_,)@/(S*N+a@\+\s}h

Surprisingly close to Pyth, let's see if this can be golfed...
Test it here.
Explanation
L        e# Push an empty array to build up the lines in.
q        e# Read input.
{        e# While the top of the stack is truthy (non-empty)...
  ' @f+  e#   Prepend a space to each line we already have.
  _,)    e#   Get the number of lines we already have and increment.
  @/     e#   Split the input into chunks of that size.
  (S*    e#   Pull off the first chunk (the next line) and join with spaces.
  N+     e#   Append a linefeed.
  a@\+   e#   Append it to our list of lines.
  \s     e#   Pull up the other chunks of the input and join them back into one string.
}h

Why doesn't it work if I change '  to S???

@geokavel Because S is a string, not a character, so f will map over that string instead of the list of lines.

That was my guess. Do you have any idea as to the rationale for making S a string?

@geokavel No I don't.

Ruby, 84 77 73 bytes
->v{1.upto(n=v.size**0.5*1.4){|i|puts" "*(n-i)+v[i*(i-1)/2,i].chars*" "}}

77 bytes
->v{0.upto(n=(v.size*2)**0.5-1){|i|puts" "*(n-i)+v[i*(i+1)/2,i+1].chars*" "}}

Reduced few more bytes by removing variable r as suggested by steveverrill.
84 bytes
->v{n=(v.size*2)**0.5-1;0.upto(n){|i|puts" "*(n-i)+v[(r=i*(i+1)/2)..r+i].chars*" "}}

Ungolfed:
->v {
  1.upto(n=v.size**0.5*1.4) { |i|
    puts" "*(n-i)+v[i*(i-1)/2,i].chars*" "
  }
}

First calculating triangular number from the input string
n=v.size**0.5*1.4

i.e. for example input string size is 120 and our triangular number n, will be 15.
puts" "*(n-i)+v[i*(i-1)/2,i].chars*" "

In the above line, it prints spaces followed by series of string which are fetched from the input string using following pattern
[[0,0],[1,2],[3,5],[6,9]]
Usage:
f=->v{1.upto(n=v.size**0.5*1.4){|i|puts" "*(n-i)+v[i*(i-1)/2,i].chars*" "}}
f["Thisrunofcharactersismeanttohavealengththatcanbeexpressesasatriangularnumber.Diditwork?Youtellme,Ican'tcountverywell,ok?"]
              T
             h i
            s r u
           n o f c
          h a r a c
         t e r s i s
        m e a n t t o
       h a v e a l e n
      g t h t h a t c a
     n b e e x p r e s s
    e s a s a t r i a n g
   u l a r n u m b e r . D
  i d i t w o r k ? Y o u t
 e l l m e , I c a n ' t c o
u n t v e r y w e l l , o k ?

Wow, our approaches are very similar, but we seem to have complementary golfing knowledge. I didn't know upto doesn't require an integer argument, (times most certainly does.) I've incorporated some of your syntax into a revision of my answer. The biggest tip I have for you is, you don't need that variable r. Just use a , instead of  .. and the number after the comma is the total number of elements to return, rather than the end of the range.

True. Thanks for the tip i'm updating my answer right away :)

Pyth, 27 bytes
Js.IsSGlzWz+*-J=hZdjd<~>zZZ

                               z = input()
                               Z = 0
                               d = ' '
    sSG                        G -> tri(G)
  .I   lz                      Find the (float) input whose output is len(z).
 s                             Convert to int.
J                              Save as J.
         Wz                    while z:
               =hZ             Z += 1
            *-J  Zd            Generate J-Z spaces.
                      ~>zZ     Remove the first Z characters from z.
                     <    Z    Generate those first Z characters.
                   jd          Join on spaces.
           +                   Add the two together and print.

Test Suite
An interesting approach - imperative, and uses .I. Probably golfable.

Ruby approach 2 rev 1, 76 bytes
->s{s=s.chars*' '
0.upto(w=s.size**0.5-1){|i|puts' '*(w-i)+s[i*i+i,i*2+2]}}

Optimized using syntax ideas from Vasu Adari's answer, plus a few twists of my own.
Ruby approach 2 rev 0, 93 bytes
->s{s=s.chars.to_a.join(' ')
w=(s.size**0.5).to_i
w.times{|i|puts' '*(w-i-1)+s[i*i+i,i*2+2]}}

Completely different approach. First we add spaces in between the characters of the input. Then we print out the rows line by line.
Ruby approach 1, 94 bytes
->s{n=-1;w=((s.size*2)**0.5).to_i
(w*w).times{|i|print i/w+i%w<w-1?'':s[n+=1],-i%w==1?$/:' '}}

this ended up far longer than anticipated.
w contains the number of printable characters in the bottom row, or equivalently, the number of lines.
Every line contains w whitespace characters (the last of which is the newline) so the idea is to print these whitespace characters and insert the printable characters where necessary.

C, 138 136 134 bytes
Takes a string as an input :
j,r,k,a;f(char*s){j=strlen(s);r=k=sqrt(1+8*j)/2;for(;r--;printf("\n")){for(j=r;j--;)printf(" ");for(j=k-r;j--;)printf("%c ",s[a++]);}}

You seem to have beat JavaScript with C by 1 byte so far :D

@MarkKCowan yes, apparently. I hope I make it even smaller! :)

@SahilArora - You can replace printf(" ") and printf("\n") with puts(" ") and puts("\n"). Each substitution will save you 2 bytes.:)

@enhzflep I tried it already, it gave an ambiguous output!

Oh. :( Works fine here on win7 with gcc 4.7.1 - I guess it's to do with the way that the printf output is flushed to stdout. +1 for beating Javascript.

@enhzflep Yeah I guess the same. Thanks btw!

Minkolang 0.14, 42 bytes
(xid2;$I2*`,)1-[i1+[" "o]lrx" "$ii-1-D$O].

Try it here.
Explanation
(                Open while loop
 x               Dump top of stack
  i              Loop counter (i)
   d2;           Duplicate and square
      $I2*       Length of input times two
          `,     Push (i^2) <= (length of input)
            )    Close for loop; pop top of stack and exit when it's 0

1-[                              Open for loop that repeats sqrt(len(input))-1 times
   i1+[                          Open for loop that repeats (loop counter + 1) times
       " "o                      Push a space then read in character from input
           ]                     Close for loop
            l                    Push 10 (newline)
             r                   Reverse stack
              x                  Dump top of stack
               " "               Push a space
                  $i             Push the max iterations of for loop
                    i-           Subtract loop counter
                      1-         Subtract 1
                        D        Pop n and duplicate top of stack n times
                         $O      Output whole stack as characters
                           ].    Close for loop and stop.

Such a perfect byte count! good job!

@TanMath but 42 is not a triangular number!

CJam, 50 Bytes
q:QQ,1>{,{),:+}%:RQ,#:IR2ew<{~Q<>:LS*L,I+(Se[N}%}&

Try it here.
Explanation
q:QQ,1>{  e# Only proceed if string length > 1, otherwise just print.
,{),:}%:R e# Generates a list of sums from 0 to k, where k goes from 0 to the length of the string [0,1,3,6,10,15,21,...]
Q,#:I     e# Find the index of the length of the string in the list
R2ew<     e# Make a list that looks like [[0,1],[1,3],[3,6],...,[?,n] ]where n is the length of the string
{~Q<>:L   e# Use that list to get substrings of the string using the pairs as start and end indices
S*        e# Put spaces between the substrings
L,I+(Se[N e# (Length of the substring + Index of string length in sum array -1) is the length the line should be padded with spaces to. Add a new line at the end.
%}&

Python 2, 88 85 bytes
s=t=raw_input()
i=1
while s:print' '*int(len(t*2)**.5-i)+' '.join(s[:i]);s=s[i:];i+=1

Thanks xnor for saving 3 bytes.

Doesn't shortening s mess up the number-of-spaces calculation?

Oh right. I removed a temporary variable before submitting but didn't realise that it invalidated the code.

What if you do like before but save a back-up S=s=raw_input()?

Good suggestion. I think there's probably a shorter overall strategy though.

Crossed out 88 looks funny

@pinkfloydx33 You've obviously never experienced crossed out 44.

Java, 258 194
Golfed:
String f(String a){String r="";int t=(((int)Math.sqrt(8*a.length()+1))-1)/2-1;int i=0,n=0;while(n++<=t){for(int s=-1;s<t-n;++s)r+=" ";for(int j=0;j<n;++j)r+=a.charAt(i++)+" ";r+="\n";}return r;}

Ungolfed:
public class TriangulatingText {

  public static void main(String[] a) {
    // @formatter:off
    String[] testData = new String[] {
      "R",
      "cat",
      "monk3y",
      "meanIngfu1",
      "^/\\/|\\/[]\\",
      "Thisrunofcharactersismeanttohavealengththatcanbeexpressedasatriangularnumber.Diditwork?Youtellme,Ican'tcountverywell,ok?",
    };
    // @formatter:on

    for (String data : testData) {
      System.out.println("f(\"" + data + "\")");
      System.out.println(new TriangulatingText().f(data));
    }
  }

  // Begin golf
  String f(String a) {
    String r = "";
    int t = (((int) Math.sqrt(8 * a.length() + 1)) - 1) / 2 - 1;
    int i = 0, n = 0;
    while (n++ <= t) {
      for (int s = -1; s < t - n; ++s)
        r += " ";
      for (int j = 0; j < n; ++j)
        r += a.charAt(i++) + " ";
      r += "\n";
    }
    return r;
  }
  // End golf
}

Program output:
f("R")
R

f("cat")
 c
a t

f("monk3y")
  m
 o n
k 3 y

f("meanIngfu1")
   m
  e a
 n I n
g f u 1

f("^/\/|\/[]\")
   ^
  / \
 / | \
/ [ ] \

f("Thisrunofcharactersismeanttohavealengththatcanbeexpressedasatriangularnumber.Diditwork?Youtellme,Ican'tcountverywell,ok?")
              T
             h i
            s r u
           n o f c
          h a r a c
         t e r s i s
        m e a n t t o
       h a v e a l e n
      g t h t h a t c a
     n b e e x p r e s s
    e d a s a t r i a n g
   u l a r n u m b e r . D
  i d i t w o r k ? Y o u t
 e l l m e , I c a n ' t c o
u n t v e r y w e l l , o k ?

You could probably statically import System.out to save some bytes.

import static System.out; is 25 bytes, and System. is 7 bytes. It is used three times, and 21 < 25 so it would actually increase the size by 4 bytes. Good lead, though, static imports can save space and not everyone knows about them.

I was going through old answers when I found this one: "write a program or function" which I didn't realize at first. Stripping out the class stuff saved space. I made it into a proper function and found a few more bytes to shave off.

JavaScript (ES6), 135 bytes
w=>{r='';for(s=j=0;j<w.length;j+=s++);for(i=j=0;w[j+i];j+=++i)r+=Array(s-i-1).join` `+w.slice(j,i+j+1).split``.join` `+'
';return r}

De-golf + demo:

function t(w) {
    r = '';
    for (s = j = 0; j < w.length; j += s++);
    for (i = j = 0; w[j + i]; j += ++i) r += Array(s - i - 1).join` ` + w.slice(j, i + j + 1).split``.join` ` + '
';
    return r;
}

document.write('
' + t(prompt()));

What's the goal of for (s = j = 0; j < w.length; j += s++);? Also, inside a
, you can use \n instead of
. Also, you forgot to mention that it is ES6.

The goal of the first loop is to count the length of the last line, so as to indent each line properly.

JavaScript (ES6), 106 bytes
a=>(y=z=0,(f=p=>p?" ".repeat(--p)+a.split``.slice(y,y+=++z).join` `+`
`+f(p):"")(Math.sqrt(2*a.length)|0))

Uses recursion instead of a for loop to build the string.
To find the length of the longest row, use the formula for the nth triangular number T_n is T_n = (n^2 + n)/2. Given n and solving for T_n using the quadratic formula, we have:
1/2 * n^2 + 1/2 * n - T_n = 0

a = 1/2, b = 1/2, c = -T_n

-1/2 + sqrt(1/2^2 - 4*1/2*-T_n)
------------------------------- = sqrt(1/4 + 2*T_n) - 1/2
             2*1/2

It turns out that after flooring, adding 1/4 inside the square root doesn't change the result, hence the formula for the longest row is Math.sqrt(2*a.length)|0.

TeaScript, 44 Bytes
r(m=$s(2*xn)|0)ßp.R(m-i)+x·.S(v,v+=Æw)jø+§)µ

This uses the same method as my JavaScript answer, but is a lot shorter.
Ungolfed
r(m=$s(2*xn)|0)m(#p.R(m-i)+xs``.S(v,v+=++w)j` `+`
`)j``

Powershell, 69 bytes
($args|% t*y|?{$r+="$_ ";++$p-gt$l}|%{$r;rv r,p;$l++})|%{' '*--$l+$_}

Less golfed test script:
$f = {

(
    $args|% t*y|?{  # test predicate for each char in a argument string
        $r+="$_ "   # add current char to the result string
        ++$p-gt$l   # return predicate value: current char posision is greater then line num
    }|%{            # if predicate is True
        $r          # push the result string to a pipe
        rv r,p      # Remove-Variable r,p. This variables will be undefined after it.
        $l++        # increment line number
    }

)|%{                # new loop after processing all characters and calculating $l
    ' '*--$l+$_     # add spaces to the start of lines
}                   # and push a result to a pipe

}

@(
    ,("R",
    "R ")

    ,("cat",
    " c ",
    "a t ")

    ,("monk3y",
    "  m ",
    " o n ",
    "k 3 y ")

    ,("meanIngfu1",
    "   m ",
    "  e a ",
    " n I n ",
    "g f u 1 ")

    ,("^/\/|\/[]\",
    "   ^ ",
    "  / \ ",
    " / | \ ",
    "/ [ ] \ ")

    ,("Thisrunofcharactersismeanttohavealengththatcanbeexpressedasatriangularnumber.Diditwork?Youtellme,Ican'tcountverywell,ok?",
    "              T ",
    "             h i ",
    "            s r u ",
    "           n o f c ",
    "          h a r a c ",
    "         t e r s i s ",
    "        m e a n t t o ",
    "       h a v e a l e n ",
    "      g t h t h a t c a ",
    "     n b e e x p r e s s ",
    "    e d a s a t r i a n g ",
    "   u l a r n u m b e r . D ",
    "  i d i t w o r k ? Y o u t ",
    " e l l m e , I c a n ' t c o ",
    "u n t v e r y w e l l , o k ? ")

    ,("*/\/|\/|o\/|o|\/o|o|\/||o|o\/o|||o|\/o||o|||\/||o|||o|\/|o|||o||o\",
    "          * ",
    "         / \ ",
    "        / | \ ",
    "       / | o \ ",
    "      / | o | \ ",
    "     / o | o | \ ",
    "    / | | o | o \ ",
    "   / o | | | o | \ ",
    "  / o | | o | | | \ ",
    " / | | o | | | o | \ ",
    "/ | o | | | o | | o \ ")

) | % {
    $s,$expected = $_
    $result = &$f $s
    "$result"-eq"$expected"
    $result
}

Output:
True
R
True
 c
a t
True
  m
 o n
k 3 y
True
   m
  e a
 n I n
g f u 1
True
   ^
  / \
 / | \
/ [ ] \
True
              T
             h i
            s r u
           n o f c
          h a r a c
         t e r s i s
        m e a n t t o
       h a v e a l e n
      g t h t h a t c a
     n b e e x p r e s s
    e d a s a t r i a n g
   u l a r n u m b e r . D
  i d i t w o r k ? Y o u t
 e l l m e , I c a n ' t c o
u n t v e r y w e l l , o k ?
True
          *
         / \
        / | \
       / | o \
      / | o | \
     / o | o | \
    / | | o | o \
   / o | | | o | \
  / o | | o | | | \
 / | | o | | | o | \
/ | o | | | o | | o \

05AB1E, 11 bytes
ā£õKεSðý}.c

Try it online!

Vyxal C, 5 bytes
KÞṁvṄ

Try it Online!
 Þṁ   # Mold (without repeating elements) to...
K     # Prefixes
   vṄ # Join each on spaces
      # (C flag) center the result

Bash + sed, 87
for((;i<${#1};i+=j));{
a+=(${1:i:++j})
}
printf %${j}s\\n ${a[@]}|sed 's/\S/ &/g;s/.//'

C#, 202
string r(string s,List<string> o,int i=1){o=o.Select(p=>" "+p).ToList();o.Add(String.Join(" ",s.Substring(0,i).ToCharArray()));return s.Length==i?String.Join("\n",o):r(s.Substring(i,s.Length-i),o,i+1);}

I don't know if this is legal in code-golf but, does passing a list in the function count? I can't find a way to recurse this without a List< string > declared outside the function so I put it as a parameter.
Usage:
 r("1",new List<string>());
 r("123", new List<string>());
 r("123456", new List<string>());
 r("Thisrunofcharactersismeanttohavealengththatcanbeexpressedasatriangularnumber.Diditwork?Youtellme,Icanstcountverywell,ok?",new List<string>());

C, 102 bytes
i,j;main(n,s){for(n=sqrt(strlen(gets(s))*2);j<n;printf("%*.1s",i>1?2:i*(n-j),i++>j?i=!++j,"\n":s++));}

R, 142 bytes
Pretty sure I can get this down more. Still working on that though. I feel like I'm missing an easy recursion -- but I haven't been able to shorten it right.
f=function(a){n=nchar(a);l=which(cumsum(1:n)==n);w=strsplit(a,c())[[1]];for(i in 1:l){cat(rep(" ",l-i),sep="");cat(w[1:i],"\n");w=w[-(1:i)]}}

ungolfed
f=function(a){
    n = nchar(a)                 #number of characters
    l= which(cumsum(1:n)==n)     #which triangle number
    w= strsplit(a,c())[[1]]      #Splits string into vector of characters
    for (i in 1:l) {
        cat(rep(" ",l-i),sep="") #preceeding spaces
        cat(w[1:i],"\n")         #Letters
        w=w[-(1:i)]              #Shifts removes letters (simplifies indexing)
    }
}

Vyxal j, 24 bytes
{:|&›:¥Ẏ⅛¥ȯ}¾ƛfṄ¾LnL-ð*p

Try it Online!

authors: n̴̖̋h̷͉̃a̷̭̿h̸̡̅ẗ̵̨́d̷̰̀ĥ̷̳


text:
Number of pieces on a checkers board
Introduction
A normal checkers board contains 8 x 8 = 64 squares:

You can see that in total, there are 12 white pieces. Black and white always have the same amount of pieces. If there are any more pieces on the board, the pieces would neighbouring, which is not allowed for this challenge. To clarify things, here are some examples:
The smallest board possible for this challenge is 3 x 3:

You can see that the maximum amount of pieces is equal to 2. So, when given N = 3, you need to output 2. If the input is N = 4, we get the following:

You can see that the maximum amount is also 2. So for N = 4, the output should be 2. For N = 5, the output should be equal to 5:

Examples
STDIN:  3
STDOUT: 2

STDIN:  4
STDOUT: 2

STDIN:  5
STDOUT: 5

STDIN:  6
STDOUT: 6

STDIN:  8
STDOUT: 12

Rules

Your submission must be a program, or function etc.
that takes one integer and outputs or returns the number of pieces on the board
You can safely assume that the input is an non-negative integer > 2
This is code-golf, so the program with the least amount of bytes wins!
Note that the square in the lower left of the board is always dark. Pieces are only placed on dark squares
You have to occupy a full row with pieces

Why the restriction to full programs and STDIN/STDOUT? IMO that's just unfair to languages that have necessary program and/or input overhead.

@ThomasKwa, you're right. Functions etc. are now allowed

Par, 8 bytes
✶″½↓┐*½┐

One byte is used per character.
Explanation
               ## [implicit: read line]      Example
✶              ## Convert to number           7
″              ## Duplicate                   7 7
½              ## Divide by two               7 3.5    half the board
↓              ## Minus one                   7 2.5    leave one row empty
┐              ## Ceiling                     7 3      a whole number of rows
*              ## Multiply                    21       total number of spaces
½              ## Divide by two               10.5     only the blue squares
┐              ## Ceiling                     11       starts with blue, so round up

7 bytes ✶½″↓┐*┐ by halving before dup.

Hexagony, 19 bytes
?({{&2'2':{):!/)'*/

Try it online.
Explanation
This is still the same computation as I've used in my CJam and Labyrinth answers, but due to Hexagony's... special... memory model, it's a bit trickier to squeeze the computation into 19 bytes (so that it fits inside a side-length 3 hexagon).
Like my Labyrinth answer, this terminates with a division-by-0 error.
Here is the unfolded code:

As I said the code is entirely linear. You can piece the executed path together in order grey-purple-green-red-blue. The path actually continues a bit further until it hits the : on the left. Removing the / (which only redirect control flow), the entire program unrolled linearly is:
?({2':{)'*){&2':!:&?':

So the question is how does it work. Hexagony's memory is the line graph of a hex grid, where each edge of the grid contains an integer value (initially zero). The memory pointer (MP) is always on one edge and points in a certain direction along that edge. Arithmetic operations are generally applied to the two edges pointed at and stored in the edge the MP is on.
For this program, we'll be using the three edges labelled A, B, C, with the MP starting as shown here:

So here is how this works:
?  Read an integer N from STDIN into edge A.
(  Decrement to get N-1.
{  Move the MP forwards onto edge B.
2  Set the edge to 2.
'  Move the MP backwards onto edge C.
:  Divide edge A by edge B (rounding down) to compute (N-1)/2.
{  Move the MP forwards onto edge A.
)  Increment to restore value of N.
'  Move the MP backwards onto edge B.
*  Multiply edges A and C to compute N*(N-1)/2.
)  Increment to compute N*(N-1)/2 + 1.
{  Move the MP forwards onto edge C.
&  This actually a copy operation, but we use it to reset the edge to zero.
2  Set the edge to 2.
'  Move the MP backwards onto edge A.
:  Divide edge B by edge C to compute (N*(N-1)/2 + 1)/2.
!  Output the result as an integer. We're basically done now.
:  no-op (we already have this value)
&  Copy either B or C into A (doesn't matter).
?  Read a zero (EOF) into A.
'  Move the MP backwards onto an unused cell.
:  Divide some unused cell by A (which is zero), terminating with an error.

{{ moves the memory edge twice so the & in the second row seems to be doing nothing? Both neigbours should be 0 there

@Eumel That's not the order in which the code is executed. After the first {, the IP jumps to the 2 in the left corner. After the ) in the right corner, the IP jumps to the ' in the bottom left corner. Then the IP traverse lines 2 and 4 in a weird cyclically wrapping way.

oh i thought it only changed the ME not the IP. also +1 just for using hexagony that language is just too funny

@Eumel It does. That's just how the edges of the code wrap in Hexagony.

LabVIEW, 28 20 LabVIEW Primitives

CJam, 10 bytes
ri_(2/*)2/

Test it here.
Explanation
ri   e# Read input and convert to integer N.
_    e# Duplicate N.
(2/  e# Decrement, integer divide by two, to determine the number of rows that can be used.
*    e# Multiply by the input to determine the number of cells that can be used.
)2/  e# Increment, integer divide by two, which essentially ceil()s the result of the
     e# division.

Labyrinth, 11 bytes
Woohoo, only one byte behind CJam.
?:(#/*)_2/!

Try it online.
It's essentially the same thing:
? reads an integer value.
: duplicates the result.
( decrements it.
# pushes the stack depth which happens to be 2.
/ is integer division.
* is multiplication.
) increments the result.
_ pushes a 0.
2 turns it into a 2.
/ is once again integer division.
! prints the result as an integer.

However, at this point the program doesn't terminate yet. Instead, the instruction pointer has hit a dead end and turns around. But now / tries to compute 0/0 which terminates with an error.

Seriously, 8 bytes
,;D½L*½K

Seriously has the handy ½ (float divide by 2), and K (ceiling), so we don't need to add one before division.
Try it here with explanation.

Python 2, 22 21 bytes
lambda n:~-n/2*n+1>>1

I first separate in two cases, odd N and even N.
With odd N we can fill (N - 1)/2 rows, containing on average N/2 pieces. Since the first row always has more pieces we should ceil this result. So when N is odd we have ceil((N-1)/2 * N/2) pieces.
With even N we can fill N/2 - 1, or floor((N - 1)/2) rows, each row containing N/2 pieces.
We can combine these two expressions by ceil(floor((N-1)/2) * N/2). Since ceil(x/2) = floor((x+1)/2) we can use flooring division: ((N - 1) // 2 * N + 1) // 2.

JavaScript, 37 35 bytes
alert(((n=prompt()/2)-.5|0)*n+.5|0)

Explanation
Uses a similar technique to the rest of the answers. This is the ungolfed algorithm:
var n = parseInt(prompt());
var result = Math.ceil(Math.floor((n - 1) / 2) * n / 2);
alert(result);

dc, 12
?d1-2/*1+2/p

Test output:
$ for t in 3 4 5 6 8; do echo $t | dc -e?d1-2/*1+2/p; done
2
2
5
6
12
$

Pyth, 9 bytes
/h*/tQ2Q2

Same algorithm as my Python 2 answer.

Java, 230 155 52
Golfed:
int f(int s){return(int)Math.ceil(s*((s-1)/2)/2.0);}

Ungolfed:
public class NumberOfPiecesOnACheckersBoard {

  public static void main(String[] args) {
    // @formatter:off
    int[][] testData = new int[][] {
      {3, 2},
      {4, 2},
      {5, 5},
      {6, 6},
      {8, 12}
    };
    // @formatter:on

    for (int[] data : testData) {
      System.out.println("Input: " + data[0]);
      System.out.println("Expected: " + data[1]);
      System.out.print("Actual:   ");
      System.out.println(new NumberOfPiecesOnACheckersBoard().f(data[0]));
      System.out.println();
    }
  }

  // Begin golf
  int f(int s) {
    return (int) Math.ceil(s * ((s - 1) / 2) / 2.0);
  }
  // End golf

}

Program output:
Input: 3
Expected: 2
Actual:   2

Input: 4
Expected: 2
Actual:   2

Input: 5
Expected: 5
Actual:   5

Input: 6
Expected: 6
Actual:   6

Input: 8
Expected: 12
Actual:   12

throws Exception is permissible.

OP allowed functions.

You could use the Scanner class for input.  That would save you a bunch of bytes I think.  (The BufferedReader/InputStreamReader combo may be better in general usage, but this is code golf, and Scanner works just fine for simple input.)

Converting to a stand-alone function and using parameters/return values instead of standard input/output made a huge difference.

Japt, 16 14 bytes
U-1>>1 *U+1>>1

Try it online!
How it works
Pretty simple:
         // Implicit: U = input number
U-1>>1   // Subtract 1 from U and integer divide by 2.
*U+1>>1  // Multiply the result by U, add 1, and integer divide by 2.
         // Implicit: output last expression

I wish there were some way to take into account that the two halves of the code are so similar. Suggestions welcome!
Old version (16 bytes):
U*½-½|0 *U*½+½|0

MATLAB, 37 25 bytes
@(a)ceil(fix(a/2-.5)*a/2)

I believe this should work, does for all test cases.
It also works on Octave. You can try online here.

For the old code I added the program to that workspace in a file named checkerboard.m. You can run it by simply entering checkerboard at the prompt, then when it starts, enter the required size at the prompt. The result will be printed.
For the new code, simply enter the code posted here into the prompt, then call the anonymous function as ans(n).

Thanks for the up votes, finally reached 1000 Rep :) Woop.

@ThomasKwa thanks for pointing that out. Saved 12 bytes :).

Pyth, 17 14 13 bytes
-3 bytes thanks to Ypnypn!
Rearranged the numbers of the * operator to save 1 byte.
/+*Q-/Q2-1%Q2 1 2 (original)
/h*Q-/Q2!%Q2 2
/h*-/Q2!%Q2Q2

Explanation:
When n is even, we can occupy n/2-1 rows with n/2 pieces, making a total of n*(n/2-1)/2 pieces. This expression is equivalent to (n*(n/2-1)+1)/2
When n is odd, we can find how twice the number of pieces would look like, twice the number of pieces will span n-1 rows, and if I take away one piece, we can divide the n-1 rows into (n-1)/2 groups of 2 rows such that each group has n pieces, so the expression for this case is (n*(n/2)+1)/2
Now that both expressions are quite similar, we can write the code.
/h*-/Q2!%Q2Q2
        %Q2   Check if the number is odd
       !      Logical not to make 1 if even and 0 if odd
    /Q2       n/2
   -          n/2-1 if even, and n/2 if odd
  *        Q  n*(n/2-1) if even, n*(n/2) if odd
 h            Add one
/           2 Divide the result by two.

My first time using a golfing language.

Zilog ez80 machine code, 9 bytes
In hex:
6C 2D CB3D ED6C 2C CB3D

In assembly:
ld l,h
dec l
srl l
mlt hl
inc l
srl l

Input is in register h, and output is in l.
The Zilog ez80 is an 8-bit processor with an 8 bit accumulator and 24-bit registers. Unlike the z80, it has a mlt (8-bit multiply) instruction, which, in 16-bit mode, multiplies the high and low bytes of a register pair, here hl, and stores back in hl.
This only works for values for which twice the result fits in 8 bits; that is, n≤23.

TI-BASIC, 13 bytes
⁻int(⁻.5Ansint(Ans/2-.5

TI-BASIC's implicit multiplication helps, but it doesn't have integer division. ⁻int(⁻X is a shorter form of ceil(x).

vba, 46
Function f(x)
f=(((x-1)\2)*x+1)\2
End Function

Call with ?f(x), or =f(A1) in a formula

Javascript, 33 bytes
a=prompt();alert(a*(a-1>>1)+1>>1)

If an ES6 function is allowed then 18 bytes:
a=>a*(a-1>>1)+1>>1

Retina, 18 bytes
11(..?$)?
$_
11?
1

Input and output is in unary.
Try it online!
The latest version of Retina (newer than this challenge) could handle decimal I/O for four additional bytes:
.+
$*
11(..?$)?
$_
11?

Try it online!
With unary input and decimal output, we can do 16 bytes, but that seems like a bit of a stretch:
11(..?$)?
$_
11?

Explanation
Still the same approach as anyone elses, but using regex replacement on a unary representation of the number.
11(..?$)?
$_

This computes n*((n-1)/2). We do this by matching two characters at a time (division by two) and replacing them with the entire string (multiplication by n). The decrement of n is done by skipping the remainder of the string, if only one or two characters are left.
11?
1

This is integer division by 2, rounded up. We simply replace two characters with one (division by 2), but allow the last match to consist of only one character (rounding up).

Congratulations on your 1000th answer :p

Prolog, 39 38 bytes
Code:
p(N):-X is ((N-1)//2*N+1)//2,write(X).

Explanation:
Subtract 1 from input and integer divide by 2 to get number of rows available.
Multiply that number by input to get number of squares available.
Add one and integer divide by 2 to round up, since at at least half the rows
will have a checker at the first square.
Print.

Example:
p(8).
12

Try it online here
Edit: Saved 1 byte by replacing ceil/2 with +1//2

Python 3, 39 bytes
This is a little bloated, but I'm not sure I could golf much further than this. A link for testing.
n=int(input());print(((n-1)//2*n+1)//2)

Mumps, 17 bytes
R I W I-1\2*I+1\2

Thanks to Emigna for the simple algorithm explanation. This exploits Mumps' mathematics "deficiency" that operations are executed strictly left-to-right (not PEMDAS) so parenthesis are not required. :-)
Output does look a tad odd, however, as Cache's Ensemble (the Mumps environment that I have access to) does not automatically output carriage returns even when pressed on input. If you want it prettier, add 4 characters for pre/post carriage returns:
R I W !,I-1\2*I+1\2,!

Thanks!

Bash, 32 bytes
read a;echo $((a*(a-1>>1)+1>>1))

Batch, 30 bytes
@cmd/cset/a(%1*((%1-1)/2)+1)/2

38 bytes if input on stdin is required:
@set/pa=
@cmd/cset/a(a*((a-1)/2)+1)/2

Pyke, 8 bytes, noncompeting
Dt2f*h2f

dup,dec,half,mult,inc,half
Try it here!

source: Stack Exchange

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

sort: votes


text:
Hexagonal maze time!
Time for another maze challenge, but not as you know it.
The rules for this challenge are a little different than most maze challenges. The tile types are defined as follows:

S: The location on the maze you start at
E: The location you are trying to get to
0: Wall that you can't cross
+: Floor that you can cross

You can travel in one of six directions: up-left, up-right, left, right, down-left, or down-right.
\ /
-S-
/ \

The maze does not wrap. The goal is to find the shortest path string to get from S to E.
Input:
Input is space separated lines like the mazes shown. No trailing space will follow a line.
Output:
A string of R, L, and F where

R rotates you right (clockwise) 60 degrees
L rotates you left (counter clockwise) 60 degrees
F moves you one space in the direction you are pointing

You start pointing left-up
The shortest path is counted by the length of the string produced, not the number of positions visited. Your program must print the shortest path as the solution.
If the maze is unsolvable you should output Invalid maze!.
(>>> is the output)
     0 0 0 0
    0 + 0 + 0
   0 0 0 + + 0
  0 + 0 + 0 + 0
 0 0 + + 0 0 + 0
0 0 + 0 + 0 0 + 0
 E 0 + 0 0 + + 0
  + + 0 + 0 + 0
   0 0 0 0 0 +
    + 0 + + +
     0 S 0 0

>>>RFRFFLFLFRFFLFFFLFLFFRFLFLFRFRFRF

  + 0 0 0 0 0 0
 0 0 0 0 0 + + 0
0 0 E 0 + 0 0 + 0
 0 0 0 0 0 0 0 +
  0 + 0 0 + + +
   0 0 + + 0 0
    S + 0 0 0

>>>Invalid maze!

0 E S

>>>LF

 E + 0
0 + + +
 0 0 S
  + +

>>>FFLF

  E
 0 +
0 + +
 0 +
  S

>>>RFFLFF

 0 E + 0 0
0 + 0 0 + +
 + 0 + + + 0
  + 0 + 0 + 0
   + + + 0 S

>>>FFLFLFFRFRFFRFF

 E 0 + + 0
0 + 0 + + 0
 + + + 0 + 0
  + 0 0 0 0 0
   + + + + 0
    + 0 S 0

>>>FLFFRFFRFLF

(Note that some of the mazes have other solutions that are the same length but are not listed here)

Hoping for a Hexagony solution...

I'll award a 500 point bounty to a Hexagony solution.

@lirtosiast2 years later, I think hexagony might be a stretch for this problem ;)

Let's wait for a few more years.

Can there be a trailing newline?

Sure. filllllleeeeerrrrrr

As nice as it is to be awarded a checkmark, that's not really the point of [tag:code-golf]. Can I request the other answer be reawarded the checkmark?

Python 2, 291 bytes
def f(M):
 Y=map(max,M).index("S");X=M[Y].find("S");V={()};Q=[(0,0,0,1,"")]
 while Q:
    try:x,y,u,v,p=s=Q.pop(0);c=(Y>=y<=X-2*x)*ord(M[Y-y][X-2*x-y])
    except:c=0
    if c==69:return p
    if{c%2*s[:4]}-V:V|={s[:4]};Q+=(x+u,y+v,u,v,p+"F"),(x,y,-v,u+v,p+"R"),(x,y,u+v,-u,p+"L")
 return"Invalid maze!"

A function, f, taking the maze as a list of rows, and returning a solution, if one exists.
Explanation
Performs a breadth-first search on the graph of position/direction pairs to find the shortest path from S to E.
What's interesting is finding a compact way to represent positions and directions on a hexagonal grid, that admits simple "stepping" (i.e., moving in a certain direction) and rotation.
It's tempting to use complex numbers here, to represent coordinates on a "real" hexagonal grid, but this is not a very good idea for a number of reasons, the most serious of which is the fact that we need to plug in a √3 somewhere to make it work (sin 60° = √3/2), which, when using floating-point numbers, is a no go if we need absolute precision (e.g., for keeping track of the states we've already visited;) you can try firing up your JavaScript console and typing Math.sqrt(3)*Math.sqrt(3) == 3 and see for yourself.
But, we can use a little trick!
Instead of using complex numbers, let's define hexagonal numbers in a similar vein, as a pair of real numbers a + bh, where h plays a similar role to the imaginary i when dealing with complex numbers.
Just like with complex numbers, we can associate the pair (a, b) with a point on the plane, where the real axis points right, the imaginary axis points 60° up, and they both intersect the unit regular hexagon when the real and the imaginary parts equal 1, respectively.
Mapping this coordinate system to the cells of the maze is trivial.

Unlike i, the constant h is defined by the relation h2 = h - 1 (solving for h might reveal some insights.)
And that's it!
Hexagonal numbers can be added and multiplied, using the above relation, much like complex numbers:
(a + bh) + (c + dh) = (a + c) + (b + d)h,and (a + bh) · (c + dh) = (ac - bd) + (ad + bc + bd)h.
These operations have the same geometric interpretation as their complex counterparts: addition is vector addition, and multiplication is scaling and rotation.
In particular, to rotate a hexgonal number 60° counter-clockwise, we multiply it by h:(a + bh) · h = -b + (a + b)h, and to rotate the same number 60° clockwise, we divide by h:(a + bh) / h = (a + bh) · (1 - h) = (a + b) - ah.
For example, we can take the unit hexagonal number pointing right, 1 = (1, 0), a full circle, going counter-clockwise, by multiplying it by h six times:(1, 0) · h = (0, 1); (0, 1) · h = (-1, 1); (-1, 1) · h = (-1, 0); (-1, 0) · h = (0, -1); (0, -1) · h = (1, -1);(1, -1) · h = (1, 0).
The program uses hexagonal numbers in this fashion to represent the current position in the maze and the current direction, to advance in the specified direction, and to rotate the direction to the left and to the right.

Hexagony, 2437 bytes
The long-awaited program is here:
(.=$>({{{({}}{\>6'%={}{?4=$/./\_><./,{}}{<$<\?{&P'_("'"#<".>........_..\></</(\.|/<>}{0/'$.}_.....><>)<.$)).><$./$\))'"<$_.)><.>%'2{/_.>(/)|_>}{{}./..>#/|}.'/$|\})'%.<>{=\$_.\<$))<>(|\4?<.{.%.|/</{=....$/<>/...'..._.>'"'_/<}....({{>%'))}/.><.$./{}{\>$\|$(<><$?..\\<.}_>=<._..\(/.//..\}\.)))))<...2/|$\){}/{..><>).../_$..$_>{0#{{((((/|#.}><..>.<_.\(//$>))<(/.\.\})'"#4?#\_=_-..=.>(<...(..>(/\")<((.\=}}}\>{}{?<,|{>/...(...>($>{)<.>{=P&/(>//(_.)\}=#=\4#|)__.>"'()'\.'..".(\&P'&</'&\$_></}{)<\<0|\<.}.\"\.(.(.(/(\..{.>}=P/|><.(...(..."/<.{"_{{=..)..>})<|><$}}/\}}&P<\(/._...>\$'/.>}/{}}{)..|/(\'.<(\''"")$/{{}})<..'...}}>3#./\$<}|.}|..$.><${{}/>.}}{{<>(""''/..>){<}\?=}{\._=/$/=_>)\{_\._..>)</{\=._.....>(($>}}<.>5#.\/}>)<>-/(.....{\<>}}{{/)\$>=}}}))<...=...(\?{{{?<\<._...}.><..\}}/..>'P&//(\......(..\})"'/./&P'&P{}}&P'<{}\{{{({{{(.\&P=<.><$"&1}(./'"?&'&"\.|>}{?&"?&'P&/|{/&P''</(\..>P&{/&/}{}&'&},/"&P'&?<.|\}{&?"&P'&P'<._.>"&}\(>))<\=}{}<.{/}&?"&"&/"&"?&}\.|>?&"?&{{}}?&//x'&{((<._\($|(}.\/}{/>=&'P&"&/".{3?<.|\"&P'&P}{}&P'<.>&{}}?&"&'P&\=}}<.}/2?".?''5?"/?1{(}\."..../{},<../&//&"&P'&P'&"&"</{}}{{/>"?1''?.'({/}}{}<..>?&"?&}}$>)|P/<.>"&'P&'P&"&"&{/........._/"\$#1}/._.........|,($<'"}'?/_$P#"$0'${)$})$)|........(>/\.#1?<$<|.....>?&}$>=?&"?&/1$..>I;n;v;a;l;i;d;P0;m;a\|\"(}}({=/..$_...\"&P=},}}&P'<.|><....................;...>1"(}}){=/_....>'P&'P&}}_?&/#.>}?4'%\/<...@;1P;e;z<._><>"))'?=<.$$=..\&P}{&</\"><_'|/'&=}<.>{{.<.........|>(/>3")}}){=/=/_.>}P&"?/"<).}_.>?4{=:<.|_...........\$\2$'>4")}}({/."\{&P'&?/><.?|>P...."/=(>(/./(}{{\..>(<>(<>?5'"((..'/...#,</,}{{\.......;.F>..\(...}....._.._..._..._........__..'$......\.<R..$.>))<$}{{&P'&?}<.\$$.\...................$\.<>L\.\(('_"\>}P&"?&{/__/=(.(<.>_)..<...>....\..._.<.....&?=\}=&?"&<.."'>.\>))<.|>))\.|$.>&"?&{{}=P&}?&=}/{\.>&{{P/{">)<|\{<(|\(_(<>\_\?"&P'&P}{{{&<=_.>\&\?"&?<|'{/(/>{{/_>.{/=/\\.>'P&"?&"?&"?/._(\)\\>?&"/_|.>/.$/|$..\\><..\&?}{{}&P'&<}.._>{<|\{}<._$>-")<.>_)<|{)$|..>}=P&"?&"?/...{"./>'P&/=_\{?(/>(<>\(|)__.\&?}}{}&P<}.$.\&P'&P'&<\})))&=<\)<'.'_,><.>"?&'P&'/.|>?&{{}?&"?/>&"?&"?&}}<.".(\\\&?={&P<{..\"&?"&P'&<.?....|.$'\$/\"/.,.>{}{}=/..>&'P&}{{}P/\{}&P{(&?"&?"<'.(\&?"&<}..\?"&?"&<.>P&={}}?&}}P&'P&/.'.>&"?/..>P&}}{{P/\}&P'&?={&?<$}=\"."\P'<{..\'&P'&<....>'P&{}P&"?&{{<\\..>&/$.>}{?&"?/|'$&.P&$P\$'&P={(/..\P\\.\{&?"&?\...\?{{}=<$&P'&P<.,./<?\...{}=P\"&<.>=P&""'?&'P&'/$.#1.>{?1#=$\&'P/\}&P'&?={(,}<._?_&\&?{=&{*=}4<.>P&"?&"?&'P&/1_$>}?&}}=?&){?/\{}&P'&?={&?#<$

Try it online!
"Readable" version:
                             ( . = $ > ( { { { ( { } } { \ > 6 ' % = { } { ? 4 = $ / .
                            / \ _ > < . / , { } } { < $ < \ ? { & P ' _ ( " ' " # < " .
                           > . . . . . . . . _ . . \ > < / < / ( \ . | / < > } { 0 / ' $
                          . } _ . . . . . > < > ) < . $ ) ) . > < $ . / $ \ ) ) ' " < $ _
                         . ) > < . > % ' 2 { / _ . > ( / ) | _ > } { { } . / . . > # / | }
                        . ' / $ | \ } ) ' % . < > { = \ $ _ . \ < $ ) ) < > ( | \ 4 ? < . {
                       . % . | / < / { = . . . . $ / < > / . . . ' . . . _ . > ' " ' _ / < }
                      . . . . ( { { > % ' ) ) } / . > < . $ . / { } { \ > $ \ | $ ( < > < $ ?
                     . . \ \ < . } _ > = < . _ . . \ ( / . / / . . \ } \ . ) ) ) ) ) < . . . 2
                    / | $ \ ) { } / { . . > < > ) . . . / _ $ . . $ _ > { 0 # { { ( ( ( ( / | #
                   . } > < . . > . < _ . \ ( / / $ > ) ) < ( / . \ . \ } ) ' " # 4 ? # \ _ = _ -
                  . . = . > ( < . . . ( . . > ( / \ " ) < ( ( . \ = } } } \ > { } { ? < , | { > /
                 . . . ( . . . > ( $ > { ) < . > { = P & / ( > / / ( _ . ) \ } = # = \ 4 # | ) _ _
                . > " ' ( ) ' \ . ' . . " . ( \ & P ' & < / ' & \ $ _ > < / } { ) < \ < 0 | \ < . }
               . \ " \ . ( . ( . ( / ( \ . . { . > } = P / | > < . ( . . . ( . . . " / < . { " _ { {
              = . . ) . . > } ) < | > < $ } } / \ } } & P < \ ( / . _ . . . > \ $ ' / . > } / { } } {
             ) . . | / ( \ ' . < ( \ ' ' " " ) $ / { { } } ) < . . ' . . . } } > 3 # . / \ $ < } | . }
            | . . $ . > < $ { { } / > . } } { { < > ( " " ' ' / . . > ) { < } \ ? = } { \ . _ = / $ / =
           _ > ) \ { _ \ . _ . . > ) < / { \ = . _ . . . . . > ( ( $ > } } < . > 5 # . \ / } > ) < > - /
          ( . . . . . { \ < > } } { { / ) \ $ > = } } } ) ) < . . . = . . . ( \ ? { { { ? < \ < . _ . . .
         } . > < . . \ } } / . . > ' P & / / ( \ . . . . . . ( . . \ } ) " ' / . / & P ' & P { } } & P ' <
        { } \ { { { ( { { { ( . \ & P = < . > < $ " & 1 } ( . / ' " ? & ' & " \ . | > } { ? & " ? & ' P & /
       | { / & P ' ' < / ( \ . . > P & { / & / } { } & ' & } , / " & P ' & ? < . | \ } { & ? " & P ' & P ' <
      . _ . > " & } \ ( > ) ) < \ = } { } < . { / } & ? " & " & / " & " ? & } \ . | > ? & " ? & { { } } ? & /
     / x ' & { ( ( < . _ \ ( $ | ( } . \ / } { / > = & ' P & " & / " . { 3 ? < . | \ " & P ' & P } { } & P ' <
    . > & { } } ? & " & ' P & \ = } } < . } / 2 ? " . ? ' ' 5 ? " / ? 1 { ( } \ . " . . . . / { } , < . . / & /
   / & " & P ' & P ' & " & " < / { } } { { / > " ? 1 ' ' ? . ' ( { / } } { } < . . > ? & " ? & } } $ > ) | P / <
  . > " & ' P & ' P & " & " & { / . . . . . . . . . _ / " \ $ # 1 } / . _ . . . . . . . . . | , ( $ < ' " } ' ? /
 _ $ P # " $ 0 ' $ { ) $ } ) $ ) | . . . . . . . . ( > / \ . # 1 ? < $ < | . . . . . > ? & } $ > = ? & " ? & / 1 $
  . . > I ; n ; v ; a ; l ; i ; d ; P 0 ; m ; a \ | \ " ( } } ( { = / . . $ _ . . . \ " & P = } , } } & P ' < . |
   > < . . . . . . . . . . . . . . . . . . . . ; . . . > 1 " ( } } ) { = / _ . . . . > ' P & ' P & } } _ ? & / #
    . > } ? 4 ' % \ / < . . . @ ; 1 P ; e ; z < . _ > < > " ) ) ' ? = < . $ $ = . . \ & P } { & < / \ " > < _ '
     | / ' & = } < . > { { . < . . . . . . . . . | > ( / > 3 " ) } } ) { = / = / _ . > } P & " ? / " < ) . } _
      . > ? 4 { = : < . | _ . . . . . . . . . . . \ $ \ 2 $ ' > 4 " ) } } ( { / . " \ { & P ' & ? / > < . ? |
       > P . . . . " / = ( > ( / . / ( } { { \ . . > ( < > ( < > ? 5 ' " ( ( . . ' / . . . # , < / , } { { \
        . . . . . . . ; . F > . . \ ( . . . } . . . . . _ . . _ . . . _ . . . _ . . . . . . . . _ _ . . ' $
         . . . . . . \ . < R . . $ . > ) ) < $ } { { & P ' & ? } < . \ $ $ . \ . . . . . . . . . . . . . .
          . . . . . $ \ . < > L \ . \ ( ( ' _ " \ > } P & " ? & { / _ _ / = ( . ( < . > _ ) . . < . . . >
           . . . . \ . . . _ . < . . . . . & ? = \ } = & ? " & < . . " ' > . \ > ) ) < . | > ) ) \ . | $
            . > & " ? & { { } = P & } ? & = } / { \ . > & { { P / { " > ) < | \ { < ( | \ ( _ ( < > \ _
             \ ? " & P ' & P } { { { & < = _ . > \ & \ ? " & ? < | ' { / ( / > { { / _ > . { / = / \ \
              . > ' P & " ? & " ? & " ? / . _ ( \ ) \ \ > ? & " / _ | . > / . $ / | $ . . \ \ > < . .
               \ & ? } { { } & P ' & < } . . _ > { < | \ { } < . _ $ > - " ) < . > _ ) < | { ) $ | .
                . > } = P & " ? & " ? / . . . { " . / > ' P & / = _ \ { ? ( / > ( < > \ ( | ) _ _ .
                 \ & ? } } { } & P < } . $ . \ & P ' & P ' & < \ } ) ) ) & = < \ ) < ' . ' _ , > <
                  . > " ? & ' P & ' / . | > ? & { { } ? & " ? / > & " ? & " ? & } } < . " . ( \ \
                   \ & ? = { & P < { . . \ " & ? " & P ' & < . ? . . . . | . $ ' \ $ / \ " / . ,
                    . > { } { } = / . . > & ' P & } { { } P / \ { } & P { ( & ? " & ? " < ' . (
                     \ & ? " & < } . . \ ? " & ? " & < . > P & = { } } ? & } } P & ' P & / . '
                      . > & " ? / . . > P & } } { { P / \ } & P ' & ? = { & ? < $ } = \ " . "
                       \ P ' < { . . \ ' & P ' & < . . . . > ' P & { } P & " ? & { { < \ \ .
                        . > & / $ . > } { ? & " ? / | ' $ & . P & $ P \ $ ' & P = { ( / . .
                         \ P \ \ . \ { & ? " & ? \ . . . \ ? { { } = < $ & P ' & P < . , .
                          / < ? \ . . . { } = P \ " & < . > = P & " " ' ? & ' P & ' / $ .
                           # 1 . > { ? 1 # = $ \ & ' P / \ } & P ' & ? = { ( , } < . _ ?
                            _ & \ & ? { = & { * = } 4 < . > P & " ? & " ? & ' P & / 1 _
                             $ > } ? & } } = ? & ) { ? / \ { } & P ' & ? = { & ? # < $

Tested on Esoteric IDE: TIO might time out on some of the larger test cases but all verified. Many thanks to Timwi, this wouldn't have been possible without the IDE.
There's quite a bit of empty space, so I might have been able to fit this onto a side-length 28 hexagon (instead of side-length 29) but that will be a massive task so I'm probably not going to attempt it.
Basic Explanation
Click the images for a larger and more detailed version.
Functions

Note: Divisions are generally correct but may occasionally be a rough guess.
This code is quite "functional" - as much as Hexagony allows it to be. There are eight main functions in this code labelled in the above diagram, named by the numbers with which they are called (so their instruction pointer numbers are that number mod 6). In (rough) order of calling, they are (quoted names are locations in memory which will be explained later):

S: The starting function - reads the input and sets up the "reference array", then starts the "path stack" with the three paths F, R and L ready for main processing. Instruction pointer 0 moves to function 0 while the execution moves to function 1.
1 (-11): The main function - uses 2 to get a path, 3 to check its validity, and if valid goes to function -110/-10 twice and then 4 three times to copy the new paths across into the "path stack", finishing by returning to itself. May call function 5 if the path is at the end location.
2: Gets the next path off the "path stack" ready for processing, calls function -1 if no paths left on the stack. Returns to function 1.
3: Takes a pair of values as well as the move number and checks the "reference array" to see whether the current path has ended at a valid location. A valid location is either the start within the first 3 moves, or any + within 2 moves of it first being reached. Returns to function 1.
-10/-110: Copies the current path. Returns to function 1.
0: Helps function 1 to manage direction of movement with F. Returns to function 1.
4: Takes a copy of the current path and interlinked with function 1 changes it into the same path with either F, R or L appended. Returns to function 1.
5: Takes the path and prints out the correct path (e.g. FFLF), then terminates the program.
-1: Prints Invalid maze! and terminates.
(Double arrows): Due to lack of space, function 1/-11 had to go off into the space above function -1.

Memory

Note: Thanks to Esoteric IDE again for the diagram
The memory consists of three main parts:

Reference array: The grid is stored columns 2 apart, with a value at each step:

0 represents either a  , 0 or a valid place that was accessed more moves ago than would be required to exit the place in any direction.
1 represents a + that hasn't yet been reached.
(higher number) represents the move number where there will have been enough moves to exit the place in any direction.
10 also represents a new-line: these are never reached assuming they immediately follow the last non-white-space character.

Rail: Consists of -1s with a single -2 on the left, allows memory pointer to quickly return to the core processing area.
Path stack: Stores each of the untested paths in order by path ID (which is directly related to move number so the shorter paths are tested first). The path is stored as follows:

Rot: the rotation at the end of the current path: 0 for up-left and increasing clockwise to 5
Move: the current move number (instructions - 1)
Path: the current path, stored in quaternary with F, R, L as 1, 2, 3 respectively
x/y: coordinates at the end of the current path: x+1 -1s right then y values up (though y=0 is processed as 1 anyway for the purposes of separating the rail from the reference data)

Other important memory locations:

The x/y of the E is stored here.
This space is used to transition paths in and out of memory.
This location is the centre of where each path is stored during processing.

The next step is running your program through your program to find the shortest maze route.

I know somebody will post it. Finally...  / I also have a different plan, which should probably take less code than yours. Never actually have time to implement it.

@user202729 would be interesting to hear about it. This method can probably be golfed at least 2 sizes down I would say, but there's almost certainly something better out there.

Just waiting for @lirtosiast.

Apologies for the delay.

Python 3, 466 bytes
Would have probably ended up smaller if I used depth-first search or something. This monstrosity uses Dijkstra and is quite fast, but very long.
The code defines a function S that takes a multiline string with the maze and returns the result.
def F(M,L,c):y=M[:M.index(c)].count("\n");return L[y].index(c),y
def S(M):
 L=M.split("\n");Q=[("",)+F(M,L,"S")+(0,)];D={};R=range;H=len;U=R(2**30)
 while Q:
  C,*Q=sorted(Q,key=H);w,x,y,d=C
  for e in R(H(L)>y>-1<x<H(L[y])>0<H(D.get(C[1:],U))>H(w)and(L[y][x]in"+SE")*6):D[C[1:]]=w;E=(d+e)%6;Q+=[(w+",R,RR,RRR,LL,L".split(",")[e]+"F",x+[-1,1,2,1,-1,-2][E],y+[-1,-1,0,1,1,0][E],E)]
 J=min([D.get(F(M,L,"E")+(d,),U)for d in R(6)],key=H);return[J,"Invalid maze!"][J==U]

Here is a test of the code.
Ungolfed
def find_char(maze, lines, char):
    y = maze[:maze.index(char)].count("\n")
    return lines[y].index(char), y
def solve(maze):
    lines = maze.split("\n")
    x, y = find_char(maze, lines, "S")
    queue = [("", x, y, 0)]
    solutions = {}
    very_long = range(2**30)
    x_for_direction = [-1,1,2,1,-1,-2]
    y_for_direction = [-1,-1,0,1,1,0]
    rotations = ["","R","RR","RRR","LL","L"]
    while len(queue) > 0:
        queue = sorted(queue, key=len)
        current, *queue = queue
        route, x, y, direction = current
        if 0 <= y < len(lines) and 0 <= x < len(lines[y]) and lines[y][x] in "+SE" and len(solutions.get(current[1:], very_long)) > len(route):
            solutions[current[1:]] = route
            for change in range(6):
                changed = (direction + change) % 6
                queue += [(route + rotations[change] + "F", x + x_for_direction[changed], y + y_for_direction[changed], changed)]
    end_x, end_y = find_char(maze, lines, "E")
    solution = min([solutions.get((end_x, end_y, direction), very_long) for direction in range(6)], key=len)
    return "Invalid maze!" if solution == very_long else solution

Wow, very nice. How long did this take you to write?

@JAtkin Well, the file was created 1.5 hours ago, although I'm not sure how much of the time I actually spent working on the code. Also, it's 3am here, so my productivity is obviously at its max.

Nice, I spent 2+ hours, and most of mine was already written for a standard maze.

Do you have an ungolfed version?

@JAtkin I ungolfed the code to a readable state.

Thanks. rotations doesn't need R,RR,RRR,. Since RRR will turn you around and you will travel on the tile you just left it will never be the shortest path. I think you can replace it with just R,RR,, unless I have misread your logic. If I did you should still be able to remove it because turning around, going back and turning around again will be 2 chars longer than the direct path.

@JAtkin It's needed, because you might need to turn around at the start. Without the starting position it would work with L,,R.

Good point. Now I need to fix mine ;)

Groovy, 624 bytes. Fore!
Time time get the ball rolling with a big one. Takes multi-line string as arg to Q
Q={a->d=[0]*4
a.eachWithIndex{x,y->f=x.indexOf('S');e=x.indexOf('E');
if(f!=-1){d[0]=f;d[1]=y}
if(e!=-1){d[2]=e;d[3]=y}}
g=[]
s={x,y,h,i,j->if(h.contains([x, y])|y>=a.size()||x>=a[y].size()|x<0|y<0)return;k = a[y][x]
def l=h+[[x, y]]
def m=j
def n=1
if(h){
o=h[-1]
p=[x,y]
q=[p[0]-o[0],p[1]-o[1]]
n=[[-2,0]:0,[-1,-1]:1,[1,-1]:2,[2,0]:3,[1,1]:4,[-1,1]:5][q]
r=n-i
m=j+((r==-5|r==5)?' LR'[(int)r/5]:['','R','RR','LL','L'][r])+'F'}
if(k=='E')g+=m
if(k=='+'|k=='S'){s(x-2,y,l,n,m)
s(x+2,y,l,n,m)
s(x+1,y+1,l,n,m)
s(x+1,y-1,l,n,m)
s(x-1,y+1,l,n,m)
s(x-1,y-1,l,n,m)}}
s(d[0],d[1],[],1,'')
print(g.min{it.size()}?:"Invalid maze!")}

Ungolfed version:
def map =
        """
  + 0 0 0 0 0 0
 0 0 0 0 0 + + 0
0 0 E 0 + 0 0 + 0
 0 0 0 0 0 0 0 +
  0 + 0 0 + + +
   0 0 + + 0 0
    S + 0 0 0""".split('\n').findAll()
//map =
//        """
// 0 + +
//E + 0 S 0
// 0 0 0 +
//  + + +""".split('\n').findAll()

//map = [""]// TODO remove this, this is type checking only
//map.remove(0)
//reader = System.in.newReader()
//line = reader.readLine()
//while (line != '') {
//    map << line
//    line = reader.readLine()
//}

startAndEnd = [0, 0, 0, 0]
map.eachWithIndex { it, idx ->
    s = it.indexOf('S'); e = it.indexOf('E');
    if (s != -1) {
        startAndEnd[0] = s; startAndEnd[1] = idx
    }
    if (e != -1) {
        startAndEnd[2] = e; startAndEnd[3] = idx
    }
}

def validPaths = []
testMove = { x, y, visited ->// visited is an array of x y pairs that we have already visited in this tree
    if (visited.contains([x, y]) || y >= map.size() || x >= map[y].size() || x < 0 || y < 0)
        return;

    def valueAtPos = map[y][x]
    def newPath = visited + [[x, y]]

    if (valueAtPos == 'E') validPaths += [newPath]
    if (valueAtPos == '+' || valueAtPos == 'S') {
        println "$x, $y passed $valueAtPos"
        testMove(x - 2, y, newPath)
        testMove(x + 2, y, newPath)

        testMove(x + 1, y + 1, newPath)
        testMove(x + 1, y - 1, newPath)

        testMove(x - 1, y + 1, newPath)
        testMove(x - 1, y - 1, newPath)
    }
}

//if (!validPath) invalid()
testMove(startAndEnd[0], startAndEnd[1], [])
println validPaths.join('\n')

//println validPath

def smallest = validPaths.collect {
    def path = ''
    def orintation = 1
    it.inject { old, goal ->
        def chr = map[goal[1]][goal[0]]
        def sub = [goal[0] - old[0], goal[1] - old[1]]
        def newOrin = [[-2, 0]: 0, [-1, -1]: 1, [1, -1]: 2, [2, 0]: 3, [1, 1]:4, [-1, 1]:5][sub]
        def diff = newOrin - orintation// 5L -5R
        def addedPath= ((diff==-5||diff==5)?' LR'[(int)diff/5]:['', 'R', 'RR', 'LL', 'L'][diff]) + 'F'//(diff == 0) ? '' : (diff > 0 ? 'R'*diff : 'L'*(-diff)) + 'F'
//        println "old:$old, goal:$goal chr $chr, orintation $orintation, sub:$sub newOrin $newOrin newPath $addedPath diff $diff"
        path += addedPath
        orintation = newOrin
        goal
    }
    path
}.min{it.size()}
//println "paths:\n${smallest.join('\n')}"
if (smallest)
    println "path $smallest"
else
    println "Invalid maze!"

C#, 600 574 bytes
Complete program, accepts input from STDIN, output to STDOUT.
Edit: there was a bug in the wrap handling (didn't break on any of the given test cases) which would have added 1 byte, so I did a bit more golfing to compensate.
using Q=System.Console;struct P{int p,d;static void Main(){string D="",L;int w=0,W=0,o,n=1;for(;(L=Q.ReadLine())!=null;D+=L)w=(o=(L+="X").Length+1)>w?o:w;for(;W<D.Length;)D=D.Insert(W+1,"".PadLeft(D[W++]>87?w-W%w:0));P[]K=new P[W*6];var T=new string[W*6];P c=K[o=0]=new P{p=D.IndexOf('S')};for(System.Action A=()=>{if(c.p>=0&c.p<W&System.Array.IndexOf(K,c)<0&&D[c.p]%8>0){T[n]=T[o]+L;K[n]=c;n=D[c.p]==69?-n:n+1;}};o<n;o++){c=K[o];L="R";c.d=++c.d%6;A();L="L";c.d=(c.d+4)%6;A();L="F";c=K[o];c.p+=new[]{~w,1-w,2,1+w,w-1,-2}[c.d%6];A();}Q.WriteLine(n>0?"Invalid maze!":T[-n]);}}

It starts by reading in the map, appending ( to each line so that it knows where it ends, and can go back and add in a load of spaces to make the map rectangular, and with a row of spaces along the right side (this saves us doing wrapping checks as will be explained below). It works out the width of rectangle at some point in this, and ascertains the total length of the Map.
Next, it initialises everything for a Breadth-First-Search. Two biggish arrays are created, one to store all the states we need to explore in our search, the other to record the route we took to get to each state. The initial state is added to the due array, with the head and tail pointers pre-set someway above. Everything is 1-indexed.
We then iterate until the tail crashes into the head, or at least it appears to have crashed into the head. For each state we've visited, we attempt to add a new state at the same position where we are rotated left or right, and then one where we have moved forward. The directions are indexed, with the initial direction (defaulting to 0) corresponding to "up-left".
When we try to queue a state, it is bound checked, but not wrap checked, because of the columns of spaces on the right side, which is picked up on by the "are we allowed to be here?" check (you aren't allowed to be on spaces). If the state is queued, we then check if it's on the E cell, and if it is, we set the head of the queue to be minus itself, which causes the main loop to exit, and tells the last line of the program to print out the corresponding route, rather than the failure message (which shows if we run out of states to expand (the tail crashes into the head)).
using Q=System.Console;

// mod 8 table (the block of zeros is what we are after - it's everywhere we /can't/ go)
//   0 (space)
// O 0
// X 0
// S 3
// + 3
// E 5

struct P
{
    int p,d;
    static void Main()
    {
        // it's probably a bad thing that I have my own standards for naming this stupid read sequence by now
        string D="", // map
        L; // line/path char

        int w=0, // width
        W=0, // full length
        o, // next state to expand
        n=1; // next state to fill

        for(;(L=Q.ReadLine())!=null;D+=L) // read in map
            w=(o=(L+="X").Length+1)>w?o:w; // assertain max length (and mark end, and remove any need for wrap checking)

        // now we need to add those trailing spaces...
        for(;W<D.Length;)
            D=D.Insert(W+1,"".PadLeft(D[W++]>87?w-W%w:0)); // inject a load of spaces if we hit an X

        P[]K=new P[W*6]; // create space for due states (can't be more states than 6*number of cells)
        var T=new string[W*6]; // create space for routes (never done it this way before, kind of exciting :D)
        P c=K[o=0]=new P{p=D.IndexOf('S')}; // set first state (assignment to c is just to make the lambda shut up about unassigned variables)

        // run bfs
        for(

            System.Action A=()=> // this adds c to the list of states to be expanded, if a whole load of checks pass
            {
                if(//n>0& // we havn't already finished - we don't need this, because we can't win on the first turn, so can't win unless we go forward, which we check last
                   c.p>=0&c.p<W& // c is within bounds
                   System.Array.IndexOf(K,c)<0&& // we havn't seen c yet (the && is to prevent the following lookup IOBing)
                   D[c.p]%8>0) // and we can move here (see table at top of code)
                {
                    T[n]=T[o]+L; // store route
                    K[n]=c; // store state
                    n=D[c.p]==69?-n:n+1; // check if we are at the end, if so, set n to be negative of itself so we know, and can look up the route (otherwise, increment n)
                }
            }

            ;o<n;o++) // o<n also catches n<0
        {
            c=K[o]; // take current
            L="R"; // say we are going right
            c.d=++c.d%6; // turn right
            A(); // go!

            L="L"; // say we are going left
            c.d=(c.d+4)%6; // turn left
            A(); // go!

            L="F"; // say we - you get the picture
            c=K[o];
            c.p+=new[]{~w,1-w,2,1+w,w-1,-2}[c.d%6]; // look up direction of travel (~w = -w-1)
            A();
        }

        // check if we visited the end
        Q.WriteLine(n>0?"Invalid maze!":T[-n]); // if n<0, then we found the end, so spit out the corresponding route, otherwise, the maze is invlida
    }
}

Like most of my Graph-Searches on this site, I am making good use of C# structs, which default to compare by literal value.

Python 2, 703 bytes
Not as good as the other two versions, but at least it works haha. Set M to the maze.
Since I have no experience at solving mazes, it just goes by a brute force approach, where it'll find all the solutions it can that doesn't involve crossing back over itself. It calculates the turns from the shortest ones, and then chooses the shortest result from that.
z=zip;d=z((-1,1,-2,2,-1,1),(-1,-1,0,0,1,1));E=enumerate;D={};t=tuple;o=list;b=o.index
for y,i in E(M.split('\n')):
 for x,j in E(o(i)):
  c=(x,y);D[c]=j
  if j=='S':s=c
  if j=='E':e=c
def P(s,e,D,p):
 p=o(p);p.append(s);D=D.copy();D[s]=''
 for i in d:
  c=t(x+y for x,y in z(s,i))
  if c not in p and c in D:
   if D[c]=='E':L.append(p+[c])
   if D[c]=='+':P(c,e,D,p)
def R(p):
 a=[0,1,3,5,4,2];h=d[0];x=p[0];s=''
 for c in p[1:]:
  r=t(x-y for x,y in z(c,x));n=0
  while h!=r:n+=1;h=d[a[(b(a,b(d,h))+1)%6]]
  s+=['L'*(6-n),'R'*n][n<3]+'F';x=t(x+y for x,y in z(x,h))
 return s
L=[];P(s,e,D,[])
try:l=len(min(L))
except ValueError:print"Invalid maze!"
else:print min([R(i)for i in L if len(i)==l],key=len)

Messy ungolfed version:
maze = """
     0 0 0 0
    0 + 0 + 0
   0 0 0 + + 0
  0 + 0 + 0 + 0
 0 0 + + 0 0 + 0
0 0 + 0 + 0 0 + 0
 E 0 + 0 0 + + 0
  + + 0 + 0 + 0
   0 0 0 0 0 +
    + 0 + + +
     0 S 0 0
     """
directions = [(-1, -1), (1, -1),
              (-2, 0), (2, 0),
              (-1, 1), (1, 1)]

maze_dict = {}
maze_lines = maze.split('\n')
for y, row in enumerate(maze_lines):
    if row:
        for x, item in enumerate(list(row)):
            coordinates = (x, y)
            maze_dict[coordinates] = item
            if item == 'S':
                start = coordinates
            elif item == 'E':
                end = coordinates

list_of_paths = []

def find_path(start, end, maze_dict, current_path=None):
    if current_path is None:
        current_path = []
    current_path = list(current_path)
    current_path.append(start)
    current_dict = maze_dict.copy()
    current_dict[start] = '0'

    for direction in directions:
        new_coordinate = (start[0] + direction[0], start[1] + direction[1])

        if new_coordinate in current_path:
            pass

        elif new_coordinate in current_dict:
            if current_dict[new_coordinate] == 'E':
                list_of_paths.append(current_path + [new_coordinate])
                break
            elif current_dict[new_coordinate] == '+':
                find_path(new_coordinate, end, current_dict, current_path)

find_path(start, end, maze_dict)

def find_route(path):

    heading_R = [0, 1, 3, 5, 4, 2]
    heading = (-1, -1)
    current_pos = path[0]
    current_heading = directions.index(heading)
    output_string = []
    for coordinate in path[1:]:
        required_heading = (coordinate[0] - current_pos[0], coordinate[1] - current_pos[1])

        count_R = 0
        while heading != required_heading:
            count_R += 1
            heading_index = directions.index(heading)
            heading_order = (heading_R.index(heading_index) + 1) % len(heading_R)
            heading = directions[heading_R[heading_order]]

        if count_R:
            if count_R > 3:
                output_string += ['L'] * (6 - count_R)
            else:
                output_string += ['R'] * count_R

        output_string.append('F')
        current_pos = (current_pos[0] + heading[0], current_pos[1] + heading[1])
    return ''.join(output_string)

routes = []
try:
    min_len = len(min(list_of_paths))
except ValueError:
    print "Invalid maze!"
else:
    for i in list_of_paths:
        if len(i) == min_len:
            routes.append(find_route(i))

    print 'Shortest route to end: {}'.format(min(routes, key=len))

You can replace if heading != required_heading: while heading != required_heading:  with just while heading != required_heading:

Yeah thanks haha, I'd noticed a few things including that when doing the golfed version, just didn't update the original code, I'll do that bit now since I've just managed to shave off a few more characters

Nice! (filling the 15 char min)

<This is an unrecognized HTML tag, so SE no likey.>

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

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


text:
How should I tile my kitchen?
I recently ordered some new and colorful tiles to replace my boring old white tiling for my kitchen.  However, when the tiles arrived, they were all in a weird shape!  Therefore, I need a program to figure out how to arrange the tiles so that I need to use as few of my old boring white tiling as possible.
Even though the tiles are weird, I'm not a fan of abstract design stuff, so the tiling should be regular. To be precise, it should be a lattice: there should no rotation or reflection of the tiles, and there should be two translations S and T which are combined to place the tiles with relative offsets of aS + bT for all a and b. Of course, the tiles shouldn't overlap when placed in this lattice arrangement.
I'll give you the tile in string format, and I need you to output the tiling.  You may need to cut some of the tiles where they extend beyond the edges of my kitchen.  For example:
abc        abcdefabcdef
 def   ->  cdefabcdefab
           efabcdefabcd

can be broken down as
+-----+   +-+-----+   +-+
|a b c|d e f|a b c|d e f|
+-+   +-+---+-+   +-+---+
 c|d e f|a b c|d e f|a b
  +-+---+-+   +-+---+-+
 e f|a b c|d e f|a b c|d
----+-+   +-----+-+   +-

where the translations are (+6, 0) and (+4, +1). All but three of the tiles have been cut in this example.
You will be given a string to tile either via function parameter or STDIN.  Spaces in the tile are considered "empty" and can be filled with other tiles.
My kitchen is 30x30 squares big, so all you need to do is make the number of empty squares is as small as possible in that area.  You only need to print out 1 valid 30x30 square, which means that there may not be any lattice arrangement which has a 30x30 square with fewer empty squares.
Examples (I'm not going to give the full 30x30 square for brevity):
Input:
ab
 a
Output:
abaaba
baabaa
aabaab

Input:
xxx
x x y
xxx

Output:
xxxxxxxxxxx
xyxxyxxyxxy
xxxxxxxxxxx
xxxxxxxxxxx
xyxxyxxyxxy
xxxxxxxxxxx

Input:
012
 3 4
  56
Output:
0123 456
23 45601
 4560123
5601234

Input:
rrr
R r
Output:
rrrR r
R rrrr
rrrR r

Input:
defg
  c
ab
Output:
cabdefg cab
defg cabdef
g cabdefg c
abdefg cabd
efg cabdefg
 cabdefg ca
bdefg cabde
fg cabdefg

Your program should run in a reasonable amount of time, and this is code-golf, so the shortest program wins!

I'm not sure I understand the question. Are we supposed to find a lattice arrangement of the tiles which avoids overlap and contains a 30x30 area with minimum uncovered space, and then output that 30x30 area?

Yes.  How can I make it clearer in my post?

I'll make an edit, and if you don't like it you can roll it back.

Why wouldn't the single offset (3,0) be valid in your first example? That also results in a proper lattice.

(3,0) is perfectly acceptable response.  It's not as obvious what is happening unless there's also a vertical offset, which is why I did use a vertical offset :)

APL (Dyalog Unicode), 193 bytes
{G←{⍵⊃⍨⊃⍋(+/' '=,)¨⍵}
G{s←,30-⍳,⍨61
G,⊢∘⊂⌺30 30⊢((≢a)/⍪' '~⍨,x)@(B∘.+a)⊢''⍴⍨(⍴b)+⊃⌈/a←(⊢-⌊/)(⊃+/)¨s×⊂⍵}¨o/⍨(⍱/X∊⍨+/,-/)¨o←,∘.,⍨⊂¨∪{⍵/⍨0<2⊥¨×⍵}(,B∘.-⍸b<(1∊⊢)⌺3 3⊢b)~X←,B∘.-B←⍸b←(⍉0,⌽)⍣4⊢' '≠x←⍵}

Try it online!
A monadic dfn that takes a matrix of characters and returns the 30-by-30 matrix of a possible tiling with minimal blanks. Runs in 5 seconds for the smallest test case and in under a minute for the last one.
The idea
The task looks pretty straightforward at first glance, but it was surprisingly hard to derive a valid solution, and even harder to get one that "runs in a reasonable amount of time" (which somewhat explains why it was unanswered so far).
The first obstacle was that there are infinitely many possible tiling vectors. I solved this by limiting the vectors to the ones where the original tile and the moved tile share at least a point. If ab is the given tile, this means the following movements are considered as tiling vector candidates:
                                        AB   AB  AB  AB   AB
ABab    ab   ab  ab  ab   ab    abAB  ab    ab   ab   ab    ab
      AB    AB   AB   AB    AB

Then I filter out redundant ones (keeping only one of \$v\$ or \$w\$ when \$v = -w\$), generate all possible pairs of these candidate tiling vectors, and only keep the ones \$v, w\$ where neither \$v+w\$ nor \$v-w\$ movement overlaps with the original tile.
Reasoning: We know that the pairs of tiles at offsets \$(0, v)\$ and \$(0, w)\$ do not overlap, and therefore \$(v, v+w)\$ and \$(w, v+w)\$. Once it is known that \$(0, v+w)\$ and \$(v, w)\$ (alternatively \$(0, v-w)\$) pairs are safe, we know that \$(0, v, w, v+w)\$ are mutually safe, and by translation in four directions \$v, w, -v, -w\$, the entire infinite tiling is safe.
Given a full list of candidate vector pairs, I chose a naive way: for each vector pair, generate a large enough board of actual tiling, extract all 30-by-30 regions, and choose the one with the smallest number of blanks. For that, I used \$-30 \le a,b \le 30\$ for the formula \$av + bw\$. In order to prevent the memory (and execution time) blowing up, I apply this filtering twice, first within each vector pair, and then across all minimally chosen boards.
Ungolfed
The code changed a lot while golfing, but the core idea remains the same.
f←{
  ⍝ A boolean matrix where 1 means non-blanks, padded once to all directions
  bool←(⍉0,,∘0)⍣2⊢' '≠x←⍵
  ⍝ Spread 1s to adjacent cells (8 directions)
  padded←({1∊⍵}⌺3 3>⊢)bool
  ⍝ Extract the coordinates of ones
  cbool←⍸bool
  cpadded←⍸padded
  ⍝ badoffs: All offsets that move a cell to already occupied cell
  ⍝ offs: All offsets that move a cell to a cell adjacent to the tile,
  ⍝       badoffs removed and (negative, any) and (zero, negative) removed
  offs←∪{⍵/⍨0<2⊥¨×⍵}(,cbool∘.-cpadded)~badoffs←,cbool∘.-cbool
  ⍝ Pairs of valid offsets
  offpairs←,∘.,⍨⊂¨offs
  ⍝ Remove offset pairs (v,w) if v+w or v-w is bad
  filter←{⍱/(⍺+⍵)(⍺-⍵)∊badoffs}/¨offpairs
  pairs←filter/offpairs

  ⍝ Aux. function: Select the matrix with smallest number of blanks
  MinBlanks←{⍵⊃⍨⊃⍋(+/' '=,)¨⍵}
  ⍝ Aux. function: Given an offset pair, tile the floor using them and
  ⍝                extract the 30x30 region with minimum blanks
  GetResults←{
    somepair←⍵
    ⍝ -30 to 30, inclusive (the values of a and b)
    steps←30-⍳61
    ⍝ All values of av + bw, offset to the minimum coordinates of (0,0)
    alloffs←⊃{,(steps×⊂⍺)∘.+steps×⊂⍵}/somepair
    alloffs-←⌊/alloffs
    ⍝ Initialize a big enough blank grid
    dims←(⍴bool)+⊃⌈/alloffs
    grid←dims⍴''
    ⍝ Fill the grid with the tiles' cells moved accordingly
    filled←((≢alloffs)/⍪' '~⍨,x)@(cbool∘.+alloffs)⊢grid
    ⍝ Extract all 30x30 regions and return the one with minimum blanks
    results←,{⊂⍵}⌺30 30⊢filled
    MinBlanks results
  }
  ⍝ Map the above function over each of the pairs, and extract min blanks
  results←GetResults¨pairs
  MinBlanks results
}

About time this got answered!

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


text:
How many squares, cubes, fourth powers, etc. do I need to sum to n?
You are given a nonnegative integer n and an integer p >= 2. You need to add some p-th powers (p=2 means squares, p=3 means cubes) together to get n. This is always for any nonnegative n, but you don't know many p-th powers (of any positive integer) you'll need.
This is your task: find the minimum number of p-th powers that can sum to n.
Examples
>>> min_powers(7, 2)
4                       # you need at least four squares to add to 7
                        # Example: (2)^2 + (1)^2 + (1)^2 + (1)^2 = 4 + 1 + 1 + 1 = 7
>>> min_powers(4, 2)
1                       # you need at least one square to add to 4
                        # Example: (2)^2 = 4
>>> min_powers(7, 3)
7                       # you need at least seven cubes to add to 7
                        # Example: 7*(1)^3 = 7
>>> min_powers(23, 3)
9                       # you need at least nine cubes to add to 23
                        # Example: 2*(2)^3 + 7*(1)^2 = 2*8 + 7*1 = 23

A related Wikipedia article on this problem, Waring's problem.
Rules

Your code must be a program or a function.
Input is two integers n and p in any order. You can assume all inputs are valid (n is any positive integer, p >= 2
Output is an integer representing the number of powers needed to sum to n.
This is code golf, so the shortest program wins., not necessarily the most efficient.
Any and all built-ins are allowed.

As always, if the problem is unclear, please let me know. Good luck and good golfing!

Well, it looks like brute force will win. I hope not though.

This problem is incredibly hard, and I doubt that any answer will either ever finish while giving correct results.

At least have upper bounds

Pyth, 20 19 bytes
Saved 1 byte thanks to FryAmTheEggman.
L&bhSmhy-b^dQS@bQyE

Takes input on two lines, p first and then n.
Try it online. Test suite.
Explanation
The code defines a recursive function y(b) that returns the result for min_powers(b, p).
L                      define a function y(b):
 &b                      return b if it's 0
             S           get a list of positive integers less than or equal to
              @bQ        the p:th root of b
     m                   map the integers to:
        -b                 subtract from b
          ^dQ              the p:th power of the current integer
       y                   recurse on the above
      h                    increment the result
    hS                   find the smallest result number and return it
                 yE    calculate y(n) and print

Mathematica 61 50 bytes
With 11 bytes saved by LegionMammal978.
When restricted to powers of counting numbers, this problem is straightforward (in Mathematica).  When extended to include powers of integers, it's a nightmare.
(k=0;While[PowersRepresentations[#,++k,#2]=={}];k)&

Test Cases
(k = 0; While[PowersRepresentations[#, ++k, #2] == {}]; k) &[7, 2]
(k = 0; While[PowersRepresentations[#, ++k, #2] == {}]; k) &[4, 2]
(k = 0; While[PowersRepresentations[#, ++k, #2] == {}]; k) &[7, 3]
(k = 0; While[PowersRepresentations[#, ++k, #2] == {}]; k) &[23, 3]

4
1
7
9

PowersRepresentationsp[n,k,p] finds all the cases in which n can be expressed as a sum of k positive integers raised to the p-th power.

For example,
PowersRepresentations[1729, 2, 3]

{{1, 12}, {9, 10}}

Checking,
1^3 + 12^3

1729

9^3 + 10^3

1729

Competitively languages like Mathematica defeat the purpose of these things... it doesn't take any creativity to know a function name.  But still, well written.

@csga5000 Hey, golfing languages win 99% of the challenges on this site...

@LegionMammal978 While I don't agree with csga's point, golfing things down in golfing languages requires a huge amount of creativity.

Agreed, no awards for creativity on this submission. Nor for compactness: the Pyth submission is less than half the length.  Problems become challenging for languages like Mathematica when they can be recast as instances of more general phenomena and when unusual combinations of high-level functions can play a role.  They also become more interesting.

Java - 183 177 bytes
int p(int a,int b){int P,c,t,l=P=t=a,f=0;double p;while(P>0){a=t=l;c=0;while(t>0){if(a-(p=Math.pow(t,b))>=0&&t<=P){while((a-=p)>=0)c++;a+=p;}t--;}f=c<f||f==0?c:f;P--;}return f;}

183 bytes
int p(int a,int b){int P,c,t,l,f=0;P=t=l=a;double p;while(P>0){a=t=l;c=0;while(t>0){if(a-(p=Math.pow(t,b))>=0&&t<=P){while((a-=p)>=0){c++;}a+=p;}t--;}f=c<f||f==0?c:f;P--;}return f;}

Ungolfed
int p(int a, int b){
    int P,c,t,l=P=t=a,f=0;
    double p;
    while (P>0){
        a=t=l;
        c=0;
        while (t>0){
            if (a-(p=Math.pow(t, b))>=0 && t<=P){
                while((a-=p)>=0)c++;
                a+=p;
            }
            t--;
        }
        f=c<f||f==0?c:f;
        P--;
    }
    return f;
}

Result
System.out.println(p(7, 2));    // 4
System.out.println(p(4,2));     // 1
System.out.println(p(7,3));     // 7
System.out.println(p(23,3));    // 9

This answer is invalid. p(32,2) returns 5 when it should return 2 (4^2 + 4^2 = 32).

@Pietu1998 Ok I'll modify it.

@Pietu1998 How would you do it?

I did it recursively, checking each possible power for every number.

@Pietu1998 I'll try it thank you;

@Pietu1998 Got it, it works now, thanks again.

@YassinHajaj +1 for java and doing it yourself

@csga5000 thx man :)

Python 2, 66 bytes
f=lambda n,p:n and-~min(f(n-k**p,p)for k in range(1,n+1)if n/k**p)

Recursively tries subtracting each p-th power which leaves the remainder non-negative, computing its value on each remainder, and taking the minimum  plus 1. On 0, outputs 0.
The ugly check if n/k**p (equivalent to if k**p<=n) is to stop the function from going into the negatives and trying to take the min of the empty list. If Python has min([])=infinity, this wouldn't be needed.

Wow. This is a lot shorter than my test code on Python. +1!

C (gcc), 122 bytes
r(n,p,k,s,j,b){if(!k)return n!=s;for(b=j=1;j<n;b*=r(n,p,~-k,s+(int)pow(j++,p)));n=b;}f(n,p,k){for(k=0;r(n,p,++k,0););n=k;}

Try it online!