[Question]
  [
The three-dimensional Levi-Civita symbol is a function `f` taking triples of numbers `(i,j,k)` each in `{1,2,3}`, to `{-1,0,1}`, defined as:
* `f(i,j,k) = 0` when `i,j,k` are not distinct, i.e. `i=j` or `j=k` or `k=i`
* `f(i,j,k) = 1` when `(i,j,k)` is a cyclic shift of `(1,2,3)`, that is one of `(1,2,3), (2,3,1), (3,1,2)`.
* `f(i,j,k) = -1` when `(i,j,k)` is a cyclic shift of `(3,2,1)`, that is one of `(3,2,1), (2,1,3), (1,3,2)`.
The result is the [sign](https://en.wikipedia.org/wiki/Parity_of_a_permutation) of a permutation of `(1,2,3)`, with non-permutations giving 0. Alternatively, if we associate the values `1,2,3` with orthogonal unit basis vectors `e_1, e_2, e_3`, then `f(i,j,k)` is the [determinant](https://en.wikipedia.org/wiki/Determinant) of the 3x3 matrix with columns `e_i, e_j, e_k`.
**Input**
Three numbers each from `{1,2,3}` in order. Or, you may choose to use zero-indexed `{0,1,2}`.
**Output**
Their Levi-Civita function value from `{-1,0,1}`. This is code golf.
**Test cases**
There are 27 possible inputs.
```
(1, 1, 1) => 0
(1, 1, 2) => 0
(1, 1, 3) => 0
(1, 2, 1) => 0
(1, 2, 2) => 0
(1, 2, 3) => 1
(1, 3, 1) => 0
(1, 3, 2) => -1
(1, 3, 3) => 0
(2, 1, 1) => 0
(2, 1, 2) => 0
(2, 1, 3) => -1
(2, 2, 1) => 0
(2, 2, 2) => 0
(2, 2, 3) => 0
(2, 3, 1) => 1
(2, 3, 2) => 0
(2, 3, 3) => 0
(3, 1, 1) => 0
(3, 1, 2) => 1
(3, 1, 3) => 0
(3, 2, 1) => -1
(3, 2, 2) => 0
(3, 2, 3) => 0
(3, 3, 1) => 0
(3, 3, 2) => 0
(3, 3, 3) => 0
```
  
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 5 bytes
```
ṁ4IṠS
```
[Try it online!](https://tio.run/##ASEA3v9qZWxsef//4bmBNEnhuaBT/zPhuZczwrU7IsOH4oKsR/8 "Jelly – Try It Online")
### Algorithm
Let's consider the differences **j-i, k-j, i-k**.
* If **(i, j, k)** is a rotation of **(1, 2, 3)**, the differences are a rotation of **(1, 1, -2)**. Taking the sum of the signs, we get **1 + 1 + (-1) = 1**.
* If **(i, j, k)** is a rotation of **(3, 2, 1)**, the differences are a rotation of **(-1, -1, 2)**. Taking the sum of the signs, we get **(-1) + (-1) + 1 = -1**.
* For **(i, i, j)** (or a rotation), where **i** and **j** may be equal, the differences are **(0, j-i, i-j)**. The signs of **j-i** and **i-j** are opposite, so the sum of the signs is **0 + 0 = 0**.
### 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.
```
[Answer]
# [Python 2](https://docs.python.org/2/), 32 bytes
```
lambda i,j,k:(i-j)*(j-k)*(k-i)/2
```
[Try it online!](https://tio.run/##XcoxCoNAEEbhWk/xN@JumEVcO0FPkkYRyczoKmLj6TfGQjDNKz7eeuyfJfg4osE7Tt3cDx2YhLQ27MS@jDg9q45tcW7LBgYHlARPqOo0@ZE86TL9s2TdOOwwTBCCWkLuWmR@yJFhvDl@AQ "Python 2 – Try It Online")
### Algorithm
Let's consider the differences **i-j, j-k, k-i**.
* If **(i, j, k)** is a rotation of **(1, 2, 3)**, the differences are a rotation of **(-1, -1, 2)**. Taking the product, we get **(-1) × (-1) × 2 = 2**.
* If **(i, j, k)** is a rotation of **(3, 2, 1)**, the differences are a rotation of **(1, 1, -2)**. Taking the product, we get **1 × 1 × (-2) = -2**.
* For **(i, i, j)** (or a rotation), where **i** and **j** may be equal, the differences are **(0, i-j, j-i)**. Taking the product, we get **0 × (i-j) × (j-i) = 0**.
Thus, dividing the product of the differences by **2** yields the desired result.
[Answer]
# [Wolfram Language (Mathematica)](https://www.wolfram.com/wolframscript/), 9 bytes
```
Signature
```
[Try it online!](https://tio.run/##y00syUjNTSzJTE78n6Zgq/A/ODM9L7GktCj1f0BRZl5JtLKOgpKCrp2Cko5CWrRybKyCmoK@g0JIaUFOanF0taGOgpGOgnEtEMf@BwA "Wolfram Language (Mathematica) – Try It Online")
---
# [Wolfram Language (Mathematica)](https://www.wolfram.com/wolframscript/), 18 bytes
Saved 2 bytes thanks to Martin Ender.
```
Det@{#^0,#,#^2}/2&
```
[Try it online!](https://tio.run/##y00syUjNTSzJTE78n6Zgq/DfJbXEoVo5zkBHWUc5zqhW30jtf0BRZl5JtLKOgpKCrp2Cko5CWrRybKyCmoK@g0JIaUFOanF0taGOgpGOgnEtEMf@BwA "Wolfram Language (Mathematica) – Try It Online")
[Answer]
# 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...
[Answer]
# 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.
[Answer]
# [Haskell](https://www.haskell.org/), 26 bytes
```
(x#y)z=(x-y)*(y-z)*(z-x)/2
```
[Try it online!](https://tio.run/##TYpBDkAwFAWv8hKb/6Ul2HIEJxCLLiS@IoJF27h7dcdmMpPMbC47rWuM5DLPoSOnPefkdUgM2nFZx83Ijg6bOXocp@w3BiJRWBQsK5Agw8LJ8UDQagxVUTRjGv5hvxjjCw "Haskell – Try It Online")
Nasty IEEE floats...
[Answer]
# JavaScript (ES6), 38 bytes
Overcomplicated but fun:
```
(a,b,c,k=(a+b*7+c*13)%18)=>k-12?+!k:-1
```
[Try it online!](https://tio.run/##ZZJNa4QwEEDv/oopWEzWZGkmh5YtcfHQQmmhP0CEjan2w2UtWnoRf7td6@LqDgQPz3nJO8yX/bWNqz@/f@Shesv7wvTMikw4URpmw2x1G7qV0vxa3XETlVLhNrwqN1L1MRhIPIAkUQKGkwq4ScWMICF6SZBYSCwcLXUmmlh6tORyaP4YkkQkiTglThchaUTSiFPjjJwa1YIgmZlbmiTqKVEtyIV1KpRqgZAMXWiaPKaJNSV66b3nxeuiqh@s@2AsSf6X5PivTjmYCFx1aKp9vt5X72zH/NZ2wm@z4eM6DjICv63z5rgyxbhevBsIGAMD3kLw@hzABoLH@Okl6Hac938 "JavaScript (Node.js) – Try It Online")
---
# JavaScript (ES6), 28 bytes
Using the standard formula:
```
(a,b,c)=>(a-b)*(b-c)*(c-a)/2
```
[Try it online!](https://tio.run/##ZZJNa4QwEEDv/oo5CCYl2TaT25ZYPLRQWugPCMLGVPvBsilaehF/u9WupLoDksPLPPMO8@l@XOfbj69veQqv9diYkTlRCc9Nzpys@BWrpJ9OLx2/xrEAAzYBsFYJmL9SwE0pVgQJ0VuCxEJi4dlS/0QTS58tuR1aP4YkEUkixsT4IySNSBoxNq7I0qg2BMnM2tIkUcdEtSEX1lIo1QYhGbrQNHlMEysmJuVtkhS7JrT3zr8zZu3fakx3bcnB5ODDqQvHencMb@zA0t4NIu2r@fADB5lD2rd1N61MsyzVMBMwBmZ8B9nLUwZ7yB6Kx@dsOHA@/gI "JavaScript (Node.js) – Try It Online")
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E), ~~7~~ 5 bytes
*1 byte saved thanks to @Emigna*
```
ĆR¥P;
```
[Try it online!](https://tio.run/##MzBNTDJM/f//SFvQoaUB1v//RxvpKBjqKBjHAgA "05AB1E – Try It Online")
[Answer]
# [APL (Dyalog)](https://www.dyalog.com/), ~~11~~ 9 bytes
*2 bytes saved thanks to @ngn*
```
+/×2-/4⍴⎕
```
[Try it online!](https://tio.run/##Lcy9DUBQAEXh3hR6EXGvhSRCI6E1AQ2dWMQGNnmLPH8nt7jJKb567PNmqvuhi2GZ25gV16G8qMJ6hm1/W2yTMn2W/C/e34suuuimm@6vC0c4whGOcIQjHOEIxzjGMY5xjGMc4xjnfd8 "APL (Dyalog Unicode) – Try It Online")
[Answer]
# [Ruby](https://www.ruby-lang.org/), 28 bytes
```
->a,b,c{(a-b)*(b-c)*(c-a)/2}
```
[Try it online!](https://tio.run/##KypNqvyfZvtf1y5RJ0knuVojUTdJU0sjSTcZSCbrJmrqG9X@L7KN1jLQ0zOK5SrSKyjKTylNLtEo0inS1MtNLKiuyawBa7XNtC5QiM7USYsGc2Nja/8DAA "Ruby – Try It Online")
[Answer]
## CJam (16 bytes)
```
1q~{)1$f-@+:*\}h
```
[Online demo](http://cjam.aditsu.net/#code=1q~%7B)1%24f-%40%2B%3A*%5C%7Dh&input=%5B3%202%202%5D). Note that this is based on [a previous answer of mine](https://codegolf.stackexchange.com/a/143775/194) which uses the Levi-Civita symbol to calculate the Jacobi symbol.
[Answer]
# [Ruby](https://www.ruby-lang.org/), 56 bytes
```
->t{t.uniq!? 0:(0..2).any?{|r|t.sort==t.rotate(r)}?1:-1}
```
[Try it online!](https://tio.run/##bU7bioQwDH33K7IFoYIW67wJHT9EZOhqZQWn7fYCzlq/3Smu7tMSQpJzkpxj/OdrH9le3N3qiJfT90cDZY1LQqqMcPlq1mCCI1YZx5gjRjnuBDbZ1tC6oNuuvNPeWWDQlvkVNGZBz@Gvof@xMbqkpXmV3zpihBbx/fDQwjx9VJqUxLeM/Ewan0IZEbz/gkFBmGQEchCLFn08CglAPyspopeDIk@u17CEZYuMEdbPLlJjeyx1ETuMo9RCcYe0soBTmyFIoT0//95clbFLCRpAmluLoAY08mlGXSLksL8B "Ruby – 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
}
```
[Answer]
# [Husk](https://github.com/barbuz/Husk), 7 bytes
```
ṁ±Ẋ-S:←
```
[Try it online!](https://tio.run/##yygtzv7//@HOxkMbH@7q0g22etQ24f///9FGOsY6hrEA "Husk – Try It Online")
# Explanation
Straight port of Dennis's [Jelly answer](https://codegolf.stackexchange.com/a/160365/78915). `S:←` copies the head of the list to the end, `Ẋ-` takes adjacent differences, and `ṁ±` takes the sign of each element and sums the result.
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 8 bytes
```
⁼QȧIḂÐfḢ
```
[Try it online!](https://tio.run/##ASMA3P9qZWxsef//4oG8UcinSeG4gsOQZuG4ov///1szLCAyLCAxXQ "Jelly – Try It Online")
Seems too ungolfed. :(
[Answer]
# [Add++](https://github.com/cairdcoinheringaahing/AddPlusPlus), 13 bytes
```
L,@dV@GÑ_@€?s
```
[Try it online!](https://tio.run/##S0xJKSj4/99HxyElzMH98MR4h0dNa@yL/6vkJOYmpSQqGNoBkbGdEZc/F5KQkZ2hnSG6kDFI6D8A "Add++ – Try It Online")
[Answer]
**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
```
[Answer]
# [Stax](https://github.com/tomtheisen/stax), 8 [bytes](https://github.com/tomtheisen/stax/blob/master/docs/packed.md#packed-stax)
```
äN§lüy²Å
```
[Run and debug it](https://staxlang.xyz/#p=844e156c8179fd8f&i=[1,1,1]%0A[1,1,2]%0A[1,1,3]%0A[1,2,1]%0A[1,2,2]%0A[1,2,3]%0A[1,3,1]%0A[1,3,2]%0A[1,3,3]%0A[2,1,1]%0A[2,1,2]%0A[2,1,3]%0A[2,2,1]%0A[2,2,2]%0A[2,2,3]%0A[2,3,1]%0A[2,3,2]%0A[2,3,3]%0A[3,1,1]%0A[3,1,2]%0A[3,1,3]%0A[3,2,1]%0A[3,2,2]%0A[3,2,3]%0A[3,3,1]%0A[3,3,2]%0A[3,3,3]&a=1&m=2)
Translates to `-(b-a)(c-b)(a-c)/2`.
[Answer]
# [J](http://jsoftware.com/), 12 bytes
```
1#.2*@-/\4$]
```
[Try it online!](https://tio.run/##Tc0xCsJQFETRPqsYVAiK@ZoZq4AgCFZW1lqJQWzcf/U1VS6PVwxcOJ@6KO2o46BWW@01/L8rOt@ul9ovizenbnc/rB513ah5Pd9fjeqn4zBH5mFmZmZmYRZmmTMTNVETNVETNVETNVETDdEQDdEQDdEQDdEQnUbqDw "J – 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
[Answer]
# [Japt](https://github.com/ETHproductions/japt), 7 bytes
```
änUÌ xg
```
[Try it](https://ethproductions.github.io/japt/?v=1.4.5&code=5G5VzCB4Zw==&input=WzEsMiwzXQ==)
---
## Explanation
```
            :Implicit input of array U
ä           :Get each consecutive pair of elements
 n          :Reduce by subtracting the first from the last
  UÌ        :But, before doing that, prepend the last element in U
     g      :Get the signs
    x       :Reduce by addition
```
---
## Alternative
Takes input as individual integers.
```
NänW ×z
```
[Try it](https://ethproductions.github.io/japt/?v=1.4.5&code=TuRuVyDXeg==&input=MSwyLDM=)
[Answer]
# Java 8, 28 bytes
```
(i,j,k)->(i-j)*(j-k)*(k-i)/2
```
Port of [*@Dennis*' Python 2 answer](https://codegolf.stackexchange.com/a/160375/52210).
[Try it online.](https://tio.run/##ZZJBTsMwEEX3nGKUlUPiIGZ2VHADuukSWJg0INupWzVuJYR69uA4WdB@yflSxn6at/jOnI12Wz@2vRkGejU2/N4R2RC745dpO1pPv3lArZrS1lO6nL5cpdtL@tIZoom2pTUFeqZR2drVvtQvympX3iunfUqvbfnA42omDqfPPhELeN7bLe2SgNrEow3fbx@mnJfHbojqsabp5I1XI8aR3IwYQUaQERQEBUG5ARlVGVUZVRlVGVUZVRlVGVUZVQVVBVUFVQVVBVUFVQVVBVXln@p1v3JN8hts41yXzc8Qu12zP8XmkIoU@6BsVdRF5XL6qnh6j0UVmnYp6bLlMv4B)
[Answer]
# [Python](https://docs.python.org/2/), 33 bytes
```
lambda i,j,k:(i^j!=k or-~j-i)%3-1
```
[Try it online!](https://tio.run/##VY7NCsMgEAbP8Sm2h4KCQl1vAd@kFFLaEJM0DWIpvfTV7U@MccHL8I3LzK/Q3SeMrT3GsbmdLw042cuh5u7U7@wAd6/evXJib5SOz86NV9A1sIr/NSEDWHDT/AhcsMp/oU0Lq2bvpgBZlN7aEDnXEn5PSDgItiJSNAUilZHKuMg6oaGyWWRVzPk00g6kHZg7ls9IQ5CGYA5ZMYXoDZGuWTa0w@QOvWEppwylN0Y6l7ahpw2Vc8cH "Python 2 – Try It Online")
I tried for a while to beat the [product-of-differences approach](https://codegolf.stackexchange.com/a/160375/20260), but the best I got was 1 byte longer.
]