text:
Parentheses into Footnotes
Background
LISP programmers have taken over the world!
Parentheses have been declared as sacred characters, and from now on, they can only be used in LISP programs.
It has been decided that parentheses in literary works shall be replaced by footnotes, and it's your job to automate this for simplified Markdown text.
Input
Your input is a single string containing alphabetic ASCII characters, spaces, and the special characters ,.!?().
It will not contain newlines or digits.
The parentheses will be correctly matched.
Output
You shall convert each matched pair of parentheses in the input string into a footnote.
This happens as follows:

Replace the first matching pair of parentheses and the substring between them by a running number that starts from 1, wrapped between the Markdown tags  and .
Append to the end of the string

two newlines,
the Markdown tag ,
the number from step 1,
a space,
the substring between the parentheses, and
the closing tag , in this order.

If there are still parentheses left in the string, go to step 1.

Your output is the resulting string, possibly with a trailing newline.
You don't have to implement this exact algorithm, as long as your output is correct.
Note that there may be nested parentheses; in that case, we'll have footnotes that contain references to other footnotes.
The substring between parentheses may also be empty.
See the test cases below for examples.
Rules and Scoring
Your can write either a full program or a function.
The lowest byte count wins, and standard loopholes are disallowed.
If your language does not natively support decimal numbers (cough Retina cough), you may give the footnote numbers in another base, including binary or unary; however, using unary numbers imposes a penalty of +20%.
Test Cases
Input:
This input contains no parentheses.

Output:
This input contains no parentheses.

Input:
This has (some) parentheses (but not so many).

Output:
This has 1 parentheses 2.

1 some

2 but not so many

Input:
This has (nested (deeply (or highly?) nested)) parentheses (and several groups).

Output:
This has 1 parentheses 2.

1 nested 3

2 and several groups

3 deeply 4 nested

4 or highly?

Input:
Hmm()(()(,))  a()((trt)(v( (((((wut)))))(X)(Y)(Z) )!?!?!?!))oooooooo(oooo)oooo

Output:
Hmm12  a34oooooooo5oooo

1

2 67

3

4 89

5 oooo

6

7 ,

8 trt

9 v10!?!?!?!

10  11121314

11 15

12 X

13 Y

14 Z

15 16

16 17

17 18

18 wut

Note the empty lines between the footnotes.

Can my program contain parentheses even if it's not written in Lisp or is that a punishable offence now?

@MartinBüttner Parentheses in non-LISP programs are grudgingly permitted, as long as they're used for the greater good, like converting other parentheses into footnotes.

Can the input be multiple lines?  In that case, should footnotes be placed after each line, or at the end?  E.g., what is the output for foo (bar)\nfoot (note)?

@xebtl The input is always a single line. See section Input: "It will not contain newlines or digits."

:( @ this spec numbering footnotes breadth-first instead of depth-first

Perl, 81 75 72 bytes
71 bytes code + 1 byte command line argument.
Requires Perl 5.10 or newer (for recursive regex support)
$i++;s#(\((((?1)|.)*?)\))(.*)#$i$4

$i $2#s&&redo

Usage:
perl -p entry.pl input.txt

Explanation
-p parameter will print the result of applying the given commands to the input, avoiding the need for an explicit print.
The regex (\(((?1)|.)*?)\)) is looking for the outermost set of brackets from the start of the string. When this is found, we perform the substitution, ensuring we only add the  at the very end of the input (by capturing everything until the end of the input using (.*)).
We then repeat the regex substitution on the now-substituted string using redo, which will continually apply the regex substitution until it no longer matches. The s modifier ensures that the . in the regex will match new lines, which is necessary because we re-apply the regex match on the result of the previous regex substitution.

You might be able to get away with with [^)]  or even . instead of [^()] becuase of the guarantee that the input will be balanced correctly.

+1 for introducing me to recursive regexes :-).  But I think on a strict reading of the challenge this is incorrect: If the string contains newlines, footnotes will be placed after each line rather than at the end.  (See my request for clarification above.)

Good point @MartinBüttner - we can get away with . by making the match lazy. @xebtl, the challenge states "It will not contain newlines or digits"

Emacs Lisp, 335 bytes
Foreword. This answer and the Scheme ones are currently the only answers officially sanctioned by both the Mighty Popular Republic of LISP and the Church of Emacs. Other answers, shorter or not, are considered a threat to peace. In particular, and with a profound disdain to any libelious allegation of McCarthyism that is sporadically heard from hostile opponents of the state, we enjoin anyone who has information about the real identity of the anonymous  authors writing Nonlisp answers to contact your Local Bureau. It is reminded that everyone should take time to reflect and upvote in accordance to what he or she deeply believes will not threaten his or her future interactions with official representants of the power in place. Code is data. Data is code.
(defun p()(let(b(cpt 0)n)(goto-char 0)(while(search-forward"("()t)(setf b(point)n(number-to-string(incf cpt)))(backward-char)(forward-sexp)(backward-char)(kill-region b(point))(delete-backward-char 1)(delete-forward-char 1)(insert ""n"")(save-excursion(end-of-buffer)(newline 2)(insert ""n" ")(yank)(insert"")))))

More elegantly:
(defun parens ()
  (let (b(cpt 0)n)
    (goto-char 0)
    (while(search-forward"("()t)
      (setf b(point)n(number-to-string(incf cpt)))
      (backward-char)
      (forward-sexp)
      (backward-char)
      (kill-region b(point))
      (delete-backward-char 1)
      (delete-forward-char 1)
      (insert ""n"")
      (save-excursion
       (end-of-buffer)
       (newline 2)
       (insert ""n" ")
       (yank)
       (insert "")))))

Retina, 96 86 83 bytes * 120% = 99.6
The source code of this solution consists of two files:
+s`\((((\()|(?<-3>\))|[^)])*).(.*)(?<=(1+).*?)?

1$5$4

1$5 $1

Explanation
This is a very direct implementation of the algorithm as described in the challenge. The code consists of a single regex substitution which turns the first set of parentheses into a footnote. This substitution is repeated via the + until the string stops changing, which here means that the regex no longer matches (because it can't find any more parentheses).
The footnotes are enumerated in unary, so that I can simply look for the last footnote's number and append a 1 to create the next one.
The regex for finding the first set of parentheses is based on the standard technique for matching parentheses with balancing groups (hrhr, "matching parentheses"). It has been shortened a bit by using an unnamed group and by assuming that the parentheses are correctly balanced (which means we can omit the ( from the negated character class and match the final ) with a simple . and we also don't need to ensure that the capture stack is empty).
After matching the parentheses and capturing their contents into group 1, we capture the remainder of the string with (.*) into group 4 and then search back through the the string for the first set of 1s with a negative lookbehind. If we find such a substring, we store in group 5. If we don't, we lookbehind fails, but that's okay because it's optional - it just means that $5 will give an empty string which is the unary representation of 0 and which is also correct.
The substitution string then simply pieces everything together based on the capturing groups. The footnote number is incremented by prepending a 1 to the last number with 1$5.

Retina is on a winning streak!

@orlp Or is it? ;) Balancing groups are no match for recursive regex. That and not being able to handle decimal numbers...

Time to steal the PHP wrapper and implement Retina around PCRE:

@n̴̖̋h̷͉̃a̷̭̿h̸̡̅ẗ̵̨́d̷̰̀ĥ̷̳ Normally, I'd rather have balancing groups than recursion, but there are some cases where the latter is more concise. Maybe one day I'll reimplement the .NET regex flavour for Retina and patch in some additional features. ;)

Sacred JavaScript, 1510 bytes
Fellow rebels, do not give in to their tyrannical demolition of the parenthesis! You must persevere! From the start, programming has been a free enterprise. Now, it has become a pervaded show of piety. We must show nothing less then absolute fearsomeness. Therefore, I have fought back!
    ( )( (((  ((  )( )  (( ))( )) (( ( ((  ) ( ()( ) (( ) )(( ((( ()((( ) ( ) )((  ) (((((( )( (())((  ) ) )( ()(( ((()((()   ( (  (  ( )) ((  )( ) (( ) )((((  ( () ) )( ( ()(( )( () ((( )(( ) )( ()((( ) ( )  ( )() (((( () ) (((( () ) ((() ) ()  ( (  (  ( )) ( )(  ((((( )) ((  )( ) (( ) )((((  ) )  ()(  ((() ( ()(( ) ( ) )(( ))(((  (( ) ((  ) ( ()(( )( ) ()  ( (  (  ( ()( ) )( ()(  ) ()  ( (  (  ( )( (( ( (( )  ((((( ))  ) )(( )) ((  )( ) (( ) )((((  ) ()( ))  ) ) (( )( () (((   ( ) )((  )( )(((( ))( )() ) ()( ))  (()( (()( ((()((()   ( (  (    (  ( )) ( )(  (((((( )(( ( (( )) ( ((  ) )( ) )( ( )( ((() ( )( ((() ( ()( ()( ()   ) )( ()(( ) ()  ( (  (    (  ( )) ( )(  (((((( )(( ( (( )) ( ((  ) )( ) )( ( )( (((( ( )( ((() ( ()( ()( (()( ) )( ()(( ) ()  ( (  (    (  ( )) ( )(  (((( ( ) ( ()( ((() ( ()( ())(( ) ( ) )( ()(( ))) ) ()  ( (  (  ((())  ( (  (  ((( ( ) )((( )( () ((( )(((   ( )) ( )  ( ) ) ((((( )) ((  )( ) (( ) )((((  (())( ))  (()( ()(( ((()  ( (  (  ( )(  ) )(((( ( () ((( ) ( ) )(( ((((   ( ()(( )  ( ) ) (((( () )( ((( ((((((()( ((() ((   () )( )(( (()) ( )( ( )( ((() ) ()  ( (  (  (( ) ( ) )(( ))(((  (( ) ((  ) ( ()( ) (( ) )(( ((( ()((( ) ( ) )((  ) (((((( )( () ((( ) ( ) )(( ((((   ( ()(( )  ( ) ) ((((((( ( (()) ( )( ) ) (( )((((  ( ()) ) )) ( )( (()(((  ) (()( ( )( ) )  () )(( )((((  ( ()) ) )) ( )( ((() (()( ( )(  ( (  ( ( ) ) (( )((((  ( ()) ) )) ( )( (()(((  ) (()( ( )( ( () ( )( (()(( )(  (()( ( )( ) )  () )(( )((((  ( ()) ) )) ( )( (())((  ) (()( ()(( ((() ) ()  ( (((())

No rules against using the sacred characters in a non-Lisp language. Nope, not at all. (In a little less compact way:)
( )( (((  ((  )( )  (( ))( )) (( ( ((  ) ( ()( ) (( ) )(( ((( ()((( )
( ) )((  ) (((((( )( (())((  ) ) )( ()(( ((()((()   ( (  (  ( )) ((  )
( ) (( ) )((((  ( () ) )( ( ()(( )( () ((( )(( ) )( ()((( ) ( )  ( )()
 (((( () ) (((( () ) ((() ) ()  ( (  (  ( )) ( )(  ((((( )) ((  )( ) (
( ) )((((  ) )  ()(  ((() ( ()(( ) ( ) )(( ))(((  (( ) ((  ) ( ()(( )(
 ) ()  ( (  (  ( ()( ) )( ()(  ) ()  ( (  (  ( )( (( ( (( )  ((((( ))
 ) )(( )) ((  )( ) (( ) )((((  ) ()( ))  ) ) (( )( () (((   ( ) )((  )
( )(((( ))( )() ) ()( ))  (()( (()( ((()((()   ( (  (    (  ( )) ( )(
 (((((( )(( ( (( )) ( ((  ) )( ) )( ( )( ((() ( )( ((() ( ()( ()( ()
 ) )( ()(( ) ()  ( (  (    (  ( )) ( )(  (((((( )(( ( (( )) ( ((  ) )(
 ) )( ( )( (((( ( )( ((() ( ()( ()( (()( ) )( ()(( ) ()  ( (  (    (
( )) ( )(  (((( ( ) ( ()( ((() ( ()( ())(( ) ( ) )( ()(( ))) ) ()  ( (
  (  ((())  ( (  (  ((( ( ) )((( )( () ((( )(((   ( )) ( )  ( ) ) ((((
( )) ((  )( ) (( ) )((((  (())( ))  (()( ()(( ((()  ( (  (  ( )(  ) )(
((( ( () ((( ) ( ) )(( ((((   ( ()(( )  ( ) ) (((( () )( ((( ((((((()(
 ((() ((   () )( )(( (()) ( )( ( )( ((() ) ()  ( (  (  (( ) ( ) )(( ))
(((  (( ) ((  ) ( ()( ) (( ) )(( ((( ()((( ) ( ) )((  ) (((((( )( () (
(( ) ( ) )(( ((((   ( ()(( )  ( ) ) ((((((( ( (()) ( )( ) ) (( )((((
( ()) ) )) ( )( (()(((  ) (()( ( )( ) )  () )(( )((((  ( ()) ) )) ( )(
 ((() (()( ( )(  ( (  ( ( ) ) (( )((((  ( ()) ) )) ( )( (()(((  ) (()(
 ( )( ( () ( )( (()(( )(  (()( ( )( ) )  () )(( )((((  ( ()) ) )) ( )(
 (())((  ) (()( ()(( ((() ) ()  ( (((())

This compiles to the expanded JavaScript in my other answer. This is a joke submission.

Lua, 222 216 204 201 bytes
Golfed:
s=io.read()g="%b()"c=1k=string l=k.find t=k.sub o=k.format a,b=l(s,g)while a do s=t(s,0,a-1)..o("%d",c)..t(s,b+1,#s).."\n\n"..o("%d %s",c,t(s,a+1,b-1))c=c+1 a,b=l(s,g)end print(s)

Ungolfed:
input=io.read()
inputFormat="%d"
footnoteFormat="%d %s"
counter=1
a,b=string.find(input,"%b()")
while a do
    current=string.sub(input,a+1,b-1)
    input=input.."\n\n"..string.format(footnoteFormat, counter, current)
    input=string.sub(input,0,a-1)..string.format(inputFormat, counter)..string.sub(input,b+1,#input)
    counter=counter+1
    a,b=string.find(input,"%b()")
end

print(input)

wouldn't a repeat a,b=l(s,g) ... untill a<1 loop be shorter than your while?

Scheme, 92 bytes
Frustrated with implementing the breadth-first search in Real Lisp,1 the powers-that-be decide to take a more pragmatic approach.  After all, Parentheses are sacred, but brackets are not.2
(lambda(s)(list->string(map(lambda(c)(case c((#\()#\[)((#\))#\])(else c)))(string->list s)))

1. listen not to those heretics from the so-called “church” of Emacs!
2. They are not Racket programmers, are they?

Scheme shall be called Schism: saying it is the "Real Lisp" is the actual heresy. And you say it is pragmatic? This hack of an answer shows the true nature of schemers ;-)

@coredump And you would claim your monstrously non-functional elisp answer is an instance of True Lisp?  It may take a little longer, true, but when the Scheme answer is finished, it will be The Right Thing!

Haskell, 210 bytes
n#x|b==""=a|1<2=a++""++m++""++((n+1)#(c++"\n\n"++m++' ':init d++""))where m=show n;(a,b)=span(/='(')x;(d,c)=[x|x@(y,_)<-map(`splitAt`(tail b))[0..],'('!y<')'!y]!!0;c!l=[1|m<-l,m==c]
p=(1#)

Usage example:
*Main> putStrLn $ p "This has (nested (deeply (or highly?) nested)) parentheses (and several groups)."
This has 1 parentheses 2.

1 nested 3

2 and several groups

3 deeply 4 nested

4 or highly?

How it works:
n # x                      -- # does all the work, n is the current number of the
                           --   footnote and x the input string
  | b=="" = a              -- if b (see below) is empty, there's no ( in the
                           --   string and the result is 'a' (see below)
  | 1<2   = a++""++m++""++ ((n+1)#(c++"\n\n"++m++' ':init d++""))
                           -- otherwise (b not empty) build the output string
                           --   starting with 'a' and a footnote number and a
                           --   recursive call with the current footnote appended
                           --   to the rest of the string

  where
  m = show n;              -- turn n into string
  (a,b) = span (/='(') x;  -- split the input string x into two parts:
                           --   a: everything before the first (
                           --   b: beginning with the first ( to the end
                           --   if there's no (, a is x and b is empty
  (d,c) = [x|x@(y,_)<-map(`splitAt`(tail b))[0..],'('!y<')'!y]!!0;
                           -- find matching ) in the tail of b ('tail' to remove leading '(')
                           --   d: everything before and including the matching )
                           --   c: everything behind the matching )
  c!l=[1|m<-l,m==c]        -- helper function that builds a list of 1s for every character searched for
                           --   we have reached the matching ) if the list for ( is
                           --   shorter (less than, <) the list for )

p=(1#)                     -- start with footnote 1

Scheme, 533 bytes
With indentation:
(letrec ((l string->list)
         (n number->string)
         (? null?)
         (p (lambda (o) (or (pair? o)(? o))))
         (a car)
         (d cdr)
         (e append)
         (i 0)
         (x
          (lambda (h t)
            (if (? h)
                t
                (case (a h)
                  ((#\()
                   (let ((s (x (d h) ())))
                     (x (a s) (e t (d s)))))
                  ((#\)) (cons (d h) (list t)))
                  (else
                   (x (d h) (e t (list (a h)))))))))
         (f
          (lambda (h t F)
            (cond ((? h)
                   (let ((w (e t F)))
                     (if (find p w) (f w()()) w)))
                  ((p(a h))
                   (set! i(+ 1 i))
                   (f (d h)
                      (e t (e (l "")
                              (l (n i))
                              (l "")))
                      (e F (e (l "\n\n")
                              (l (n i))
                              '(#\ )
                              (a h)
                              (l "")))))
                  (else (f (d h)
                           (e t (list (a h)))
                           F))))))
  (print (list->string (f (x (l (read-line))
                             ())
                          ()
                          ()))))

Yes, this is 533 bytes when all the optional whitespace is removed.  Bask in the functional glory.
I implemented more or less the algorithm in the description: x groups the input by parentheses and f replaces the first level of groups by footnotes, repeating until no more groups are left.  I am sure it can be made shorter, but I do not see how it could be made much shorter without switching to a different algorithm.
As written, it is a complete program.  You can try it out here, but because repl.it apparently cannot deal with (read-line) you have to put the input string in its place.  A completely ungolfed version is here.
EDIT: As pointed out in the comments, I changed the parentheses () into  brackets [] in the repl.it versions.  This was purely for convenience during programming and debugging.  The version as posted now works with ().

+1, but I don't understand why you change square brackets. If I change #\[ '#]` by the respective parenthesis (and update tests), this works without problem. Is there a reason you left the square ones? is it related to your previous answer?

@coredump you are absolutely right.  I changed to brackets because (a) paren character literals messed up repl.it's paren matching and (b) in debugging, output (which will include a lot of parens from lists) was much more readable with brackets.  Then I just left it that way.  I will edit.

JavaScript ES6, 244 bytes
Serious answer (only works on FireFox, to my knowledge)
d=(s,n=1)=>{u=s.search(/\(/);if(index<a=0)return s;for(i=index;i<s.length;i++){if(s[i]==")")a-=1;if(s[i]=="(")a+=1;if(!a)break}return d(s.replace(v=s.slice(index,i+1),""+n+"")+`

`+n+" "+v.replace(/^\(|\)$/g,"")+"",n+1)}

Expanded:
function deparen(s,n=1){
    index = s.search(/\(/);
    if(index<0) return s;
    a=0;
    for(i=index;i<s.length;i++){
        if(s[i]==")") a-=1;
        if(s[i]=="(") a+=1;
        if(!a) break;
    }
    v=s.slice(index,i+1)
    f=v.replace(/^\(|\)$/g,"");
    return deparen(s.replace(v,""+n+"")+"\n\n"+n+" "+f+"",n+1);
}

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


text:
Also want my cake
Introduction
Today is my birthday,
Yes my parents spend a lot time at home during the cold December holidays as many others.
So I also want my cake.
But I have a problem: I just sent the invitations today so I'm not sure how many friends will come. Also I don't want to order a big cake because I have been on a diet since last year and don't want to keep temptation leftovers in the fridge.
Challenge
Write a full program to output the cake design so my baker prepares just enough cake for everyone.
Input Integer 1 <= n <= 999.  Worst case I eat my cake alone.

Each slice will have a unique label number 1 .. n sequenced left to right, then top to bottom.
Write in the middle line and align center the best way you can.
Slice size is a square of 3x3 (this is why upper limit is 999).
* indicate where to cut each slice.

Output
n = 1 => Side = RoundUP(sqrt(1)) = 1
*****
*   *
* 1 *
*   *
*****

n = 3 => Side = RoundUP(sqrt(3)) = 2
*********
*   *   *
* 1 * 2 *
*   *   *
*********
*   *
* 3 *
*   *
*****

n = 5 => Side = RoundUP(sqrt(5)) = 3
*************
*   *   *   *
* 1 * 2 * 3 *
*   *   *   *
*************
*   *   *
* 4 * 5 *
*   *   *
*********

n = 10 => Side = RoundUP(sqrt(10)) = 4
*****************
*   *   *   *   *
* 1 * 2 * 3 * 4 *
*   *   *   *   *
*****************
*   *   *   *   *
* 5 * 6 * 7 * 8 *
*   *   *   *   *
*****************
*   *   *
* 9 * 10*
*   *   *
*********

Winning
Shortest code in bytes wins.

Happy Birthday!

Oh God, what have I started?! D: We need a [tag:cake] tag now ;)

What can I say september have a lot of bdays :)

@BetaDecay Can you point me to how create the leader board?

@JuanCarlosOropeza http://meta.codegolf.stackexchange.com/questions/5139/leaderboard-snippet

Do the numbers have to be as shown: 1 (and presumably 3) digits centred, and 2 digits right of centre? Or can they be justified in whatever way is easiest?

Worst case I eat my cake alone. - I consider this the best case scenario.

Relevant xkcd

Python 2, 241 239 237 bytes
i=input()
s=int(round(i**.5+.5))
q="*"*5;p="*   *"
v=lambda x,y:"\x1b[%d;%dH".join(["",q,p,"*{}*",p,q])%tuple(i for j in zip(range(x*4+1,x*4+6),[y*4+5]*5)for i in j)
print"".join([v(j/s,j%s).format(`j+1`.center(3," "))for j in range(i)])

Lots of ANSI goodness...
Defines a function for drawing a box at a position on the screen.
Then calls it with the relevant positions that are in the cake.
Finally adds the numbers using str.format() and str.center
NOTE: If your terminal isn't big enough to display everything at once, it will get 'cropped' and you won't be able to see anything past the last row.

source: Stack Exchange

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

sort: votes


text:
Am I perfect (number)?
This is my first challenge!
Background
Perfect number is a positive integer, that is equal to the sum of all its divisors, except itself.
So 6 is perfect number, since 1 + 2 + 3 = 6.
On the other hand 12 is not, because 1 + 2 + 3 + 4 + 6 = 16 != 12.
Task
Your task is simple, write a program, which will, for given n, print one of these messages:

I am a perfect number, because d1 + d2 + ... + dm = s == n
  I am not a perfect number, because d1 + d2 + ... + dm = s [<>] n

Where
d1, ... dm are all divisors of n except for n.
s is the sum of all divisors d1, ..., dm (again, without n).
[<>] is either < (if s < n) or > (if s > n).
Examples
For n being 6: "I am a perfect number, because 1 + 2 + 3 = 6 == 6"
For n being 12: "I am not a perfect number, because 1 + 2 + 3 + 4 + 6 = 16 > 12"
For n being 13: "I am not a perfect number, because 1 = 1 < 13"
Rules

n is not bigger than your language's standard int.
You can read n from standard input, from command line arguments or from a file.
Output message has to be printed on standard output and no additional characters can appear in the output (it may have trailing whitespace or newline)
You may not use any built-ins or library functions which would solve the task (or its main part) for you. No GetDivisors() or something like that.
All other standard loopholes apply.

Winner
This is code-golf so shortest code in bytes wins!

@orlp It is not, I edited the challenge, thanks for that.

Why do you use = and == in the same equation? That makes no sense. It should be d1 + d2 + ... + dm = s = n IMO.

Could you give some example input and output, for example with inputs 6 and 12?

@orlp first = is assignment. Second == is comparism.

@Zereges That's nonsensical. There is nothing being assigned. Only compared.

@orlp It is intended.

Related: http://codegolf.stackexchange.com/questions/49718/calculate-the-first-n-perfect-numbers

@flawr Related, but closed as unclear.

What is being assigned? I don't see any variables. I only see constants, and you can't assign anything to a constant.

@corsiKa Ok, so I'll tell it in other way. First = is elementary school's, it means, computing the value of sum of divisors. The second == is to show off, that the value is the same.

Does it matter if there are extra spaces in the list of numbers, e.g. I am a perfect number, because<space><space>1<space>+<space><space>2 +<space><space>4<space>+<space><space>7<space>+<space>14 == 28

@TomCarpenter Yes, it matters. You can have trailing whitespace/newline, but no whitespaces in the middle of output.

I figured as much. Fortunately I found a way to combat it in my MATLAB code after I left the comment. :)

I wrote a four byte answer... and then I realized how the output is supposed to work.

Pyth, 81 bytes
jd[+WK-QsJf!%QTStQ"I am"" not""a perfect number, because"j" + "J\=sJ@c3"==<>"._KQ

Try it online: Demonstration or Test Suite
Explanation:
                                 implicit: Q = input number
               StQ               the range of numbers [1, 2, ..., Q-1]
          f                      filter for numbers T, which satisfy:
           !%QT                     Q mod T != 0
         J                       save this list of divisors in J
      -QsJ                       difference between Q and sum of J
     K                           save the difference in K

jd[                              put all of the following items in a list
                                 and print them joined by spaces:
                  "I am"           * "I am"
   +WK                  " not"       + "not" if K != 0
"a perfect number, because"        * "a perfect ..."
j" + "J                            * the divisors J joined by " + "
       \=                          * "="
         sJ                        * sum of J
            c3"==<>"               * split the string "==<>" in 3 pieces:
                                        ["==", "<", ">"]
           @        ._K              and take the (sign of K)th one (modulo 3)
                       Q           * Q

Java, 255 270 bytes (Still FF in base 17)
class C{public static void main(String[]a){int i=new Integer(a[0]),k=0,l=0;a[0]=" ";for(;++k<i;)if(i%k<1){l+=k;a[0]+=k+" ";}}System.out.print("I am "+(l==i?"":"not ")+"a perfect number, because "+a[0].trim().replace(" "," + ")+" = "+l+(l==i?" == ":l<i?" < ":" > ")+i);}}

And a more readable version:
class C {
    public static void main(String[] a) {
        int i = new Integer(a[0]), k = 0, l = 0;
        a[0] = " ";
        for(; ++k<i ;){
            if (i % k == 0) {
                l += k;
                a[0] += k + " ";
            }
        }
        System.out.print("I am " + (l == i ? "" : "not ") + "a perfect number, because " + a[0].trim().replace(" "," + ") + " = " + l + (l == i ? " == " : l < i ? " < " : " > ") + i);
    }
}

Previously didn't work for odd numbers, so I had to tweak a few things. At least I got lucky with the byte count again. :)

will l == i work over 255 ?

I know if ruins your byte count, but you could save a character by replacing the last three (of four) occurrences of a[0] with a 'String b' and use 'b' in their place

R, 158 163 157 153 143 141 bytes
Still room to golf this I think.
Edit: Replaced if(b<n)'<'else if(b>n)'>'else'==' with c('<'[b<n],'>'[b>n],'=='[b==n]).  The paste(...) is replaced with an rbind(...)[-1].  Thanks @plannapus for a couple more bytes.
n=scan();a=2:n-1;b=sum(w<-a[!n%%a]);cat('I am','not'[b!=n],'a perfect number, because',rbind('+',w)[-1],'=',b,c('<'[b<n],'>'[b>n],'==')[1],n)

Ungolfed
n<-scan()             # get number from stdin
w<-which(!n%%1:(n-1)) # build vector of divisors
b=sum(w)              # sum divisors
cat('I am',           # output to STDOUT with a space separator
    'not'[b!=n],      # include not if b!=n
    'a perfect number, because',
    rbind('+',w)[-1], # create a matrix with the top row as '+', remove the first element of the vector
    '=',
    b,                # the summed value
    c(                # creates a vector that contains only the required symbol and ==
        '<'[b<n],     # include < if b<n
        '>'[b>n],     # include > if b>n
        '=='
    )[1],             # take the first element
    n                 # the original number
)

Test run
> n=scan();b=sum(w<-which(!n%%1:(n-1)));cat('I am','not'[b!=n],'a perfect number, because',rbind('+',w)[-1],'=',b,c('<'[b<n],'>'[b>n],'==')[1],n)
1: 6
2:
Read 1 item
I am a perfect number, because 1 + 2 + 3 = 6 == 6
> n=scan();b=sum(w<-which(!n%%1:(n-1)));cat('I am','not'[b!=n],'a perfect number, because',rbind('+',w)[-1],'=',b,c('<'[b<n],'>'[b>n],'==')[1],n)
1: 12
2:
Read 1 item
I am not a perfect number, because 1 + 2 + 3 + 4 + 6 = 16 > 12
> n=scan();b=sum(w<-which(!n%%1:(n-1)));cat('I am','not'[b!=n],'a perfect number, because',rbind('+',w)[-1],'=',b,c('<'[b<n],'>'[b>n],'==')[1],n)
1: 13
2:
Read 1 item
I am not a perfect number, because 1 = 1 < 13
>

There should be + sign in between divisors.

@Zereges I've just noticed that and will fix shortly

+1 for the brilliant rbind trick! You can save 2 extra bytes if you assign 2:n-1 to a variable, say a: which(!n%%1:(n-1))  thus becomes a[!n%%a]. (The full code being then n=scan();a=2:n-1;b=sum(w<-a[!n%%a]);cat('I am','not'[b!=n],'a perfect number, because',rbind('+',w)[-1],'=',b,c('<'[b<n],'>'[b>n],'==')[1],n))

@plannapus  Thanks, I was really pleased with that myself.

Python 2, 183 173 170 bytes
b=input();c=[i for i in range(1,b)if b%i<1];d=sum(c);print'I am %sa perfect number because %s = %d %s %d'%('not '*(d!=b),' + '.join(map(str,c)),d,'=<>='[cmp(b,d)%3::3],b)

Examples:
$ python perfect_number.py <<< 6
I am a perfect number because 1 + 2 + 3 = 6 == 6
$ python perfect_number.py <<< 12
I am not a perfect number because 1 + 2 + 3 + 4 + 6 = 16 > 12
$ python perfect_number.py <<< 13
I am not a perfect number because 1 = 1 < 13
$ python perfect_number.py <<< 100
I am not a perfect number because 1 + 2 + 4 + 5 + 10 + 20 + 25 + 50 = 117 > 100
$ python perfect_number.py <<< 8128
I am a perfect number because 1 + 2 + 4 + 8 + 16 + 32 + 64 + 127 + 254 + 508 + 1016 + 2032 + 4064 = 8128 == 8128

Thanks to xnor for saving 13 bytes!

'=<>'[cmp(b,d)] - join the revolution!

Excellent, thanks! Oh, wait ... :)

@Celeo I came up with a similar solution. You can write b%i<1 for b%i==0. For ['not ',''][int(d==b)], you don't need the int, because Python will convert automatically. Moreover, you can use string mulitplication "not "*(d!=b).

@xnor thanks for the suggestions!

@Celeo You can adjust orlp's suggestion to work as "=<>="[cmp(b,d)%3::3].

Clever, @xnor, thanks!

Julia, 161 157 bytes
n=int(ARGS[1])
d=filter(i->n%i<1,1:n-1)
s=sum(d)
print("I am ",s!=n?"not ":"","a perfect number, because ",join(d," + ")," = $s ",s<n?"<":s>n?">":"=="," $n")

Ungolfed:
# Read n as the first command line argument
n = int(ARGS[1])

# Get the divisors of n and their sum
d = filter(i -> n % i == 0, 1:n-1)
s = sum(d)

# Print to STDOUT
print("I am ",
      s != n ? "not " : "",
      "a perfect number, because ",
      join(d, " + "),
      " = $s ",
      s < n ? "<" : s > n ? ">" : "==",
      " $n")

CJam, 90 bytes
"I am"rd:R{R\%!},:D:+R-g:Cz" not"*" a perfect number, because "D'+*'=+D:++'=C+_'=a&+a+R+S*

For comparison, printing a single = could be achieved in 83 bytes.
Try it online in the CJam interpreter.
How it works
"I am"  e# Push that string.
rd:R    e# Read a Double from STDIN and save it in R.
{       e# Filter; for each I in [0 ... R-1]:
  R\%!  e# Push the logical NOT of (R % I).
},      e# Keep the elements such that R % I == 0.
:D      e# Save the array of divisors in D.
:+R-g   e# Add the divisors, subtract R and compute the sign of the difference.
:Cz     e# Save the sign in C and apply absolute value.
"not "* e# Repeat the string "not " that many times.

" a perfect number, because "

D'+*    e# Join the divisors, separating by plus signs.
'=+D:++ e# Append a '=' and the sum of the divisors.
'=C+    e# Add the sign to '=', pushing '<', '=' or '>'.
_'=a&   e# Intersect a copy with ['='].
+a+     e# Concatenate, wrap in array and concatenate.
        e# This appends "<", "==" or ">".
R+      e# Append the input number.
S*      e# Join, separating by spaces.

Lua, 244 231 bytes
Golfed:
n=io.read("*n")d={}s="1"t=1 for i=2,n-1 do if n%i==0 then table.insert(d,i)s=s.." + "..i t=t+i end end print(("I am%s a perfect number, because %s = %s"):format(t==n and""or" not", s, t..(t==n and" == "or(t>n and" > "or" < "))..n))

Ungolfed:
n=io.read("*n")
divisors={}
sequence="1"
sum=1
for i=2,n-1 do
    if n%i==0 then
        table.insert(divisors,i)
        sequence=sequence.." + "..i
        sum=sum+i
    end
end

print(("I am%s a perfect number, because %s = %s"):format(sum==n and""or" not", sequence, sum..(sum==n and" == "or(sum>n and" > "or" < "))..n))

Perl, 148 Bytes
$a=<>;$_=join' + ',grep{$a%$_==0}1..$a-1;$s=eval;print"I am ".($s==$a?'':'not ')."a perfect number because $_ = $s ".(('==','>','<')[$s<=>$a])." $a"

With line breaks:
$a=<>;
$_=join' + ',grep{$a%$_==0}1..$a-1;
$s=eval;
print"I am ".($s==$a?'':'not ')."a perfect number because $_ = $s ".(('==','>','<')[$s<=>$a])." $a"

I've had a poke over this and you can save 10 bytes by removing the outer parens around the 'not ' and '==','>','<' statements and switching from . to , (since nothing is added when printing a list). Also moving your assignments into parens the first time they're used saves a couple, and if you change the logic slightly to grep$a%_<1,1..($a=<>)-1 and $a!=($s=eval)&&'not ' you should shave off a few more! Hope that all makes sense!

Ruby, 174 160 155 136 134 128 122 Bytes
n=6;a=[*1...n].reject{|t|n%t>0};b=a.inject(:+)<=>n;print"I am#{" not"*b.abs} a perfect number, because ",a*?+,"<=>"[b+1],n

Saved another 6 Bytes :)
Thanks to
Tips for golfing in Ruby

The print command still bothers me.. And I need to figure out a way to shorten the if-statement ternary ? needs an else clause I cannot provide and only accepts one call per case

only one print statement is left :)

JavaScript (ES6), 146
Using template strings, it works in Firefox and latest Chrome.

for(n=prompt(),o=t=i=1;++i<n;)n%i||(t+=i,o+=' + '+i)
alert(`I am ${t-n?'not ':''}a perfect number because ${o} = ${t} ${t<n?'<':t>n?'>':'=='} `+n)

C#, 252 bytes
class A{static void Main(string[]a){int i=int.Parse(a[0]);var j=Enumerable.Range(1,i-1).Where(o=>i%o==0);int k=j.Sum();Console.Write("I am "+(i!=k?"not ":"")+"a perfect number, because "+string.Join(" + ",j)+" = "+k+(k>i?" > ":k<i?" < ":" == ")+i);}}

Hassium, 285 Bytes
Disclaimer: Works with only the latest version of Hassium due to issues with command line args.
func main(){n=Convert.toNumber(args[0]);s=1;l="1";foreach(x in range(2,n-3)){if(n%x==0){l+=" + "+x;s+=x;}}if(s==n)println("I am a perfect number, because "+l+" = "+s+" == "+s);else {print("I am not a perfect number, because "+l+" = "+s);if(s>n)println(" > "+n);else println(" < "+n);}}

More readable version:
func main() {
    n = Convert.toNumber(args[0]);
    s = 1;
    l = "1";
    foreach(x in range(2, n - 3)) {
            if (n % x== 0) {
                    l += " + " + x;
                    s += x;
            }
    }
    if (s == n)
            println("I am a perfect number, because " + l + " = " + s + " == " + s);
    else {
            print("I am not a perfect number, because " + l + " = " + s);
            if (s > n)
                    println(" > " + n);
            else
                    println(" < " + n);
    }
}

I can't seem to convince Hassium to read my command-line arguments. If I execute mono src/Hassium/bin/Debug/Hassium.exe t.hs 6, it says System.ArgumentException: The file 6 does not exist.. 2. This doesn't work with this version, which is the lastest commit before this challenge was posted. Please add a disclaimer to your answer that state that your submission is non-competing.

I tried it on Windows (built using MVS2015) and got same error.

This is an issue that was updated literally 15 minutes ago. Clone the Hassium and compile again. I am very sorry as I ran into the exact same problem.

It works fine with the latest version. Now if you could just add the disclaimer, I'll be happy to remove my downvote. (By the way, you can ping me by adding @Dennis to your comment. Otherwise, I don't get notified of your reply.)

@Dennis I added it in. Thank you for your notification :)

MATLAB, 238
Never going to be the shortest of all languages, but here's my attempt with MATLAB:
n=input('');x=1:n-1;f=x(~rem(n,x));s=sum(f);a='not ';b=strjoin(strtrim(cellstr(num2str(f')))',' + ');if(s>n) c=' > ';elseif(s<n) c=' < ';else c=' == ';a='';end;disp(['I am ' a 'a perfect number, because ' b ' = ' num2str(s) c num2str(n)])

And this is in a slightly more readable form:
n=input();      %Read in the number using the input() function
x=1:n-1;        %All integers from 1 to n-1
f=x(~rem(n,x)); %Determine which of those numbers are divisors
s=sum(f);       %Sum all the divisors
a='not ';       %We start by assuming it is not perfect (to save some bytes)
b=strjoin(strtrim(cellstr(num2str(f')))',' + '); %Also convert the list of divisors into a string
                                                 %where they are all separated by ' + ' signs.
%Next check if the number is >, < or == to the sum of its divisors
if(s>n)
    c=' > ';    %If greater than, we add a ' > ' to the output string
elseif(s<n)
    c=' < ';    %If less than, we add a ' < ' to the output string
else
    c=' == ';   %If equal, we add a ' == ' to the output string
    a='';       %If it is equal, then it is a perfect number, so clear the 'not' string
end

%Finally concatenate the output string and display the result
disp(['I am ' a 'a perfect number, because ' b ' = ' num2str(s) c num2str(n)])

I've managed to save 2 more bytes by not using a function. Instead you run the line of code and it requests the number as an input. Once run it displays the output at the end.

Perl 6, 138 bytes
$_=get;
my$c=$_ <=>my$s=[+] my@d=grep $_%%*,^$_;
say "I am {
    'not 'x?$c
  }a perfect number, because {
    join ' + ',@d
  } = $s {
    «> == <»[1+$c]
  } $_"

( The count ignores the newlines, and indents, because they aren't needed )
@d is the array holding the divisors.
$s holds the sum of the divisors.
$c is the value of the comparison between the input, and the sum of the divisors.
( effectively $c is one of -1,0,1, but is really one of Order::Less, Order::Same, or Order::More )
In 'not 'x?$c, ?$c in this case is effectively the same as abs $c, and x is the string repetition operator.
«> == <» is short for ( '>', '==', '<' ).
Since $c has one of -1,0,1, we have to shift it up by one to be able to use it to index into a list.
Technically this will work for numbers well above 2⁶⁴, but takes an inordinate amount of time for numbers above 2¹⁶.

Pyth, 84 bytes
jd+,+"I am"*.aK._-QsJf!%QTtUQ" not""a perfect number, because"+.iJm\+tJ[\=sJ@"=<>"KQ

Invalid answer, because I refuse to implement = and == in the same equation.

+1 for refusing to "implement = and == in the same equation."

Ruby, 164 Bytes
->i{t=(1...i).select{|j|i%j==0};s=t.inject &:+;r=['==','>','<'][s<=>i];puts "I am #{'not ' if r!='=='}a perfect number, because #{t.join(' + ')} = #{s} #{r} #{i}"}

Test
irb(main):185:0> ->i{t=(1...i).select{|j|i%j==0};s=t.inject &:+;r=['==','>','<'][s<=>i];puts "I am #{'not ' if r!='=='}a perfect number, because #{t.join(' + ')} = #{s} #{r} #{i}"}.call 6
I am a perfect number, because 1 + 2 + 3 = 6 == 6

irb(main):186:0> ->i{t=(1...i).select{|j|i%j==0};s=t.inject &:+;r=['==','>','<'][s<=>i];puts "I am #{'not ' if r!='=='}a perfect number, because #{t.join(' + ')} = #{s} #{r} #{i}"}.call 12
I am not a perfect number, because 1 + 2 + 3 + 4 + 6 = 16 > 12

irb(main):187:0> ->i{t=(1...i).select{|j|i%j==0};s=t.inject &:+;r=['==','>','<'][s<=>i];puts "I am #{'not ' if r!='=='}a perfect number, because #{t.join(' + ')} = #{s} #{r} #{i}"}.call 13
I am not a perfect number, because 1 = 1 < 13

Emacs Lisp, 302 Bytes
(defun p(n)(let((l(remove-if-not'(lambda(x)(=(% n x)0))(number-sequence 1(- n 1)))))(setf s(apply'+ l))(format"I am%s a perfect number, because %s%s = %s %s %s"(if(= s n)""" not")(car l)(apply#'concat(mapcar'(lambda(x)(concat" + "(number-to-string x)))(cdr l)))s(if(= sum n)"=="(if(> sum n)">""<"))n)))

Ungolfed version:
(defun perfect (n)
  (let ((l (remove-if-not '(lambda (x) (= (% n x) 0))
              (number-sequence 1 (- n 1)))))
    (setf sum (apply '+ l))
    (format "I am%s a perfect number, because %s%s = %s %s %s" (if (= sum n)"" " not") (car l)
        (apply #'concat (mapcar '(lambda (x) (concat " + " (number-to-string x))) (cdr l)))
        sum (if(= sum n)
            "=="
          (if(> sum n)
              ">"
            "<"))
        n)))

Powershell, 164 bytes
$a=$args[0]
$b=(1..($a-1)|?{!($a%$_)})-join" + "
$c=iex $b
$d=$a.compareto($c)
"I am $("not "*!!$d)a perfect number, because $b = $c $(("==","<",">")[$d]) $a"

A few of the common and not so common PoSh tricks;

Create the sum, then evaluate it with iex
Compareto to index the gt, lt, eq array
!!$d will evaluate to true == 1 for $d = 1 or -1, and false == 0 for $d = 0

awk, 150
n=$0{for(p=i=s=n>1;++i<n;)for(;n%i<1;p+=i++)s=s" + "i;printf"I am%s a perfect number, because "s" = "p" %s "n RS,(k=p==n)?_:" not",k?"==":p<n?"<":">"}

Wasted some bytes on making this correct for input 1. I'm not sure if that is expected.
n=$0{
    for(p=i=s=n>1;++i<n;)
        for(;n%i<1;p+=i++)s=s" + "i;
    printf "I am%s a perfect number, because "s" = "p" %s "n RS,
           (k=p==n)?_:" not",k?"==":p<n?"<":">"
}

05AB1E, 58 bytes
„I€ÜIÑ¨©OIÊi'€–}“€…íÀ‚³,ƒ«“®vy'+}\'=®ODI.S"==><"211S£sèIðý

Try it online or verify all test cases.
Explanation:
„I€Ü              # Push dictionary string "I am"
IÑ¨               # Push the divisors of the input-integer, with itself removed
   ©              # Store it in the register (without popping)
    O             # Get the sum of these divisors
     IÊi   }      # If it's not equal to the input-integer:
        '€–      '#  Push dictionary string "not"
“€…íÀ‚³,ƒ«“       # Push dictionary string "a perfect number, because"
®v   }            # Loop `y` over the divisors:
  y'+            '#  Push the divisor `y`, and the string "+" to the stack
      \           # Discard the final "+"
       '=        '# And push the string "="
®O                # Get the sum of the divisors again
  D               # Duplicate it
I.S               # Compare it to the input-integer (-1 if smaller; 0 if equal; 1 if larger)
   "==><"         # Push string "==><"
         211S£    # Split into parts of size [2,1,1]: ["==",">","<"]
              sè  # Index into it (where the -1 will wrap around to the last item)
I                 # Push the input-integer again
ðý                # Join everything on the stack by spaces
                  # (and output the result implicitly)

See this 05AB1E tip of mine (section How to use the dictionary?) to understand why „I€Ü is "I am", '€– is "not", and “€…íÀ‚³,ƒ«“ is "a perfect number, because".

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

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


text:
Whole-number powers
Some numbers like 64 can be expressed as a whole-number power in multiple ways:
64 ^ 1
 8 ^ 2
 4 ^ 3
 2 ^ 6

Output a sorted array of all possible such powers (here, [1,2,3,6]) in as few bytes as possible.

Input
A positive whole number that's greater than 1 and less than 10000.

Output
An array of whole-number powers p (including 1) for which the input can be expressed as a^p with whole-number a. The outputs may have decimals, as long as they are in order.
Any floating point issues must be handled by the program.

Examples
Input: 3
Output: [1]

Input: 9
Output: [1, 2]

Input: 81
Output: [1, 2, 4]

Input: 729
Output: [1, 2, 3, 6]

Scoreboard
For your score to appear on the board, it should be in this format:
# Language, Bytes

Strikethroughs shouldn't cause a problem.

function getURL(e){return"https://api.stackexchange.com/2.2/questions/"+QUESTION_ID+"/answers?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+ANSWER_FILTER}function getAnswers(){$.ajax({url:getURL(answer_page++),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){answers.push.apply(answers,e.items),answers_hash=[],answer_ids=[],e.items.forEach(function(e){var s=+e.share_link.match(/\d+/);answer_ids.push(s),answers_hash[s]=e}),useData(answers)}})}function getOwnerName(e){return e.owner.display_name}function useData(e){var s=[];e.forEach(function(e){var a=e.body.replace(/<s>.*<\/s>/,"").replace(/.*<\/strike>/,"");console.log(a),VALID_HEAD.test(a)&&s.push({user:getOwnerName(e),language:a.match(VALID_HEAD)[1],score:+a.match(VALID_HEAD)[2],link:e.share_link})}),s.sort(function(e,s){var a=e.score,r=s.score;return a-r}),s.forEach(function(e,s){var a=$("#score-template").html();a=a.replace("{{RANK}}",s+1+"").replace("{{NAME}}",e.user).replace("{{LANGUAGE}}",e.language).replace("{{SCORE}}",e.score),a=$(a),$("#scores").append(a)})}var QUESTION_ID=58047,ANSWER_FILTER="!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe",answers=[],answer_ids,answers_hash,answer_page=1;getAnswers();var VALID_HEAD=/<h\d>([^\n,]*)[, ]*(\d+).*<\/h\d>/;
body{text-align:left!important}table thead{font-weight:700}table td{padding:10px 0 0 30px}#scores-cont{padding:10px;width:600px}#scores tr td:first-of-type{padding-left:0}
<link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b">

Scores

	User	Language	Score

{{RANK}}	{{NAME}}	{{LANGUAGE}}	{{SCORE}}

Yes! I overlooked it. Thank you very much. @steveverrill

My answer prints [1 2 3 6] for the last test case. Could it also print [6 3 2 1], [1.0 2.0 3.0 6.0] or [6.0 3.0 2.0 1.0]?

The roots should be in ascending order; however, decimals are fine. @Dennis

What can we assume about input sizes and floating-point arithmetic? This affects the solution where you try to take roots of the number and see if the result is integer.

I've added some more details. Hopefully I've resolved these questions. @xnor

I think the references to roots were confusing everyone, so I rewrote it in terms of powers. Feel free to change things back.

I appreciate the edit! Suggestions and revisions are always welcome, provided they improve my question's quality (which I believe yours did). I've only recently started asking questions on this particular network, and find the community generally welcoming. Criticism and correction is much appreciated! @xnor

You've asked for a "program" but in most languages a program cannot output an array, only a text representation of one (to stdout or possibly as a return value). In Ruby, for example, this is normally the array elements separated by newlines, which looks different from your representation. Is this OK? Or do you require a function which returns an array?

Simply find the largest valid power and then list its factors!

If the language can not naturally return an array, as represented above, I will accept the closest alternative. @steveverrill

Related. Related.

Pyth, 10 bytes
f}Q^RTSQSQ

Demonstration
For each power, it generates the list of all numbers up to the input taken to that power, and then checks if the input is in the list.

Haskell, 38
f n=[b|b<-[1..n],n`elem`map(^b)[1..n]]

Pretty straightforward. The list comprehension finds values of b for which the input n appears among [1^b, 2^b, ..., n^b]. It suffices to check b in the range [1..n].

Python 2, 53
lambda n:[i/n for i in range(n*n)if(i%n+1)**(i/n)==n]

Brute forces all combinations of bases in exponents in [0, n-1] and bases in [1, n].

Python 3, 56 bytes

lambda n:[i for i in range(1,n)if round(n**(1/i))**i==n]

This is really clumsy. Tests if each potential i-th root gives an integer by rounding it, taking it the power of i, and checking that it equals to original.
Directly checking that the root is a whole number is tricky because floating points give things like 64**(1/3) == 3.9999999999999996. Rounding it to an integer let us check if taking the power returns to the original value. Thanks to ypercube for suggesting this, saving 1 byte.
feersum has a shorter and more clever solution. You all should really upvote that.

Wouldn't it be accurate if you checked round(n**(1/i),0)**i==n ?

@ypercube Good call, together with 0 being the default accuracy for round, this saves a byte.

Pyth, 11 10 12 bytes
fsmqQ^dTSQSQ

Checks all possible combinations of powers. Very slow.

APL, 17 bytes
(X=⌊X←N*÷⍳N)/⍳N←⎕

My first APL program; golfing suggestions are appreciated.
              N←⎕  ⍝ Store input into N
             ⍳     ⍝ The list [1 2 ... N]
            /      ⍝ Select the elements A for which
      N*÷⍳N)       ⍝ N^(1/A)
(X=⌊X←             ⍝ equals its floor (that is, is an integer)

Please add pseudocode/explanation. But +1 (can't vote right now) for using APL ( - being terse before it was cool) :-)

Also +1, much love for APL. Ultimate golfing vehicle.

Based on the pseudocode, this is unlikely to work (unless APL performs an approximate floating-point equality test). For example, with pow(pow(7,3),1./3)) I get 6.99999999999999 in C or Python. This is because accuracy is lost when calculating 1/A.

@feersum I don't know about offline interpreters, but all powers of 3 work correctly on tryapl.org.

@ThomasKwa It seems that an approximate equality test is indeed used. http://www.dyalog.com/uploads/documents/Papers/tolerant_comparison/tolerant_comparison.htm

CJam, 23 bytes
rimF{1=:E){E\d%!},}%:&p

This works by taking the prime factorization of n and computing the intersection of the divisors of all exponents.
It is a bit longer than my other solution, but I expect it to work (and finish instantly) for all integers between 2 and 263 - 1.
Try it online in the CJam interpreter.
How it works
ri                       Read an integer from STDIN.
  mF                     Push its prime factorization.
    {             }%     For each [prime exponent]:
     1=:E                  Retrieve the exponent and save it in E.
         ){     },         Filter; for each I in [0 ... E]:
           E\d%              Compute E % Double(I).
                             (Casting to Double is required to divide by 0.)
               !             Push the logical NOT of the modulus.
                           Keep I if the result is truhty, i.e., if I divides E.
                    :&   Intersect all resulting arrays of integers.
                      p  Print the resulting array.

Jelly, 6 bytes
ÆEg/ÆD

Try it online!
    ÆD    The list of divisors of
ÆE        the exponents in the prime factorization of the input
   /      reduced by
  g       greatest common divisor.

JavaScript (ES5), 73 bytes 81 bytes 79 bytes 75 bytes
for(n=+prompt(),p=Math.pow,i=0;i++<n;)p(.5+p(n,1/i)|0,i)==n&&console.log(i)

Checks to see if closest integer power of possible root equals n. ~~(.5+...) is equivalent to Math.round(...) for expressions within integer range (0 to 2^31 - 1).
Edit: Used lazy && logic instead of if to shave 2 bytes and added prompt for input since question added a clarification. Was previously assuming input was stored in n.
Edit 2: Changed ~~(.5+...) to .5+...|0 to save two bytes by avoiding grouping.
Edit 3: Removed var  to save 4 bytes. In non-strict mode, this is acceptable.

You can shave a couple bytes by juggling expressions: for(var p=Math.pow,i=1;i++<n;p(~~(.5+p(n,1/i)),i)==n&&console.log(i));

@Alhadis thanks for your input, I'll make an edit in a bit

@PatrickRoberts You could squeeze p=Math.pow into prompt saving 1 byte

@vihan, that would be an invalid declaration, since var is required

Unless you meant for instead of prompt..

Erm. Technically, prompt isn't JavaScript... it's a method defined by the DOM's Window interface, which is mean to be language-agnostic. But yeah. ;)

@Alhadis it's valid client-side JavaScript, and the only method of input available that doesn't require using the DOM, plus prompt is commonly accepted in code-golfing on this site so I already know it's allowed.

Brachylog, 8 bytes
≥^↙.?≥ℕ≜

Try it online!
Takes input through its input variable and generates each power through its output variable, in ascending order as required, unlike the old solution ≥ℕ≜^↙.?∧ which just so happens to have the exact same length.
≥           Some number which is less than or equal to
            the input,
 ^          when raised to the power of
  ↙.        the output,
    ?       is the input.
       ≜    Label
            the output
      ℕ     as a whole number
     ≥      which is less than or equal to
    ?       the input.

I don't have any rigorous justification for asserting that every exponent is no greater than the input, but in order for the program to actually terminate it needs to be bounded.
ḋḅlᵛf is a far shorter (non-generator) solution for all of the given test cases, but it fails if the input isn't a power of a product of distinct primes. (Come to think of it, since all of the test cases are powers of primes, ḋlf also works...) The best I've come up with to salvage the idea, ḋḅlᵐḋˢ⊇ᵛ×f, comes out to 10 bytes.

05AB1E, 3 bytes
Ó¿Ñ

Try it online!
Port of Unrelated String’s Jelly answer.
Ó       # exponents in the prime factorization
 ¿      # gcd
  Ñ     # divisors

CJam, 20 bytes
ri_,1df+\1$fmL9fmO&p

For input n, this computes logb n for all b less or equal to n and keeps the results that are integers.
This should work for all integers between 2 and 9,999. Run time is roughly O(n).
Try it online in the CJam interpreter.
How it works
ri                   e# Read an integer N from STDIN.
  _,                 e# Copy N and transform it into [0 ... N-1].
    1df+             e# Add 1.0 to each, resulting in [1.0 ... Nd].
        \1$          e# Swap the array with N and copy the array.
           fmL       e# Mapped log base N: N [1.0 ... Nd] -> [log1(N) ... logN(N)]
              9fmO   e# Round each logarithm to 9 decimals.
                  &  e# Intersect this array with [1.0 ... Nd].
                   p e# Print the result.

Is 15,625 the only input on which it fails or is it the only which failed that you tested?

There are most definitely others. In fact, I just found out that it failed for 4913 as well, which made my previous revision invalid.

JavaScript ES7, 66 bytes
Takes advantage of experimental array comprehensions. Only works on Firefox.
n=>[for(i of Array(n).keys(m=Math.pow))if(m(0|.5+m(n,1/i),i)==n)i]

Possible golfing. I'll probably try to squish the expressions a little shorter and hopefully find an alternative to the long Array(n).keys() syntax.
Could be shorter but JavaScript has horribly floating point accuracy.

Ah, learned something new... cool.

Ruby, 50
->n{(1..n).map{|i|(n**(1.0/i)+1e-9)%1>1e-8||p(i)}}

Prints to screen.
Ruby, 57
->n{a=[]
(1..n).map{|i|(n**(1.0/i)+1e-9)%1>1e-8||a<n{(1..n).map{|i|(n**(1.0/i)+1e-9)%1>1e-8||puts(i)}}

g=->n{a=[]
(1..n).map{|i|(n**(1.0/i)+1e-9)%1>1e-8||a<<i}
a}

f.call(4096)
puts g.call(4096)

Calculates each root and tests them modulo 1 to see if the remainder is less than 1e-8. Due to limited precision some valid integer roots are calculated to be the form 0.9999.., hence the need to add 1e-9 to them.
Up to the nth root of n is calculated, which is total overkill, but seemed the shortest way to write a non-infinite loop.

DC, 104 bytes
Input is taken from terminal, output is printed and also on the stack.
Because this uses the ? operator, you need to use dc -e "<solution>" or dc <file with solution in it>.
Nobody ever sees my answers, let alone vote on them, but I really just enjoy solving problems in DC. It's the least efficient solution in this thread so far, but I thought I'd post it anyways.
1sb?sn[lesi]ss[lble1+dse^dln=sln>c]sc[liSflq1+sq]sm[Lfplq1-dsq0
c]sc
[lb                 ]   load our base num (register b)
[  le               ]   load our exponent (register e)
[    1+dse          ]   add 1 to the exponent, copy and store in the e register
[         ^d        ]   raise the base to the exponent and copy it
[           ln=s    ]   load the user input, if that is equal to the power result run the macro in register s
[               ln>c]   load the user input, if it's greater than the power result run the macro in register c (this one)
[                   ]sc save this macro in register c

Macro to save a valid exponent value as found from the above exponent macros to another stack
[liSflq1+sq]sm
[liSf      ]     copy the i register to the top of the stack in register f
[    lq1+sq]     add 1 to the q register
[          ]sm   save this macro in the m register

Macro to run the 2x above macro (macro c) through all bases from 2 to our target number
[lb1+sb0si0selcxli0!=mlbln!=h]dsh
[lb1+sb                      ]     add 1 to the base number
[      0si0se                ]     reset the i and e registers (previously found value and exponent
[            lcx             ]     load and run the c macro
[               li0!=m       ]     load the result of the c macro and if it's not 0, run m to save it to the f stack
[                     lbln!=h]     if our base number is not equal to our target number, run macro h (this macro)
[                            ]dsh  duplicate this macro and save one copy, so that one is left on the stack to run later

Macro to print the values from the f stack
[Lfplq1-dsq0<p]dsp
[Lfp          ]      load the top value from the f register and print it
[   lq1-dsq   ]      load the q register and subtract one from it and save it
[          0<p]      if the q register is greater than 0, run macro p (this macro) again
[             ]dsp   duplicate this macro and save one copy, so that one is left on the stack to run later

xx finally run the two macros on the stack (h and then p)

I would guess that not many people know DC. Answering new questions (especially being one of the earliest answers) will help with getting more attention. You might also try using TIO links for your answers, as that's very popular. Here's DC on TIO.

Thanks! I'll definitely use that for answers going forwards!

Stax, 6 bytes
£ÅeÉåC

Run and debug it
All divisors of the gcd of exponents in the prime factorization.  It's the same as the jelly algorithm.

Ruby, 46 bytes
Brute force solution. Self-explanatory; for input \$n\$, find all numbers \$e\$ where for some \$b\$, \$b^e=n\$.
->n{(0..n).select{|e|(1..n).find{|b|b**e==n}}}

Try it online!

C# (Visual C# Interactive Compiler), 93 bytes
g=n=>Enumerable.Range(1,n);
f=n=>g(n).SelectMany(x=>g(n).Where(y=>(Math.Pow(x,y)==n))).Reverse()

Try it online!

Japt, 10 bytes
õ
f@mpX øN

Try it
õ            :Implicit input of integer U
õ            :Range [1,U]
f@mpX øN     :Reassign to U
f            :Filter
 @           :By passing each X through the following function
  m          :  Map U
   pX        :    Raise to the power of X
      ø      :  Contains
       N     :    Any element of the (singelton) array of inputs


text:
Reconstruct a Text Rectangle from Diagonal Strips
This challenge is inspired by a SO question about traversing a matrix by enumerating all its diagonal strips.
Instead of a matrix, consider a block of text:
ABCD
EFGH
IJKL

Traversing this block's SW-NE diagonals from left to right, starting from the top left corner and ending in the bottom right, results in the following output:
A
EB
IFC
JGD
KH
L

Challenge
Write a program or a function that execute the reverse of the process described above. That is, given a set SW-NE diagonal strips, output the block of text that produced it.
Input and Output
Both input and output can be represented as strings with newlines, or arrays/lists of strings.
Trailing newlines are optional.
The input will consist of at least one printable character and can be assumed to be correct (there will not be inconsistent row lengths).
The output block will always have a number of columns greater than or equal to the number of rows.
Test Cases
Input:
A

Output:
A

Input:
.
LI
PO.
PV.
CE
G

Output:
.I..
LOVE
PPCG

Input:
M
DA
AIT
LAR
SGI
/OX
/N
/

Output:
MATRIX
DIAGON
ALS///

Will the input strings contain any spaces?

Also, is trailing whitespace allowed?

@kirbyfan64sos Yes, input may contain spaces. Trailing whitespace is allowed.

CJam, 23 20 bytes
{_z,,Nf*W%\.+zW%sN%}

Try it here.

Taking advantage of the input format (and not breaking on spaces): {_z,,Nf*W%\.+zW%sN%}

@Dennis Do I count the curly braces, because it's a "function"? I'm new to CJam golf.

Yes. The block (with curly brackets) is CJam's closest alternative to an anonymous function/lambda, so this counts as 20 bytes.

Python 2, 84
L=[]
for w in input():
 i=0;L+=[''][:len(w)-len(L)]
 for c in w:i-=1;L[i]+=c
print L

Input and output are lists of strings.
input: ['A','EB','IFC','JGD','KH','L']
output: ['ABCD', 'EFGH', 'IJKL']

The list of lines L to output is built up as we read the input. Each new character is appended to a line, starting from the last line i=-1 and progressing towards the front.
Whenever the new line to add is too long for the list, a new empty line is appended: L+=[''][:len(w)-len(L)]. I'm hoping for a way to shorten this part.

Python 2, 165 162 169 163 bytes
import sys
j=map(list,[e.strip() for e in sys.stdin.readlines()])
r=max(1,len(j)-2)
while j:
 s=''
 for b in range(r):s+=j[b].pop()
 j=[e for e in j if e]
 print s

Reads all lines from input, then turns them into a list of lists. Loops while that list has elements. In each iteration, it pops the last element from the number of inner lists equal to the number of columns in the output. The list is then cleaned and the line printed.
Examples:
$ python rectangle.py << EOF
> A
> EB
> IFC
> JGD
> KH
> L
> EOF
ABCD
EFGH
IJKL
$ python rectangle.py << EOF
> .
> LI
> PO.
> PV.
> CE
> G
> EOF
.I..
LOVE
PPCG
$ python rectangle.py << EOF
> M
> DA
> AIT
> LAR
> SGI
> /OX
> /N
> /
> EOF
MATRIX
DIAGON
ALS///

Thanks to w0lf for saving 6 bytes.
PYG, 139 bytes
j=M(L,[e.strip() for e in sys.stdin.readlines()])
r=Mx(1,len(j)-2)
while j:
 s=''
 for b in R(r):s+=j[b].pop()
 j=[e for e in j if e]
 P(s)

Is the last s='' needed?

Ah, it sneaked in there; thanks!

Python, 332 325 bytes
Because Python.
n=[]
v=[]
x=y=-1
l=0
s=""
while 1:
 k=raw_input()
 if len(k)<1:break
 n.append(k)
while 1:
 if l>len(n):break
 y+=1
 try:
    x+=1;k=n[y][x]
    if[x,y]not in v:s+=k;v.append([x,y])
    else:raise
 except:
    try:
     x-=1;k=n[y][x]
     if[x,y]not in v:s+=k;v.append([x,y])
    except:s+="\n";x=-1;y=l;l+=1
print s[:s.rstrip("\n").rfind("\n")]

This is a [code-golf] question, which means answers must try to be a short as possible. Try removing some whitespace and simplifying your algorithm to save more space. Check out this great resource on golfing in python if you need ideas.

I'll check it out, thanks!


text:
Code me some golf
If you haven't played golf before, here's a list of golf-related terms I use in this question

Shot, also called a stroke: Every time the ball is hit, this is a shot.
Hole: A golf course is split into holes, in which the goal is to hit a ball from one designated location to another in as few shots as possible.
Tee: Where you start a hole.
Pin or Flag: Where you finish a hole
Fairway, Rough, Water, and Green: Features on a golf course that affect how one plays the ball in real life. (How they affect the program is specified below)

I'm going out to play golf tomorrow, and I find that sometimes, I have trouble figuring out what club to use to hit a certain yardage. So I decided to write down my clubs and their yardages per shot.
First Assumption: All holes are due north of their tee boxes.
All of these yardages measure the possibilities for how far north the ball travels. The ball will travel a random integer distance between the bounds specified for each club (inclusive).
As a master golfer, none of my shots have any horizontal shift. This means that all of my shots go in a straight line directly at the flag.
Club #     Club        Yardage
1          Driver      300-330
2          3-Wood      270-299
3          5-Wood      240-269
4          3-Iron      220-239
5          4-Iron      200-219
6          5-Iron      180-199
7          6-Iron      160-179
8          7-Iron      140-159
9          8-Iron      120-139
10         9-Iron      100-119
11         P-Wedge     80-99
12         S-Wedge     50-79
13         L-Wedge     0-49
14         Putter      (only on green)

As a person who enjoys programming, I decide that I want to model a round of golf and set a goal for how well I want to do tomorrow. However, like any amateur programmer, after ten minutes, I gave up and asked for help on Stack Overflow (just kidding). Here are some more data about the course.
Second Assumption: Hole Geography

All numbers that describe distances on the course are integers.
Each hole is a straight line. The straight line distance between each hole and the pin (the end of the hole) is Length.
Fairways are segments with length defined by flen. The value listed for flen is the range of yardages north from the tee where fairway is.
Water hazards are segments that have length defined by wlen, which has the same properties as flen.
The green has a length defined by glen.
All parts of the course that are not fairway, water, or green are rough.

Here is a chart describing each hole on the course.
Hole #     Length      flen               wlen        glen
1          401         54-390                         391-425
2          171                            1-165       166-179
3          438         41-392             393-420     421-445
4          553         30-281,354-549     282-353     550-589
5          389         48-372                         373-404
6          133                                        125-138
7          496         37-413             414-484     484-502
8          415         50-391                         392-420
9          320         23-258             259-303     304-327

How to play Golf (for this program)

Always aim exactly at the flag.
Hit the ball as close to the pin as possible, trying to keep the ball on the fairway or (preferably) on the green.
When you land a shot in the water, your next shot must be played from the same place as the shot that went into the water.
Once the ball lands on the green, only the putter can be used. If the ball lands strictly more than 5 yards from the pin, then I putt twice. Otherwise, I putt once.
It is possible to hit a shot past the pin.

Scoring
My score on a hole is the number of shots I take, plus one stroke for every time I land in rough or the water.
The program
Okay, that was a lot of rules, now let's talk about the program.
The course should be defined as above in the program, because the course is constant. Different golfers, however, have different distances for each shot, so the input to STDIN should be a set of ranges of yardages, arranged in increasing order of club number and separated by commas (with no whitespace).
The output should be how I "play" the round of golf. The hold number should be specified at the beginning of each line as Hole #: where # is the current hole. Each shot that is not a putt is of the following form: {club,distance of shot,condition of ball,distance to pin}. The details of the shot should be separated by commas but no whitespace in the above order. The shots themselves should be written in order of how they are played and separated by a space. Once the ball lands on the green, the program should print how many putts I take, in the format {# putts}. At the end of each line, the number of shots I took on the hole should be separated from the other shots by a space and printed as (#). Each hole should be on its own line and written in order. Finally, on the last (tenth) line of the program, the total number of shots for the round should be printed as Total: # shots.
There is no set "strategy" that your program is required to take. You can write a program with any strategy you want. Example strategies include maximizing the percent chance of landing on the green and maximizing the distance of each shot until reaching the hole.
SAMPLE INPUT
300-330,270-299,240-269,220-239,200-219,180-199,160-179,140-159,120-139,100-119,80-99,50-79,0-49

SAMPLE OUTPUT
Hole 1: {Driver,324,Fairway,77} {S-Wedge,70,Green,7} {Two putts} (4)
Hole 2: {6-Iron,162,Water,171} {6-Iron,168,Green,3} {One putt} (4)
Hole 3: {Driver,301,Fairway,137} {8-Iron,131,Green,6} {Two putts} (4)
Hole 4: {3-Wood,288,Water,553} {3-Wood,276,Fairway,277} {3-Wood,291,Green,14} {Two putts} (6)
Hole 5: {Driver,322,Fairway,67} {S-Wedge,62} {One putt} (3)
Hole 6: {8-Iron,120,Rough,18} {L-Wedge,10,Green,8} {Two putts} (5)
Hole 7: {Driver,325,Fairway,171] {6-Iron,170,Green,1} {One putt} (3)
Hole 8: {Driver,306,Fairway,109} {9-Iron,100,Green,9} {Two putts} (4)
Hole 9: {Driver,308,Green,12} {Two putts} (3)
Total: 36 shots

I'll admit, this is a rather ambitious challenge for a first post on CG.SE, so I'd be glad to talk about how to improve this challenge in comments. Thank you for your help.

I'd really appreciate it if, for us non-golfers, you didn't use as many golfing terms (e.g. "tee boxes" and "horizontal shift"). :)

I'll add a list of golf-related terms. When playing golf, the ball doesn't always go straight, so I just said that the ball always goes directly towards the hole, and thus does not have any horizontal shift.

Say the pin is at 301 yards, and there is fairway from 0~299 yards, green from 300~315 yards, and water from 316~330 yards. What club will be chosen? What if the water is replaced by rough?

Ideally, the program should be able to come up with its own strategy.

What do you mean by "optimal strategy"? Minimizing average number of strokes? As for winning criterion I'd go with code-golf.

I meant that the program should come up with its own strategy for playing the round. For the example you gave, the program could choose the "safe" option of trying to get on the green in two shots, or using a driver to go for the green in one as the "risky" option.

So either strategy is admissible there? What if the pin is at 300 yards, and there is green from 0~300 yards and water from 300 yards on?

@ThomasKwa I think OP means that some sort of standard risk factor applies. Say the shot has a 50% chance of success (ending up with one less shot), but a 75% chance of failing (landing in the water, +1 shot), the risk outweighs the gains and the shot shouldn't be attempted. Say that maybe the chance of a failed shot has to be x% less than the chance of "gaining" a shot for it to be attempted. You could then experiment with that value to create riskier or safer players. If this is what OP means though, it should be a requirement.

@Jan I added that specification.

Does "choose a random club" count as a strategy? What about "choose the driver every time"?

Those are possible strategies, but not great ones in terms of number of shots. "Driver every time" would probably do better in a golfing challenge than in shot-optimization, so I think I'm going to change this into a programming challenge.

Python 2.7: 43 40.5 shots average
This is my first post here so bear with me.
Since the poster was thinking of treating this like a programming challenge, not code golf, I tackled it as more a programming challenge. I attempted to keep my solution and shot logic simple but it turned out more ugly as things got complicated quickly.
My Code
Some things to think of while reading: the program creates a list of clubs used called 'clubs', and a list called 'distances' that is distance the ball has traveled from the tee, hlen is the length of the hole, d1s is the distance each shot travels.
First I define the course. Each fairway, water, and green length had to be defined so later the program could check the condition of the ball, so I added non-integers values for the parts of the course that did not exist.
from random import randint
import numpy as np

#Hole      Length     flen               wlen           glen    Name
hole1 = [    401,     54, 390,       390.5, 390.5,    391, 425, 'Hole 1']
hole2 = [    171,    0.5, 0.5,           1, 165,      166, 179, 'Hole 2']
hole3 = [    438,     41, 392,         393, 420,      421, 445, 'Hole 3']
hole4 = [    553,     30, 549,         282, 353,      550, 589, 'Hole 4']
hole5 = [    389,     48, 372,         1.5, 1.5,      373, 404, 'Hole 5']
hole6 = [    133,    0.5, 0.5,         1.5, 1.5,      125, 138, 'Hole 6']
hole7 = [    496,     37, 413,         414, 484,      484, 502, 'Hole 7']
hole8 = [    415,     50, 391,         1.5, 1.5,      392, 420, 'Hole 8']
hole9 = [    320,     23, 258,         259, 303,      304, 327, 'Hole 9']

holes = [hole1, hole2, hole3, hole4, hole5, hole6, hole7, hole8, hole9]

Here I defined the main logic for choosing a club. The program attempts to maximize distance by choosing the driver for all lengths greater than the max driver distance and chooses a club with range that contains the distance to the hole otherwise. This requires the range provides by the club input to be continuous, i.e. no gaps in shot distance. A realistic requirement since one can hit a club without a full backswing to limit the distance of their shot to the maximum distance of the next most powerful club.
def stroke(distance):
    Length = abs(hlen - distance)
    if Length >= Driver_a:
        club = 'Driver'
        d = randint(Driver_a,Driver_b)
    elif Length >= Wood3_a and Length <= Wood3_b:
        club = '3-Wood'
        d = randint(Wood3_a,Wood3_b)
    elif Length >= Wood5_a and Length <= Wood5_b:
        club = '5-Wood'
        d = randint(Wood5_a,Wood5_b)
    elif Length >= Iron3_a and Length <= Iron3_b:
        club = '3-Iron'
        d = randint(Iron3_a,Iron3_b)
    elif Length >= Iron4_a and Length <= Iron4_b:
        club = '4-Iron'
        d = randint(Iron4_a,Iron4_b)
    elif Length >= Iron5_a and Length <= Iron5_b:
        club = '5-Iron'
        d = randint(Iron5_a,Iron5_b)
    elif Length >= Iron6_a and Length <= Iron6_b:
        club = '6-Iron'
        d = randint(Iron6_a,Iron6_b)
    elif Length >= Iron7_a and Length <= Iron7_b:
        club = '7-Iron'
        d = randint(Iron7_a,Iron7_b)
    elif Length >= Iron8_a and Length <= Iron8_b:
        club = '8-Iron'
        d = randint(Iron8_a,Iron8_b)
    elif Length >= Iron9_a and Length <= Iron9_b:
        club = '9-Iron'
        d = randint(Iron9_a,Iron9_b)
    elif Length >= Pwedge_a and Length <= Pwedge_b:
        club = 'P wedge'
        d = randint(Pwedge_a,Pwedge_b)
    elif Length >= Swedge_a and Length <= Swedge_b:
        club = 'S wedge'
        d = randint(Swedge_a,Swedge_b)
    elif Length >= Lwedge_a and Length <= Lwedge_b:
        club = 'L wedge'
        d = randint(Lwedge_a,Lwedge_b)
    else : print 'stroke error'
    return club, d

Next, I define a put function that two putts for all lengths greater than 5 yards to the hole and one putt for 5 and less. I also include an option for hitting the ball directly into the hole called 'chip in'.
def putt(distance):
    Length = abs(hlen - distance)
    if Length > 5:
        club = '2 putts'
    elif Length == 0:
        club = 'chip in'
    else:
        club = '1 putt'
    return club

Here is where the strategy gets a little funky. In order to keep it simple and also prevents getting stuck in a loop of driving into water only to drop the ball at the location of the previous shot and drive into the water again, I actually backtrack, hitting the ball backward with the sand wedge and then have the code evaluate the shot again this time hopefully shooting just in front of the water so the next shot can clear it. This strategy is penalized by the rough penalty but is effective for clearing water.
def water():
    club = 'S wedge'
    d = randint(50,79)
    return club, d

This program counts the number of strokes per hole after that hole has been played. It adds the penalties for the shots in the rough and adds the penalties for hitting into the water by summing a array called water that is appended after each water shot. This takes advantage of the fact that fairway always leads to water or to the green for every hole in the course. It would have to be changed for courses that contained rough in the middle of the fairway.
def countstrokes(clubs, distances, waters):
    distances = np.array(distances)
    mask1 = distances < flen1
    mask2 = distances > grn2
    extra = sum(mask1*1)+sum(mask2*1) + sum(waters)
    if clubs[-1] == 'chip in' : strokes = len(clubs)-1+extra
    elif clubs[-1] == '2 putts' : strokes = len(clubs) +1+extra
    elif clubs[-1] == '1 putt' : strokes = len(clubs)+extra
    else : print 'strokes error'
    return strokes

After the main code runs, condition looks at the distances the ball was at during the hole and reports the condition of the ball. I ran into one issue with condition because of the way I treated hitting the ball into the water in the main program. In the program, if the ball was hit into the water, it was immediately moved back to the location of where the shot was hit. The distance was recorded after the ball is moved back so the condition of the ball cannot be ‘water’. If you hit the ball off the tee on hole 4 into the water, the program prints the distance you hit the ball and the club but the length to the hole will remain unchanged and the condition will be 'rough' since the ball is dropped at 0 distance which is in the rough. You can uncomment a print 'water' flag if you want to be told how many times the ball is hit into the water before each hole.

def condition(distances):
    conditions=[]
    for distance in distances:
        if distance >= grn1 and distance <= grn2:
            conditions.append('green')
        elif distance >= flen1 and distance <= flen2:
            conditions.append('fair')
        else:
            conditions.append('rough')
    return conditions

Here is the main part of the code which loads the holes and plays the game. After initializing some conditions the code runs 'stroke' hitting the ball towards the hole, including reverse if the hole was overshot, until either water or green is encountered. If water is encountered, it adds to a penalty counter and runs the program water and after moving the ball back to the location it was hit from. If the green is encountered, put is called and the hole is terminated. After the distances and clubs are analyzed to determine the condition of each shot and the shots are tallied.
def golf(driver_a, driver_b, wood3_a, wood3_b, wood5_a, wood5_b, iron3_a, iron3_b, iron4_a, iron4_b, iron5_a, iron5_b, iron6_a, iron6_b, iron7_a, iron7_b, iron8_a, iron8_b, iron9_a, iron9_b, pwedge_a, pwedge_b, swedge_a, swedge_b, lwedge_a, lwedge_b):
    global Driver_a, Driver_b, Wood3_a, Wood3_b, Wood5_a, Wood5_b, Iron3_a, Iron3_b, Iron4_a, Iron4_b, Iron5_a, Iron5_b, Iron6_a, Iron6_b, Iron7_a, Iron7_b, Iron8_a, Iron8_b, Iron9_a, Iron9_b, Pwedge_a, Pwedge_b, Swedge_a, Swedge_b, Lwedge_a, Lwedge_b
    Driver_a, Driver_b, Wood3_a, Wood3_b, Wood5_a, Wood5_b, Iron3_a, Iron3_b, Iron4_a, Iron4_b, Iron5_a, Iron5_b, Iron6_a, Iron6_b, Iron7_a, Iron7_b, Iron8_a, Iron8_b, Iron9_a, Iron9_b, Pwedge_a, Pwedge_b, Swedge_a, Swedge_b, Lwedge_a, Lwedge_b = driver_a, driver_b, wood3_a, wood3_b, wood5_a, wood5_b, iron3_a, iron3_b, iron4_a, iron4_b, iron5_a, iron5_b, iron6_a, iron6_b, iron7_a, iron7_b, iron8_a, iron8_b, iron9_a, iron9_b, pwedge_a, pwedge_b, swedge_a, swedge_b, lwedge_a, lwedge_b
    totals =[]
    for hole in holes:
        distance = 0
        strokes = 0
        clubs = []
        distances = []
        d1s = []
        waters=[]
        global hlen, flen1, flen2, wtr1, wtr2, grn1, grn2
        hlen, flen1, flen2, wtr1, wtr2, grn1, grn2, name = hole
        while True:
            club1, d1 = stroke(distance)
            clubs.append(club1)
            if distance > hlen:
                d1 = -d1
            distance = distance + d1
            d1s.append(d1)
            if distance >= wtr1 and distance <= wtr2:
                #print 'water'
                waters.append(1)
                distance = distance - d1
                distances.append(distance)
                club1, d1 = water()
                if distance < wtr1:
                    d1 = - d1
                distance = distance + d1
                d1s.append(d1)
                clubs.append(club1)
            distances.append(distance)
            if distance >= grn1 and distance <= grn2:
                club1 = putt(distance)
                clubs.append(club1)
                break
        strokes =  countstrokes(clubs, distances, waters)
        totals.append(strokes)
        conditions = condition(distances)
        shots = len(d1s)
        print name, ':',
        for x in xrange(0,shots):
            print '{', clubs[x], ',', d1s[x],',', conditions[x],',', hlen-distances[x], '}',
        print '{',clubs[-1], '}', '{',strokes ,'}'
    print 'Total:', sum(totals), 'shots'
    return sum(totals)

The code is run like
golf(300,330,270,299,240,269,220,239,200,219,180,199,160,179,140,159,120,139,100,119,80,99,50,79,0,49)

and the out looks like this:
Hole 1 : { Driver , 308 , fair , 93 } { P wedge , 96 , green , -3 } { 1 putt } { 3 }
Hole 2 : { 6-Iron , 166 , green , 5 } { 1 putt } { 2 }
Hole 3 : { Driver , 321 , fair , 117 } { 9-Iron , 105 , green , 12 } { 2 putts } { 4 }
Hole 4 : { Driver , 305 , rough , 553 } { S wedge , -62 , rough , 615 } { Driver , 326 , fair , 289 } { 3-Wood , 293 , green , -4 } { 1 putt } { 8 }
Hole 5 : { Driver , 323 , fair , 66 } { S wedge , 73 , green , -7 } { 2 putts } { 4 }
Hole 6 : { 8-Iron , 125 , green , 8 } { 2 putts } { 3 }
Hole 7 : { Driver , 314 , fair , 182 } { 5-Iron , 181 , green , 1 } { 1 putt } { 3 }
Hole 8 : { Driver , 324 , fair , 91 } { P wedge , 91 , green , 0 } { chip in } { 2 }
Hole 9 : { Driver , 317 , green , 3 } { 1 putt } { 2 }
Total: 31 shots

This was one the lowest score of many trials, with an absolute lowest of 26 in 100,000 runs. But still under a typical par of 34-36 even with 8 strokes on hole 4.
I'll include the code I used to find the distribution of games with the above specified clubs.
import matplotlib.pyplot as plt
class histcheck(object):

    def __init__(self):
        self = self

    def rungolf(self, n=10000):
        results=[]
        for x in xrange(0,n):
            shots = golf(300,330,270,299,240,269,220,239,200,219,180,199,160,179,140,159,120,139,100,119,80,99,50,79,0,49)
            results.append(shots)
        self.results = results

    def histo(self, n=20):
        plt.figure(figsize=(12,12))
        plt.hist(self.results, bins=(n))
        plt.title("Histogram")
        plt.xlabel("Shots")
        plt.ylabel("Frequency")
        plt.show()

Running
play = histcheck()
play.rungolf()
play.hist()

gives the following histogram

and the mean and median can be found using
np.mean(play.results)
np.meadian(play.results)

a mean of about 43 and a median of 41. Not too bad for 9 holes with simple shot optimization.
It is all yours now
Go ahead and copy and tweak my program and evaluate it using my tools in order to lower the average number of shots. Let me know if there is anything scenario I didn't account for or go ahead and make a golfed version. I think that the best program would be one that returned the lowest average shots for a number of club inputs. My code isn't the best option for that but I thought I'd get the ball rolling.
Update
def water():
    if clubs[-1] =='S wedge':
        club = 'S wedge'
        d = randint(50,79)
    elif clubs[-1] !='S wedge':
        club = 'S wedge'
        d = -randint(50,79)
    else: print 'water error'
    return club, d

By changing the water logic so that it attempts to hit the ball forward by a small amount after encountering water instead of backwards if the previous club used was not the sand wedge, it improved the mean to 40.5 and the median to 39 after testing with one million runs. Minimum of 23, maximum of 135. Sometimes you get lucky, sometimes you don't. Check out the new histogram.


text:
All possible orders of items of unknown type
This is code golf. Fewest bytes wins, only standard libraries, etc.
Write code, in any language, to output all possible same-length permutations of all items of an array / list / object in the input format and any order, grouped in whatever way you like. The items can be of ANY type, as allowed by the programming language.
Example input and output (inputting array, outputting array of arrays).
Inputs:
[1, 2, 3]

and outputs:
[
    [1, 2, 3],
    [1, 3, 2],
    [2, 1, 3],
    [2, 3, 1],
    [3, 1, 2],
    [3, 2, 1]
]

Code-Golf: Permutations reposts not allowed!

I don't see how the type of items changes anything. Permuting elements of an array doesn't depend on the type of items it contains

@Fatalize But... That's inactive now.

...what? I don't understand.

Every answer to that can apply here

@muddyfish Yes, you're right. But it is an interesting codegolf.

then necro the old question. Thats OK (I think)

@Fatalize Probable duplicate. But that's inactive. Should this still be closed?

@muddyfish What's necroing? (Yes, I'm new here.)

answer anyway, even if its inactive

Pyth, 3 bytes
.pQ

:D
Live demo.

+1 Yup! It works. And it's not a repost.

This might have to be closed. If it is, I recommend you move your answer to the question above.


text:
Is this a candidate Calvin Number?
This challenge is a tribute to our Legendary Challenge Writer™,
Calvin's Hobbies — now renamed to Helka Homba —, in the same spirit as
Generate Dennis Numbers.
Calvin is a pretty impressive contributor to PPCG, with the 6th most reputation
overall and probably indisputibly the best challenge writing skills out of all
of us. However, of course, for this challenge, we will focus on his user ID.
26997 might not look very interesting at first. In fact, it's almost
interesting in a few ways. For example, here's a chart of 26997 mod <n> for
certain values of n:
n   |  26997 % n
----+-----------
3   |  0
4   |  1
5   |  2
6   |  3
7   |  5 :(
8   |  5
9   |  6
10  |  7

However, 26997 is one of the few numbers that can be represented by (n * 10)n - n, where n is an integer > 0.
Here are the first few numbers which can be expressed in this way, which we
will henceforth call Calvin Numbers:
9
398
26997
2559996
312499995
46655999994
8235429999993
1677721599999992
387420488999999991
99999999999999999990
28531167061099999999989
8916100448255999999999988
3028751065922529999999999987
1111200682555801599999999999986
437893890380859374999999999999985
184467440737095516159999999999999984
82724026188633676417699999999999999983
39346408075296537575423999999999999999982
19784196556603135891239789999999999999999981
10485759999999999999999999999999999999999999980

These Calvin Numbers have some interesting properties. More patterns emerge
when we right-align them and highlight all the 9s:

The ones that we're interested in for this challenge are:

Regardless of n, every Calvin Number ends with
10n - n.
So, Calvin(1) ends with 9, Calvin(2) ends with 98, and the pattern
continues 997, 9996, 99995, etc., with each successive Calvin
Number counting down and adding an extra 9 to the beginning.
For values of n where n % 10 == 0 (i.e. n is divisble by 10), Calvin(n)
ends with 102n - n.
That is, the pattern extends for twice as many digits as normal, with an
extra number of 9s at the beginning equal to n.
When n is a power of 10 (10, 100, 1000, etc.), the pattern extends
even further—every single digit is either a 9 or a 0.
This pattern is the following:
(n + 1) * 10n - n
nines, and
n zeroes. This is easier to understand in a chart (your solution will
only have to handle numbers up to 10000 anyway, so this is all you need):
n      |  Calvin(n)
-------+-----------------------
10     |  19 nines, 1 zero
100    |  298 nines, 2 zeroes
1000   |  3997 nines, 3 zeroes
10000  |  49998 nines, 4 zeroes

The number of nines even exhibits several properties of Calvin Numbers
itself, but that's too much detail for this challenge.

Challenge
Calvin Numbers get far too big, far too quickly, for a "get the nth Calvin
Number challenge to be feasible in languages without arbitrary-precision
integers. Therefore, the challenge is to determine whether a number fits the
above patterns—that is, whether a number is a "candidate Calvin Number" or not.
Here are the criteria for a number to be considered a candidate Calvin Number
(hereafter referred to as a CCN for short):

It ends with a number that fits the pattern
10n - n for an integer n.
So, to be a CCN, a number must end with 9, or 98, or 997, 9996, 99995, etc.
If the last digit is 0, it must also end with
102n - n, for the same n as in the
previous point.
This means that 12312312399999999999999999999999999999999999980 is not a
CCN, but 10485759999999999999999999999999999999999999980 is (it's the
correct one, in fact).
If the value of n in the previous two steps is a power of 10, the entire
number must fit the third pattern described above.

Input / Output
The input will be provided as a string, and it will always represent a number
that is less than Calvin(10000) + 10000 (which can also be expressed as
1050000). (To clarify, the greatest possible input is
50000 nines, and the least possible input is 1.)
The output should be a truthy value if the input represents a number which is a
CCN, and a falsy value otherwise. For the definitions of these terms, see
meta.
Test cases
Inputs that should result in a truthy value:
9
26997
99999999999999999990
437893890380859374999999999999985
10485759999999999999999999999999999999999999980
[encoded data, 4654 characters]

Inputs that should result in a falsy value:
1
26897
79999999999999999990
437893890380859374299999999999985
12312312399999999999999999999999999999999999980
[encoded data, 4660 characters]

Rules

You may not, at any point in your program, handle integers larger than
18446744073709551615 (264), if your language has
support for arbitrary-precision integers (or number types with a high enough
precision to allow storing numbers greater than this).
This is simply to prevent solutions that loop through all possible Calvin
Numbers (or all possible values of 10n - n).
This is code-golf, so the shortest code in bytes will win.

"If the value of n in the previous two steps is a power of 10, the entire number must fit the third pattern described above." What does the 'third pattern' refer to?

@feersum There's a bulleted list of three things—it's the last one.

I don't understand why the second-to-last falsy test-case is falsy. What rule does it violate?

@AlexisKing Good catch; anything that ends in 9 should be truthy. Fixed.

@Doorknob Even with that change, the number still seems to fit the criteria. Shouldn't a number ending in 845 have 152 nines? It seems to have more than enough. Were there supposed to be half the number?

@AlexisKing Gah, you're right. Fixed again, thanks.

Is this in the OEIS?

Racket, 353
(require srfi/13)(let([s(~a(read))])(for/or([n(range 1 999)])(and(let*([y(string-length(~a n))])(string-suffix?(string-append(make-string(-(if(=(modulo n 10)0)(* 2 n)n)y)#\9)(~r #:min-width y #:pad-string"0"(-(expt 10 y)n)))s))(let([n(inexact->exact(/(log n)(log 10)))])(or(not(integer? n))(string-prefix?(make-string(-(*(+ 1 n)(expt 10 n))n)#\9)s))))))

Accepts a number from stdin, outputs #t or #f.
Ungolfed version:
(require srfi/13)

(define (calvin? str)
  (for/or ([n (in-range 1 10001)])
    (and (10^n-n$? n str)
         (or (not (integer? (/ (log n) (log 10))))
             (expt-of-ten-check? n str)))))

(define (10^n-n$? n str)
  (let* ([div-by-ten? (zero? (modulo n 10))]
         [digits (string-length (~a n))]
         [nines (- (if div-by-ten? (* 2 n) n) digits)]
         [suffix (string-append (make-string nines #\9)
                                (~r #:min-width digits #:pad-string "0" (- (expt 10 digits) n)))])
    (string-suffix? suffix str)))

(define (expt-of-ten-check? n str)
  (let* ([n (inexact->exact (/ (log n) (log 10)))]
         [nines (- (* (add1 n) (expt 10 n)) n)]
         [prefix (make-string nines #\9)])
    (string-prefix? prefix str)))

I normally don't do code golf, and Racket certainly isn't the most suitable language for it, but nobody had answered yet, so I figured I'd give it a shot. ;)

They might've been waiting for me to answer, but given my post history it's probably best that you didn't wait around ;)