g | x | w | all
Bytes Lang Time Link
005Japt x180326T233802ZShaggy
033Python180329T033534Zxnor
009APL Dyalog180326T223603ZUriel
015x86180327T001823Zqwr
009Wolfram Language Mathematica180327T044713Zalephalp
028Java 8180327T091232ZKevin Cr
00505AB1E180326T224450ZUriel
012J180327T071358ZGalen Iv
008Stax180327T061533ZWeijun Z
038JavaScript ES6180326T223610ZArnauld
020Octave180327T012624ZNick Alg
028Ruby180327T010156ZLevel Ri
032Python 2180326T231007ZDennis
044SHELL180326T231544ZAli ISSA
013Add++180327T001446Zcaird co
007Husk180326T235940ZSophia L
026Haskell180326T232136Ztotallyh
005Jelly180326T223142ZDennis
056Ruby180326T224454Zbenj2240
008Jelly180326T221801ZErik the
016CJam180326T221338ZPeter Ta

Japt -x, 7 5 bytes

ä!gUÌ

Try it

ä!gUÌ     :Implicit input of array U
ä         :Consecutive pairs reduced by
 !g       :  Signs of differences, inverted
   UÌ     :After first prepending last element of U
          :Implicit output of sum of resulting array

Python, 33 bytes

lambda i,j,k:(i^j!=k or-~j-i)%3-1

Try it online!

I tried for a while to beat the product-of-differences approach, but the best I got was 1 byte longer.

APL (Dyalog), 11 9 bytes

2 bytes saved thanks to @ngn

+/×2-/4⍴⎕

Try it online!

x86, 15 bytes

Takes arguments in %al, %dl, %bl, returns in %al. Straightforward implementation using Dennis's formula.

 6: 88 c1                   mov    %al,%cl
 8: 28 d0                   sub    %dl,%al
 a: 28 da                   sub    %bl,%dl
 c: 28 cb                   sub    %cl,%bl
 e: f6 e3                   mul    %bl
10: f6 e2                   mul    %dl
12: d0 f8                   sar    %al
14: c3                      retq 

Aside: I think I understand why %eax is the "accumulator" now...

Wolfram Language (Mathematica), 9 bytes

Signature

Try it online!


Wolfram Language (Mathematica), 18 bytes

Saved 2 bytes thanks to Martin Ender.

Det@{#^0,#,#^2}/2&

Try it online!

Java 8, 28 bytes

(i,j,k)->(i-j)*(j-k)*(k-i)/2

Port of @Dennis' Python 2 answer.

Try it online.

05AB1E, 7 5 bytes

1 byte saved thanks to @Emigna

ĆR¥P;

Try it online!

J, 12 bytes

1#.2*@-/\4$]

Try it online!

Direct translation of Uriel's APL solution into J.

Explanation:

4$] Extends the list with its first item

2 /\ do the following for all the overlapping pairs in the list:

*@- find the sign of their difference

1#. add up

Stax, 8 bytes

äN§lüy²Å

Run and debug it

Translates to -(b-a)(c-b)(a-c)/2.

JavaScript (ES6), 38 bytes

Overcomplicated but fun:

(a,b,c,k=(a+b*7+c*13)%18)=>k-12?+!k:-1

Try it online!


JavaScript (ES6), 28 bytes

Using the standard formula:

(a,b,c)=>(a-b)*(b-c)*(c-a)/2

Try it online!

Octave, 20 bytes

@(v)det(eye(3)(:,v))

Pretty direct implementation of the determinant formula. Permutes the columns of the identity matrix then takes the determinant.

Ruby, 28 bytes

->a,b,c{(a-b)*(b-c)*(c-a)/2}

Try it online!

Python 2, 32 bytes

lambda i,j,k:(i-j)*(j-k)*(k-i)/2

Try it online!

Algorithm

Let's consider the differences i-j, j-k, k-i.

Thus, dividing the product of the differences by 2 yields the desired result.

SHELL, 44 Bytes

 F(){ bc<<<\($2-$1\)*\($3-$1\)*\($3-$2\)/2;}

tests :

 F 1 2 3
 1

 F 1 1 2
 0

 F  2 3 1
 1

 F 3 1 2
 1

 F 3 2 1
 -1

 F 2 1 3
 -1

 F 1 3 2
 -1

 F 1 3 1
 0

Explanation :

 The formula is : ((j - i)*(k - i)*(k - j))/2

BC, 42 Bytes

 define f(i,j,k){return(j-i)*(k-i)*(k-j)/2}

tests:

 f(3,2,1)
 -1
 f(1,2,3)
 1
 f(1,2,1)
 0

Add++, 13 bytes

L,@dV@GÑ_@€?s

Try it online!

Husk, 7 bytes

ṁ±Ẋ-S:←

Try it online!

Explanation

Straight port of Dennis's Jelly answer. S:← copies the head of the list to the end, Ẋ- takes adjacent differences, and ṁ± takes the sign of each element and sums the result.

Haskell, 26 bytes

(x#y)z=(x-y)*(y-z)*(z-x)/2

Try it online!

Nasty IEEE floats...

Jelly, 5 bytes

ṁ4IṠS

Try it online!

Algorithm

Let's consider the differences j-i, k-j, i-k.

Code

ṁ4IṠS  Main link. Argument: [i, j, k]

ṁ4     Mold 4; yield [i, j, k, i].
  I    Increments; yield [j-i, k-j, i-k].
   Ṡ   Take the signs, replacing 2 and -2 with 1 and -1 (resp.).
    S  Take the sum.

Ruby, 56 bytes

->t{t.uniq!? 0:(0..2).any?{|r|t.sort==t.rotate(r)}?1:-1}

Try it online!

Once we rule out cases where the values of the triplet are not unique, t.sort is equivalent to (and shorter than) [1,2,3] or [*1..3]

->t{
  t.uniq! ? 0                     # If applying uniq modifies the input, return 0
          : (0..2).any?{|r|       # Check r from 0 to 2:
              t.sort==t.rotate(r) #   If rotating the input r times gives [1,2,3],
            } ? 1                 #     return 1;
              :-1                 #     else return -1
}

Jelly, 8 bytes

⁼QȧIḂÐfḢ

Try it online!

Seems too ungolfed. :(

CJam (16 bytes)

1q~{)1$f-@+:*\}h

Online demo. Note that this is based on a previous answer of mine which uses the Levi-Civita symbol to calculate the Jacobi symbol.