text:
Calculate a tip
You and a friend walk into a bar. The bartender treats you well, so you decide to tip him. So you pull out your trusty pocket computer and write a quick program to calculate a tip for you since it has no built in calculator. But wait! Your operator keys are broken! Your task is to calculate a 20% tip for any given input amount. The test inputs will be in the form of xx.xx e.g. 20.96. Here are the rules:

No use of the following in mathematical form operators: + - * / % (Thanks Wally West)
No use of built in percent functions or APIs
No accessing the network
No use of eval or similar
No Windows Calculator (yes people have answered with it before)
No built in tip functions (Not that any language would have one)

Output should be rounded up to two decimal places.
Score is based on length in bytes.
-20% if your program can accept any tip amount. Input for amount will be given in the form of xx e.g. 35 not 0.35

Do I just need to output 20% of the input? Your wording is very weird, and I have never seen tip used in this meaning

@mniip yes. Your output is 20% of the input.

@mniip: A tip is a bizarre extra amount of money you're expected to pay at a restaurant that isn't part of the official price. I don't know if they do that in Russia.

If the + key is broken on your computer, the better way to do it is to open a character map, look up "plus" and enter unicode character u002B.

@user2357112 I always heard them referred to as gratuity

Oh, that new generation... I would rather use paper and pen if I can't mentally divide a number by 5.

@user2357112 In Russia it is called literally "for tea" (чаевые) and is usually 5-10% of the bill. In most of the cases it's up to you to pay it or not, if otherwise is stated in the menu.

@VisioN Note: dividing by five is equivalent to dividing by 10 then multiplying by 2, and both should be very easy mental operations.

Come on! you have a Doge too?

@TheDoctor It confused the hell out of me! I checked both your profiles to figure it out. I didn't know if you were the same person or not.

@TheDoctor wow very same. much confuse.

@Milo yours should be looking the other way

Can someone clarify the rules: Is using the forbidden operations allowed if you don't use those operators? Is multiplication allowed if you don't use *?

possible duplicate of Add without addition (or any of the 4 basic arithmetic operators)

@TheDoctor is it really a duplicate though? Because it's not adding.

It is essentially my question, except using multiplication.

@TheDoctor But I thought we were doge buddies!

TheDoctor: There should only be one doge [evil laugh]

@ace Thank you ace. Finally some sense around here.

I wish we could round down to the nearest whole number, and that input would be whole and in unary. Then I could use this really short /// answer: Try it online!. Input goes after the last /.

Javascript 81
EDIT : The result is now a real rounding, not truncated.
Do not use ANY math here, just string manipulation and bitwise operators.
All the + char are string concatenation, or string to float conversion.
Works for any xx.xx input and outputs in (x)x.xx format
s='00'+(prompt().replace('.','')<<1);(+s.replace(/(.*)(...)/,'$1.$2')).toFixed(2)

Trick explained : 20% is divided by 10 and multiplied by 2.

Make a division by 10 by moving the dot to the left (string manipulation)
Multiply each part by 2 by moving bits to the left (bitwise operation)

When input is 99.99, this returns 19.998, so it's not "rounded up to two decimal places" as per the OP.

Umm this is a long solution, but it has 12 upvotes. What is going on with code-golf's voting?

@Quincunx Yes you are right its not popularity contest!

Since it is a code-golf, I will probably not win, but this doesnt mean that people can't like my solution... Often, code-golf winners are not those with the most upvotes.

@n̴̖̋h̷͉̃a̷̭̿h̸̡̅ẗ̵̨́d̷̰̀ĥ̷̳, absolutly ! Thank you for pointing this out. Fixed now :)

Still truncates instead of rounding up...

@Geobits, solution with true rounding given.

@Quincunx I always keep the language in mind when upvoting. I find a 50-char PHP solution far more upvote-worthy than a 20-character GolfScript solution.

J (9 characters)
A short answer in J:
^.(^.2)^~ 32

...and I do not speak J. What does it say?

It says: compute 32 raised to power log(2); usually, exponent is at the right of ^ but here ~ indicates the order should be reversed; (^.2)is log(.2), and the initial ^. which is executed last is the logarithm of everything compute dpreviously: thus log(32^log(.2))

Pure bash, 50 43 chars
Pretty sure this'll be beat, but here's a start:
a=$[10#${1/.}<<1]
echo ${a%???}.${a: -3:2}

As per the comments:

/ is not a division operator here, it is part of a pattern substitution parameter expansion
% is not a modulo operator here, it is part of a parameter expansion
- is not a subtraction operator here, it is a negation, which was allowed as per the comments

Output:

$ ./20pct.sh 0.96
.19
$ ./20pct.sh 20.96
4.19
$ ./20pct.sh 1020.96
204.19
$

I think I see a forward slash in there.

@Milo that / is part of a bash parameter expansion and not a division operator.  Allowed or not?

I would allow it, it's not a mathematical operator in this case...

Ok I'll allow it.

@Milo I guess I need a ruling on the - in the -3 string indexing as well.  No explicit subtraction, but these are expressions of negative numbers

That's ok. I meant specifically no math operators.

-3 acts as a negation not a subtraction... @Milo, you need to account for negation and other ways that these operators can be used aside from their mathematical equivalents... for example + can be used as a concatenator in JavaScript...
Can I make a suggestion? Change "No use of the following operators: + - * / %" to "No use of the following operators in their mathematical form:  + - * / %"

@WallyWest To play devil's advocate, the negation here is still a mathematical operator.  Perhaps "No use of the following operators in their non-unary mathematical form: + - * / %" ;-)

My APL solution was downvoted because it was using the * key (though not the multiplication mathematical function); remember for your own solution that /, % and - are broken KEYS (whatever they mean).

@ברוכאל beats me.  I explicitly called out these things, so the spec could be tightened up.  Some compensatory upvotes coming your way ;-)...

APL (9 characters, new code with 7 characters, fixed with 13 characters)
Compute 20% of the given amount.
{⍟⍵*⍨*.2} 32

In APL * is the exponential operator.
Try it online.
But why use a function for that? See this new version:
⍟(*.2)* 32

Try it online.
Please, before downvoting, the * is not forbidden as a KEY and it doesn't mean multiplication here.
OK, here is the version rounding to 2 decimals (Dyalog APL):
⎕PP←2⋄⍟(*.2)* 32.01

Exponentiation is still a mathematical operation, and * is disallowed in any mathematical form as per the rules of the challenge.

Exponentiation is not fobidden here and other solutions actually use it, but you are right concerning the fact that * is forbidden as a key and not as its mathematical meaning.

@Tony H. Please, could you remove your downvote, since obviously all comments in other solutions seem to finally accept such KEYS as long as they aren't used for the forbidden mathematical operations in the initial list.

http://codegolf.stackexchange.com/questions/23814/calculate-a-tip#comment49870_23834

@TheDoctor I myself posted the comment you are referring to; the exact chronology was: I was among the first to post my solution (the second if I remember well) this morning; quickly after Tony H. downvoted my solution; then I saw many other using the same keys, and I added the comments because I thought at that time * was forbidden; then only it became obvious that * was allowed with no multiplication meaning. Please, have a look at all other solutions; they all use either + or / or * keys, and many of them also use exponentiation; why am I the single one not to be allowed of that?

@ברוכאל - except mine

@ברוכאל It's my understanding that usage of an asterisk in any way that pertains to a mathematical meaning is forbidden, that includes exponentiation. Every other answer thus-far that uses exponents is in a language that uses the caret (^) for such an operator, or a function call is used. There is no specification by the OP that * is disallowed only if it's used in the context of multiplication. I suspect it would be helpful if OP were to rule on this, to settle which one of us is misinterpreting the rules of the challenge and to clear up the confusion.

Perhaps × and ÷ are allowed, those are not listed.

@marinus right ;-) not even thought about it.

You actually need to count in terms of bytes, not characters. I count 15 bytes (unicode counts as two).

Where is the rounding up to 2 decimal places?

@ n̴̖̋h̷͉̃a̷̭̿h̸̡̅ẗ̵̨́d̷̰̀ĥ̷̳  True, forgot about it; I will fix it today.

Python 98*0.8=78.4
d=`len('X'*int("{}{:>02}".format(*(raw_input()+".0").split('.')))*2)`;print'%s.%s'%(d[:-3],d[-3:])

Python 74 (without bonus)
d=len('X'*int(raw_input().replace('.',''))*2);print'%s.%s'%(d[:-3],d[-3:])

Note

+ is used for string concatenation
* used to create copies of string

Ungolfed
def tip():
    amount = raw_input()
    #Add an extra decimal point so that we can accept integer
    #amount
    amount += ".0"
    #Split the integer and decimal part
    whole, frac = amount.split('.')
    #Multiply amount by 100 :-)
    amount = "{}{:>02}".format(whole, frac)
    #Create amount copies of a character
    st = 'X'*amount
    #Double it
    st *= 2
    #Calculate the Length
    d = len(st)
    #Display the result as 3 decimal fraction
    print'%s.%s'%(d[:-3],d[-3:])

Note
In spirit of the question, I believe the following solution though follows all rules of the question is an abuse
Python 41
print __import__("operator")(input(),0.2)

Finally
If you insist that the mathematical symbols are forbidden, her is a 90 character solution
Python 90 (without any mathematical symbol)
print' '.join(str(int(raw_input().replace(".",""))<<1)).replace(' ','.',1).replace(' ','')

As already said, * and + are broken KEYS (whatever you use them for).

@ברוכאל: No use of the following in mathematical form operators: + - * / % (Thanks Wally West). In other words, the question needs to be rephrased. And I have not used them in mathematical form

OK, but in that case, the downvote of the APL solution was'nt really fair, since no other solution has been downvoted for that reason.

Your answer is going to have problem with miniscule amount of money, e.g. 0.05.

You can use \input`(backticks included) instead ofraw_input`.

R, 30 27 36 34
Updated to round to 2 decimal places
Saved 2 characters thanks to plannapus
Creates a vector from 0 to x and takes the 2nd element.
a=function(x)round(seq(0,x,l=6)[2],2)

Example:
> a(20.36)
[1] 4.07

Further explanation:
seq(0,x,len=6)

creates a vector of length 6 from 0 to the input value x, with the values in between equally spaced.
> seq(0,5,len=6)
[1] 0 1 2 3 4 5

The first value is then 0%, the second 20%, third 40%, etc.

Wait... what ? Please give more details of how it works for those (like me) who don't know R.

@Michael updated my answer to explain the code

Your solution doesn't do any rounding.

@n̴̖̋h̷͉̃a̷̭̿h̸̡̅ẗ̵̨́d̷̰̀ĥ̷̳ you are right (but most solutions aren't rounding anything). 9 extra characters would do "normal" rounding. Only rounding up would be way harder...

@Rift: I have tested several answers (mostly Python, JS and Perl, since they are easily available) and most of them do rounding. None of those I have tested rounds up, though.

@n̴̖̋h̷͉̃a̷̭̿h̸̡̅ẗ̵̨́d̷̰̀ĥ̷̳ Ok I need to update my answer as soon as I'm at home.

You can shorten seq(0,x,len=6) to seq(0,x,l=6) thanks to arguments partial matching.

dc + sed + pipes (44 characters)
My third answer (one APL, one J, and now one with the old and venerable dc).
dc -e 5o?p|sed -e 's/\(.\)$/.\1/'|dc -e 5i?p

It will ask for an INTEGER input and compute 20% with a tricky way. Input is converted to base 5 (easy to do with many other tools but wait...); a dot is appended before the last digit with sed (unfortunately, dc can't handle strings very well), and THEN, dc converts back from base 5 on a float number (not all tools can do that).

"INTEGER input" doesn't meet the spec.  I think you can fix it by changing your sed expression: dc -e 5o?p|sed 's/\(.\)\./.\1/'|dc -e 5i?p.  With this and removing seds -es, this is 42.  But the result is still not to spec (not 2 decimal places)

@DigitalTrauma. You are right. But this solution was actually rather a proof of concept and I was more interested by the unusual property of base conversion in dc (and also in bc). Thank you for your comment and your fix in sed.

Mathematica, 19
Log[(E^.2)^Input[]]

No use of the mathematical operators of +, -, *, /, or %. Uses properties of logarithms to calculate the answer; when you simplify the expression, you get .2*Input[]
With the bonus (30 * 0.8 = 24):
Log[((E^.01)^Input[])^Input[]]

Input the percentage first, then the amount.
When you simplify the expression, you get Input[]*Input[]*.01.
Thanks to ברוכאל for help with shortening the code.

Are you really sure it can't be simplified? To me Log[E^2] or Log[E^Input[]] can be written more shortly. Even 10^-1 can be written .01 (though I don't use Mathematica but I am pretty sure it can). The whole expression (E^10^-1)^Log[E^2] seems to be something like E^.2, isn't it?

Python, 88
This is no where near short, but this demonstrate how a normal mental division by five should be done. This assumes that the input must be of the form xx.xx
import math
a,b=raw_input().split('.')
print'%.2f'%math.ldexp(float(a[0]+'.'+a[1]+b),1)

Or for input of any length, an addition of 3 characters is required.
import math
a,b=raw_input().split('.')
print'%.2f'%math.ldexp(float(a[:-1]+'.'+a[-1]+b),1)

Explanation: We take the input as string, then move the decimal point one place forward (dividing by 10). We then cast it to a float, and use the ldexp function to multiply it by 2.
Note that in this answer, the + are string concatenation operators, and the % are used to format print.
If you insist on not using any of these characters, here is a 159 character solution:
import math
a,b=raw_input().split('.')
l=[a[0]]
l.append('.')
l.append(a[1])
l.append(b)
c=str(math.ldexp(float(''.join(l)),1))
print ''.join([c[0:2],c[2:4]])

Already said for many other answers, but I really don't think that + and - are allowed since the KEYS are broken (whatever they mean in your piece of code).

@ברוכאל: See my response to your comment in my answer

Used your .split('.') in my answer, chopped one char

dc + sed -- 45 * 0.8 = 36
(Inspired by the answer by ברוכאל)

Handles any tip amount (integer or float)

Example runs (input is accepted via STDIN):
$ dc -e 5o?.0+p|sed 's/\(.\)\./.\1/'|dc -e 5i?p
42
8.400
$ dc -e 5o?.0+p|sed 's/\(.\)\./.\1/'|dc -e 5i?p
20.96
4.1920

The .0+ idea is great; I voted up for your solution inspired by mine, but some may tell you are using addition; maybe some workaround? I tried dc -e 9k5o?v2^p but it is 2 characters more.

@ברוכאל I didn't realize that the + even in this context might qualify as addition.

@ברוכאל I'll delete this one.  Request you to modify your so that it could handle floats and qualify for -20%!

TI-89 Basic - 39 * 0.8 = 31.2
Input y:Input x:Disp ln(((e^y)^.01)^x))

Works by inputting the two numbers, then using the logarithm properties to compute x * y / 100.
If I can assume input from placement in global variables x and y, then this is much shorter, for a score of 17 * 0.8 = 13.6:
ln(((e^y)^.01)^x)

Without bonus (12):
ln((e^.2)^x)

But if it needs to be wrapped in a function, then this works (38 chars, for 30.4):
:f(x,y):Func:ln(((e^y)^.01)^x):EndFunc

Please, see my comments to your other solution (in Mathematica); this code can really be simplified much.

Input x,y ??? Works in 83/84.

@Timtech Doesn't work in 89, but maybe I can do something like Input{x,y} (does 83/84 have ln?)

@Quincunx Yes, see my new answer.

žr¹msmžr.n - shameless port of this code into 05AB1E.

JavaScript (ES6) (Regex) 142
Regex is great and it can do many things. It can even do maths!
a=('x'.repeat(prompt().replace('.', ''))+'xxxx').match(/^((x*)\2{99}(x{0,99}))\1{4}x{0,4}$/);c=a[3].length;alert(a[2].length+'.'+(c<10?'0'+c:c))

Readable version:
function tip(m) {
    var s = 'x'.repeat(m.replace('.', '')) + 'xxxx';
    var a = s.match(/^((x*)\2{99}(x{0,99}))\1{4}x{0,4}$/);
    var c = a[3].length;
    if (c < 10) c = '0' + c;
    return a[2].length + '.' + c;
}

The tip() function expects String argument, rather than Number.
All instances of *, /, + are not related to math operations.

+ is string concatenation in all instances it is used.
* is part of RegExp syntax
/ is the delimiter of RegExp literal

The input must use . as decimal point, and there must be 2 digits after decimal point.
Stack Snippet

<button onclick = "a=('x'.repeat(prompt().replace('.', ''))+'xxxx').match(/^((x*)\2{99}(x{0,99}))\1{4}x{0,4}$/);c=a[3].length;alert(a[2].length+'.'+(c<10?'0'+c:c))">Try it out</button>

Perl, 50 60 bytes
$_=<>;s|\.||;$_<<=1;$_="00$_";m|\d{3}$|;printf'%.2f',"$`.$&"

The input is expected at STDIN. It must contain the decimal separator with two decimal digits. The output is written to STDOUT.
Update: The step $_<<=1 removes leading zeroes. Therefore m|\d{3}$| would not match for bills < 1. Therefore ten bytes $_="00$ were added, Now even 0.00 works.
Examples:

Input: 20.96, output: 4.19
Input: 12.34, output: 2.47

Ungolfed version:
$_=<>;
s|\.||; # multiply by 100
$_ <<= 1; # multiply by 2
$_="00$_";
m|\d{3}$|; # divide by 1000
printf '%.2f'," $`.$&"

First the number is read from STDIN. Then the decimal dot is removed, that is multiplied with 100. Then the amount is doubled by a shifting operator.
Then the decimal dot is reinserted and the result is printed and rounded to two decimal digits.
50 bytes, if bill ≥ 1:
If x.xx is greater or equal than 1.00, then 10 bytes can be removed:
$_=<>;s|\.||;$_<<=1;m|\d{3}$|;printf'%.2f',"$`.$&"

Python, 81 80 89 characters
a,b=map(str,raw_input().split('.'));c=str(int(a+b)<<1).zfill(4);print c[:-3]+'.'+c[-3:-1]

Explanation
x = raw_input()       # say 20.96
a , b = x.split('.')  # a = 20 , b = 96
c = a + b             # c = '2096'      # string concatenation , multiplying by 100
d = int(c)<<1         # multiply by 2 by bitshift left , c = 4096
e = str(d).zfill(4)   # zfill pads 0's making the string
                      # atleast 4 chars which is required
                      # for decimal notation next

#     divide by 1000 (4) + . (4.) + fraction rounded to 2 decimals (4.09)
print        e[:-3]      +   '.'  +              e[-3:-1]

Technically, this is cheating as it truncates to two decimals rather than rounding it but I can argue that it rounds down(Better for you, less tip).

I think you can do [-3:] instead of [-3:-1]

@Quincunx Can't , the -1 is to truncate to two decimals.

@n̴̖̋h̷͉̃a̷̭̿h̸̡̅ẗ̵̨́d̷̰̀ĥ̷̳  Yep, fixed it.

JavaScript 251 (forced restriction: no +, -, *, ? or % in any manner)
While I know this won't win, I figured I'd try to get brownie points through taking a very strict approach and not even think about using the restricted operators in any shape or form... as a result, I came up with this beauty...
A=(x,y)=>{for(;x;)b=x^y,x=(a=x&y)<<1,y=b;return y};D=(x,y,i=x,j=0)=>{for(;i>=y;)i=A(i,A(~y,1)),j=A(j,1);return j};alert(parseFloat((x="00".concat(String(D(prompt().replace(".",""),5)))).substr(0,A(x.length,y=A(~2,1))).concat(".").concat(x.substr(y))))

I used bitwise operations to create the Add function A, and then started chaining up from there:
The integer division function D used a series of Negated Addition (subtraction in the form of A(x,A(~y,1) over a loop; the rest is string manipulation and concatenation so as to avoid using + concatenation operators...
The number must be provided in decimal form with two decimal places for this to work...

Ah, it will now... though if I had to keep to the new rules, I had to expand on it... 251 bytes now...

PHP 107 *.8 = 85.6
can't really run for code-golf with PHP, but at least I can operate on strings. accepts both numbers as command-line arguments.
<? @$r=strrev;unset($argv[0]);echo$r(substr_replace($r(str_replace('.','',array_product($argv)))),'.',2,0);

had to reverse it twice since I can't use -2 :(

Haskell 32 Chars -20% = 25.6 Chars
t y x=log $(^x)$(**0.01)$ exp y

Abuses the fact that exponents become multiplication in logarithms.

source: Stack Exchange

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

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

sort: votes


text:
Calculate prime gaps
Finding primes is a programming rite of passage and very frequently the first serious program someone creates (usually with trial division).
But primes alone are already worn out. A next far more interesting thing is to get the prime gaps: the so-far-longest gaps between consecutive primes. These are quite rare and "precious". A first few pairs and their differences are:
2 3 1
3 5 2
7 11 4
23 29 6
89 97 8
113 127 14
...

My father used to calculate these by hand for fun up to 10k. Let's see how short a code you can get.
Write a program which goes through primes and produces a line of output every time the difference between two consecutive primes is bigger than that of any two previous consecutive primes.
Your output can either be the two primes followed by their gap, or just the gap.  If you choose the later add 10 to your overall score.
For instance, between 3 and 5, there is a gap 2 units wide. The gap between 5 and 7 is also 2, but that's old news, we don't care any more. Only when you see a new biggest gap, you report it. This reflects how the primes are getting less and less frequent, as the gaps become wider and wider.
Rules:

no builtin functions for prime testing, prime generation or prime gaps
no retrieving http://oeis.org/A002386 or similar (I can smell you cheaters from far away :) )
no precomputed arrays
keep printing until your internal integer type fails on you

Answers are scored in characters, plus the potential 10 penalty. With lower scores being the goal.
You can also show off versions with builtin functions if they are interesting. Be creative.

EDIT:
Most of the answers are brilliant and deserve more recognition. However, so far, a GolfScript entry with 48 characters is the shortest.

In your example 3 is the end of a pair, and the start of the next pair, while this is not the case for other numbers. What do you want?

Nevermind, I got it now.

You may want to rewrite your rule as "no builtin functions for prime testing, prime calculation or prime gaps". Otherwise an obvious solution would use a function that returns the n th prime, then increment n, run the function again and find the difference.

Aww. i love OEIS

I have the same doubt as @mmumboss. Could you please xplain?

Calculate gaps between primes, but only output the biggest so far (record lengths).

GolfScript 66 59 57 49 48
[2.0{:d{;\;.{).{(1$1$%}do(}do.2$-.d>!}do].p~.}do

Although I'm having trouble running it here http://golfscript.apphb.com/ (maybe that site doesn't like the infinite loop?) but it works fine when I run it on my computer with golfscript.rb. I'm pretty new to GolfScript so this can probably be golfed down even further. UPDATE: I don't think this can be golfed down much more without changing the algorithm somehow.
First few lines printed (If you do not like the "" being printed you can add ; at the beginning of the script, but that bumps it up to 49 chars) :
[2 3 1]
["" 3 5 2]
["" 7 11 4]
["" 23 29 6]
["" 89 97 8]
["" 113 127 14]
["" 523 541 18]
["" 887 907 20]
["" 1129 1151 22]
...

General human-readable idea of how this works (a few things slightly different since I'm not using a stack in this version) :
cur_prime = 2
next_prime = 2
gap = 0

do {
    do {
        cur_prime = next_prime
        do {
            next_prime = next_prime + 1
            possible_factor = next_prime
            do {
                possible_factor = possible_factor - 1
            } while (next_prime % possible_factor > 0)
        } while (possible_factor != 1)
    } while (next_prime - cur_prime <= gap)

    gap = next_prime - cur_prime
    print [cur_prime next_prime gap]
} while (true)

Python, 121 110 109 108 104 103 characters
p,n,m=[2],3,0
while 1:
 if all(n%x for x in p):
  c=n-p[0]
  if m<c:m=c;print(p[0],n,c)
  p=[n]+p
 n+=1

First time I tried to answer here, I hope I did it right... not sure I even counted the characters right.
Hmmm, I could save another character on the print by downgrading to Python 2.x...

121 chars, make the title a heading with # , you seriously don't count the chars by hand do you? http://www.javascriptkit.com/script/script2/charcount.shtml

No, I didn't count by hand :) But I've seen other Python answers to some questions flattened to one line in a way that reduced whitespace, and frankly I'm not sure whether a newline is counted as 1 or 2 characters...

We count newlines as 1 character unless the question's rules explicitly state otherwise. Welcome to PPCG!

Welcome! Nice answer, and it also has some room for improvement. For example, if all(n%x>0for x in p): is a bit shorter. You can also save some characters by moving statements onto the same line (e.g. a=1;b=2;f()).

Latest change broke the code by not pushing [n] to the front like stated.

Downgrading to Python 2 would also allow you to mix spaces for one level and tabs for two levels saving three extra chars.

Oh my, you're right! Is it legit though, to change my answer's language version?

JavaScript, 90 85 78 74 chars
Short Code
(Google Closure Compiler - Advanced Optimizations; some manual edits; more edits by @MT0)
for(a=b=2,c=0;b++;)for(d=b;b%--d;)d<3&&(c<b-a&&console.log(a,b,c=b-a),a=b)

Long Code
var lastPrime = 2,
    curNumber = lastPrime,
    maxDistance = 0,
    i;

// check all numbers
while( curNumber++ ) {

  // check for primes
  i = curNumber;
  while( curNumber % --i != 0 ) {}

  // if prime, then i should be equal to one here
  if( i == 1 ) {

    // calc distance
    i=curNumber-lastPrime;

    // new hit
    if( maxDistance < i ) {
      maxDistance = i;
      console.log( lastPrime, curNumber, maxDistance );
    }

    // remember prime
    lastPrime = curNumber;
  }
}

Output
2 3 1
3 5 2
7 11 4
23 29 6
89 97 8
113 127 14
523 541 18
887 907 20
1129 1151 22
1327 1361 34
9551 9587 36
15683 15727 44
19609 19661 52
31397 31469 72
...

Pretty inefficient test for primes, but that way it uses less characters.
First post here, so please excuse any mistakes.

78 Characters - for(a=b=2,c=0;b++;){for(d=b;b%--d;);1==d&&(c<b-a&&console.log(a,b,c=b-a),a=b)}

@MT0 Thanks. Did not spot those. Edited.

Even more inefficient but 74 characters - for(a=b=2,c=0;b++;)for(d=b;b%--d;)d<3&&(c<b-a&&console.log(a,b,c=b-a),a=b)

Mathematica, 114 108
Allows infinite output, although after a certain point in the sequence the fan spins up and you begin to suspect that your CPU is playing Freecell while doing its best to look busy.
p@x_:=NestWhile[#+1&,x+1,Divisors@#≠{1,#}&];m=0;q=1;While[1<2,If[p@q-q>m,Print@{q,p@q,p@q-q};m=p@q-q];q=p@q]

Output sample (These are the ones it picks up in the first ~30s):
{1,2,1}
{3,5,2}
{7,11,4}
{23,29,6}
{89,97,8}
{113,127,14}
{523,541,18}
{887,907,20}
{1129,1151,22}
{1327,1361,34}
{9551,9587,36}
{15683,15727,44}
{19609,19661,52}
{31397,31469,72}
{155921,156007,86}
{360653,360749,96}
{370261,370373,112}
{492113,492227,114}
{1349533,1349651,118}
{1357201,1357333,132}
{2010733,2010881,148}

Ungolfed code:
p@x_ := NestWhile[
   # + 1 &,
   x + 1,
   Divisors@# ≠ {1, #} &];
m = 0;
q = 1;
While[
 1 < 2,
 If[
  p@q - q > m,
  Print@{q, p@q, p@q - q}; m = p@q - q];
 q = p@q]

Does it recognize ≠?

Yes, it just doesn't export that way but it will parse it just fine when you paste code into the notebook. I've already scored it accordingly but I'll revise to simplify.

how many characters if you do use mathematica's built-in Prime functions?

Since the entire p@x_ definition is just a reimplementation of NextPrime, it can be replaced by p=NextPrime;

Haskell - 122 116 114 112 110
q=[n|n<-[3..],all((>0).rem n)[2..n-1]]
d m((p,q):b)|q-p>m=print(p,q,q-p)>>d(q-p)b|q>p=d m b
main=d 0$zip(2:q)q

(Inefficient) prime list expression stolen from Will Ness.
-edit- I never knew x|y=z|w=q would be valid.

MATLAB 104 89
Just implemented the basic method by checking every possible division.
a=2;g=0;for n=3:inf;b=n*(sum(mod(n,1:n)<1)<3);h=b-a;if(h>g)g=h;[a,b,h]
end;a=max(a,b);end

Output:
  2     3     1
  3     5     2
  7    11     4
 23    29     6
 89    97     8
113   127    14
523   541    18
887   907    20

I'm on octave and this inf thing doesn't work (and print is deferred until the loop ends). Does matlab have lazy range evaluation?

Matlab prints realtime, each iteration of the loop. When I start my program I get a warning that the maximum index is 2147483647, and then it starts. Alternatively I could replace inf with intmax, but that is three chars more.

76 chars, dogelang
Converted from my Python version:
g=0
i=l=2
while i+=1=>all$map(i%)(2..i)=>(i-l>g=>(g=i-l),print(l,i,g)),(l=i)

Output:
(2, 3, 1)
(3, 5, 2)
(7, 11, 4)
(23, 29, 6)
(89, 97, 8)
(113, 127, 14)
(523, 541, 18)
(887, 907, 20)
(1129, 1151, 22)
...

Should be selected as the winner!

Golfscript, 59 51 50 chars
Man each character is extremely difficult to lose:
0[2.{).,2>{\.@%!},{.2$-.4$>{].p~\[}{;\;}if..}or}do

Output:
[2 3 1]
[3 5 2]
[7 11 4]
[23 29 6]
[89 97 8]
[113 127 14]
...

Explanation:
The stack is set up so each iteration starts with the stack like this, the top being to the right. The [ indicates the current array marker, meaning when the interpreter encounters a ], everything on the stack from the mark to the top is put into an array.
g [ last | cur

g is the maximum gap so far. From the top down:
 command         | explanation
-----------------+----------------------------------------
 0[2.            | initialize vars g=0, last=2, cur=2
 {...}do         | loop forever...

Inside the loop:
 )               | cur += 1
 .,2>{\.@%!},    | put all divisors of cur into a list
 {...}or         | if the list is empty, cur is prime, so
                 | the block is executed. otherwise,
                 | 'do' consumes the stack, sees it is truthy,
                 | and loops again

How does it put all divisors into a list? Let's do it step by step
 Command         | explanation                                  | stack
-----------------+----------------------------------------------+----------------
                 | initial stack                                | n
 .,              | make list of 0..n-1                          | n [0,1,...,n-1]
 2>              | take elements at index 2 and greater         | n [2,3,...,n-1]
 {...},          | take list off stack, then iterate through    |
                 | the list. on each iteration, put the current |
                 | element on the stack, execute the block, and |
                 | pop the top of the stack. if the top is      |
                 | true then keep the element, else drop it.    |
                 | when done, push list of all true elements    |
                 | So, for each element...                      | n x
   \.            |   Swap & dup                                 | x n n
   @             |   Bring x around                             | n n x
   %             |   Modulo                                     | n (n%x)
   !             |   Boolean not. 0->1, else->0. Thus this is 1 |
                 |   if x divides n.                            | n (x divides n)
                 | So only the divisors of n are kept           | n [divisors of n]

What does it do if the divisors are empty?
 Command         | explanation                                  | stack
-----------------+----------------------------------------------+----------------
                 | initial stack                                | g [ last | cur
  .              | dup                                          | g [ l | c | c
  2$             | copy 3rd down                                | g [ l | c | c | l
  -              | sub. This is the current gap, cur-last       | g [ l | c | c-l
  .              | dup                                          | g [ l | c | c-l | c-l
  4$             | copy 4th down                                | g [ l | c | c-l | c-l | g
  >              | is cur gap > max gap so far?                 | g [ l | c | c-l | c-l>g
  {#1}{#2}if..   | #1 if c-l > g, #2 otherwise, and do ".." in  | ... | g [ c | c | c
                 | either situation                             |

Two paths: yes and no. If yes (note that if consumes the top value on the stack):
 Command         | explanation                                  | stack
-----------------+----------------------------------------------+----------------
                 | initial stack. note that now the old `g` is  | XX [ l | c | g
                 | garbage and `c-l` is the new `g`.            |
 ]               | close the array                              | XX [l, c, g]
 .p              | duplicate it and print it, consuming the dup | XX [l, c, g]
 ~               | pump array back onto the stack. Note now the | XX | l | c | j
                 | array marker [ is gone.                      |
 \               | swap.                                        | XX | l | g | c
 [               | mark the array                               | XX | l | g | c [
 .               | this is the part after the if. dups the top, | XX | l | g [ c | c
                 | but it does this in two steps, first popping |
                 | c then putting two copies on top, so the     |
                 | array marker moves                           |
 .               | dup again                                    | XX | l | g [ c | c | c

If no:
 Command         | explanation                                  | stack
-----------------+----------------------------------------------+----------------
                 | initial stack. In this case g is still the   | g [ l | c | c-l
                 | max gap so far                               |
 ;\;             | dump top of stack, swap, and dump again      | g [ c
 ..              | the part after the if. dup twice             | g [ c | c | c

Note in either case, our stack is now in the form ... | g [ c | c | c.
Now the do pops the top value off the stack - always c - and loops if it is positive. Since c always increasing, this is always true, so we loop forever.
Once popped, the top of the stack is g [ c | c, meaning last has been updated to c, the array mark is in the same place, and g is still where we expect it.
These are the convoluted operations of GolfScript. I hope you enjoyed following along!

Excellent elucidation!

Ruby, 110
Only for Ruby 2.0 due to the lazymethod:
(2..1.0/0).lazy.select{|n|!(2...n).any?{|m|n%m==0}}.reduce([2,0]){|(l,t),c|d=c-l;p [l,c,d]if d>t;[c,d>t ?d:t]}

Output:
[2, 3, 1]
[3, 5, 2]
[7, 11, 4]
[23, 29, 6]
[89, 97, 8]
[113, 127, 14]
[523, 541, 18]
[887, 907, 20]
[1129, 1151, 22]
[1327, 1361, 34]
[9551, 9587, 36]
[15683, 15727, 44]
[19609, 19661, 52]
[31397, 31469, 72]
[155921, 156007, 86]
[360653, 360749, 96]
[370261, 370373, 112]
[492113, 492227, 114]
...

Perl, 105 bytes
$p=2;$d=0;L:for($i=2;++$i>2;){!($i%$_)&&next L for 2..$i-1;if($i-$p>$d){$d=$i-$p;print"$p $i $d\n"}$p=$i}

Ungolfed:
$p = 2;
$d = 0;
L: for ($i = 2; ++$i > 2; ){
    !($i % $_) && next L for 2..$i-1;
    if ($i - $p > $d) {
        $d = $i - $p;
        print "$p $i $d\n"
    }
    $p = $i
}

The algorithm is simple, $p remembers the previous prime number. Then $i goes from 3 up to, when the type $i "fails on me" or become negative because of overflow. $i is tested the crude way by checking all divisors from 2 to $i-1. A line is printed, if the current difference is larger than the previous printed difference $d.
With some more bytes the run-time can be improved:
$p = 2;
$d = 0;
L: for ($i=3; $i > 2; $i += 2){
    for ($j=3; $j <= sqrt($i); $j += 2){
        next L if !($i%$j)
    }
    if ($i - $p > $d) {
        $d = $i - $p;
        print "$p $i $d\n"
    }
    $p = $i
}

The result starts with:
2 3 1
3 5 2
7 11 4
23 29 6
89 97 8
113 127 14
523 541 18
887 907 20
1129 1151 22
1327 1361 34
9551 9587 36
15683 15727 44
19609 19661 52
31397 31469 72
155921 156007 86
360653 360749 96
370261 370373 112
492113 492227 114
1349533 1349651 118
1357201 1357333 132
2010733 2010881 148
4652353 4652507 154
17051707 17051887 180
20831323 20831533 210
47326693 47326913 220
...

That's not correct, you need to find the series of increasing gaps. See for instance the Ruby or Matlab answer for the expected output.

@mmumboss: Oh, I have overlooked this. Fixed now.

Good for a language where all the variables require minimum 2 characters.

Perl 95 90 bytes
for($n=$c=2;$p=$c;$c-$p>$g&&printf"$p $c %d\n",$g=$c-$p){$c=$n if(1x++$n)!~/^(11+?)\1+$/}

old Non golf version:
$n=$c=2;
while($p=$c){
    $c=$n if (1x++$n)!~/^(11+?)\1+$/;
    if ($c-$p>$g) {$g=$c-$p;print "$p $c $g\n"}
}

This is similar to my other submission, sans bash.

I'm not annoying, I just want to see how far can this go. Here:
for($n=$c=2;$p=$c;$c-$p>$g&&printf"$p $c %d\n",$g=$c-$p){$c=$n if(1x++$n)!~/^(11+?)\1+$/}

@orion that is some serious for loop abuse haha!

Python, 93 91 chars
Naive prime checking (check if divisible by anything from 2 to n (less chars than to n/2)):
g=0;i=l=2
while 1:
 i+=1
 if all(i%x for x in range(2,i)):
    if i-l>g:g=i-l;print l,i,g
    l=i

Second level of indent is one tab character.
Output:
2 3 1
5 7 2
7 11 4
23 29 6
89 97 8
113 127 14
523 541 18
...

Nice, I forgot that range up to n only checks up to n-1

Bash and some Perl for prime regex (167 157 143 112 bytes)
n=2
c=2
while p=$c
do perl -e\(1x$[++n]')=~/^(11+?)\1+$/&&exit 1'&&c=$n
((c-p>g))&&g=$[c-p]&&echo $p $c $g
done

some output:
$./golfd.sh
2 3 1
3 5 2
7 11 4
23 29 6
89 97 8
113 127 14
523 541 18
887 907 20
1129 1151 22

Using regex's NP backtracking to completely circumvent any loops and control structures is pure perfection. However, test is protesting quite a lot, and it doesn't work for me. You could also use some let n++ and let f=c-p and replace test with [. Or possibly test in (()) where you don't need $ or spaces.

test -n $d returned true for an empty string. test -n "$d" was fine but longer. However, man page says -n is optional, and it turns out test $d was ok. And therefore [ $d ] too. And g=0 had to be initialized.

@orion, sorry for some reason it seemed to work once now it broke on my machine too, i reverted it to 167. I'll try to add some of your other suggestions

Your environment maybe had predefined variables.

@orion for some reason your edit was rejected, can you re-edit?

I'll just say it here. Use backtics instead of $(), p=$[c] actually works, ((f>g)) is shorter (nice to have so many alternative brackets), quotes around echo are unnecessary (inside perl too: $_ is fine, or just only print without arguments).

How about 121? :)
n=3;c=2;while :;do p=$c;perl -e\(1x$n')=~/^(11+?)\1+$/&&exit 1'&&c=$n;let n++;f=$[c-p];((f>g))&&g=$f&&echo $p $c $g;done and you could still squeeze out a bit more. Also, if you post a perl-only version, you may win :)

This one just keeps giving more. n=2;c=2;while p=$c;do perl -e\(1x$[++n]')=~/^(11+?)\1+$/&&exit 1'&&c=$n;((c-p>g))&&g=$[c-p]&&echo $p $c $g;done

C: 493 302 272 246
int e(int j){for(int i=2;i<j;i++)if(j%i<1)return 0;return 1;}void f(int a,int b,int c){if(e(a)&e(b))if(c<b-a){printf("%d %d %d\n",a,b,b-a);f(a+1,b+1,b-a);}else f(a+1,b+1,c);if(e(b))f(a+1,b,c);if(e(a))f(a,b+1,c);f(a+1,b+1,c);}int main(){f(2,3,0);}

I used recursion not the usual loop of for or while.
int isPrime(int num){
    for( int i=2; i<num; i++ )
        if(num%i < 0) return 0;
    return 1;
}
void fun(int n1, int n2, int gap){
   if( isPrime(n1) & isPrime(n2) ){
        if( gap < n2-n1 ){
           printf("%d %d %d\n", n1, n2, n2-n1);
           fun(n1+1, n2+1, n2-n1);
        }else{
           fun(n1+1, n2+1, gap);
        }
   }
   if( isPrime(n2) ){
       fun(n1+1, n2, gap);
   }
   if( isPrime(n1) ){
       fun(n1, n2+1, gap);
   }
   fun(n1+1, n2+1, gap);
}

int main(){
   fun(2,3,0);
}

Output:
2 3 1
3 5 2
7 11 4
23 29 6
89 97 8
113 127 14
523 541 18
887 907 20
1129 1151 22
1327 1361 34
9551 9587 36
15683 15727 44
19609 19661 52

This doesn't work. true/false are not defined, but even if we fix that, it's reporting wrong gaps. For instance, there are A LOT of primes between 25219 and 43237. Your recursion is leaking at the top, because you are not testing isPrime(n2), you are letting primes between n1 and n2. And this can't really be fixed, because you can't increase n2 without meeting primes.

You are right! It is wrong! My thinking was wrong from the beginning.

Now it is better.. :)

+1 Now that it's fixed I like it - it's nicely unusual (although not efficient). You could golf it down a lot. Skip return in main. Skip the last else. Replace && -> & and num%i==0 with num%i<1. And by the ancient c standards (there will be warnings), you don't need to specify return values for void and int functions (their arguments also default to int).

I was playing a bit and got it down to 151 characters, with a single unconditional recursive call, only one type specifier (int) and much reduced prime testing function:
e(j,i){while(j%++i);return i==j;}f(a,b,c){int A=e(a,1),B=e(b,1);if(A&B&&c<b-a)printf("%d %d %d\n",a,b,c=b-a);f(a+(B|!A),b+(A|!B),c);}main(){f(2,3,0);}

Oracle SQL, 216 202 196 172 + 10 = 182
Just noticed this in the question:

Lowest character count wins. +10 characters if you only print the gaps without the primes.

As this is SQL and the keywords are so long it's actually better to take the penalty, giving the following. It's the same idea as the original.
with c as(select level+1n from dual connect by level<1e124)select lead(n)over(order by n) from(select*from c a where not exists(select*from c where n<a.n and mod(a.n,n)=0))

which prettifies to:
with c as (
 select level + 1 n
   from dual
connect by level < 1e124
        )
select lead(n) over ( order by n )
  from ( select *
           from c a
          where not exists( select *
                              from c
                             where n < a.n
                               and mod(a.n, n) = 0
                                   )
                )

Old answer (196)
with c as(select level+1n from dual connect by level<1e124)select n,p,p-n from(select n,lead(n)over(order by n)p from(select*from c a where not exists(select*from c where n<a.n and mod(a.n,n)=0)))

and in a readable format:
with c as (
 select level + 1 n
   from dual
connect by level < 1e124
        )
select n, p, p-n
  from ( select n, lead(n) over ( order by n ) p
           from ( select *
                    from c a
                   where not exists (
                                select *
                                  from c
                                 where n < a.n
                                   and mod(a.n, n) = 0
                                       )
                         )
                )

This creates a number generator in c, the innermost sub-select creates the primes numbers using a Sieve of Eratosthenes, the outer works out the previous prime and finally the last select subtract one from the other.
This won't return anything because it's performing 1 x 10 124 recursive queries... So, if you want it to work lower this number to something sensible.

When it comes to a challenge like this one, I think of SQL as not so much Turing-complete, but Turing-obstinate.

But it is Turning-complete @Jonathan, though getting it there is sometimes "interesting" :-)?

Knowing it is Turing-complete, I was aiming to jest. Missed the mark, apparently. :) Anyway, there are several T-SQL answers in my profile...bring your Oracle and let's have a duel!

C (100)
My own contribution, no special algorithm, just golf:
i,g,r,p=2;main(){for(;r=p;p-r>g?printf("%d %d %d\n",r,p,g=p-r):0)for(i=0;i-p;)for(i=1,++p;p%++i;);}

" +10 characters if you only print the gaps without the primes." - if you remove printing of r and p you will have fewer characters and score the bonus :)

Completness is pretty :)

Haskell, 134C
Golfed:
c n=null[x|x<-[2..n-1],n`mod`x==0]&&n>1
p=filter c[1..]
g l(m:n:o)
 |(n-m)>l=do print(m,n,n-m);g(n-m)(n:o)
 |True=g l(n:o)
main=g 0 p

Ungolfed:
-- c function checks if n is a prime number
c n=null[x|x<-[2..n-1],n`mod`x==0]&&n>1

-- p is an infinite list of primes
p=filter c[1..]

-- g function prints a list of primes and differences.
--   l is the maximum difference seen so far
--   (m:n:o) is the list of unprocessed primes
g l(m:n:o)
 |(n-m)>l=do print(m,n,n-m);g(n-m)(n:o)
 |True=g l(n:o)

-- main starts the ball rolling with a default max-seen value of 0
main=g 0 p

Love that lazy evaluation!

D - 153 + 10 = 163
I'm willingly taking the +10 penalty here, because the char count is still lower than it would have been if I had printed the primes as well.
Golfed:
import std.stdio;bool p(int l){int n;foreach(i;1..l+1)n+=l%i==0?1:0;return n==2;}void main(){int g;foreach(l;0..int.max)if(l.p){if(g>0)(l-g).write;g=l;}}

Readable version:
import std.stdio;

bool prime( int number )
{
    int divisors;

    foreach( i; 1 .. number + 1 )
        divisors += number % i == 0 ? 1 : 0;

    return divisors == 2;
}

void main()
{
    int lastPrime;

    foreach( number; 0 .. int.max )
        if( number.prime )
        {
            if( lastPrime > 0 )
                ( number - lastPrime ).write;

            lastPrime = number;
        }
}

Haskell, 154 144 137 123

The primes p are generated using the sieve of erasthotenes #, and then filtered and printed using %.
p=2:3#1
n#m|all((>0).mod n)$take m p=n:(n+1)#(m+1)|1<2=(n+1)#m
(l:u@(o:_))%k|o-l>k=print(l,o,o-l)>>u%(o-l)|1<2=u%k
main=p%0

The output looks like
(2,3,1)
(3,5,2)
(7,11,4)
(23,29,6)
(89,97,8)

which I hope is okay.

Javascript 138
for(var a=2,b=0,c=0;a++;){var d;a:{for(var e=a,f=2;f<e;f++)if(0==e%f){d=!1;break a}d=!0}d&&(0!=b&&a-b>c&&(c=a-b,console.log(b,a,c)),b=a)}

Copy this code to your browser console. It will for like forever as the max number is something around 1.79*10^308.
Ungolfed:
var number = 2;
var lastPrime = 0;
var gap = 0;

while(number++)
{
    if (isPrime(number)) {
        if (lastPrime != 0) {
            if (number - lastPrime > gap)
            {
                gap = number - lastPrime;
                console.log(lastPrime, number, gap);
            }
        }

        lastPrime = number;
    }
}

function isPrime(n){
    for (var i = 2; i < n; i++) {
        if (n % i == 0)
            return false;
    }
    return true;
}

C# 162 161 chars
151 chars + 10 penalty chars = 161 chars
Short version:
using System;class P{static void Main(){int p=2,g=0;for(int i=3;;i++){for(int j=2;j<i;j++)if(i%j==0)goto e;if(i-p>g)Console.WriteLine(g=i-p);p=i;e:;}}}

Long version:
using System;

class PrimeGaps
{
    private static void Main()
    {
        int lastPrime = 2;
        int largestGap = 0;

        for (int i = 3; true; i++)
        {
            // Prime test
            for (int j = 2; j < i; j++)
                if (i%j == 0)
                    goto nextI; // Skip to next iteration of i

            // Largest gap check
            if (i - lastPrime > largestGap)
            {
                largestGap = i - lastPrime;
                Console.WriteLine(largestGap);
            }

            // Remember last prime
            lastPrime = i;

            nextI:
                ; // Do nothing
        }
    }
}

It was actually better to take 10 chars penalty, since it's shorter writing g (11 chars with penalty) than p+" "+i+" "+g (13 chars without penalty).

Ruby 90 86 84 83 chars
r,i,g=2,2,0;while i+=1 do(2...i).all?{|j|i%j>0}&&((i-r<=g||p([r,i,g=i-r]))&&r=i)end

Some boolean short circuits, abuse of expression evaluation, etc.

JAVASCRIPT 174 char
var p=[2],l=2,g=0;
for(var n=3;n>0;n+=2){
  var o=0;
  for(var t=0;t<p.length;++t){
    if(n/p[t] == parseInt(n/p[t])){
      o=1;
    }
  }
  if(o==0){
    p.push(n);
    if(n-l>g){
      g=n-l;
      console.log(l,n,g);
    }
    l=n;
  }
}

short version:
var p=[2],l=2,g=0;for(var n=3;n>0;n+=2){var o=0;for(var t=0;t<p.length;++t){if(n/p[t] == parseInt(n/p[t])){o=1;}}if(o==0){p.push(n);if(n-l>g){g=n-l;console.log(l,n,g);}l=n;}}

C 248
Code compares consecutive prime numbers a, b and then checks if gaps are larger than g then finds next pair of primes.
#include <cstdio>
void f(int* a, int* b){*a =*b;int t=1;while (*b += 2){t=1;for(int i=3;i<*b;i+=2){if(*b%i==0){t=0; break;}}if(t)break;}}
int main(){int a=2,b=3,g=0;do{(b-a>g)?printf("%d %d %d\n",a,b,(g=b-a)): f(&a,&b);} while(b>=0);return 0;}

This is C++, is it not?

Game Maker Language, 74 + 55 = 129
Assuming all uninitialized variables as 0 (this is the default with some versions of Game Maker).
n=2while(n++){if p(n){if l{if n-l>g{g=n-l;show_message_ext("",l,n,g)}}l=n}

Script p is below:
r=1a=argument0for(i=2i<a;i++){if a mod i=0r=0}return r}

Game Maker Language, 85
Assuming all uninitialized variables as 0 (this is the default with some versions of Game Maker).
a=2b=2for(d=2;b++;1)for(c<b-a;b mod --d;1)d<3&&(c=b-a&&show_message_ext("",a,b,c)a=b)

Perl, 87 bytes (using a module)
use Math::Prime::Util":all";$l=2;forprimes{if($_-$l>$m){say"$l $_ ",$m=$_-$l}$l=$_}1e14

I wrote the module, but we'd have to add an extra 565,000 characters to the tally.  Mostly posting for fun, but also to give a performance alternative since I don't see any so far using builtins.  4.6s for gaps to 1e9, 36s for gaps to 1e10, 6.5min for 1e11.
Pari/GP 2.8 can be done basically the same way, albeit over 2x slower:
l=2;m=0;forprime(p=2,1e14,if(p-l>m,print(l," ",p," ",m=p-l));l=p)

Perl 153
Short code:
$i=$a=2;while($a=$i++){if(p($i)){if($m<$m2=$i-$a){$m=$m2;print"$a $i $m$/"}}}sub p{$d=2;$s=sqrt$_[0];while(){return 0if!($_[0]%$d);return 1if$d>$s;$d++}}

easy to Read:
$i=$a=2;
while($a=$i++){
  if(p($i)){
    if($m<$m2=$i-$a){
      $m=$m2;
      print"$a $i $m$/"
    }
  }
}
sub p {
  $d=2;
  $s=sqrt$_[0];
  while(){
    return 0if!($_[0]%$d);
    return 1if$d>$s;
    $d++;
  }
}

This outputs all gaps, not just the biggest so far.

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

authors: دانلود فیلم سانسور شده

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


text:
Determine if Strings are equal
Your task is simple. Determine if one string equals the other (not address, the value) without the use of equality operators (such as ==, ===, or .equal()) or inequality (!=, !==) anything similar for other languages. This means anywhere! You may not use these operators anywhere in the code. You may however, you use toggles such as !exp as you're not directly comparing the exp != with something else.
In addition, you may not use any functions such as strcmp, strcasecmp, etc.
As for comparison operators (>=, <=, >, <), they are also disallowed. I realize that some answers include this, but I'd really like to see more answers that don't borderline the equality operator.

An example using PHP is shown:
<?php

$a = 'string';
$b = 'string';

$tmp = array_unique(array($a, $b));

return -count($tmp) + 2;

Simply return true or false (or something that evaluates in the language to true or false like 0 or 1) to indicate if the strings match. The strings should be hardcoded seen in the above example. The strings should not be counted in the golf, so if you declare the variable before hand, don't count the declaration.

Is it necessary to output the result, or simply write a function to return a bool? If writing a complete program is required, that could make-or-break answers in languages with (relatively) significant boilerplate to create a functioning executable like Java and C# (such is the nature of the beast, but this challenge has little in the way of concrete guidelines, leaving much to interpretation/choice). And how are we to take the strings? Hardcoding, reading from STDIN, pass as command-line arguments?

Is this [code-golf] or a [popularity-contest]? It can't be both.

Sorry, I have modified my questions to reflect both comments.

So inequality is allowed?

If the strings are to be hardcoded more than once(each) , do i have to count their length?

You can declare the strings in a variable, (such as $a, $b), and those declarations shouldn't count in your final golf.

Can I return 0/1 instead of False/True

@DaveChen You should change the title to identical instead of equal

is >/< allowed?

The function int strcmp(const char *, const char *) in C returns 0 if the strings are the same and non-zero otherwise. Is the use of this function allowed?

I am voting to close this challenge as unclear as it is a [tag:code-golf] question centering around a non-observable requirement

Python 49 45 18 22 15 14
( + 3 if string variables are considered)
print{a:0,b:1}[a]

The string should be hard coded at the two occurrences of a and one occurrence of b surrounded by quotes.
a and b should be pre-initialized to the strings.

Python shell, 9
( + 3 if string variables are considered)
{a:0,b:1}[a]

Output in shell
>>> a = 'string'
>>> b = 'string'
>>> {a:0,b:1}[a]
1
>>> a = 'string'
>>> b = 'stringgg'
>>> {a:0,b:1}[a]
0
>>> {'string':0,'string':1}['string']
1
>>> {'stringggg':0,'string':1}['stringggg']
0
>>>

Explanation
Creates a dict(hash table) with the key of first and second string.
If second string is the same, the value of first is replaced by that of second.
Finally, we print the value of first key.
EDIT: OP allowed 0/1 instead of False/True as well as using pre-initialized variables.

@manatwork Golfscript and perl below use 0/1, can't I use that?

@manatwork Done

I am counting 16 instead of 13, for your second solution.

@Abhijit the a and b are not to be included, the strings should be hard-coded there, that's why I added + 2*len(str1) + len(str2) + 6 (')

+1 for clevernesse but this is by far not the shortest anymore ;)

@avalancha Thanks, I think the upvotes are because this is a python solution and not golfscript, brainf**k or j.

Python (17 11):
b in a in b

(Checks if b is contained in a and a is contained in b, if that wasn't clear from the code.)
Alternative python: (8 7)
derived from Tom Verelst's Go solution:
b in[a]

Bonus: this works for any type.
EDIT:
Wait a second, just read that you can also directly program in the strings, and don't have to count quotes... (or at least, that what golfscript does). So... Python on par with golfscript? Oh my!
Alternative alternative Python (5 4):
(thanks  Claudiu)
"string"in["string"]

original:
"string" in["string"]

Alternative Alternative Alternative Bendy-ruly Python (2):
"string"is"string"

Nothing was said about comparison keywords (This is not a serious submission, just something that occurred to me...)

You could use b in a in b. The and a is not necessary...

Now it is duplicate of willem's answer.

You could get it down to seven characters by removing the whitespace between in and [a]. i.e. b in[a] should work.

Oh, didn't know that. Thanks :)

Impressive! Also didn't know that

@Synthetica: You can also remove the whitespace: "string"in["string"] works.

@Claudiu Thanks! Didn't realize!

"string" in["string"] also works in Julia, but "string"in["string"] does not.

JavaScript, 11 10
Strings have to be stored in a and b.
!(a>b|a<b)

Edit: thanks Danny for pointing out, | is enough instead of ||

You are using inequality operators.

No, I am using greater than and less than operators. Those were not forbidden in the contest.

+1. This is going to work identically in many other languages too.

I may be wrong but can't you remove one |?

Definitely a rules oversight - comparison functions are banned, as are equality and inequality operators, but comparison operators aren't mentioned.

-1 for <> - perhaps rules changed after you wrote this solution?

@philcolbourn Yes, rules changed yesterday but answer is 2 days old.

Ruby, 11
s = 'string'
t = 'string'
!!s[t]&t[s]

Checks if each string is contained within the other.

!(a<b||b<a) would be the same...

except you can't use <>

Python - 11 (without the strings)
>>> a = 'ss'
>>> b = 's'
>>> a in b in a
False

In the same spirit:a<=b<=a which is only 7 characters. Although I don't know whether the comparison <= would be considered an "inequality". From the question it appears that any comparison that is not an equality check is okay, which would allow <=.

yeah, thats a nice one @Bakuriu, and I agree, its not totally clear when the rules are violated or not. 'in' after all alsoome how contains an equal statement.

GolfScript (5 chars)
'string1''string1'].&,(

Fairly straightforward port of the PHP reference implementation. Leaves 0 (=false) on the stack if the strings are the same, or 1 (=true) if they're different.

doesn't work for me: 1 if the string are the same, and 2 if they're different. 'string1''string1'].&,1& works

@guy777, this assumes that the stack is empty at the start. The question is rather vague on program fragments. You're probably testing it as a whole program and starting with an empty string on the stack from stdin.

C++, 63 58 56
const char* a = "string";
const char* b = "string";
int main(){while(*a**b*!(*a^*b))++a,++b;return!(*a^*b);}

Could you get away with auto instead of const char*?

I think so yes, but since the rules say the string variables aren't counted towards the character count I didn't bother to golf them.

Could you fold increments into the while test and leave the body empty? And if you go for c instead of c++, remove int at the beginning.

I don't see any way to reduce the character count by folding the increments into the while test without hitting the same bug of accessing a string past the end I pointed out in Abhijit's C answer. You only want to increment a and b if both tests pass (neither a nor b is pointing to the null terminator and a is equal to b). There's probably a way to improve on this but I haven't been able to find it!

Javascript (45 bytes):
Here is another solution in Javascript.
var a='string',b='string',c=!a.replace(b,'');

The space is important.
c should be true.

Only !a.replace(b,'')  is counted. So character count should be 16. Actually, some people even count it 14, since you can specify the string directly.

coreutils: uniq -d
Just enter your two strings as the standard input of a pipe and uniq -d | grep -q . will print nothing but will have a return value of success or error. If you want to print the boolean, just replace with uniq -d | grep -c .
How many characters? I let you count; uniq -d|grep -q . with no extra spaces has 17 characters in it, but since the whole job is performed by uniq, I would say this solution is a 0-character one in... uniq own language!
Actually, uniq -d will print one line if the two strings are identical, and nothing if the are different.

APL (8 9)
Update: the old one does  not work for strings of different lengths.
{∧/∊⌿↑⍺⍵}

↑⍺⍵: make a matrix with ⍺ on the first line and ⍵ on the second line, filling blanks with spaces.
∊⌿: For each column, see if the upper row contains the lower row (as in the old version).
∧/: Take the logical and of all the values.

Old one:
{∧/⍺∊¨⍵}

⍺∊¨⍵: for each combination of elements in ⍺ and ⍵, see if the element from ⍺ contains the element from ⍵. Since in a string these will all be single characters, and a string contains itself, this is basically comparing each pair of characters.
∧/: take the logical and of all the values (if all the characters match, the strings are equal)

This fails on strings that are equal except for trailing spaces.

PHP - 49 characters
!(strlen($a)^strlen($b)|strlen(trim($a^$b,"\0")))

Couldn't something like this work: !strlen(str_replace($a,'',$b)); It should return 1 if two strings are equal?

@D.Kasipovic Interesting, but I think it fails for $a == 'foo' and $b = 'foofoo' :)

True, how about this then, it limits replace to one !strlen(preg_replace("/{$a}/", '', $b, 1)); and is 45 characters?

I suppose you could use anchors instead, but more importantly it would require preg_quote() as well :)

Python - 12
not({a}-{b})

This solution uses sets. Subtracting equal sets will result in an empty set, which has a boolean value of False. Negating that will result in a True value for a and b being equal strings.
>>> a="string1"
>>> b="string2"
>>> not({a}-{b})
False

>>> a="string"
>>> b="string"
>>> not({a}-{b})
True

Edit: Thanks to Peter Taylor for pointing out the unnecessary whitespace.

What output does this give for a="s", b="ss"?

@PeterTaylor: Since "s"!="ss", it will output False. Case sensitivity is also preserved. It even works for a="", b="s". The code does not convert strings to sets, but creates sets containing the strings.

Ah, {} isn't the same as set(). You can save 1 char by removing the whitespace.

@PeterTaylor: Thanks for pointing out the unnecessary whitespace.
{a} is equivalent to set([a]).

How about not {a}-{b}?

C — 62
e(char*p,char*q){for(;*p&*q&&!(*p^*q);q++,p++);return!(*p^*q);}

Tested. Call as e(str1, str2)
Come to think of it, if you don't count the char*p,char*q, which seems only fair, it's only 49 bytes :)

Welcome to the site! For code-golf challenges, we encourage you to trim as many bytes from your code as you can, and post the byte count in your answer header.  Check out the Tips for Golfing in C thread for some good ideas.

You don't really need np and nq. One loop will do, because if you reach the end of one string before the other they will have a different value.

Thanks. I realize that. I was working on my shortened version (above). Going back to see if I can shorten it further.

*p&*q may stop the loop too early (e.g. '0'&'A'==0)

@ugoren: If *p=='0' & *q=='A', we want the loop to stop early, as we know the strings are not equal.

@Emmet, Right, I was looking at the pieces separately. But then, testing *p is enough, you don't need &*q.

What if p is longer than q? We want it to stop when either p or q is pointing at a NUL or we might run off the end of the shorter one and segfault.

Can you move p++ to the body of the loop?

Strings have to be stored in a and b. Will not work if either is null.
C#, 53
string.IsNullOrEmpty(a.Replace(b,"")+b.Replace(a,""))

C#, 28
a.Contains(b)&&b.Contains(a)

PHP, 68 Bytes
I assume you're prohibited to use any comparison operators. So < or > are included.
The idea is to use bitwise XOR. In different languages this operator has different syntax - I'll show an example for PHP. There it's available with ^. Unfortunately, its behavior with strings isn't as good as it could be, so you'll need to check string length before. That is because in PHP, xor will strip the longer string down to the length of the shorter string.
Next thing is to work with strings properly, because a single xor will not produce a result, available for further operations in PHP. That's why unpack() was used. So, the code would be:
return !(strlen($a)^strlen($b)) & !array_filter(unpack('c*', $a^$b))

It's longer than option with < / > but it won't use them. Also, the important thing is about PHP type juggling (so empty array will be cast to false). Or maybe there's a simpler way to check if an array contain non-zero members (Edit: while I've been typing this, there's a good catch with trim() in another answer, so we can get rid of array operations)
But I believe there are languages, where we can do just a ^ b - literally, getting the result. If it's 0 (treated from all resulted bytes) - then our strings are equal. It's very easy and even more simple than < or > stuff.

Mathematica / Wolfram Language, 15 bytes
2 - Length[{a} ∪ {b}]

Pretty self explanatory, sets each string as a set, then checks the length of the union of the two sets. If the strings are the same, returns 1, otherwise returns 0. If I'm allowed to return '2' for "different" and '1' for "same", subtract two bytes.

Java - 162 147 characters
The idea is to compare the difference of each byte, same bytes will have difference 0.
The program will throw java.lang.ArrayIndexOutOfBoundsException for when bytes are different (try to access a negative index) or when strings are of different length. It will catch the exception and return 0 (strings not equal), or return 1 otherwise (strings equal).
Compressed:
String a = "12345";
String b = "12345";
byte[]x=a.getBytes(),y=b.getBytes();int z,i=a.length()-b.length();try{for(byte d:x){z=d-y[i];z=x[-z*z];i++;}}catch(Exception e){return 0;}return 1;

Normal:
String a = "12345";
String b = "12345";
byte[] byteArrA = a.getBytes();
byte[] byteArrB = b.getBytes();

int byteDifference = 0;
int i = a.length() - b.length();

try {
    for (byte aByte : byteArrA) {
        byteDifference = aByte - byteArrB[i];
        byteDifference = byteArrA[-byteDifference*byteDifference];
        i++;
    }
} catch (Exception e){
    return 0;
}

return 1;

Comparison operators exist in the loop.

Thank you @hexafraction, I updated answer to not include them.

Haskell -- 9
elem a[b]

Note that this, just like many entries here, is just an expression. This is not a Haskell program.

Prolog 7
e(A,A).

This makes use of the pattern matching feature in Prolog to unify the 2 arguments to the predicate, which effectively tests for equals equivalence when there is no unbound variable.
Sample usage:
?- e("abcd", "Abcd").
false.

?- e("abcd", "abcd").
true.

Technically speaking, the behavior of this solution is that of unification operator =/2, rather than that of ==/2, which checks for term equivalence. The difference shows when unbound variables are involved. In this solution, when unbound variable is supplied, the predicate will return true when unification is successful. In comparison, ==/2 will compare order of term without unification.

PHP, 21
This one is doing the job using variable indirection.
$$a=$b;!!$$b;

Or, if you don't need it to be bool
$$a=$b;$$b;

EDIT : I forgot to handle the case where you try to compare two empty strings, so the code now is
$$a=$b;!($a.$b)||$$b;

which is 21 chars.

I expected this to give errors when given strings which aren't valid identifiers, but to my surprise it doesn't.

Two problems: 1. Returns true when comparing "0" and "". 2. Returns true when $b is the name of an existing variable (in the current symbol table) having a value that converts to true (e.g. "GLOBALS" or "_SERVER" in global scope, or "b" in any scope), even when $b is not equal to $a.

CPython: 6
a is b

>>> a = 'string'
>>> b = 'string'
>>> c = 'STRING'
>>> a is b
True
>>> a is c
False

The use of is is obviously pretty suspect, but since the task specifically calls out that we're to determine value equality rather than reference equality, and is only compares object identity, I feel like it may not fall under the list of banned operators.
Of course there's also some question as to whether this is even valid; it works on all of my systems, but it's implementation-specific and probably won't always work if the strings aren't defined by hand in the interactive interpreter.

PHP
    $string = 'string';
    isset( ${'string'} );

This script may not have any utility, but atleast this provides a way to compare strings.
PHP
Aother one:
    $string = 'something';
    $text   = 'something';
    return count( array( $string => 1 , $text => 1 ) ) % 2;

Wow very lovely. And doing it like this can make it possible to use any string (with spaces and unicode).

C 342 golfed
#include <stdio.h>
#define N 100
#define P(x) printf("%s\n",x)
#define G(x) gets(x)
void e(int x){x?P("y"):P("n");}
int main(){
char s[N],t[N];char *p,*q;int r=0; int n=0,m=0;int i=1;p=s,q=t;
if((p=G(s))&&(q=G(t))){while (*p){n+=i*(int)*p;m+=i*(int)*q;i++;p++;q++;if(!(*q)){break;}}
if(!*p&!*q){if(!(m-n)){r=1;}}e(r);}
return 0;
}

Note: Visual Studio complains if you don't use their safe methods eg gets_s.
CodeBlocks with mingw compiles without warnings.
C 655 not golfed
Code creates weighted sum of chars for each string.
If the difference is zero then they are equal, including 2 empty strings:
    #include <stdio.h>
#define N 100
#define P(x) printf(x)
#define G(x) gets_s(x)

void e(int x){ x ? P("equal\n") : P("not equal\n"); }
int main()
{
    char s[N], t[N];//words
    char *p = 0, *q = 0;
    int r = 0; //result 0=false
    int n=0, m=0; //weighted sums
    int i = 1; //char pos start at 1
    if ((p=gets_s(s)) &&
        (q=gets_s(t)))
    {
        while (*p)
        {
            n += i*(int)*p;
            m += i*(int)*q;
            i++;
            p++;
            q++;
            if (!(*q)){
                break;
            }
        }

        if (!*p && !*q){ //both same length strings
            if (!(m - n)){ r = 1; } //weighted sums are equal
        }//else r=0, false=>not equal

        e(r);
    }
    else{
        P("error\n");
    }
    getchar();
}

Nice job, but you should probably golf it.

I can't compile your submission. I get "Undefined symbols for architecture x86_64:
"_gets_s", referenced from:
_main in golf-310cf2.o
ld: symbol(s) not found for architecture x86_64"

Python
It's long and it's not beautiful, but this is my first entry!
def is_equal(a,b):
    i=0
    a,b=list(a),list(b)
    if len(a)>len(b):
        c=a
        lst=b
    else:
        c=b
        lst=a
    try:
        while i<len(c):
            for j in c:
                if j not in lst[i]:
                    return False
                i+=1
    except IndexError:
        return False
    return True

R (4 chars)
'string1'%in%'string2'

Or, for an actual function,
(6 chars)
`%in%`

which is called with
`%in%`(x,y)

As R is  a vector-based language, is treated as a string and b is treated as a vector of one string, so this is similar to the elem a[b]/a in b in a/a in[b] solutions in spirit.

grep 14 characters
Of course, I only count the grep code; the two strings are on two consecutive lines in the input (either a pipe or a file or even an interactive session).
$ echo -e 'string\nstring' | grep -cPzo "(?s)^(\N*).\1$"
1
$ echo -e 'string\nstring1' | grep -cPzo "(?s)^(\N*).\1$"
0
$ echo -e 'string1\nstring' | grep -cPzo "(?s)^(\N*).\1$"
0

Matlab: 12 chars (after the strings are in variables)
~(x*x'-y*y')

The code including assignments would be:
x='string1'
y='string2'
~(x*x'-y*y')

The very crazy way
Just for the fun, but many ways for making it fail if one thinks about it. More over, don't forget the strings will be EXECUTED by the shell.
$ echo -e 'string\nstring1' | sed -e '1s/^/#define /' | cpp | sh 2>/dev/null && echo true
$ echo -e 'string\nstring' | sed -e '1s/^/#define /' | cpp | sh 2>/dev/null && echo true
true
$ echo -e 'string1\nstring' | sed -e '1s/^/#define /' | cpp | sh 2>/dev/null && echo true

A good counter-example is comparing "string" as first string and "rm -Rf /" as a second string; just check as root and see: it will say "true" though both strings obviously aren't the same.

JavaScript [18 bytes]
(_={})[a]=1,!!_[b]

OR
!!((_={})[a]=_)[b]

This will return true if a == b and false if a =/= b. The logic behind is creating an object with a value of a as a property and returning 1 or undefined in case if a property of b value exists or doesn't exist in that object.

The rules say you're allowed to return an object that evaluates to true or false, so the !! is not necessary

@James_pic Yeah, but otherwise it will return 1 or undefined (or object/undefined for the second case).

I interpreted the rules as saying that truth-y and false-y values would do in place of true and false, so I'd think that 1 or undefined were good enough.

@James_pic I just wanted to be on the safe side :) If so, then 18-2 = 16 bytes.

JavaScript [15 bytes]
![a].indexOf(b)

This will return true if a == b and false if a =/= b. The script is looking for the value of b in the array that holds a single element of value of a.

C - 86 83
main(int i,char**v){return*v[1]&!(*v[1]++^*v[2]++)?main(3,v):!(*--v[1]^*--v[2]);}

Obvioulsy not the shortest, but this doesn't work with string variables and instead takes the strings as input from the console. Also, I sort of like the recursive main, even if it's obviously not the shortest version. But certainly the least advisable.

You don't need spaces around many operators. For example, char** v can be written as char**v. There are some exceptions (like 42 / *pointer), but in most cases spaces can be safely removed near special characters.

And an apersand too much. Not on top today.

Python, 7 chars.
b in[a]

Where b and a are strings.

You can write this b in[a] with one less character.

C++: 104 105 characters
#include<string>
#include<set>
template<typename T>
int f(T a,T b){std::set<T>S={a};return S.count(b);}

EDIT: Saved a character by making it a template function.
Function itself is 51 characters. Other C++ answers already posted are shorter, but I wanted to try one that wasn't also pure C. In fact, this requires C++11. For earlier versions of C++ you can replace std::set<T>S={a}; with std::set<T>S(&a,&a+1); at the expense of an extra 5 characters.

Excel VBA
Function stringmatch()
a = ""
b = ""
For i = 1 To Len(a)
If Asc(Right(Left(a, i), 1)) - Asc(Right(Left(b, i), 1)) Or Len(a) - Len(b) Then
debug.print "string unnmatch"
Exit Function
End If
Next
debug.print  "string match"
End Function

I think your <> is classified as an inequality operator, which is not permitted by the rules.

@Ace oh thx, seeing "=" is allowed I thought "<>" is also allowed

= is allowed as an assignment operator. If your language uses this symbol as an equality operator you still cannot use it. (This applies to Visual Basic .NET, I don't know about Excel VBA.)

Oh ok thanks, I have used another expression (edited code)

Java (235 characters for golfed version at bottom).
Strings are not hardcoded, but this is a trivial change.
   public boolean areEqual(String a, String b) {
    int[] q = new int[1];
    int i = 0;
    try {
        while (true) {
            noOp(q[(int) a.charAt(i) - (int) b.charAt(i)]);
            i++;
        }
    } catch (Error e) {
        try {
            a.charAt(i);
        } catch (Error e2) {
            try {
                b.charAt(i) {catch(Error e3){
                    return true;
                }
                }
            }

            return false;
        }
        return true;
    }
}

public void noOp(int i) {
}

Traverses both strings, using the difference in chars to select an array index (which is 0-based). No in-loop comparisons or Math.max used. Using Error as a throwable instead.
Golfed for use under certain circumstances (instantiated class, used from same package):
boolean a(String a,String b){boolean t=true,f=!t;int[]q={1};int i=0;try{while(t){q[(int)a.charAt(i)-(int)b.charAt(i)];i++;}}catch(Error e){try{a.charAt(i);}catch(Error z){try{b.charAt(i){catch(Error g){return t;}}}return f;}return t;}}

Any purpose for noOp?

The golfed and ungolfed code don't compile...

@ColeJohnson I'm guessing the noOp function is because array[i] isn't a statement by itself. Rather than calling a function OP could just set the value of that array index since it's not used anyway.

Groovy  347
def compare(str1,str2){
    def str1val = 0
    def str2val = 0

    MessageDigest md5 = MessageDigest.getInstance("MD5")
    md5.digest(str1.getBytes("UTF-8")).each{ str1val += it*2 }
    md5.digest(str2.getBytes("UTF-8")).each{ str2val += it*2 }

    if(!(str1val-str2val)) {
        return true
    } else {
        return false
    }
}

Perl - 10
/^\Q$w\E$/

The input is in $_ and $w. The output is stored in $&.

APL (Dyalog Extended), 4 bytesSBCS
Anonymous tacit infix function. Requires ⎕IO←0
~⍳⍥⍮

Try it online!
⍥⍮ put each argument into a list
⍳ index of right list's elements in left list (0 if match, 1 if not)
~ logical NOT

5 bytes possible

@KritixiLithos What was yours?

2= in place of -1=

@KritixiLithos Wouldn't = be forbidden? I had ¯1+.

Ah, forgot about that

PowerShell, 30 bytes
param($a,$b)$a-in$b-and$b-in$a

Try it online!
Takes two string inputs as command line parameters, -a and -b.
PowerShell, 20 16 bytes
-4 bytes thanks to @mazzy!
!($args|gu).Rank

Try it online!
Alternate answer, takes two strings as commandline arguments.

nice alternative. you can save more Try it online!

@mazzy thanks, I didn't even know the Rank property existed until now!

Python, 79
a=list(a)
b=list(b)
for i in range(len(a)):
 if ord(a[i])-ord(b[i])<0:
  print 'n'

The question has been edited: the strings should be hard-coded, though I think your approach is better (golfier).

It will print n multiple times

At the cost of a few chars, I could make it better

Your program does not return whether the strings are equal or not, although it could be changed trivially to suit the rules.

Perl, 24 bytes
$r=!(-1+keys{$a,1,$b,1})

The two strings are given in $a and $b. The result is stored in $r.
The trick is using a hash array. If the strings are equal, then only one hash entry is created.

A standalone variant that gets the string from STDIN and returns 0, if the strings match and 1 otherwise:
$h{<>}=$h{<>}=1;exit -1+keys%h

Python - 52 chars without strings (76 with strings)
The in operator might be skirting the edges, but the rules disallow strict equality comparison, not similarity comparison.
a="string"
b="string"
x=a in b and not(len(a)-len(b)>0 or len(a)-len(b)<0)

Python 2 - 50 54 (including strings)
Thanks to Ace for way around the "==" issue
a='string'
b='string'
not(len(''.join(set(a+b)))-len(a))

Output
True

Non-equal strings
a='string'
b='String'
not(len(''.join(set(a+b)))-len(a))

Output
False

Can't use ==, even if you're not comparing the strings.

You may wish to use not (len(''.join(set(a+b)))-len(a)) instead.

Ruby, 21
Online version
Strings have to be stored in a and b:
!!(a+b=~/^(#{a})\1$/)

Checks if the concatenation of a and b contains a twice.

Insufficient. Gives true for a="string"; b="stringstring". You have to anchor the regular expression to the start of string too with ^.

I feel like =~ needs to be forbidden, or you can just do !!(a=~/^#{b}$/)

Well, it's just an abbreviation for .match(x): !!(a+b).match(/^(#{a})\1$/) - but yes, it somehow is an equality operator...

D 30
string a="somestring";
string b="somestring";

return !reduce!"a|b"(a[]^b[]);

I think !reduce! falls under the banned equality operators.

it negates the integer result, no different than the C solution using the same xor trick

C++ - 66 57 53
int c(char*a,char*b){return *a-*b?0:*a?c(++a,++b):1;}

with the ungolfed version:
int mystrcmp( char* a, char* b )
{
  // If the characters don't match, we're done
  if( *a - *b )
  {
      return 0;
  }

  // If they do match, and both were nulls, we are done
  if( !*a )
  {
      return 1;
  }

  return mystrcmp( ++a, ++b );
}

Driver program in original post below.

Old version:
The golfed version:
int c(char*a, char*b){while(*a|*b)if(*a++-*b++)return 0;return 1;}

Here is a full driver program with comments:
#include <iostream>

using std::cout;
using std::endl;

int mystrcmp( char* a, char* b ) {
   // The comparison will continue as long as both *a and *b are not '\0'.
   // If one of them goes '\0' but the other does not, the strings are not
   // of equal length and at that point we will return 0.
   while( *a | *b ) {
     // Compare the current character and return 0 if they are not equal.
     // *a++ will return the value of *a and then increment the pointer -
     // see http://stackoverflow.com/questions/9255147/does-p-increment-after-dereferencing
     if(*a++ - *b++) {
       return 0;
     }
   }

   // If we got here, both strings are equal up to and including the last '\0'.
   return 1;
}

int main()
{
   // Prints 1
   cout << mystrcmp("Hello.", "Hello.") << endl;

   // Prints 1
   cout << mystrcmp("Hello, world!", "Hello, world!") << endl;

   // Prints 0
   cout << mystrcmp("Hello", "Hello.") << endl;

   // Prints 0
   cout << mystrcmp("Hello.", "Zello.") << endl;

   // Prints 0
   cout << mystrcmp("Hello", "Hallo") << endl;

   // Prints 0
   cout << "Hello World" << endl;

   return 0;
}

You can drop the parentheses: *a-*b?0:*a?c(++a,++b):1

Thanks @n̴̖̋h̷͉̃a̷̭̿h̸̡̅ẗ̵̨́d̷̰̀ĥ̷̳, for some reason I thought there would a problem with the precedence.

C++ 30
#include<string>
std::string a = "test", b = a;
int main(){return!(a<b||a>b);}

I'm not counting the first two lines because:

The strings should not be counted in the golf.

And here are some tests.

Delphi (412 83 75)
Can probably be done shorter but was fun to do, going to see if i can get some off.
412 -> 83 Cant believe I missed this... Checks if s1 is in s2 and if s2 is in s1.
Saved 329 chars Cheers
83 -> 75 Thanks to Manatwork. Changed check if s1 is in s2 and other way around. Saved 8 characters
const s1='string12';s2='string12';begin Write(Pos(s1,s2)*Pos(s2,s1)>0);end.

Ungolfed
const
  s1='string12';
  s2='string22';
begin
  Write(Pos(s1,s2)*Pos(s2,s1)>0);
end.

A few tests I made shows that Pos(s1,s2)*Pos(s2,s1)>0 would also do it.

Dart - 15
Strings are stored in a en b.
[a].contains(b)

[a] creates a List with a.

Q - [3 bytes]
a:"string"
b:"string"

a~b

I think this is a valid answer as ~ isn't an equals operator.
From a Q tutorial:

~  asks whether two entities have the same contents.
http://kx.com/q/d/primer.htm

C#
I know there's already a C# answer, I just wanted to show other options. :)
boolean:

51
!Convert.ToBoolean(new[]{a,b}.Distinct().Count()-1)

1 or 0:

32
-new[]{a,b}.Distinct().Count()+2

C#
void Main()
{
    Console.WriteLine(StringEqual("pie","pie")); // true
}

bool Equals(int a,int b)
{
    var aBytes = BitConverter.GetBytes(a);
    var bBytes = BitConverter.GetBytes(b);

    return aBytes.SequenceEqual(bBytes);
}

bool StringEqual(string a,string b)
{
    int i = 0;
    return a.All((c) => Equals((int)c,(int)b[i++]));
}

why not just a.SequenceEqual(b) ???

@Habib I'm stupid. :D

C#
I already posted the answer But just found a number of ways in C#
 var b = "abcdef";
 var a = "abcdef";
 // the best one is this.
 bool repace = a.Replace(b, "").Length < 1 && b.Replace(a, "").Length < 1;
 bool contsins = ("a" + a).Contains(b) && ("b" + b).Contains(a);

forget to mention considering string are not empty.

Javascrpt: 38 chars (without a-b declarations) || 31 without alert()
a="string";
b="string";

o={};o[a]=0;alert(o.hasOwnProperty(b))

sets an object key named the value of a -- checks for a key named the value of b in that object.
without alert:
o={};o[a]=0;o.hasOwnProperty(b)

J - 6 char
A J expression which tests for string equality without testing for string equality? Here's one:
e./a;b        NB. is a boxed in b boxed?

Not good enough? Want some more options? Go ahead, have some more, J has plenty.
<:#~.a;b      NB. (the number of the unique items among the two) - 1
1-{:~:a;b     NB. 1 - (whether the second item is unique, given the first)
2-#]/.~a;b    NB. 2 - (the number of piles the strings will sort themselves into)
+/(/:*\:)a;b  NB. is sorting them forwards the same as sorting them backwards?
A.|./:\:~a;b  NB. will sorting them forwards after sorting them backwards do anything?

The common subexpression here, a;b, is a linked to b. It puts a and b into boxes before appending them into a list. This is J's closest approximation to non-rectangular arrays: if you just tried to put the two strings in a 2-item list, the shorter would be padded with spaces on the right, which could result in you comparing 'a' and 'a ' as equal.

Python 15 - 2( if you hard code the string in the solution) = 13
>>> s = 'string'
>>> t = 'string'
>>> 1 is len({s,t})
True
>>> s = 'string1'
>>> t = 'string2'
>>> 1 is len({s,t})
False

Python 17
>>> s = 'string'
>>> t = 'string'
>>> s in t and t in s
True
>>> s = 'string1'
>>> t = 'string2'
>>> s in t and t in s
False

Perl, 25 bytes
$r="$a$b"=~/^(\Q$a\E)\1$/

The input is expected in variables $a and $b. The result is stored in $r.
It uses a regular expression to check, whether the concatenation "$a$b" is a duplicate of $a.

Does that answer allow for "regex-special" charaters in either $a or $b? (will it still match properly if $a contains a .?

@IQAndreas: Yes, the special characters are disabled by \Q...\E.

Python (7)
Assuming strings are stored in variables a and b:
a<=b<=a

Emacs Lisp
(split-string-and-unquote a b)

returns nil when a == b, something else when a != b
(print (if (split-string-and-unquote a b) "not equal..." "equal!"))

If I'm doing string work in elisp I use the popular package s.el in which it could be written a little shorter and without a negated output
(not (s-split a b t))

Java - 193
new int[]{0,1,0}[new BigInteger(a.getBytes()).subtract(new BigInteger(b.getBytes())).signum()+1]

No comparison operators at all, not even a < or >.

This is just a code snippet. The consensus for challenges on PPCG is that a full program or function is required unless explicitly stated in the question. Moreover 1 and 0 are not truthy and falsey in java so I'm not sure this is allowed. Finally you're making use of Java's BigInteger but you're not taking the byte count hit for the import of that class.

C - 45 characters
r;main(){ // 9 chars here
    char *a = "str2";
    char *b = "str1";
while(r+=*a^*b,*a++**b++);return!r;} // 36 more here

Fails if: a="str1"; b="str1b"

Works for me. The catch is when run from terminal, "equal" means "failure" (non-zero return code).

You're right. My apologies. When I ran it, I was inconsistently thinking of the shell's idea of true/false and C's, which are the opposite way around.

C, 48 chars
c(char*a,char*b){return*a++-*b?0:!*b++||c(a,b);}

Recursion is often shorter than a loop.
Subtraction easily replaces a comparison.

Lua, 147
a="string" b="string" y=string.byte s=string.sub m=math.abs c=1 for i=1,math.max(#a,#b) do d=y(s(a,i)) e=y(s(b,i))if not((d and e)and(m(d) - m(e)))then c=0 break end end

Assumes a and b are the strings. c should be 1 (true)

C#, pretty straightforward.
static bool equal(string s1, string s2)
{
    int i = 0;
    try { while (true) if (!isZero((int)s1[i] - (int)s2[i++])) return false; }
    catch { }
    return isEnd(s1, i) && isEnd(s2, i);
}

static bool isEnd(string s, int i)
{
    try { char c = s[i]; return false; }
    catch { }
    return true;
}

static bool isZero(int x)
{
    try { int y = 1 / x; return false; }
    catch { }
    return true;
}

Bash, 14
Assuming strings are in A and B, then
[ -z ${A/$B} ]

will return a true (0) or false (1) value in $?.
How do I use it?
A="string";B="string";[ -z ${A/$B} ]&&echo same

How does it work?
${A/$B} replaces $B in $A with nothing. Only if $A=$B then result will be an empty string. [ -zn X ] tests for empty or null string and sets $? to 0 if empty.
Update: should be -z not -n in test.

Java
import java.util.HashSet;
public class Equals {
    public static boolean equals(String s1, String s2){
        HashSet<String> sSet = new HashSet<>();
        sSet.add(s1);
        return !sSet.add(s2);
    }
    public static void main(String[] args) {
        System.out.println(equals("Apple","Tpple"));
    }
}

This can still be golfed a bit. Also you should include the bytecount in the title of your answer :]

Python 56
a = "string"
b = "string"

not any(ord(x)*len(a)-ord(y)*len(b) for x,y in zip(a,b))

A bit longer than the shortest Python examples, but probably about the best I can do without using in or set notation (the former should probably be excluded, the latter has already been employed as succinctly as possible).

Rebol, 22
all[find a b find b a]

This will return none if strings are different.
Example usage in Rebol console:
>> a: "string"
== "string"

>> b: "string"
== "string"

>> c: "stringstring"
== "stringstring"

>> all [find a b find b a]
== "string"

>> all [find a c find c a]
== none

By default Rebol is case insensitive.  So use find/case to enforce stricter test:
>> b: "STRING"
== "STRING"

>> all [find a b find b a]
== "STRING"

>> all [find/case a b find/case b a]
== none

Javascript
Where x = z and x != y:
if( x.match(RegExp(z)) ) // Evaluates to True

if( x.match(RegExp(y)) ) // Evaluates to False

What if z === 'Abc.efg' and x === 'Abcdefg'?

Windows Batch (47)
@echo.>%1
@if exist %2 (exit /b 0)
@exit /b 1

This should be run in an empty directory each time ;)
It types a blank line into a file named with the first argument, and then checks if the second argument exists. For hardcoded strings, either replace the %1 and %2 or add @if "%1"=="" %0 string1 string2 to the top of the file.

Do you have a reference for your “errorlevel isn't 0 by default” comment?

perl, 20 bytes
Today I'm serving up perl two ways, saving a byte or two off the other perl solutions seen here. First, with hash slices, for 20 bytes:
@x{$a,$b}=();$_=%x%2

and then a port of the clever python solution above (also 20 bytes)
$_={$a,0,$b,1}->{$a}

C - 59
e(char*l,char*r){for(;*l&*r&&!(*l++^*r++););return!*l&!*r;}

Ruby (18)
This one is a script using the exit status instead of a function's return value: 0 is success, 1+ is failure.
exit$*.uniq.size-1

Usage:
$ ruby equality.rb a b
$ echo $?
1
$ ruby equality.rb a a
$ echo $?
0

R, 4
"string1"%in%"string2" equivalent to is.element("string1", c("string2"))

D - 34 27 bytes
!any!"a.length"(split(a,b))

Example use:
import std.stdio,std.string,std.algorithm;

void main() {
    auto a = "abcd";
    auto b = "abcd";

    writeln(!any!"a.length"(split(a,b)));
}

Output:
true

~-~! (No Comment) - 1
(might not be legal)
|string|-|string|

% if they're equal, anything else if they're not. There's an issue though; ~-~! only accepts % or ~ (0 or 1) for conditionals; if it's neither, it throws an error. So you'd have to use ==~ to actually be able to use it properly. I don't think there /is/ a way to do this in ~-~! without the equality operator if this isn't allowed.

Excel VBA, 124 Bytes
Subroutine that takes variant input a and b of the assumed type variant\string and outputs as a boolean variable to the VBE immediates window
Sub m(a,b)
c=1
For i=1To Len(a)
If Asc(Right(Left(a,i),1))-Asc(Right(Left(b,i),1)) Or Len(a)-Len(b) Then:c=0:Exit For
Next
Debug.?CBool(c)
End Sub

Operation Flashpoint scripting language, 7 bytes
a in[b]

Strings are stored in variables a and b (as allowed by the question).
Interestingly, even if direct comparison would be allowed, this would be the only valid solution, because a==b performs a case-insensitive comparison, whereas the built-in in uses case-sensitive comparison for strings internally.

[shell], 22 bytes (almost any shell (sh,bash,ksh,zsh, etc), certainly POSIX ones)
a=string
b=string

c=${a#"$b"}
echo ${#c}

Try it online!
Will output 0 if strings are equal, 1 if different. The less robust solution that doesn't deal with (*, ? and [ in $b) is two bytes shorter:
c=${a#$b}
echo ${#c}

PYTHON, 25
not bool(a.replace(b,''))

Explanation
An empty string is false in Python, so if we replace b with '' and check if it is empty that gives use true/false.

Welcome to the site! As a tip not will automatically cast to bool in python so there is no need for the bool.  However this answer doesn't work.  If a is the string xx and b is the string x then the replacement will be empty but the two are not equal.

If both a.replace(b,'') and b.replace(a,'') are empty then it will be equal so you can do something like not a.replace(b,"")+b.replace(a,"").

C#
var b="string";
var a="string";
return  Regex.IsMatch(b, "^.{" + a.Length + "}$") && Regex.IsMatch(b,"^" + a + "$");

I am afraid this counts as one of the forbidden functions.

awh.. I hope now it is fine
return Regex.IsMatch("^" + a + "$", b);
is it ?

According to your function, a = "string.!?" equals `b = "stringz".

again...... : P

Java - 54
First Golf:
Since all string's HashCode is the same with the same content, it can be useful.
(int)Math.abs(Math.signum(s.hashCode()-b.hashCode()));

This is wrong. Non-identical strings may have different hash codes.

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

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