text:
Answer to life, the universe, and everything
Task
Given a String as input, your task is to output 42 only if the input String happens to be exactly the following :
abbcccddddeeeeeffffffggggggghhhhhhhhiiiiiiiiijjjjjjjjjjkkkkkkkkkkkllllllllllllmmmmmmmmmmmmmnnnnnnnnnnnnnnoooooooooooooooppppppppppppppppqqqqqqqqqqqqqqqqqrrrrrrrrrrrrrrrrrrsssssssssssssssssssttttttttttttttttttttuuuuuuuuuuuuuuuuuuuuuvvvvvvvvvvvvvvvvvvvvvvwwwwwwwwwwwwwwwwwwwwwwwxxxxxxxxxxxxxxxxxxxxxxxxyyyyyyyyyyyyyyyyyyyyyyyyyzzzzzzzzzzzzzzzzzzzzzzzzzz

It may output any other value, produce an error or not output at all, if the input does not equal the aforementioned String.

Winning Criterion
This is code-golf, so the shortest code in bytes wins!

Many of the solutions provided here are wrong because they print 42 when the string is longer than the desired string and the prefix matches with the desired string.

@froddy: What if the only characters? following the string (is|are) a line break? My usual input mechanism doesn't care whether the input is terminated by a line break or not but yield the same in both cases, for example.

@fR0DDY : There was no clear definition on how the rest of the input should be handled, so there's no 'wrong' here.

@PatrickvL It does mention 'only' if the input is the given string. So abbcccddddeeeee...zzabc does not satisfy that i suppose and i can see some programs giving yes on that input.

@fR0DDY : Let me put it another way : There's no specification on how input is delimited, so that's open to interpretation. There's also no mention of character encoding (I guess most of us assume the default of their environment - ANSI, UTF8 and UTF16LE will be the most popular ones). Also no mention how the input is presented - is it entered via the standard input, via a command-line parameter? So you see - having all this freedom gives way to some interpretation that you would mark as 'incorrect', while others would judge it 'compliant'. NOFI, but this is daily practise for some of us.

muntoo: How should a trailing line break in the input be handled (i.e. valid input vs. valid input with a line break appendded)? Would that be invalid already since the input is not exactly the specified one? Also, may 42 be part of the output for invalid input or may 42 only be printed if the input matched?

@Joey Trailing line breaks don't have to count as input.

Is the sample input supposed to contain invisible nonprintable characters? Because it does.

Can we use uppercase instead?

This question’s score should be left as is...

Golfscript, 20
26,{.97+\{.}*}%=42`*

with new line, 21 chars (by Nabb)
26,{).[96+]*}%n+=42`*

Actually Nabb beat mine, here is original solution for with new line, 22 chars
26,{.97+\{.}*}%n+=42`*

This is simply generating source string and just comparing it against string from stdin.

26,{).[96+]*}%n+=42`* for 21 (inc newline).

Heh, it doesn't work without the n+ because the array isn't flat. You'll have to either keep your original 20 chars or add a ~ to flatten the inner terms of the array.

@Nabb, heheh, I didn't realize newline made it different.

Ruby 1.9, 46 42 39 characters
p (?a..?z).map{|a|a*$.+=1}*""==gets&&42

Assumes the input isn't terminated with a newline.

What about the newline from gets?

@steenslag: The specs don't say anything the input being terminated by a newline, so this solution assumes there is none.

C program - 78 89
Edit: Do not print 42 when there are extra characters.
Assumes input does not have a trailing newline.
main(i,j){for(i=1;i<27;i++)for(j=i;j--;getchar()==96+i?0:exit(1));puts("42"+!!gets(&i));}

If the prefix does not match, the program exits.  If the prefix matches but there is 1-3 or so extra characters, prints 2.  Otherwise, produces undefined behavior.
This can be made one character shorter by changing exit(1) to fork().  Oh, and on an unrelated note, remember to save any open documents in case, for whatever reason, your system happens to lock up.

This will print 42 if the string is longer than the desired string and the prefix matches with the desired string.

PHP (60)
Assuming the input is provided in the commandline:
for(;$i<702;)$s.=chr(96.5+sqrt($i+=2));echo$s!=$argv[1]?:42;

Explanation: you can view the string as a triangle structure.
j     i   val
0     0   a
1   1-2   bb
2   3-5   ccc
3   6-9   dddd
4 10-14   eeeee
5 15-20   ffffff
      ...

Line j starts at index i = j*(j+1)/2 (that's the triangular number formula). Solving the quadratic equation results in index i being on line j = int((sqrt(8*i+1)-1)/2) and therefore containing character 97 + int((sqrt(8*i+1)-1)/2). The 0-350 index range allows us to simplify that to 96.5 + sqrt(2*(i+1)), but that no longer holds true for larger values.
Edit: Switched to commandline input as suggested in the comments.
Edit: Uses conditional operator to save a character

+1 , that works ;)
Umm could you please elaborate as how $s.=chr(96.5+sqrt($i+=2)); works ?

Edited. I hope it makes sense :-)

for(;$i<702;)$s.=chr(96.5+sqrt($i+=2));echo($s==$argv[1])*42; Only 61 chars, assuming stdin input

@Viper_Sb: thanks for the hint; I wasn't sure about the rules so I mimicked Clyde's solution. I'll go with your suggestion.

Isn't there a space missing after the echo?

@powtac the language syntax doesn’t require a space here

58 bytes in PHP 5.6 or later: for(;704>$i+=2;)$s.=chr(96.5+$i**.5);echo$s!=$argv[1]?:42;

just a doubt here, aren't php open and close tags necessary for this code to work?

Perl, 35 43
map$s.=$_ x++$a,a..z;say 42if<>~~$s

Needs Perl 5.10 or later (run with -E), no newline in input.
I liked my side-effects regex better, but the shorter code has spoken.  Here it is as a souvenir.  Also intended for Perl 5.10 or later, but only for the advanced/experimental regex features, so only a p command-line option is needed.
$a=a;$_=/^(??{$b++;$a++."{$b}"}){26}$/&&42

Excellent. I tried hard to beat this w/recursive regex but couldn't get below 43c. :-((

Why is it necessary to say $a++."{$b}" instead of just $a++.$b?

@Timwi because I do need those braces to appear in the resulting string.  I don't want to match on literal "d4", I want "dddd", expressed as regex "d{4}"

Of course. Thanks for explaining!

Came up with a 33 byte solution for this! Try it online!

05AB1E, 7 bytes
AƶJQi42

Try it online!
Explanation
A       push lowercase alphabet
 ƶ      lift every letter, push it and multiply it by its index
  J     join the list
   Qi   does it equal the input?
     42 push 42 and output implicitly

Just going through some challenges to learn 05AB1E (and golfing in general). This challenge was marked as active yesterday and I found a short solution, so why not share? :)

Welcome to PPCG!

Haskell program - 71 67 64 57
Assumes no trailing newline, and does not output one either.
f x|x==[c|c<-['a'..'z'],_<-['a'..c]]="42"
main=interact f

Usage:
$ echo -n 'abbcccddddeeeeeffffffggggggghhhhhhhhiiiiiiiiijjjjjjjjjjkkkkkkkkkkkllllllllllllmmmmmmmmmmmmmnnnnnnnnnnnnnnoooooooooooooooppppppppppppppppqqqqqqqqqqqqqqqqqrrrrrrrrrrrrrrrrrrsssssssssssssssssssttttttttttttttttttttuuuuuuuuuuuuuuuuuuuuuvvvvvvvvvvvvvvvvvvvvvvwwwwwwwwwwwwwwwwwwwwwwwxxxxxxxxxxxxxxxxxxxxxxxxyyyyyyyyyyyyyyyyyyyyyyyyyzzzzzzzzzzzzzzzzzzzzzzzzzz' | { ./42; echo; }
42
$ echo -n 'something else' | { ./42; echo; }
42: 42.hs:1:0-54: Non-exhaustive patterns in function f

$

fwiw this code is also still very readable.

Since zipWith stops when it reaches the end of the shorter list, you can replace ['a'..'z'] with ['a'..] and save 3 characters.

@hammar: Thanks.  I saved 1 more char by using >>= (concatMap) in lieu of concat and zipWith.

@hammar: Saved even more by using do notation instead of >>= and lambda  :-)

@Joey: Another improvement: do n<-[1..26];replicate n$['`'..]!!n can be shortened by another 4 characters to do c<-['a'..'z'];[c|_<-['a'..c]]

@Joey: Or even better: [c|c<-['a'..'z'],_<-['a'..c]]

J, 29
f=:42#~((>:#a.{~97+])i.26)-:]

example:
f 'oasijfiojasef'

f 23841235

f 'abbccc...'
42

I like J. And I find it ugly and horrible. And I like it.

D: 94 Characters
void f(S)(S s){S t;foreach(i;0..26)t~=array(repeat(cast(char)(i+'a'),i+1));s==t&&writeln(42);}

More Legibly:
void f(S)(S s)
{
    S t;

    foreach(i; 0 .. 26)
        t ~= array(repeat(cast(char)(i + 'a'), i + 1));

    s == t && writeln(42);
}

Delphi, 164 132
This one builds a string and just compares it against the first command-line argument. It's shorter and less tricky than my other submission :
var s:string;c,i:int8;begin repeat s:=s+Char(c+97);i:=i-1;c:=c+Ord(i<0);if i<0then i:=c;until c=26;Write(42*Ord(s=ParamStr(1)));end.

(Note, that this version assumes that the c and i variables start out initialized at 0, as is the case in my version of Delphi (2010).)
Like my other submission, this one needs less characters if the string-building doesn't take place in a function, like I did before :

Delphi, 181
program a;{$APPTYPE CONSOLE}function s(c,i:byte):string;begin if(i>0)then Exit(Char(c)+s(c,i-1));if(c<122)then Exit(s(c+1,c-95));end;begin if(s(97,1)=ParamStr(1))then Write(42);end.

Note that the output doesn't need a newline, so WriteLn() became Write().

PHP - 45 characters
I'm surprise nobody posted any answer that used hashing. It's a very size effecient way of testing for exact string.
echo md5($argv[1],1)!='¯è a@ÛÚƒ:ïT�p'?:42;

The data is kind of hard to copy/paste since there is a null-byte in the middle of the code. Here's an hex-dump of the code for testing purposes.

65 63 68 6f 20 6d 64 35 28 24 61 72 67 76 5b 31 5d 2c 31 29 21 3d 27 af e8 a0 61 40 db da 7f 11 0f 83 3a ef 54 00 70 27 3f 3a 34 32 3b

Clever!  Though since there are technically other input values yielding this same hash, it doesn't quite satisfy the requirement of outputting 42 only if the input is in the specified format.

Scala 79
 if((for(i <- 1 to 26;j<-1 to i)yield(96+i).toChar).mkString==args(0))print(42)

Pyth, 14
*42qzsm*dhxGdG

Just constructs the necessary string, then compares with the input and multiplies by 42.

'compares with the input and multiplies by 42.' would have never thought of that on my own. You just help me shave 1 character off my solution. Thanks.

Argh, I came too late. Can you explain how it works? The function m cause me trouble…

@Jim We start with the map function, m, which applies a function to each element of its input. The input is G, the alphabet. xGd finds the position of d, the character in the alphabet, in G, the alphabet. h increases that by one, and *d replicates the character as that many times. Outside the m function, s combines the resulting list of strings into a single string, then qz checks whether the result is equal to the input. Booleans are represented as 0 if False and 1 if true, so *42 resultings in a value of 42 if True and 0 if False.

Brachylog (2), 15 bytes, language postdates challenge
⊇Ạ∧?o?ọtᵐ~⟦₁+₁₆

Try it online!
And now for an answer which works on a completely different principle to most seen here. This is a function submission (the question doesn't specify what sort of submission is desired, but functions are permitted by default).
Explanation
This answer works by defining a sort of string: those which a) contain all lowercase letters of the alphabet, b) are in sorted order, and c) for which taking the number of occurrences of each character in the string produces a sequence of consecutive integers starting from 1. (It should be clear that there are many such strings, but the one we want to special-case is the shortest.) Then if the string fulfils those criteria, we add 16 to the number of distinct characters in the string; this will produce 42 if the string is the one the question asks us to special-case, and at least 43 in all other cases. (If the string fails any of the criteria to belong to the category, the function will end in failure, which is kind-of like throwing an exception.)
Here's how to interpret the source code:
⊇Ạ∧?o?ọtᵐ~⟦₁+₁₆
⊇Ạ               {the input} contains all lowercase letters
  ∧              and
   ?o?           the input sorts to itself
                 {and; implied when two conditions overlap}
     ?ọ          the {character, number of occurrences} pairs for the input
       tᵐ        when the second element of each is taken
         ~       create an output that could have been produced by
          ⟦₁     outputting the list of integers from 1 to some input inclusive;
            +₁₆  add 16 to that input {and output it}

R, 60 58
if(readline()==paste0(rep(letters,1:26),collapse=""))cat(42)

if(scan(,"")==paste(rep(letters,1:26),collapse=""))cat(42)
Thanks for the suggestion by @giusppe

I think just paste is fine here, and you can use scan(,"") instead of readline().

Python (84)
Assumes a trailing newline at the end of the input.

import sys
if''.join(c*chr(c+96)for c in range(27))+'\n'==sys.stdin.read():print 42

Why not use raw_input instead sys.stdin.read?

@Juan: raw_input only reads a single line; I wasn't sure whether "the input" would always be a single line or whether there could be disqualifying input on later lines.

JavaScript (91 93 94 98 102 116)
Usage: a('string'), returns 42 if valid according to spec, or 0.
function a(z){for(i=r='';i++<26;)for(j=i;j--;)r+=String.fromCharCode(i+96);return(z==r)*42}

http://jsfiddle.net/g25M3/6/
Edit: Removed var and eliminated two spaces in for (.
Edit 2: Changed j>0 to j, and

return (z==r)?42:0; to
return z==r?42:0

Edit 3: Initialize i with i='', change

(z==r)?42:0 to
(z==r)*42

Edit 4: Change

for(;i<27;i++) to
while(i++<26)

Edit 5: Change

i=r='';while(i++<26) to
for(i=r='';i++<26;) and
for(j=i;j;j--) to
for(j=i;j--;)

Well you can reduce another 12 chars if you dont use var to declare variables ;)

@Clyde: Thanks! Also found I could remove space between for (.

Yeah , was about to suggest the same ;)
Oh and I coded a solution in PHP using the same logic as yours

You can save another 2 chars by replacing
return(z==r)?42:0; with return z==r?42:0

j>0 could be just j I think.

@S.Mark : yeah , and then the solution would be at 98 chars

@Clyde, @S.Mark: Thanks. Updated.

You can save another char doing return(z==r)*42

Save 1 more with while(i++<26)

I shortened this by another two characters by changing i=r='';while(i++<26) to for(i=r='';i++<26;) (first one) and for(j=i;j;j--) to for(j=i;j--;) (second one)

You could use a=z=>{yourfunctionbody}.

You can reduce your code to 83 bytes thanks to arrow functions : a=z=>{for(i=r='';i++<26;)for(j=i;j--;)r+=String.fromCharCode(i+96);return(z==r)*42}
Then you can a('abbccc..........z');

PHP  92 88 87 chars
function _($a){for($i=97;$i<123;$i++)for($j=$i-96;$j;$j--)$b.=chr($i);echo($b==$a)*42;}

EDIT
Replaced $j<0 with $j and return $b==$a?42:0; with echo $b==$a?42:0;
Replaced echo $b==$a?42:0; with echo($b==$a)*42;

Could be 80 chars if it weren't for all the freaking dollar signs.

Also see my entry for a single-loop solution.

Python - 62 chars
print("".join(x*chr(x+96) for x in range(27))==raw_input())*42

Could be shorter in Python 3: print("".join(x*chr(x+96)for x in range(27))==input())*42.

Perl, 49 46 characters
to be used in a program, not on the command line
$..=chr($+96)x$ for 1..26;$.eq(pop)&&print '42'
join('',map$_ x++$x,'a'..'z')eq pop&&print'42'

Regards
rbo
Edit: Idea ripped from Ventero

ECLiPSe Prolog - 173
c(_,[],_):-!. c(A,M,N):-length(L,N),checklist('='(A),L),append(F,L,M),P is N-1,B is A-1,c(B,F,P). ?- read_string(end_of_file,351,S),string_list(S,L),c(122,L,26),writeln(42).

JavaScript 1.8, 99 chars
function c(x)(x.replace(/([a-z])\1*/g,function(m)!(a-m.length)*m.charCodeAt(0)-96-a++,a=1)==0)*a+15

I dare you to make sense of it :)

PHP - 59
Assumes at least 1 input is provided over cli
echo md5($argv[1])!='afe8a06140dbda7f110f833aef540070'?:42;

It more or less works, except that md5 is can technically have duplications with the hashing algo.

VBA 91
There weren't any VBA answers but this works:
Function f(t)
    For i = 1 To 26
        o = o & String(i, Chr(i + 96))
    Next
    f = -42 * (t = o)
End Function

Is it really impossible to remove any whitespace from this?

Condensed Version, 61 bytes - o="":For i=1To 26:o=o &String(i,Chr(i+96)):Next:?-42*([A1]=o)

@Challenger5 No, it's not impossible. Taylor's Scott comment is exactly that. It runs in the Immediate Window and takes the value from cell A1 as input.

PowerShell v2+, 47 bytes
42*(-join(1..26|%{,[char]($_+96)*$_})-ceq$args)

Constructs a range 1..26, feeds that through a loop with |%{...}. Each iteration we use the comma operator to construct an array literal of the current [char] multiplied by the current loop number. We then -join that all together to construct the string abbcccdddd... and then use a case-sensitive -ceq comparison against our input $args, which will result in either $TRUE or $FALSE. In PowerShell, Boolean values can be implicitly cast as 1 or 0, respectively, which is what happens here with the 42*. Will print out 42 iff the input is abbccc...zzzzzzzzzzzzzzzzzzzzzzzzzz and will output 0 otherwise.

you could save a byte :) Try it online!

K, 26 Bytes
{(::;42)x~,/(1+!26)#'.Q.a}
{(::;42)x~,/(1+!26)#'.Q.a}"hello"
{(::;42)x~,/(1+!26)#'.Q.a}"abbcccddddeeeeeffffffggggggghhhhhhhhiiiiiiiiijjjjjjjjjjkkkkkkkkkkkllllllllllllmmmmmmmmmmmmmnnnnnnnnnnnnnnoooooooooooooooppppppppppppppppqqqqqqqqqqqqqqqqqrrrrrrrrrrrrrrrrrrsssssssssssssssssssttttttttttttttttttttuuuuuuuuuuuuuuuuuuuuuvvvvvvvvvvvvvvvvvvvvvvwwwwwwwwwwwwwwwwwwwwwwwxxxxxxxxxxxxxxxxxxxxxxxxyyyyyyyyyyyyyyyyyyyyyyyyyzzzzzzzzzzzzzzzzzzzzzzzzzz"
42

Thanks

{$[x~.Q.a@&1+!26;42;]} for 22 bytes.

42*(&!27)~-96+"j"$ for 18 bytes (porting my oK answer).

APL (Dyalog), 18 17 bytes
42/⍨⍞≡819⌶⎕A/⍨⍳26

Try it online!
Four obvious bytes can be saved if we are allowed to use uppercase.
42 42
/⍨ if (lit. replicated by)
⍞ character input
≡ is identical to
819⌶ the lowercased
⎕A Alphabet
/⍨ replicated by
⍳ one through
26 26

05AB1E, 7 bytes
AƶJQ42*

Try it online!

Wellp, 05AB1E keeps evolving.

Javascript, 145 bytes
Only uses recursion
((function(i,k,l){return(String.fromCharCode(97+i)==l[k+i])&&((i<25)?arguments.callee(++i,k+i,l):l.length==k+i+1)}).call(this,0,0,line)==true)*42

This approach checks each character along the way instead of creating the valid string to compare against. So, is the 'g' actually in the correct position, then return true. Finally check that the length is what is expected. Any falses on the way cause a '0' to be returned.
Thanks for the hint regarding the *42 at the end

Can save two chars by replacing ?42:0 with *42

Lua 98
i=io.read()e=0 for k=1,26 do s,e=i:find(string.char(96+k):rep(k),e+1)_=e or os.exit()end print(42)

Clojure - 61 chars
(fn[a](if(=(mapcat #(repeat%(char(+% 96)))(range 1 27))a)42))

Exploits the following facts:

Clojure can interpret any string automatically as a sequence of chars
I can use the range of numbers from 1 to 26 to both create the characters and repeat them the correct number or times to generate the "correct" input

would save 6 chars if Clojure allowed nested #()s..... important feature request for Clojure 1.4 I think!

Delphi, 127
var b:Char;c,i:Int8;begin repeat if i<0then i:=c;Read(b);if c+97<>Ord(b)then Exit;i:=i-1;c:=c+Ord(i<0)until i=27;Write(42);end.

This one reads the string from the input, compares it as it goes, writes 42 when the input matches up until the last z.

Delphi, 157
var b:pchar;c,i:byte;begin b:=CmdLine+85;c:=97;i:=1;repeat Inc(b);if b^<>Char(c)then Exit;Dec(i);if i>0then Continue;c:=c+1;i:=c-96;until i=27;Write(42);end.

Delphi, 188
program a;{$APPTYPE CONSOLE}var b:pchar;c,i:byte;begin b:=CmdLine+85;c:=97;i:=1;repeat Inc(b);if(b^<>Char(c))then Exit;Dec(i);if(i>0)then Continue;c:=c+1;i:=c-96;until(i=27);Write(42);end.

This version doesn't use a function, which saves quite a few characters when compared to the previous version of this technique :

Delphi, 213
program a;{$APPTYPE CONSOLE}function t(b:pchar;c,i:byte):byte;begin repeat Inc(b);if(b^<>Char(c))then Exit(0);Dec(i);if(i>0)then Continue;c:=c+1;i:=c-96;until(i=27);t:=42;end;begin WriteLn(t(CmdLine+77,97,1));end.

Alas a bit long, mostly because Delphi's long keywords, and the need to initialize console applications before they can write output.
Also note that I incremented CmdLine by 77 characters, as that was the offset I needed to skip over my local executablepath (Delphi has no direct argument pointer). Adjust to match your own setup (could lead to 1 less character when offset < 10).

You can set the application type under ProjectOptions/DelphiCompiler/Linking/GenerateConsoleApplication. Also, you can omit the program a; line. And the brackets around b^<>Char(c), i>0 and i=27 can be removed.

@Wouter van Nifterick: Thanks for the suggestions, I'll apply them to my other submissions too. (I didn't even know if i>0then would compile!)

C++ (110 chars)

Assumes use of the std namespace, headers, etc.  And make use of everything not specified in the question (whether it can output something else when the string doesn't match, etc.)
int main(int, char **c)
{
    string s(c[1]), t;
    for(int i=1; i < 27; i++) {
        for(int j=0; j < i; j++) {
            t += i+96;
        }
    }
    cout << 42 + s.compare(t);
}

Javascript 144
Probably can be significantly improved, recursion has always been a head far for me.
Compressed
function r(a,b,d,c){c++;if(b<d)a+=r(a,b+1,d,c);for(i=0;i<c;i++)a=String.fromCharCode(b)+a;return a}function q(a){if(q==r(a,97,122,0))return 42};

Less Compressed
function r(s, c, x, w){
    w++;
    if(c < x)
        s += r(s, c + 1, x, w);
    for(i = 0; i < w; i++)
        s = String.fromCharCode(c) + s;
    return s;
}
function q(z){
    if(q==r(z,97, 122, 0))
        return 42;
}

alert(q("rgrg"));

Groovy - 64
print args[0]!=(1..26).collect{"${(char)it+96}"*it}.join()?'':42

Q, 31 30
{$[x~(,/)(1+(!)26)#'.Q.a;42;]}

Burlesque, 24
@azr@{J**96.-.*}ms==42.*

Pretty standard solution.
@az r@            creates range from 'a to 'z
{                 start mapping the code block to each element
    J ** 96 .-    duplicates the current and gets it position in the alphabet (n)
    .*            duplicates the element n times
}ms               end mapping, with the added flourish to concatenate the mapped block
==42.*            got this from isaacg above me.

Try it here. Note that Burlesque takes anything that's before the code as input, so mess up the "abb...zzz" string to see it fail.

C++, 157 154
Compressed (headers included) [154 characters]:
#include<iostream>
#include<string>
int i,j;int main(){std::string h;std::cin>>h;for(;i<26;i++)while(j<=i+i*(i+1)/2)(h[j]=='a'+i)?j++:j;std::cout<<42;}

Compressed (headers and using namespace std assumed like in this answer) [100 characters]:
int i,j;int main(){string h;cin>>h;for(;i<26;i++)while(j<=i+i*(i+1)/2)(h[j]=='a'+i)?j++:j;cout<<42;}

Not compressed (with headers):
#include <iostream>
#include <string>
using namespace std;

int i, j;
int main()
{
    string h;
    cin >> h;
    for(i = 0 ; i < 26 ; i++)
        while(j <= i+i*(i+1)/2)
            (h[j] == 'a'+i)?j++:j;
    cout << 42;
}

Explanation:

int i,j; int main(): i and j are initialized to 0 with 8 characters instead of 12 (int i=0,j=0;)
j<=i+i*(i+1)/2: use of the triangular number formula
(h[j]=='a'+i)?j++:j: endless loop trick when j is not incremented

Edit. Headers and using statements counted

I think you are supposed to count the headers and using statements.

You're right. My solution is now 157 characters long.

Reng v.3.2, 88 bytes
(Noncompeting, postdates question.)
2#y2#z"a"1Ø         Ø3r1\
:1+>y1-?!v$z1+:#y#zRzeq!^
   ^  :y#<
i sve(*?v)
?~n>$ 2.>076**

This is one heckuvan answer.
Initial
2#y2#z"a"1Ø

Stores 2 to y (the temporary counter) and z (the overall counter), and initiates the stack with "a" then goes to the next line.
Loop
:1+>y1-?!v$z1+:#y#zRzeq!^
   ^  :y#<

First, :1+ duplicates the previously made run of characters and increments it to work with the next one. Then...
Generating N copies of a number
   >y1-?!v
   ^  :y#<

This loops until y == 0. Once y is zero, we exit the loop. Otherwise, we put y - 1 back into y and duplicate the character being worked with it.
Breaking out of this loop
          $z1+:#y#zRzeq!^

This drops y from the conditional and increments and duplicates z, which is then put into y and z. Then, if R (26 + 1) is z, we go to the next part. Otherwise, the loop continues again.
Transition
                    Ø3r1\
                        ^

This goes out of the loop, pushes 1 (our equality counter), reverses the stack, and goes to the third line.
Final
i sve(*?v)
?~n>$ 2.>076**

i sve(*?v) loops until (a) there is no input or (b) the equality counter is 0. In the first case, the first v is met, and we drop the -1 bit, skip over the >0 bit (2.), and output 42 (6*7*equality), skipping ~ with a conditional. Otherwise, the second v is encountered, and a zero is pushed before the 76**, so this makes it zero. The conditional activates the ~ (exit program) command because the TOS is falsey, and thus no output is given.

J, 21 bytes
Program:
   42*(u:96+(]#])i.27)-:

Usage:
   42*(u:96+(]#])i.27)-: 'abbcccddddeeeeeffffffggggggghhhhhhhhiiiiiiiiijjjjjjjjjjkkkkkkkkkkkllllllllllllmmmmmmmmmmmmmnnnnnnnnnnnnnnoooooooooooooooppppppppppppppppqqqqqqqqqqqqqqqqqrrrrrrrrrrrrrrrrrrsssssssssssssssssssttttttttttttttttttttuuuuuuuuuuuuuuuuuuuuuvvvvvvvvvvvvvvvvvvvvvvwwwwwwwwwwwwwwwwwwwwwwwxxxxxxxxxxxxxxxxxxxxxxxxyyyyyyyyyyyyyyyyyyyyyyyyyzzzzzzzzzzzzzzzzzzzzzzzzzz'
42

Explanation:
   42*                    NB. Multiply 42 to
      (
       u:                 NB. Convert all to characters
         96+              NB. Add 96 to all
            (]#])         NB. "]" copies the i.27, and 1 4 # 1 2 gives 1 2 2 2 2 for example
                 i.27     NB. 0 1 2 3 ... 26 (not 27)
                     )
                      -:  NB. matches the right hand side (return 1 if matches, 0 otherwise)

Pyth, 10 bytes
*42qSs.__G

Explanation:
*42qSs.__G
        _G     Reversed alphabet "zyx...a"
      ._       Prefixes ["z", "zy", ..., "zyx...a"]
    Ss         Concatenated and sorted "abbccc...zzz"
   q      Q    Compare with implicit input
*42            42 if the input matches, 0 otherwise

The input being a string, the implicit input would better be z or w instead of Q. Nice shot though!

Jelly, 13 bytes in Jelly's codepage, language postdates challenge
26RØa,ZŒṙ⁼×42

Try it online!
Explanation
26RØa,ZŒṙ⁼×42
     ,         Start with a pair of:
   Øa            the lowercase alphabet (['a', 'b', …, 'y', 'z'])
26R              and the list [1, 2, 3, 4, …, 25, 26]
      Z        Swap rows and columns (yielding [['a', 1], ['b', 2], …, ['z', 26]])
       Œṙ      Run-length decode (yielding the string in the original question)
         ⁼     1 if equal to {the original input}, 0 otherwise
          ×42  Multiply by 42

So we end up outputting 42 if the string is the special-cased string, or 0 otherwise.

05AB1E, 14 13 bytes
AvyN>×}JIQi42

Try it online!
Edit: Saved 1 byte thanks to @Okx.
My first official PPCG submission!
Explanation:
AvyN>×}JIQi42

A              # push alphabet to stack
 v    }        # foreach in ToS, element = y, index = N
  y            # push letter to stack
    N>         # increment index by 1
     ×         # repeat the letter (index + 1) times, push to stack

       J       # join stack together
        I      # push input to stack
         Q     # check if string == input
          i42  # if so, push 42 to stack, implicitly print

Welcome to PPCG!

@WheatWizard :D

Save 1 byte by using AvyN>×}JIQi42 (you can save another byte by removing the I, but you must include the I otherwise this will happen with no input: https://tio.run/nexus/05ab1e#@@9Y5liZbVd5eHqtV2CmidH//1/z8nWTE5MzUgE)

Unfortunately, this isn't competing as 05AB1E was created after this question was posted.

@Okx Thank you, and I know, I was just practicing.

Excel VBA, 50 Bytes
Anonymous VBE immediate window function that takes input from cell [A1] and outputs 42 iff the input is equal to the expected output, else 0
For i=1To 26:s=s+String(i,i+96):Next:?([A1]=s)*-42

Python, 56 bytes
lambda s:s=="".join(c*chr(c+96)for c in range(27))and 42

I know I'm late to the party, but both of the existing Python answers were full programs, which seemed suboptimal. Returns 42 for the specified input, False for everything else.

Multiplying saves a byte over and

05AB1E, 9 bytes
ASā×JQi42

Try it online!
Explanation
ASā×JQi42   Argument: s
AS          Push alphabet as array
  ā×J       Each character as many times as its index
     Q      Compare with s
      i42   If true, output 42

Perl 6, 32 bytes
{42 if $_ eq[~] 'a'..'z'Zx 1..*}

C (gcc), 86 bytes
i,c;main(a){for(i=0;i++<a&&(c=getchar())==a+96;);a>26&&c<0?puts("42"):i>a&&main(a+1);}

Try it online!

Husk, 12 10 bytes
&42=ṘN…"az

-2 bytes thanks @Zgarb!
Try it online!
       "az  -- constant string: "az"
      …     -- fill the range 'a'..'z': "abc...xyz"
    ṘN      -- replicate each character [1..] times: "abbccc...zzz..z"
   =        -- is input equal to that string?
&42         -- if it is then 42 else 0

ΣzR can be Ṙ.

Sinclair ZX81/Timex TS1000/1500 BASIC, ~138 tokenized BASIC bytes
 1 LET A$="A"
 2 LET C=NOT PI
 3 FOR I=SGN PI TO VAL "25"
 4 LET A$=A$+CHR$ (CODE "A"+I)
 5 LET C=C+SGN PI
 6 IF C<=I THEN GOTO VAL "4"
 7 LET C=NOT PI
 8 NEXT I
 9 INPUT B$
10 IF A$=B$ THEN PRINT "42"

This is the most byte efficient solution I could think of for the technology in question (whilst retaining readability, of course), however, building the string A$ does take a while so be patient (or set an emulator to a decent speed above 3.5Mhz).

Japt, 11 bytes
;¶CËpEÄ
*42

Try it

Zsh, 97 56 52 51 bytes
Builds the string then compares $1. If the input doesn't match the magic string, some integer other than 42 (or an error message) is printed. Try it online!!
for c ({a..z})repeat $[++i];s+=$c
<<<$[${#s#$1}+42]

My original solution: 97bytes (ascii evaluate input)
@GammaFunction's solutions: 56bytes 52 bytes 51 bytes (main solution)
Example:
for c ({a..z})s+=${${(l:++i:)}//?/$c};[ $s = $1 ]&&<<<42

False positive on abbccc...zzzzz[something else].

I found a 56 byte solution. Hint: ${(l:++i:)}

Nice, my early attempts to use {a..z} never worked :P

Unfortunately, I found a more boring answer at 53 bytes.. I'd leave the 56 byte answer up too, the (l) flag is a neat language feature.

Hey, I found something clever which saved another byte! Takes advantage of outputting something else (in this case some number larger than 42) if it doesn't match.

interesting, but incorrectly prints 42 given empty input

Whoops, swap the variables and it should work: ${#s#$1}. Thankfully, $1 is not treated like a glob (this strategy wouldn't work in bash for this reason).

There are two # in there, they are doing two different things: prefix removal and string length. If it is a perfect match, we get $[0+42]. Otherwise, the string is not empty, and we get $[N+42].

Bash, 68 bytes
for c in {a..z};{ for ((i=++j;i--;)){ s+=$c;};}
[ $s = $1 ]&&echo 42

Build the string, compare and print. If the input string has spaces in it, the [ comparison ] will break, but return falsy anyway.
Try it online!

Vyxal, 11 bytes
kaf₄ɾ*∑=42*

Try it Online!
kaf         # lowercase alphabet, flattened into char list
   ₄ɾ*      # Repeat by 1..26
      ∑=    # Concatenate all, 1 if input is equal to string, 0 if not
        42* # Multiply by 42

Groovy, 70
a=[];(1..26).each{a+=[(char)it+96]*it};if(args[0]==a.join(''))print 42

An anonymous user proposed saving two characters as a=[];(1..26).each{a+=[(char)it+96]*it};print args[0]!=a.join()?'':42

C++
$ cat main.cpp | wc -m -l
16     269

Not compressed
Recursive ok routine checks string for abbcccdddd....
#include <iostream>

bool ok(char *c)
{
    char *s = c;
    while(*c && *c == *s) c++;
    return (c - s == *s - 'a' + 1) && ((*c == 0 && *s == 'z') || ok(c));
}

int main(int c, char **v)
{
    if(c > 1 && ok(v[1]))
        std::cout << 42 << std::endl;

    return 0;
}

Second version
$ cat main.cpp | wc -m -l
15     239

Without recursion
#include <stdio.h>

bool ok(char *c)
{
    char i,j;
    for(i = 'a'; i <= 'z'; ++i)
    for(j = 'a'; j <= i; ++j)
        if(*c++ != i) return 0;
    return !*c;
}

int main(int c, char **v)
{
    return c > 1 && ok(v[1]) && printf("42"), 0;
}

Since this is code golf, you should post your score and your golfed code, i.e. with no unnecessary whitespace

 JavaScript (1.8), 103 characters
function f(s,i)i===+i?s.length-i-1||s.charCodeAt()-i-97:s&&s.match(/(.)\1*/g).some(f)+s.length!=351|42

Here's my rather long attempt in JavaScript... returns 42 if the string is the valid string, 43 otherwise.
Here's a prettier, earlier version with whitespace:
function f(s) {
  return s && s.match(/(.)\1*/g).some(function(x,i) {
    return x.length-i-1 || x.charCodeAt()-i-97
  })+s.length==351 && 42
}

and another version, closer to the final version (modulo whitespace removal)
function f(s,i) {
  return i===+i
       ? s.length-i-1 || s.charCodeAt()-i-97
       : s&&s.match(/(.)\1*/g).some(f)+s.length!=351 | 42
 }

R, 99
f=function(x){s="";for(i in 1:26)s=c(s,(rep(letters[i],each=i)));s=paste(s,collapse="");if(x==s)42}

Usage:
f("test")
f("abbcccddddeeeeeffffffggggggghhhhhhhhiiiiiiiiijjjjjjjjjjkkkkkkkkkkkllllllllllllmmmmmmmmmmmmmnnnnnnnnnnnnnnoooooooooooooooppppppppppppppppqqqqqqqqqqqqqqqqqrrrrrrrrrrrrrrrrrrsssssssssssssssssssttttttttttttttttttttuuuuuuuuuuuuuuuuuuuuuvvvvvvvvvvvvvvvvvvvvvvwwwwwwwwwwwwwwwwwwwwwwwxxxxxxxxxxxxxxxxxxxxxxxxyyyyyyyyyyyyyyyyyyyyyyyyyzzzzzzzzzzzzzzzzzzzzzzzzzz")
[1] 42

Javascript, 104
function f(x){var a="";for(b=97;b<123;b++)a+=Array(b-95).join(String.fromCharCode(b));if(x==a)return 42}

Should be pretty obvious, but it creates the string and then tests it against the input.
If I can golf this down any further, please let me know.

Haskell, 45 51 bytes
f x|x==zip[1..]['a'..'z']>>=uncurry replicate->"42"

zip [1..] ['a'..'z'] produces the list [(1,'a'), (2,'b'), ...].
uncurry replicate has the type (Int, a) -> [a], and uncurry replicate (n, v) produces a list of n copies of v.
>>= applies uncurry replicate to the zipped list, and concatenates the results.
Finally, that string compared to the argument and returns "42" if it is equal, or crashes.
(edited b/c I'm dumb and didn't notice the return requirement)

Your code does not compile. You need to change -> to = (f is a function, not a lambda) and put the >>= expression into parenthesis (otherwise its parsed as (x==zip[1..]['a'..'c'])>>=(uncurry replicate)).

Pylongolf2, 21 bytes
con1968701440=?42~¿

Explanations:
con1968701440=?42~¿
c                   read input
 on                 hash it and then convert into integer
   1968701440       push the (aaa.zz) thing (but hashed) into the stack
             =      compare them
              ?     if true,
               42~  output 42
                  ¿ end if statement.

That last inverted question mark messed me up by 2 bytes :|

This is incorrect if more than one string can have that hash.

Oracle SQL 11.2, 148 bytes
SELECT 42 FROM(SELECT MAX(TRANSLATE(SYS_CONNECT_BY_PATH(LPAD(' ',LEVEL+1,CHR(64+LEVEL)),';'),'A; ','A'))s FROM DUAL CONNECT BY LEVEL<27)v WHERE:1=s;

Java 8, 103 101 87 bytes
s->{String r="";for(char c=96,i;++c<123;)for(i=96;i++<c;)r+=c;return r.equals(s)?42:0;}

Returns 0 for everything that doesn't match the expected input.
Explanation:
Try it here.
s->{                       // Method with String parameter and integer return-type
  String r="";             //  String starting empty
  for(char c=96,i;++c<123;)//  Loop (1) over the lowercase alphabet:
    for(i=96;i++<c;)       //   Inner loop (2) `c-i` amount of times:
      r+=c;                //    Append that many of the current letter to the String
                           //   End of inner loop (2) (implicit / single-line body)
                           //  End of loop (1) (implicit / single-line body)
  return r.equals(s)?      //  If the input equals the String:
    42                     //   Return 42
   :                       //  Else:
    0;                     //   Return 0
}                          // End of method

I think you can remove the braces around that for-loop

SmileBASIC, 58 bytes
DEF F S
FOR I=1TO 26C$=C$+CHR$(I+64)*I
NEXT?42OR C$!=S
END

I had to make it a function since the maximum INPUT length is 128 characters.

R, 74 bytes
g=function(x){if(x==paste(rep(rep(letters[1:26]),(1:26)),collapse=""))42}

Axiom, 141 bytes
f(x:String):NNI==(c:=96;i:=0;k:=1;repeat(c:=c+1;i:=i+1;for j in 1..i repeat(k>#x or ord(x.k)~=c=>return 0;k:=k+1);c=122=>break);k=#x+1=>42;0)

ungolf
--It would return 42 if the string in input it is as string above this codegolf question
--it would return 0 in other cases; suppose Axiom ord() return 97..122 for a..z (ascii)
ff(x:String):NNI==
   c:=96;i:=0;k:=1
   repeat
      c:=c+1; i:=i+1           -- c='a'=97 i=1 k=1
      for j in 1..i repeat
               k>#x or ord(x.k)~=c=>return 0
               k:=k+1
      c=122=>break -- c==122 is 'z'
   k=#x+1=>42
   0

Japt, 13 12 11 bytes
Outputs 42 or false.
;¶CËpEÄÃ©#*

Try it online

Python 3, 58 bytes
lambda s:[42][''.join([i*chr(i+96)for i in range(27)])!=s]

Try it online!
Six years late to the party?
golfed 4 bytes off when I realized I could've used != instead of 1- ==

JavaScript, 86 Bytes
c="";for(x=0;x<26;)c+=String.fromCharCode(x+97).repeat(++x);alert(prompt("")==c?42:0);

White spaced:
c="";
for(x=0;x<26;)
    c+=String.fromCharCode(x+97).repeat(++x);
alert(prompt("")==c?42:0);

I couldn't indent by 4 spaces for some reason. Not sure if using alert is allowed.
Edit: Fixed indent

Javascript (ES6) 84 bytes
s=>[...Array(26)].map((_,i)=>String.fromCharCode(97+i).repeat(i+1)).join("")==s?42:0

I don't think an explanation is needed, but here's one anyway:
s=> // input
    [...Array(26)] // preparing alphabet array
    .map((_,i)=>String.fromCharCode(97+i).repeat(i+1)) // using the current index to get the corresponding letter and repeat it as many times as it's 1-index
    .join("")==s?42:0 // Join the array into a string and check if equal to input.

Jelly, 9 bytes
ØaxJ¤⁼×42

Try it online!
There is already a 13 byte Jelly answer, but the user had their account deleted, and it felt wrong to just edit in this code.
How it works
ØaxJ¤⁼×42 - Main link. Argument: s (string)   e.g. "abc"
Øa  ¤     - Yield the lowercase alphabet           "abc...xyz"
   J      - Yield range(length)                    [1 2 ... 25 26]
  x       - Repeat (vectorising).                  "abbccc..."
     ⁼    - Equal to the input? Call the A         0
      ×42 - Multiply 42 by A                       0

Pyth - 21 Bytes
V26=Y+Y*@GNhN;IqsYz42

Explanation:
V26=Y+Y*@GNhN;IqsYz42  z is initialised to input and Y to empty list
V26                    For N from 0 to 25
   =Y                  Set Y to
      Y                Y
     +                 Plus
        @GN            Item N of the alphabet
      *                Times
           hN          N plus one
             ;         End For
              I        If
                sY     Concatenate all elements of Y
               q       Equals
                  z    z
                   42  Print 42

APL NARS 14 chars
{⍵≡⎕a/⍨⍳26:42}

it return 42 for the request string, nothing if something else.
  f←{⍵≡⎕a/⍨⍳26:42}
  w←(⍳26)/⎕a
  f 2
  f w
42
  f 'str'

AWK, 65 bytes
{for(;i<26;)for(j=++i;j--;)L=L sprintf("%c",i+96);$0=L==$0?42:0}1

Try it online!
Maybe I should develop a golfing version of AWK, but until then, here is my AWK solution :)

K (oK), 14 bytes
Solution:
42*(&!27)~-96+

Try it online!
Explanation:
Returns 42 if the input matches the "abbccc..." otherwise 0.
42*(&!27)~-96+ / the solution
          -96+ / subtract 96 from the input (vectored)
         ~     / matches?
   (&!27)      / where (&) til (!) 27. Generates 1 2 2 3 3 3 4 4 4 4... sequence
42*            / multiply result (0 false or 1 true) by 42

Python 2, 69 bytes
x=""
for i in range(26):x+=chr(97+i)*(i+1)
if raw_input()==x:print 42

Try it online!

Julia 0.6, 55 bytes
s->join("$c"^i for (i,c) in enumerate('a':'z'))==s?42:0

Try it online!

Lua, 80 bytes
c=""for i=1,26 do c=c..string.char(i+96):rep(i)end print(c~=io.read()and""or 42)

Try it online!
Brief explanation: creates the string and then compares it with the input.
Output is an empty string or 42.

Wren, 72 bytes
Generate the range 'a'..'z'. Multiply the string-converted value by the value - 96. Join the list. Check whether the input is equal to this string.
Fn.new{|A|A==(1..26).map{|x|String.fromCodePoint(x+96)*(x)}.join()?42:0}

Try it online!

Thunno 2, 9 bytes
Ạdż×J=42×

Attempt This Online!
Explanation
Ạdż×J=42×  # Implicit input
Ạd         # Lowercase alphabet, split into a list of characters
  ż×       # Each multiplied by their 0-based index
    J=     # Equals the input string?
      42×  # Multiply by 42
           # Implicit output

authors: الشاعر حسين الحاتمي


text:
Circles of text
Find a way to make circles of a given radius using characters in a console. Please specify the font name and size. Also, please provide at least one example of the output.
For example:
Input:
3

Output:
   ******
 **      **
**        **
*          *
**        **
 **      **
   ******

...Well, something better looking than that "hand drawn" "circle" with a radius of 3.

Bonus question: Ellipses. :)

Interestingly enough, my radius-3 circle is exactly identical to yours without even trying :)

similar to http://stackoverflow.com/questions/2440314/code-golf-day

Maybe the font-part can be clarified. Copied here, all fonts will be the same; the same for font-size.

Javascript (360)
function c(r){var f=1.83;var e=2*Math.PI/(r*r*r*r*r);var s=r*2+1;var g=Array(s);for(var i=0;i<s;i++){g[i]=Array(Math.round(s*f))};for(var i=0;i<=2*Math.PI;i+=e) {var x=Math.round(f*r*Math.cos(i)+f*r);var y=Math.round(r*Math.sin(i))+r;g[y][x]=1;}for(var j=0;j<g.length;j++){for(var i=0;i<g[j].length;i++)document.write((g[j][i]==1)?'*':' ');document.writeln()}}

http://jsfiddle.net/YssSb/3/ (f is a correction factor for the line-height / font-width ratio.  If you use a square font setting, i.e., set line-height = font-size, you can set f=1 and get "square" circles. Or set f arbitrarily for ellipses.)
Output for 3 (interestingly enough, accidentally exactly the same shape as OP), 5, 15:
   ******
 **      **
**        **
*          *
**        **
 **      **
   ******

     *********
   ***       ****
 ***            **
**               **
*                 *
*                 *
*                 *
**               **
 ***            **
   ***       ****
     *********

                    ***************
               ******             ******
            ****                       *****
          ***                              ***
        ***                                  ***
      ***                                      ***
     **                                          **
    **                                            **
   **                                              **
  **                                                **
 **                                                  **
 *                                                    *
**                                                    **
*                                                      *
*                                                      *
*                                                      *
*                                                      *
*                                                      *
**                                                    **
 *                                                    *
 **                                                  **
  **                                                **
   **                                              **
    **                                            **
     **                                          **
      ***                                      ***
        ***                                  ***
          ***                              ***
            ****                       *****
               ******             ******
                    ***************

Nice looking circles you've got. ;)

a Bresenham circle in Scala (35)
The Bresenham - algorithm has 2 major points:

works without sin/ cosin.
you only calculate ¼*½ circle, the other points are found by mirroring.

How to do it:

       2 1
     DCBABCD
   GFE  |  EFG
  IJ   y|----JI
 GJ     |    /JG
 F      |   / |F
DE      | r/  |ED
C       | /   | C
B 4     |/    | B 3
A       +-------A
B 4'          x B 3'
C               C
DE             ED
 F             F
 GJ           JG
  IJ         JI
   GFE     EFG
     DCBABCD
       2'1'

We only calculate the numbers from A in the zenit to I.

Point I is at 45°, defined by x == y.
Ground zero is where the + is.
The A in the zenit is the point (x=0, y=r), r = radius.
To draw a closed circle we move clockwise (++x), which is to the right (x+=1) or down to the next point, (y-=1).
every point(x,y) on the circle is r away from the center.
Pythagoras says, r²=x²+y².
This smells like square-root and equitations with 2 solutions, but beware!
we start at A and want to know, whether we paint next the  point below or the point beneath to the right.

we calculate for both points (x²+y²) and build for both the  difference to r² (which stays of course constant).

since the difference can be negative, we take the abs from it.
then we look which point is closer to the result (r²), eo ipso smaller.
depending on that we draw the right or bottom neighbor.

the so found point

1 x, y gets mirrored
2 -x, y to the left
3 y, x at the diagonal
4 -y, x from there to the left

all those points get mirrored again to the south

1' x, -y
2' -x, -y
3' y, -x
4' -y, -x done.

This isn't code golf, but all those numbers at the top of the existing solutions made me think it is, so I spent useless time in golfing my solution. Therefore I added a useless number at the top too. It's 11 times Pi rounded.

object BresenhamCircle extends App {
    var count = 0
    val r = args(0).toInt
    // ratio > 1 means expansion in horizontal direction
    val ratio = args(1).toInt
    val field = ((0 to 2 * r).map (i=> (0 to 2 * r * ratio).map (j=> ' ').toArray)).toArray
    def square (x: Int, y: Int): Int = x * x + y * y
    def setPoint (x: Int, y: Int) {
        field (x)(y*ratio) = "Bresenham"(count)
        field (y)(x*ratio) = "Bresenham"(count)
    }
    def points (x: Int, y: Int)
    {
        setPoint (r + x, r + y)
        setPoint (r - x, r + y)
        setPoint (r + x, r - y)
        setPoint (r - x, r - y)
    }
    def bresenwalk () {
        var x = 0;
        var y = r;
        val rxr = r * r
        points (x, y);
        do
        {
            val (dx, dy) = { if (math.abs (rxr - square ((x+1), y)) < math.abs (rxr - square (x, (y-1))))
                (1, 0)
            else
                (0, -1)
            }
            count = (count + 1) % "Bresenham".length
            x += dx
            y += dy
            points (x, y)
        }while ((x <= y))
    }
    bresenwalk ()
    println (field.map (_.mkString ("")).mkString ("\n"))
}

The font-question is decided by sites webserver and your browser settings. Now, that I'm looking it is
'Droid Sans Mono',Consolas,Menlo,Monaco,Lucida Console,Liberation Mono,DejaVu Sans Mono,Bitstream Vera Sans Mono,Courier New,monospace,serif

Font-size is 12px. Pretty useless information, if you ask me, but who does?
Bonus: ellipses and sample output:
The invocation is
    scala BresenhamCircle SIZE RATIO

for example
    scala BresenhamCircle 10 2
              s e r B r e s
          h n e           e n h
      e m a                   a m e
    e r                           r e
    m                               m
  h a                               a h
  n                                   n
s e                                   e s
e                                       e
r                                       r
B                                       B
r                                       r
e                                       e
s e                                   e s
  n                                   n
  h a                               a h
    m                               m
    e r                           r e
      e m a                   a m e
          h n e           e n h
              s e r B r e s

A ratio of 2 will print a circular shape for most fonts which happen to be about twice as tall than wide. To compensate for that, we widen by 2.
# As smaller value than 2 only 1 is available:

scala BresenhamCircle 6 1
    erBre
  aes   sea
 ah       ha
 e         e
es         se
r           r
B           B
r           r
es         se
 e         e
 ah       ha
  aes   sea
    erBre

# widening it has more freedom:

scala BresenhamCircle 12 5
                                             s    e    r    B    r    e    s
                              a    h    n    e                             e    n    h    a
                         B    m                                                           m    B
                    e    r                                                                     r    e
               e    s                                                                               s    e
          B    r                                                                                r    B
     a    m                                                                                m    a
     h                                                                                h
     n                                                                                n
s    e                                                                                e    s
e                                                                                e
r                                                                                r
B                                                                                B
r                                                                                r
e                                                                                e
s    e                                                                                e    s
     n                                                                                n
     h                                                                                h
     a    m                                                                                m    a
          B    r                                                                                r    B
               e    s                                                                               s    e
                    e    r                                                                     r    e
                         B    m                                                           m    B
                              a    h    n    e                             e    n    h    a
                                             s    e    r    B    r    e    s

I restricted the ratio parameter for Int to keep it simple, but it can easily be widened to allow floats.

your character count (without unneeded newlines) is in fact 34.557519189487725623089077216075 :)  BTW: very nice solution, +1

Python (172)
172 chars including the two mandatory newlines. Uses the Bresenham algorithm for conic curves (no divisions or multiplications); it only outputs circles for square fonts, but should be exempt from staircase effects (ie. always has the same width).
y=input();t=[y*[' ']for x in range(y)];x=0;y-=1;p=3-2*y
while x<=y:t[x][y]=t[y][x]='*';n,y=((x-y+1,y-1),(x,y))[p<0];p+=4*n+6;x+=1
for s in t[::-1]+t:print"".join(s[::-1]+s)

Not very pretty, but well, I thought I'd give it a shot.
  ****
 *    *
*      *
*      *
*      *
*      *
 *    *
  ****

          ********
       ***        ***
      *              *
     *                *
    *                  *
   *                    *
  *                      *
 *                        *
 *                        *
 *                        *
*                          *
*                          *
*                          *
*                          *
*                          *
*                          *
*                          *
*                          *
 *                        *
 *                        *
 *                        *
  *                      *
   *                    *
    *                  *
     *                *
      *              *
       ***        ***
          ********

Edit: typo, replaced addition with division.

Python, 180 characters
This code makes circles if the font is square.  It's pretty easy to modify to generate nominal ellipses if you know your font height/width ratio.
import math
r=input()
d=2*r+1
c=[' '*d]*d
for a in xrange(9*d):f=math.pi*a/r/9; x=int(r+r*math.sin(f)+.5);y=int(r+r*math.cos(f)+.5);c[y]=c[y][:x]+'*'+c[y][x+1:]
for s in c:print s

Examples:
4:
  *****
 **   **
**     **
*       *
*       *
*       *
**     **
 **   **
  *****

7:
     *****
   **     **
  **       **
 **         **
**           **
*             *
*             *
*             *
*             *
*             *
**           **
 **         **
  **       **
   **     **
     *****

Could you post a sample?

+1 But 2nd place... It was close, though.

Perl (92)
I went for the “bonus question” and made it exploit the character aspect ratio to draw ellipses :)
($w)=@ARGV;for$x(-$w..$w){$p.=abs($x*$x+$_*$_-$w*$w)<$w?'*':$"for(-$w..$w);$p.=$/;}print $p;

Example outputs:
>perl circle.pl 3
  ***
 *   *
*     *
*     *
*     *
 *   *
  ***

>perl circle.pl 5
   *****
  *     *
 *       *
*         *
*         *
*         *
*         *
*         *
 *       *
  *     *
   *****

>perl circle.pl 8
      *****
    **     **
   *         *
  *           *
 *             *
 *             *
*               *
*               *
*               *
*               *
*               *
 *             *
 *             *
  *           *
   *         *
    **     **
      *****

+1 3rd place, but the shapes don't look as nice as in the other answers. (Still better than what I could program, of course. :) )

Haskell (112 109)
g n=map(zipWith(?)f.repeat)f where x?y|abs(x^2+y^2-n^2)<n='*'|0<1=' ';f=[-n..n]
main=interact$unlines.g.read

This works by checking, whether x² + y² - r² < n for all points. All points for which this is true are stars, all others are blanks.
Examples:

$ echo 3 | runhaskell circ.hs
  ***
 *   *
*     *
*     *
*     *
 *   *
  ***
$ echo 10 | runhaskell circ.hs
       *******
     **       **
    *           *
   *             *
  *               *
 *                 *
 *                 *
*                   *
*                   *
*                   *
*                   *
*                   *
*                   *
*                   *
 *                 *
 *                 *
  *               *
   *             *
    *           *
     **       **
       *******

See here for big example: http://www.ideone.com/t042u

C, 127 Bytes, Font name: Arial Super Bold
#include<math.h>
main(){int r=10,c=r*2+1,q=c*c,d;for(;q--;)d=hypot(r-q%c,r-q/c),printf("%c%s",d>r-4&&d<=r?42:32,q%c?"":"\n");}

Result:
      *********
    *************
   ***************
  *****************
 ******       ******
 *****         *****
*****           *****
****             ****
****             ****
****             ****
****             ****
****             ****
****             ****
****             ****
*****           *****
 *****         *****
 ******       ******
  *****************
   ***************
    *************
      *********

110 bytes

source: Stack Exchange

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

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

sort: votes


text:
Determine if 4 points form a square
Write a function that takes 4 points on the plane as input and returns true iff the 4 points form a square.  The points will have integral coordinates with absolute values < 1000.
You may use any reasonable representation of the 4 points as input.  The points are not provided in any particular order.
Shortest code wins.
Example squares:
(0,0),(0,1),(1,1),(1,0)    # standard square
(0,0),(2,1),(3,-1),(1,-2)  # non-axis-aligned square
(0,0),(1,1),(0,1),(1,0)    # different order

Example non-squares:
(0,0),(0,2),(3,2),(3,0)  # rectangle
(0,0),(3,4),(8,4),(5,0)  # rhombus
(0,0),(0,0),(1,1),(0,0)  # only 2 distinct points
(0,0),(0,0),(1,0),(0,1)  # only 3 distinct points

You may return either true or false for the degenerate square (0,0),(0,0),(0,0),(0,0)

We are talking 3D points here, right?

@gnibbler the "on the plane" part of the question make 3D points unlikely.

Are the points given in order?

@J B, I was thinking that it meant the points were on a plane, but I visualised a plane in 3D space for some reason :)

@J B, considering you can use any "reasonable representation of the 4 points as input", I don't see why they wouldn't be.

@Bass5098: imho, they wouldn't be because determining the order is an interesting part of the problem.  But it falls to interpreting "reasonable", I'll let Keith decide.

The points are in no particular order.

A few test cases might be nice.

@Joey: I added a few tests.

-1 for all the false solutions.

@eBusiness: -1 that you have cast 11 votes: 7 of them being down.

I haven't been much into upvoting, but I always give a wrong solution a downvote when I see one.

@eBusiness: at least you comment your downvotes but will check for corrections or just leave it as that?

I'll check again if you edit. You may also just delete and repost to throw off votes (they will be uncounted at the next score correction).

@eBusiness: no problem anyway. :)

@Keith: are identical points permitted? Like (1, 1) (1,1) (3,2) (4,5)?

@Eelvex: yes, there may be duplicates.  See the recent examples I added

Python 176 90 79 bytes
def S(A):c=sum(A)/4.0;return set(A)==set((A[0]-c)\*1j\*\*i+c for i in range(4))

Function S takes a list of complex numbers as its input (A). If we know both the centre and one corner of a square, we can reconstruct the square by rotating the corner 90,180 and 270 degrees around the centre point (c). On the complex plane rotation by 90 degrees about the origin is done by multiplying the point by i. If our original shape and the reconstructed square have the same points then it must have been a square.

A few optimizations: 1) use "S" instead of "is_square" 2) put it all on one line using ; 3) iterate over the 4 directions directly "for i in(1,1j,-1,-1j)" 4) don't need [] in set argument.

Thanks Keith. (I left out (3) as it appears to be the same length as my code)

@Keith Randall - Why was this accepted when J B has a much shorter solution?

Two reasons.  One, J would always win.  So I like to normalize a bit by language.  Also, I like this answer better because it doesn't suffer from the same problem as the distance-only answers where other figures (admittedly, only irrational ones) give false positives.

@Keith Randall - Quotes from the question: "The points will have integral coordinates" "Shortest code wins.". It's perfectly fine if you choose different criteria for selecting an answer, even subjective criteria, but then you should state that in the question.

This can be shortened to def U(A):c=sum(A)/4;d=A[0]-c;return{d+c,c-d,d*1j+c,c-d*1j}==set(A) (66 chars).

J, 28 17 25 27
J doesn't really have functions, but here's a monadic verb that takes a vector of points from the complex plane:
4 8 4-:#/.~&(/:~&:|&,&(-/~))

Method is a mix of Michael Spencer (work solely on inter-vertex lengths; but he's currently failing my rhombus2) and Eelvex's (check the sets' sizes) works.  Reading right to left:

-/~ compute all point differences
, flatten
| extract magnitude
/:~ sort up
#/.~ nub and count
4 8 4 -: must have exactly 4 equidistant (at 0), 8 a bit bigger (length 1, sides), 4 bigger yet (length sqrt 2, diagonals)

Demonstration:
   NB. give the verb a name for easier use
   f =: 4 8 4-:#/.~&(/:~&:|&,&(-/~))

   NB. standard square
   f 0 0j1 1j1 1
1

   NB. non-axis-aligned square
   f 0 2j1 3j_1 1j_2
1

   NB. different order
   f 0 1j1 0j1 1
1

   NB. rectangle
   f 0 0j2 3j2 3
0

   NB. rhombus 1
   f 0 3j4 8j4 5
0

   NB. rhombus 2
   f 0 1ad_60 1ad0 1ad60
0

For memory's sake, my previous method (required ordered vertices, but could detect regular polygons of any order):
*./&(={.)&(%1&|.)&(-1&|.)

See history for explanation and demo.  The current method could probably be expanded to other polygons, that 4 8 4 does look a lot like a binomial distribution.

Can you link to this language?

@Sargun Dhillon: http://www.jsoftware.com/

Ah, well this suffers from the same problem as my answer then. 3= is not enough to guarantee a square.

@gnibbler: Why not? I'm pretty sure it does.

@gnibbler: counter-example, please? nevermind, I got one.

@JB: Do you have a counter-example (that doesn't involve points at the same point)?

@Eelvex: yes, I'll include it in my demo.  (the right place would be the problem statement, but it might be more of a pain to type in other languages than J)

Actually, a non-square figure that satisfy the conditions that you check for does exist, a regular triangle plus one point a side-length from a tip of the triangle placed on the extended median. But the question called for integer input, so I guess the solution is ok.

Ah, ok. I was thinking of equilateral triangles with the 4th point being the centre, but that is ruled out by the integer co-ordinates

You could cut 3 characters by changing it to an explicit definition:
3 :'4 8 4-:#/.~/:~|,-/~y'

Also -3: 4 4 8-:[:/:~[:#/.~@,|@-/~.  Try it online!

-7 using paperhorse's approach: 0=[:(#@-.0j1*])]-+/%# Try it online!

Python, 71 42
lambda A: len(set(A))==4 and len(set(abs(i-j)for i in A for j in A))==3

Update 1) to require 4 different points (would previously give false positives for repeated points - are there others?)  2) to define a function per spec
For a square, the vector between any two points must be 0 (the same point), a side, or a diagonal. So, the set of the magnitude of these vectors must have length 3.
# Accepts co-ordinates as sequences of complex numbers

SQUARES=[
 (0+0j,0+1j,1+1j,1+0j),  # standard square
 (0+0j,2+1j,3-1j,1-2j),  # non-axis-aligned square
 (0+0j,1+1j,0+1j,1+0j)   # different order
]

NONSQUARES=[
 (0+0j,0+2j,3+2j,3+0j),  # rectangle
 (0+0j,3+4j,8+4j,5+0j),  # rhombus
 (0+0j,0+1j,1+1j,0+0j),   # duplicated point
 (0+0j,1+60j,1+0j,1-60j)  # rhombus 2 (J B)
]

test = "lambda A: len(set(A))==4 and len(set(abs(i-j)for i in A for j in A))==3"
assert len(test)==71

is_square=lambda A: len(set(A))==4 and len(set(abs(i-j)for i in A for j in A))==3

for A in SQUARES:
    assert is_square(A)

for A in NONSQUARES:
    assert not is_square(A)

I think the question explicitly stated a list of points, and not a vector.

False positives.

So (0+0j,0+0j,1+0j,0+1j) is a square?

My rhombus 2 is not 1+/-60j, it's more like exp(ijpi/3) for values from -1, 0, 1.  Note that as eBusiness pointed out they can't all be integral, so not really in the scope of the question.

OCaml, 145 164
let(%)(a,b)(c,d)=(c-a)*(c-a)+(d-b)*(d-b)
let t a b c d=a%b+a%c=b%c&&d%c+d%b=b%c&&a%b=a%c&&d%c=d%b
let q(a,b,c,d)=t a b c d||t a c d b||t a b d c

Run like this:
q ((0,0),(2,1),(3,-1),(1,-2))

Let's deobfuscate and explain a bit.
First we define a norm:
let norm (ax,ay) (bx,by) = (bx-ax)*(bx-ax)+(by-ay)*(by-ay)

You'll notice that there is no call to sqrt, it's not needed here.
let is_square_with_fixed_layout a b c d =
  (norm a b) + (norm a c) = norm b c
  && (norm d c) + (norm d b) = norm b c
  && norm a b = norm a c
  && norm d c = norm d b

Here a, b, c and d are points.
We assume that these points are layed out like this:
a - b
| / |
c - d

If we have a square then all these conditions must hold:

a b c is a right triangle
b c d is a right triangle
the smaller sides of each right triangle have the same norms

Observe that the following always holds:
is_square_with_fixed_layout r s t u = is_square_with_fixed_layout r t s u

We will use that to simplify our test function below.
Since our input is not ordered, we also have to check all permutations. Without loss of generality we can avoid permuting the first point:
let is_square (a,b,c,d) =
  is_square_with_fixed_layout a b c d
  || is_square_with_fixed_layout a c b d
  || is_square_with_fixed_layout a c d b
  || is_square_with_fixed_layout a b d c
  || is_square_with_fixed_layout a d b c
  || is_square_with_fixed_layout a d c b

After simplification:
let is_square (a,b,c,d) =
  is_square_with_fixed_layout a b c d
  || is_square_with_fixed_layout a c d b
  || is_square_with_fixed_layout a b d c

Edit: followed M.Giovannini's advice.

Nice. We haven't seen much OCaml here :)

Use an operator instead of n for a reduction in 20 characters: let t a b c d=a%b+a%c=b%c&&d%c+d%b=b%c&&a%b=a%c&&d%c=d%b.

Factor
An implementation in the Factor programming language:
USING: kernel math math.combinatorics math.vectors sequences sets ;

: square? ( seq -- ? )
    members [ length 4 = ] [
        2 [ first2 distance ] map-combinations
        { 0 } diff length 2 =
    ] bi and ;

And some unit tests:
[ t ] [
    {
        { { 0 0 } { 0 1 } { 1 1 } { 1 0 } }   ! standard square
        { { 0 0 } { 2 1 } { 3 -1 } { 1 -2 } } ! non-axis-aligned square
        { { 0 0 } { 1 1 } { 0 1 } { 1 0 } }   ! different order
        { { 0 0 } { 0 4 } { 2 2 } { -2 2 } }  ! rotated square
    } [ square? ] all?
] unit-test

[ f ] [
    {
        { { 0 0 } { 0 2 } { 3 2 } { 3 0 } }   ! rectangle
        { { 0 0 } { 3 4 } { 8 4 } { 5 0 } }   ! rhombus
        { { 0 0 } { 0 0 } { 1 1 } { 0 0 } }   ! only 2 distinct points
        { { 0 0 } { 0 0 } { 1 0 } { 0 1 } }   ! only 3 distinct points
    } [ square? ] any?
] unit-test

Haskell, 100 characters
Here's how I'd write the JB's J solution in Haskell. With no attempt made to damage readability by removing nonessential characters, it's about 132 characters:
import Data.List
d (x,y) (x',y') = (x-x')^2 + (y-y')^2
square xs = (== [4,8,4]) . map length . group . sort $ [d x y | x<-xs, y<-xs]

You can scrape it down a bit to 100 by removing excess spaces and renaming some things
import Data.List
d(x,y)(a,b)=(x-a)^2+(y-b)^2
s l=(==[4,8,4]).map length.group.sort$[d x y|x<-l,y<-l]

Let's use QuickCheck to ensure that it accepts arbitrary squares, with one vertex at (x,y) and edge vector (a,b):
prop_square (x,y) (a,b) = square [(x,y),(x+a,y+b),(x-b,y+a),(x+a-b,y+b+a)]

Trying it in ghci:
ghci> quickCheck prop_square
*** Failed! Falsifiable (after 1 test):
(0,0)
(0,0)

Oh right, the empty square isn't considered a square here, so we'll revise our test:
prop_square (x,y) (a,b) =
   (a,b) /= (0,0) ==> square [(x,y),(x+a,y+b),(x-b,y+a),(x+a-b,y+b+a)]

And trying it again:
ghci> quickCheck prop_square
+++ OK, passed 100 tests.

Save 11 chars by unrolling the function d. s l=[4,8,4]==(map length.group.sort)[(x-a)^2+(y-b)^2|(x,y)<-l,(a,b)<-l]

Python - 42 chars
Looks like its an improvement to use complex numbers for the points
len(set(abs(x-y)for x in A for y in A))==3

where
    A = [(11+13j), (14+12j), (13+9j), (10+10j)]
old answer:
from itertools import*
len(set((a-c)**2+(b-d)**2 for(a,b),(c,d)in combinations(A,2)))==2

Points are specified in any order as a list, eg
A = [(11, 13), (14, 12), (13, 9), (10, 10)]

`>>> A=[(0,0),(0,0),(1,1),(0,0)]

len(set((a-c)**2+(b-d)**2 for(a,b),(c,d)in combinations(A,2)))==2
True`

@Sargun, that's a special case of a whole class of inputs that don't work. I'm trying to think of a fix that doens't blow out the size of the answer. Meanwhile, Can work out the general class of failing cases?

A=[(0,0),(0,4),(2,2),(-2,2)]; len(set((a-c)**2+(b-d)**2 for(a,b),(c,d)in combinations(A,2)))==2

@Sargun: that example is a square.

to get rid of duplicated points you can add -set([0])

Python (105)
Points are represented by (x,y) tuples.  Points can be in any order and only accepts squares.  Creates a list, s, of pairwise (non-zero) distances between the points.  There should be 12 distances in total, in two unique groups.

def f(p):s=filter(None,[(x-z)**2+(y-w)**2for x,y in p for z,w in p]);return len(s)==12and len(set(s))==2

You could leave out the filter and check if the len of the set is 3. This suffers from the same false positive problem as my answer though.

f([(0,0),(0,4),(2,2),(-2,2)]) = True

f([(0,0),(0,4),(2,2),(-2,2)])  is a square

C# -- not exactly short. Abusing LINQ. Selects distinct two-combinations of points in the input, calculates their distances, then verifies that exactly four of them are equal and that there is only one other distinct distance value. Point is a class with two double members, X and Y. Could easily be a Tuple, but meh.
var points = new List<Point>
             {
                 new Point( 0, 0 ),
                 new Point( 3, 4 ),
                 new Point( 8, 4 ),
                 new Point( 5, 0 )
              };
var distances = points.SelectMany(
    (value, index) => points.Skip(index + 1),
    (first, second) => new Tuple<Point, Point>(first, second)).Select(
        pointPair =>
        Math.Sqrt(Math.Pow(pointPair.Item2.X - pointPair.Item1.X, 2) +
                Math.Pow(pointPair.Item2.Y - pointPair.Item1.Y, 2)));
return
    distances.Any(
        d => distances.Where( p => p == d ).Count() == 4 &&
                distances.Where( p => p != d ).Distinct().Count() == 1 );

PHP, 82 characters

//$x=array of x coordinates
//$y=array of respective y coordinates
/* bounding box of a square is also a square - check if Xmax-Xmin equals Ymax-Ymin */
function S($x,$y){sort($x);sort($y);return ($x[3]-$x[0]==$y[3]-$y[0])?true:false};

//Or even better (81 chars):
//$a=array of points - ((x1,y1), (x2,y2), (x3,y3), (x4,y4))
function S($a){sort($a);return (bool)($a[3][0]-$a[0][0]-abs($a[2][1]-$a[3][1]))};

But just because the bounding box is square doesn't mean the points lie in a square. Necessary but not sufficient condition. Consider (0,0), (5,5), (10,0), (0,-5). Bounding box is square (0:10, -5:5); figure is not.

OCaml + Batteries, 132 characters
let q l=match List.group(-)[?List:(x-z)*(x-z)+(y-t)*(y-t)|x,y<-List:l;z,t<-List:l;(x,y)<(z,t)?]with[[s;_;_;_];[d;_]]->2*s=d|_->false

(look, Ma, no spaces!) The list comprehension in q forms the list of squared norms for each distinct unordered pair of points. A square has four equal sides and two equal diagonals, the squared lengths of the latter being twice the squared lengths of the former. Since there aren't equilateral triangles in the integer lattice the test isn't really necessary, but I include it for completeness.
Tests:
q [(0,0);(0,1);(1,1);(1,0)] ;;
- : bool = true
q [(0,0);(2,1);(3,-1);(1,-2)] ;;
- : bool = true
q [(0,0);(1,1);(0,1);(1,0)] ;;
- : bool = true
q [(0,0);(0,2);(3,2);(3,0)] ;;
- : bool = false
q [(0,0);(3,4);(8,4);(5,0)] ;;
- : bool = false
q [(0,0);(0,0);(1,1);(0,0)] ;;
- : bool = false
q [(0,0);(0,0);(1,0);(0,1)] ;;
- : bool = false

K - 33
Translation of the J solution by J B:
{4 8 4~#:'=_sqrt+/'_sqr,/x-/:\:x}

K suffers here from its reserved words(_sqr and _sqrt).
Testing:
  f:{4 8 4~#:'=_sqrt+/'_sqr,/x-/:\:x}

  f (0 0;0 1;1 1;1 0)
1

  f 4 2#0 0 1 1 0 1 1 0
1

  f 4 2#0 0 3 4 8 4 5 0
0

Mathematica 65 80 69 66
Checks that the number of distinct inter-point distances (not including distance from a point to itself) is 2 and the shorter of the two is not 0.
h = Length@# == 2 \[And] Min@# != 0 &[Union[EuclideanDistance @@@ Subsets[#, {2}]]] &;

Usage
h@{{0, 0}, {0, 1}, {1, 1}, {1, 0}}       (*standard square *)
h@{{0, 0}, {2, 1}, {3, -1}, {1, -2}}     (*non-axis aligned square *)
h@{{0, 0}, {1, 1}, {0, 1}, {1, 0}}       (*a different order *)

h@{{0, 0}, {0, 2}, {3, 2}, {3, 0}}       (* rectangle *)
h@{{0, 0}, {3, 4}, {8, 4}, {5, 0}}       (* rhombus   *)
h@{{0, 0}, {0, 0}, {1, 1}, {0, 0}}       (* only 2 distinct points *)
h@{{0, 0}, {0, 1}, {1, 1}, {0, 1}}       (* only 3 distinct points *)

True
True
True
False
False
False
False

N.B.: \[And] is a single character in Mathematica.

Are you telling me that Mathematica doesn't have a built-in IsSquare function?

Jelly, 8 bytes
_Æm×ıḟƊṆ

Try it online!
Takes a list of complex numbers as a command line argument. Prints 1 or 0.
_Æm        Subtract mean of points from each point (i.e. center on 0)
   ×ıḟƊ    Rotate 90°, then compute set difference with original.
       Ṇ   Logical negation: if empty (i.e. sets are equal) then 1 else 0.

This seems like an enjoyable challenge to revive!

PHP, 161 158 characters
function S($a){for($b=4;--$b;)for($c=$b;$c--;){$e=$a[$c][0]-$a[$b][0];$f=$a[$c][1]-$a[$b][1];$d[$g++]=$e*$e+$f*$f;}sort($d);return$d[0]==$d[3]&&$d[4]==$d[5];}

Proof (1x1): http://codepad.viper-7.com/ZlBpOB
This is based off of eBuisness's JavaScript answer.

It's a bit unclear from the problem statement the points would come in ordered.  I'll go ask.

I don't think this will properly handle lots of cases.  For example, it will incorrectly label rhombuses as squares.

Updated this to match one of the JavaScript answers, should handle all cases.

Haskell (212)
import Data.List;j=any f.permutations where f x=(all g(t x)&&s(map m(t x)));t x=zip3 x(drop 1$z x)(drop 2$z x);g(a,b,c)=l a c==sqrt 2*l a b;m(a,b,_)=l a b;s(x:y)=all(==x)y;l(m,n)(o,p)=sqrt$(o-m)^2+(n-p)^2;z=cycle

Naive first attempt. Checks the following two conditions for all permutations of the input list of points (where a given permutation represents, say, a clockwise ordering of the points):

all angles are 90 degrees
all sides are the same length

Deobfuscated code and tests
j' = any satisfyBothConditions . permutations
          --f
    where satisfyBothConditions xs = all angleIs90 (transform xs) &&
                                     same (map findLength' (transform xs))
          --t
          transform xs = zip3 xs (drop 1 $ cycle xs) (drop 2 $ cycle xs)
          --g
          angleIs90 (a,b,c) = findLength a c == sqrt 2 * findLength a b
          --m
          findLength' (a,b,_) = findLength a b
          --s
          same (x:xs) = all (== x) xs
          --l
          findLength (x1,y1) (x2,y2) = sqrt $ (x2 - x1)^2 + (y2 - y1)^2

main = do print $ "These should be true"
          print $ j [(0,0),(0,1),(1,1),(1,0)]
          print $ j [(0,0),(2,1),(3,-1),(1,-2)]
          print $ j [(0,0),(1,1),(0,1),(1,0)]
          print $ "These should not"
          print $ j [(0,0),(0,2),(3,2),(3,0)]
          print $ j [(0,0),(3,4),(8,4),(5,0)]
          print $ "also testing j' just in case"
          print $ j' [(0,0),(0,1),(1,1),(1,0)]
          print $ j' [(0,0),(2,1),(3,-1),(1,-2)]
          print $ j' [(0,0),(1,1),(0,1),(1,0)]
          print $ j' [(0,0),(0,2),(3,2),(3,0)]
          print $ j' [(0,0),(3,4),(8,4),(5,0)]

Clojure, 159 chars.
user=> (def squares
         [[[0,0] [0,1] [1,1]  [1,0]]   ; standard square
         [[0,0] [2,1] [3,-1] [1,-2]]  ; non-axis-aligned square
         [[0,0] [1,1] [0,1]  [1,0]]]) ; different order
#'user/squares
user=> (def non-squares
         [[[0,0] [0,2] [3,2] [3,0]]    ; rectangle
          [[0,0] [3,4] [8,4] [5,0]]])  ; rhombus
#'user/non-squares
user=> (defn norm
         [x y]
         (reduce + (map (comp #(* % %) -) x y)))
#'user/norm
user=> (defn square?
         [[a b c d]]
         (let [[x y z] (sort (map #(norm a %) [b c d]))]
           (and (= x y) (= z (* 2 x)))))
#'user/square?
user=> (every? square? squares)
true
user=> (not-any? square? non-squares)
true

Edit: To also explain a little bit.

First define a norm which basically gives the distance between two given points.
Then calculate the distance of the first point to the other three points.
Sort the three distances. (This allows any order of the points.)
The two shortest distances must be equal to be a square.
The third (longest) distance must be equal to the square root of the sum of the squares of the short distances by the theorem of Pythagoras.

(Note: the square rooting is not needed and hence in the code saved above.)

JavaScript 144 characters
Mathematically equal to J Bs answer. It generates the 6 lengths and assert that the 2 greatest are equal and that the 4 smallest are equal. Input must be an array of arrays.
function F(a){d=[];g=0;for(b=4;--b;)for(c=b;c--;d[g++]=(e*e+f*f)/1e6)e=a[c][0]-a[b][0],f=a[c][1]-a[b][1];d.sort();return d[0]==d[3]&&d[4]==d[5]} //Compact function
testcases=[
[[0,0],[1,1],[1,0],[0,1]],
[[0,0],[999,999],[999,0],[0,999]],
[[0,0],[2,1],[3,-1],[1,-2]],
[[0,0],[0,2],[3,2],[3,0]],
[[0,0],[3,4],[8,4],[5,0]],
[[0,0],[0,0],[1,1],[0,0]],
[[0,0],[0,0],[1,0],[0,1]]
]
for(v=0;v<7;v++){
    document.write(F(testcases[v])+"<br>")
}

function G(a){ //Readable version
    d=[]
    g=0
    for(b=4;--b;){
        for(c=b;c--;){
            e=a[c][0]-a[b][0]
            f=a[c][1]-a[b][1]
            d[g++]=(e*e+f*f)/1e6 //The division tricks the sort algorithm to sort correctly by default method.
        }
    }
    d.sort()
    return (d[0]==d[3]&&d[4]==d[5])
}

Scala (146 characters)
def s(l:List[List[Int]]){var r=Set(0.0);l map(a=>l map(b=>r+=(math.pow((b.head-a.head),2)+math.pow((b.last-a.last),2))));print(((r-0.0).size)==2)}

C#, 107 characters
return p.Distinct().Count()==4&&
(from a in p from b in p select (a-b).LengthSquared).Distinct().Count()==3;

Where points is List of Vector3D containing the points.
Computes all distances squared between all points, and if there are exactly three distinct types (must be 0, some value a, and 2*a) and 4 distinct points then the points form a square.

JavaScript 1.8, 112 characters
Update: saved 2 characters by folding the array comprehensions together.
function i(s)(p=[],[(e=x-a,f=y-b,d=e*e+f*f,p[d]=~~p[d]+1)for each([a,b]in s)for each([x,y]in s)],/8,+4/.test(p))

Another reimplementation of J B's answer.  Exploits JavaScript 1.7/1.8 features (expression closures, array comprehensions, destructuring assignment).  Also abuses ~~ (double bitwise not operator) to coerce undefined to numeric, with array-to-string coercion and a regexp to check that the length counts are [4, 8, 4] (it assumes that exactly 4 points are passed).  The abuse of the comma operator is an old obfuscated C trick.
Tests:
function assert(cond, x) { if (!cond) throw ["Assertion failure", x]; }

let text = "function i(s)(p=[],[(e=x-a,f=y-b,d=e*e+f*f,p[d]=~~p[d]+1)for each([a,b]in s)for each([x,y]in s)],/8,+4/.test(p))"
assert(text.length == 112);
assert(let (source = i.toSource()) (eval(text), source == i.toSource()));

// Example squares:
assert(i([[0,0],[0,1],[1,1],[1,0]]))    // standard square
assert(i([[0,0],[2,1],[3,-1],[1,-2]]))  // non-axis-aligned square
assert(i([[0,0],[1,1],[0,1],[1,0]]))    // different order

// Example non-squares:
assert(!i([[0,0],[0,2],[3,2],[3,0]]))  // rectangle
assert(!i([[0,0],[3,4],[8,4],[5,0]]))  // rhombus
assert(!i([[0,0],[0,0],[1,1],[0,0]]))  // only 2 distinct points
assert(!i([[0,0],[0,0],[1,0],[0,1]]))  // only 3 distinct points

// Degenerate square:
assert(!i([[0,0],[0,0],[0,0],[0,0]]))   // we reject this case

GoRuby - 66 characters
f=->a{z=12;a.pe(2).m{|k,l|(k-l).a}.so.go{|k|k}.a{|k,l|l.sz==z-=4}}

expanded:
f=->a{z=12;a.permutation(2).map{|k,l|(k-l).abs}.sort.group_by{|k|k}.all?{|k,l|l.size==(z-=4)}}

Same algorithm as J B's answer.
Test like:
p f[[Complex(0,0), Complex(0,1), Complex(1,1), Complex(1,0)]]

Outputs true for true and blank for false

Never heard of GoRuby. Is there anything official written about it? http://stackoverflow.com/questions/63998/hidden-features-of-ruby/64124#64124

@Jonas: I haven't seen anything really official about it, the best blog post I have seen is this one.  I wasn't actually able to get it built and working but an alternative is to just copy the golf-prelude into the same folder and run ruby -r ./golf-prelude.rb FILE_TO_RUN.rb and it will work exatcly the same.

it is not necessary to sort before group_by. .sort.group_by {...} should be written as .group_by {...}

Python 97 (without complex points)
def t(p):return len(set(p))-1==len(set([pow(pow(a-c,2)+pow(b-d,2),.5)for a,b in p for c,d in p]))

This will take lists of point tuples in [(x,y),(x,y),(x,y),(x,y)] in any order, and can handle duplicates, or the wrong number of points. It does NOT require complex points like the other python answers.
You can test it like this:
S1 = [(0,0),(1,0),(1,1),(0,1)]   # standard square
S2 = [(0,0),(2,1),(3,-1),(1,-2)] # non-axis-aligned square
S3 = [(0,0),(1,1),(0,1),(1,0)]   # different order
S4 = [(0,0),(2,2),(0,2),(2,0)]   #
S5 = [(0,0),(2,2),(0,2),(2,0),(0,0)] #Redundant points

B1 = [(0,0),(0,2),(3,2),(3,0)]  # rectangle
B2 = [(0,0),(3,4),(8,4),(5,0)]  # rhombus
B3 = [(0,0),(0,0),(1,1),(0,0)]  # only 2 distinct points
B4 = [(0,0),(0,0),(1,0),(0,1)]  # only 3 distinct points
B5 = [(1,1),(2,2),(3,3),(4,4)]  # Points on the same line
B6 = [(0,0),(2,2),(0,2)]        # Not enough points

def tests(f):
    assert(f(S1) == True)
    assert(f(S2) == True)
    assert(f(S3) == True)
    assert(f(S4) == True)
    assert(f(S5) == True)

    assert(f(B1) == False)
    assert(f(B2) == False)
    assert(f(B3) == False)
    assert(f(B4) == False)
    assert(f(B5) == False)
    assert(f(B6) == False)

def t(p):return len(set(p))-1==len(set([pow(pow(a-c,2)+pow(b-d,2),.5)for a,b in p for c,d in p]))

tests(t)

This will take a little explaining, but the overall idea is that there are only three distances between the points in a square (Side, Diagonal, Zero(point compared to itself)):
def t(p):return len(set(p))-1==len(set([pow(pow(a-c,2)+pow(b-d,2),.5)for a,b in p for c,d in p]))

for a list p of tuples (x,y)
Remove duplicates using set(p) and then test the length
Get every combination of points (a,b in p for c,d in p)
Get list of the distance from every point to every other point
Use set to check there are only three unique distances
-- Zero (point compared to itself)
-- Side length
-- Diagonal length

To save code characters I am:

using a 1 char function name
using a 1 line function definition
Instead of checking the number of unique points is 4, I check that it is -1 the different point lengths (saves ==3==)
use list and tuple unpacking to get a,b in p for c,d in p, instead of using a[0],a[1]
uses pow(x,.5) instead of including math to get sqrt(x)
not putting spaces after the )
not putting a leading zero on the float

I fear someone can find a test case that breaks this. So please do and Ill correct. For instance the fact I just check for three distances, instead of doing an abs() and checking for side length and hypotenuse, seems like an error.
First time I've tried code golf. Be kind if I've broken any house rules.

Python, 66
Improving paperhorse's answer from 76 to 66:
def U(A):c=sum(A)/4;d=A[0]-c;return{d+c,c-d,d*1j+c,c-d*1j}==set(A)

Python 2, 49 bytes
lambda l:all(1j*z+(1-1j)*sum(l)/4in l for z in l)

Try it online!
Takes a list of four complex numbers as input. Rotates each point 90 degrees around the average, and checks that each resulting point is in the original list.
Same length (though shorter in Python 3 using {*l}).
lambda l:{1j*z+(1-1j)*sum(l)/4for z in l}==set(l)

Try it online!

Why not use Python 3 if that is shorter? Also, if it is allowed to return arbitrary truthy / falsy values in Python, ^ can be used instead of ==.

@Joel Python 2 is mostly preference, and that this is a really old challenge from 2011 when Python 2 was pretty much assumed Python golfing. And the challenge says to return true or false, so I stuck with that. If this was posted today, it would probably specify outputting truthy/falsey or one of two distinct values, and it might even by OK to assume that by default.

Wolfram Language (Mathematica), 32 31 bytes
Tr[#^2]==Tr[#^3]==0&[#-Mean@#]&

Try it online!
Takes a list of points represented by complex numbers, calculates the second and third central moment, and checks that both are zero.
Un-golfed:
S[p_] := Total[(p - Mean[p])^2] == Total[(p - Mean[p])^3] == 0

or
S[p_] := CentralMoment[p, 2] == CentralMoment[p, 3] == 0

proof
This criterion works on the entire complex plane, not just on the Gaussian integers.

First, we note that the central moments do not change when the points are translated together. For a set of points
P = Table[c + x[i] + I*y[i], {i, 4}]

the central moments are all independent of c (that's why they are called central):
{FreeQ[FullSimplify[CentralMoment[P, 2]], c], FreeQ[FullSimplify[CentralMoment[P, 3]], c]}
(*    {True, True}    *)

Second, the central moments have a simple dependence on overall complex scaling (scaling and rotation) of the set of points:
P = Table[f * (x[i] + I*y[i]), {i, 4}];
FullSimplify[CentralMoment[P, 2]]
(*    f^2 * (...)    *)
FullSimplify[CentralMoment[P, 3]]
(*    f^3 * (...)    *)

This means that if a central moment is zero, then scaling and/or rotating the set of points will keep the central moment equal to zero.
Third, let's prove the criterion for a list of points where the first two points are fixed:
P = {0, 1, x[3] + I*y[3], x[4] + I*y[4]};

Under what conditions are the real and imaginary parts of the second and third central moments zero?
C2 = CentralMoment[P, 2] // ReIm // ComplexExpand // FullSimplify;
C3 = CentralMoment[P, 3] // ReIm // ComplexExpand // FullSimplify;
Solve[Thread[Join[C2, C3] == 0], {x[3], y[3], x[4], y[4]}, Reals] // FullSimplify
(*    {{x[3] -> 0, y[3] -> -1, x[4] -> 1, y[4] -> -1},
       {x[3] -> 0, y[3] -> 1, x[4] -> 1, y[4] -> 1},
       {x[3] -> 1/2, y[3] -> -1/2, x[4] -> 1/2, y[4] -> 1/2},
       {x[3] -> 1/2, y[3] -> 1/2, x[4] -> 1/2, y[4] -> -1/2},
       {x[3] -> 1, y[3] -> -1, x[4] -> 0, y[4] -> -1},
       {x[3] -> 1, y[3] -> 1, x[4] -> 0, y[4] -> 1}}    *)

All of these six solutions represent squares:

Therefore, the only way that a list of points of the form {0, 1, x[3] + I*y[3], x[4] + I*y[4]} can have zero second and third central moments is when the four points form a square.

Due to the translation, rotation, and scaling properties demonstrated in points 1 and 2, this means that any time the second and third central moments are zero, we have a square in some translation/rotation/scaling state. ∎
generalization
The k-th central moment of a regular n-gon is zero if k is not divisible by n. Enough of these conditions must be combined to make up a sufficient criterion for detecting n-gons. For the case n=4 it was enough to detect zeros in k=2 and k=3; for detecting, e.g., hexagons (n=6) it may be necessary to check k=2,3,4,5 for zeros. I haven't proved the following, but suspect that it will detect any regular n-gon:
isregularngon[p_List] :=
  And @@ Table[PossibleZeroQ[CentralMoment[p, k]], {k, 2, Length[p] - 1}]

The code challenge is essentially this code specialized for length-4 lists.

The solution looks fairly interesting. Could you explain why it gives the correct answer?

@Joel I've added a proof.

Thanks a lot. It would be ideal that there could be a more intuitive mathematical explanation of this nice solution.

@Joel I can give you the thread that led me to this solution. I started by noticing that squares (as lists of coordinates, not complex numbers) have a covariance matrix that is proportional to the unit matrix; however, this condition is not sufficient (false positives). The third central moment must be zero for any structure of point symmetry. So I switched to complex representation to place a condition on the second and third central moments, and to my surprise it turned out that the second central moment is zero for squares.

Great. Thanks for showing the path to this solution.

J, 31 29 27 26
3=[:#[:~.[:,([:+/*:@-)"1/~

checks if the 8 smallest distances between the points are the same.
checks if there are exactly three kinds of distances between the points (zero, side length and diagonal length).
f 4 2 $ 0 0 2 1 3 _1 1 _2
1
f 4 2 $ 0 0 0 2 3 2 3 0
0

4 2 $ is a way of writing an array in J.

This fails the rhombus test.

@JB: I had a typo. I changed the method anyway now.

Eeew... you're taking the same method I was stealing.  Except my version's shorter :p

@JB: really? I didn't notice that. Who else checks (3 == #distances)?

@JB: oic... some check for combinations of 2. :-/

@Elevex, my answer uses permutations, so isn't comparing each point with itself, so I don't get the zero's

@gnibbler: yes I noticed. Nice idea :)

The method still fails, for instance two double points break it.

@eBusiness: double points?

Two points at the same spot.

@eBusiness: It was not clear that this kind of points are allowed. Is then (0,0) (0,0) (0,0) (0,0) a square or not?

No sorry, that is the related searching for 2 distinct distances methods that fails on that condition, yours would for instance break given a triangle with 2 equal sides containing 1 double point.

Smalltalk for 106 characters
s:=Set new.
p permutationsDo:[:e|s add:((e first - e second) dotProduct:(e first - e third))].
s size = 2

where p is a collection of points, e.g.
p := { 0@0. 2@1. 3@ -1. 1@ -2}. "twisted square"

I think the math is sound...

Checking for 2 distinct dot products doesn't cut it. Points placed in the same position may produce false positives.

Mathematica, 123 characters (but you can do better):
Flatten[Table[x-y,{x,a},{y,a}],1]
Sort[DeleteDuplicates[Abs[Flatten[Table[c.d,{c,%},{d,%}]]]]]
%[[1]]==0&&%[[3]]/%[[2]]==2

Where 'a' is the input in Mathematica list form, eg: a={{0,0},{3,4},{8,4},{5,0}}
The key is to look at the dot products between all the vectors and note that they must have exactly three values: 0, x, and 2*x for some value of x. The dot product checks both perpendicularity AND length in one swell foop.
I know there are Mathematica shortcuts that can make this shorter, but I don't know what they are.

I think this one is wrong as well, but I can't figure what the code does.

It calculates all the vectors between the 4 points, takes all of the dot products (absolute value), and expects the result to consist exactly of 0, x, 2*x for some value of x.

So 16 vectors -> 256 dot products, and you check that the high value is 2 times the low, but you don't how many there is of each value. Is that correct understood?

Yes, that correctly describes my algorithm. And I now think you're right: you could construct a scenario in which all 3 values occurred, but not in the right quantity. Rats. Should be fixable though?

@barrycarter  You can save characters by using Union instead of Sort@DeleteDuplicates.  I put your 3 lines together also:#[[1]] == 0 && #[[3]]/#[[2]] == 2 &[  Union@Abs@Flatten[Table[c.d, {c, #}, {d, #}]] &[   Flatten[Table[x - y, {x, a}, {y, a}], 1]]]

Haskell, "wc -c" reports 110 characters.  Does not check that the input has 4 elements.
import Data.List
k [a,b]=2*a==b
k _=0<1
h ((a,b):t)=map (\(c,d)->(a-c)^2+(b-d)^2) t++h t
h _=[]
j=k.nub.sort.h

I tested on
test1 = [(0,0),(3,4),(-4,3),(-1,7)] -- j test1 is True
test2 = [(0,0),(3,4),(-3,4),(0,8)]  -- j test2 is False

Note the above never gets the distance from a point to itself, so the presence of a distance of 0 would indicate a repeated point in the input list, and this will show up in the sorted list as k [0,b] so 2*0==b will always fail since b cannot be same the as 0.

Smalltalk Squeak 4.x flavour, 91 char in the form of a block:
[:p||b|b:=Bag new.p do:[:x|p do:[:y|b add:(x dist:y)]].b valuesAndCounts asSet={4. 8}asSet]

Test it with:
{
"Example squares:"
    {0@ 0. 0@ 1. 1@ 1. 1@ 0}. " standard square"
    {0@ 0. 2@ 1. 3@ -1. 1@ -2}.  " non-axis-aligned square"
    {0@ 0. 1@ 1. 0@ 1. 1@ 0}. " different order"
"Example non-squares:"
    {0@ 0. 0@ 2. 3@ 2. 3@ 0}.  " rectangle"
    {0@ 0. 3@ 4. 8@ 4. 5@ 0}.  " rhombus"
    {0@ 0. 0@ 0. 1@ 1. 0@ 0}.  " only 2 distinct points"
    {0@ 0. 0@ 0. 1@ 0. 0@ 1}.   " only 3 distinct points"
}
collect:
[:p||b|b:=Bag new.p do:[:x|p do:[:y|b add:(x dist:y)]].b valuesAndCounts asSet={4. 8}asSet].

It's a variant of #(4 8 4)

Bag is collecting the pairs ( interdistance -> number_of_occurences )
valuesAndCounts send the bag contents (a Dictionary)
asSet apply to the values in the dictionary (number_of_occurences)

A degenerated (0,0)*4 is not considered as a valid square.

Python, 67 chars, complex and distance-based, and no false positives ...
S=lambda A:len(set(A))-1==len(set([abs(K-J)for K in A for J in A]))

(I hope;-).
The sqrt in abs() may cause some roundoff problems, but probably not - abs((K-J)**2) is more reliable but compresses domain as numbers can approach to within a few digits of double precision limits.
Combines Jagu's answer (len(set(Points))-1==len(set(distances)) - brilliant IMNSHO - which drops to 85 as outer pow(...,.5) calls are unnecessary, and (...)**2 is shorter anyway) and user932's (lambda instead of def).
Neither as elegant, nor as short, as paperhorse's rotation as modified by WolframH.
I had a solution that put only the squares of the side and diagonal lengths in the set L and tested "len(L)==2 and max(set(L))/2 in L" but it never went much below 90 chars.
Tests (all should print True):
print S([(0+1j),(1+0j),(0+0j),(1+1j)])
print S([(0+0j),(2+1j),(3-1j),(1-2j)])
print S([(0+0j),(1+1j),(0+1j),(1+0j)])
print S([(1000+1j),(-1+1000j),(1-1000j),(-1000-1j)])

print not S([(0+1j),(0-1j),(0+0j),(0+1j)])
print not S([(999+1j),(-1+1000j),(1-1000j),(-1000-1j)])
print not S([(0+1j),(1+0j),(0+0j),(0-1j)])
print not S([(0+0j),(0+2j),(3+2j),(3+0j)])
print not S([(0+0j),(3+4j),(8+4j),(5+0j)])
print not S([(0+0j),(0+0j),(1+1j),(0+0j)])
print not S([(0+0j),(0+0j),(1+0j),(0+1j)])

Shouldn't print be included in the function S and thus counted?

C (gcc), 159 141 bytes
g;f(a,e)_Complex*a,e;{e=(*a+a[1]+a[2]+a[3])/4;for(g=0;a[g]-=e,g<4&cabs(a[g])==cabs(*a)&!fmod(carg(a[g++])-carg(*a),atan(1)););return g>4;}

-18 thanks to @G.Sliepen.
Try it online!
After subtracting the center point, checks that the absolute values of each complex number are equal, and that all the arguments are equal modulo π/2.

146+3 bytes. After subtracting the center point, checks that the absolute values of each complex number are equal, and that all the arguments are equal modulo π/2.

Stax, 14 bytes
┐cÜ╦┤╖ó#┬├{%ì↔

Run and debug it

Calculate the square of the distance between each pair of points.  This yields 6 numbers.
"Reduce" the 6-array by dividing each element by the array's gcd.
The shape is a square iff the product of the reduced array is 4.

2S{M{:sJF+m square of the distance between each pair of points
:_          "reduce"; divide each by the gcd of the array
:*4=        does the product of the array equal 4?

Run this one

Its not exactly shortest, but I dont think anyone proposed this strategy.
Scala, 152
def f(p:Seq[(Double,Double)])={p.map(b=>{math.sqrt(math.pow((p.map(_._1).sum/p.size)-b._1,2)+math.pow((p.map(_._2).sum/p.size)-b._2,2))}).toSet.size==1}

Basically we calculate average of all points across each axis to find presumably center of the square, and then validate that center has same distance from all points.
Properly formatted solution:
type Point = (Double, Double)
def isSquare(points: Seq[Point]): Boolean = {
  //finds center point along an axis
  def avg(axis: Seq[Double]): Double = {
    axis.sum / axis.size
  }

  //finds distance between 2 points
  def distance(a: Point, b: Point): Double = {
    val x = a._1 - b._1
    val y = a._2 - b._2
    math.sqrt((x * x) + (y * y))
  }

  //point in the center of square
  val center = (
    avg(points.map(_._1)),
    avg(points.map(_._2)))

  //find a set of distances from center to all points
  //and make sure only one is in the set
  points.map(distance(center, _)).toSet.size == 1
}

The solution is wrong. Any rectangle would pass this check.

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

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


text:
Permutation group operation
There is a well-known bijection between the permutations of \$n\$ elements and the numbers \$0\$ to \$n!-1\$ such that the lexicographic ordering of the permutations and the corresponding numbers is the same. For example, with \$n=3\$:
0 <-> (0, 1, 2)
1 <-> (0, 2, 1)
2 <-> (1, 0, 2)
3 <-> (1, 2, 0)
4 <-> (2, 0, 1)
5 <-> (2, 1, 0)

It is also well-known that the permutations of \$n\$ elements form a group (the symmetric group of order \$n!\$) - so, in particular, that one permutation of \$n\$ elements applied to a second permutation of \$n\$ elements yields a permutation of \$n\$ elements.
For example, \$(1, 0, 2)\$ applied to \$(a, b, c)\$ yields \$(b, a, c)\$, so \$(1, 0, 2)\$ applied to \$(2, 1, 0)\$ yields \$(1, 2, 0)\$.
Write a program which takes three integer arguments: \$n\$, \$p_1\$, and \$p_2\$; interprets \$p_1\$ and \$p_2\$ as permutations of \$n\$ elements via the bijection described above; applies the first to the second; and outputs the corresponding integer, reapplying the above bijection. For example:
$ ./perm.sh 3 2 5
3

This is code-golf so the shortest code in bytes wins

J, 30
I like the elegance of this:
[:A.[:{/]A.~/~i.@[

or this:
13 :'A.{/(i.x)(A.)~/y'

but they work like this:
3 f 2 5
3
12 f 8 9
17

So this is the valid entry:
([:A.[:{/i.@{.A.~/}.)".}.>ARGV

Some explanations:

3 A. 0 1 2: gives the 3rd permutation of 0 1 2 (= 1 2 0)
0 1 2 (A.)~ 3: is the same but with arguments reversed
0 1 2 (A.)~/ 3 4 5 ... "applies" (A.)~ to 3 4 5 ..., so it gives the 3rd, 4th, 5th, ... permutation of 0 1 2.
A. 1 2 0: gives the order of the permutation of 1 2 0 (= 3)
i. n: gives the sequence 0 1 2 ... n-1
1 2 0 { 0 2 1 arranges 0 2 1 by 1 2 0 (= 2 1 0)

Good job.  I took a peek at the documentation for A. yesterday, but was too tired to try and assemble in the correct order for the question O:-)

@JB: I was wondering why there was no JB+J here ... :)

Ruby - 77 chars
n,a,b=$*.map &:to_i
l=[*[*0...n].permutation]
p l.index(l[b].values_at *l[a])

Replace the last 3 lines by   p l.index(l[b].values_at(*l[a]))

Sorry for sounding rough. I meant to give advice, but I got lost in formatting problems, and apparently my editing time ran out.

ARGV.map{|x|x.to_i} -> $*.map &:to_i saves another few characters. And you can replace the second line with l=[*[*0...n].permutation].

No problem, thanks for the advice.

@Ventero: I like these. [*[*0...n].permutation] made me smile.

Python 2.6, 144 chars
import sys
from itertools import*
n,p,q=map(int,sys.argv[1:])
R=range(n)
P=list(permutations(R))
print P.index(tuple(P[q][P[p][i]] for i in R))

Jelly, 8 bytes
œ?Ụị¥/Œ¿

Try it online!
Uses 1-indexing, Jelly's default (i.e. just increment every number in the challenge body). +2 bytes to use zero indexing. Takes \$[p_1, p_2]\$ on the left and \$n\$ on the right.
The text of the question is kinda confusing. "Applying" one permutation to another is essentially sorting the elements of the second by the values of the first, which is exactly what "grade up, then index into" does.
How it works
œ?Ụị¥/Œ¿ - Main link. Takes [p1, p2] on the left and n on the right
œ?       - Generate the permutations of [1, 2, ..., n], then yield the p1'th and p2'th values
    ¥/   - Reduce those permutations by the following, with perm(p1) on the left and perm(p2) on the right:
  Ụ      -   Grade up perm(p1); This sorts the indices of perm(p1) by their corresponding values
   ị     -   Index into perm(p2) with these sorted indices
      Œ¿ - Sort the corresponding list, get all permutations and find it's index in them

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