[Question]
  [
Your task is to determine whether some arbitrary programming language has zero-indexed or one-indexed arrays based on sample inputs and outputs
### Inputs
* An array of integers with at least 2 elements
* A positive integer index
* The value of the array at that index
### Output
One of four distinct values representing:
* **One-indexed** if the language unambiguously has one-indexed arrays
* **Zero-indexed** if the language unambiguously has zero-indexed arrays
* **Unknown** if the given inputs aren't enough to determine whether the language is zero- or one- indexed because it is ambiguous.
* **Neither** if the language is not zero- or one-indexed because it is something else that may or may not make any sense.
## Example Test Cases
Formatted as `[array, elements][index] == value_at_index => output`
```
[2, 3][1] == 2  ==>  one-indexed
[2, 3][1] == 3  ==>  zero-indexed
[1, 2, 2, 3][2] == 2  ==>  unknown
[4, 5][1] == 17  ==>  neither
[-3, 5, 2][2] == 5  ==>  one-indexed
[-744, 1337, 420, -69][3] == -69  ==>  zero-indexed
[-744, 1337, 420, -69][3] == 420  ==>  one-indexed
[-744, 1337, 420, -69][3] == -744  ==>  neither
[42, 42, 42, 42, 42][2] == 42  ==>  unknown
[42, 42, 42, 42, 42][1] == 56  ==>  neither
```
## Rules and Scoring
* Use any convenient I/O methods
* Use any convenient representation for each of the four distinct categories as long as it is consistent and each possible category is mapped to exactly one value.
* You may assume that all array values are between \$-2^{31}\$ and \$2^{31} - 1\$, inclusive (i.e. the signed int32 range.)
* You may assume that arrays are no longer than \$65535\$ elements.
* You may assume that the index is in-bounds for both zero- and one-indexed semantics.
Shortest code wins. Happy golfing!
  
[Answer]
# [convey](http://xn--wxa.land/convey/), 47 bytes
Returns 0 for neither, 1 for one-based, 2 for zero-based and 3 for unknown.
```
{2+~`0
?;\2:!2[
v^<]`
?;\?+2
v^< v*+}
!>>>=?^
2
```
[Try it online!](https://xn--wxa.land/convey/run.html#eyJjIjoiezIrfmAwXG4/O1xcMjohMltcbnZePF1gXG4/O1xcPysyXG52XjwgdiorfVxuIT4+Pj0/XlxuMiIsInYiOjEsImkiOiIyXG4xIDIgMiAzXG4yIn0=)
Run for `1 2 2 3` with index `2` and value `2`:
[![full run](https://i.stack.imgur.com/3YXtw.gif)](https://i.stack.imgur.com/3YXtw.gif)
On the left we split the input lines with `;\ ^<` into the three paths.
The first one pushes two zeroes after `length of path + index` time steps into the `+`. The second one path tries to push the array into `+` – if there are values waiting (the two zeroes), they get passed through unaltered. Otherwise, they get deleted `?]`. The two values then get pushed into `=`, where they are compared to the third input. The result are two boolean bits. The second one gets multiplied by 2, then they get added together.
[Answer]
# Brainfuck, 43 bytes
`,>,[->,<],<[->->-<<]>[[-]>>++<<]>[[-]>+<]>.`
Arguments are taken in this order: value\_at\_index, index, array values.
Outputs are: 0-unknown, 1-zero indexed, 2-one indexed, 3-neither.
## How it works
```
,               read value_at_index into first cell
>,              read index into second cell
[->,<]          read the array till the one indexed element is found and store it into third cell
,               store the zero indexed element into second cell
<[->->-<<]      substract value_at_index from both saved elements
>[[-]>>++<<]    if the zero indexed element isn't equal to zero then add 2 to result
>[[-]>+<]       if the one indexed element isn't equal to zero then add 1 to result
>.              print the result
```
[Answer]
# [Haskell](https://www.haskell.org/), 27 bytes
```
(l%i)n=[l!!j==n|j<-[i,i-1]]
```
[Try it online!](https://tio.run/##hZBNCsIwEIX3nmK6EBqYgE36g2CO4AlCkFBaTU1DMV16dmPaILqRwgTmve8RHnPT/t5ZG0Ju94Y4IW2WDUK453Ci0qChhVJh7vx8abXvPAiQuWQIXCEUCIwg/Gq@6gWss7jskyoRqpQqmtWgPDqRplCVvKaMuYLzBqFkBwRaHyPn67KRiGrrj0hSF7ag35dKlOw/jsWrmqhdL/I92Y3auHiNUU9nmB7GzSB7sGDAwRNyiwYdOdHv5VR4tb3VVx9oO01v "Haskell – Try It Online")
Outputs a two-element list like `True/False`.
**28 bytes**
```
(l%i)n=[l!!i==n,l!!(i-1)==n]
```
[Try it online!](https://tio.run/##hZBBCsIwEEX3nmJcFBKYgE1ai2CO4AlKkVBaDaYhmC49u3HaILoRISHz//uEz1xNvA3OpcRcYbnXrdturdYe6WVWlJzmLs1DnM@9iUMEDS1rJYLqEEoEyRG@tVr1AtazuPKdqhDqnCqb1RCKHKI5VGevqShXKtUgVHKHIPYH4mod/iRI/fuDSO4iF/R9c4lK/sZUvN7zbjNqVvDNZKynbUwmnCDcrZ@hHcGBBQ8PYA4ten4Un8116dmPzlxiEn0ILw "Haskell – Try It Online")
**28 bytes**
```
(l%i)n=(==n).(l!!)<$>[i,i-1]
```
[Try it online!](https://tio.run/##hZBdCsIwEITfe4oVFBLYiE36g2C8gScoRUJpNRhDMX307MY0QfRFChvYmW8Iw16Vu/XGeE/MRlMriZSWbolZrehhfWw0apa3furddO6U6x1IaEjDEUSLkCNwivCrRdQziDO7/JMqEMqUyutoMBGcQFOoTF5dhFwuRI1Q8B0Cq/aBi7gsJIJa@iOQ1IXP6PelEgX/j0PxsqJtNkiyodldaRuucVfjCcaHthM0AxjQYOEJxKBGSw/se7nWv7rBqIvzrBvHNw "Haskell – Try It Online")
**29 bytes**
```
n?i=map(==n).take 2.drop(i-1)
```
[Try it online!](https://tio.run/##hZBBCsIwFET3nuIvE/gRm7QWweIJPEEpEmrV0BiD6dKzG38bit2IkEBm3hCGuenQd9bG6A6mumvPqsrx9aD7DuT6/Hx4ZkTG49CF4dTq0AWooGa1RFANQoYgOcJSq0mPYDqjK@dUjlCkVFZOhlDkEE2hInllTrlMqRIhlxsEsd0RV9PjT4LUvz@IpC5yRMubSuTyN6bixZY3qwtYMOBoCkazcbu6azMq2u8I/mncAPWceQGzaNDxvfiO2MR3e7H6GqJovf8A "Haskell – Try It Online")
[Answer]
# JavaScript (ES6), 30 bytes
Returns **0** for *neither*, **1** for *0-indexed*, **2** for *1-indexed* or **3** for *unknown*.
```
(a,i,v)=>a[i]==v|2*(a[i-1]==v)
```
[Try it online!](https://tio.run/##nZHfDoIgFIfve4pzqQ0yAXVd2Iu0LpxiUQ6albXWu9tBa2vmny0GG4x9349zOCRVck5LdbpQbTJZ53HtJESRyo3XyUZt47h6srmDW@rbg1unRp9NIReF2Tm5s2EE@JaAT4C5LvQMzwMwWlKlM3mX2WyQ58P8Q5ZmSGCTm2k1rOcZVnDVR21uussKAkEb7ke96ZbVUl32suyylCOMcW1q8ItPFE4jgfE@5xEBwZYEaLhCF2821jZV@LAATx/Bfw/AGxSMFC@YZb5X2wbx6f5Y0/tY/IIg/GLfufUL "JavaScript (Node.js) – Try It Online")
or **28 bytes** by outputting a pair of Boolean values:
```
(a,i,v)=>[a[i]==v,a[i-1]==v]
```
[Try it online!](https://tio.run/##nZFNDoIwEEb3nmKWkExV2gJxgRchLIgUrZLWoKLx8jgVTYzyk0hoWtK8980M@7zJT5taH8/M2EK1ZdJ6OWps/GSd5qnOkqRB2lngTlm7seZkKzWv7NYrvZQjiAwhQOC@Dz3PYgFgjWLaFOqmitkgL4b5u6rtkMAlP1@n4T1lOMHFHIy9mm9WIoRdeBD3pjvWKH3eqfqbZYJgiutSw198onEWS4oPhIgRJF8isGhFLvE8ONtU48MC@noL/iuAbkgw0rzkjvlc3Rjke/pjQ@9j6ReE0Qf7ym0f "JavaScript (Node.js) – Try It Online")
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 5 bytes
```
+.ịẹ⁵
```
[Try it online!](https://tio.run/##ASUA2v9qZWxsef//Ky7hu4vhurnigbX/w6fFkuG5mP//Mf9bMiwzXf8y "Jelly – Try It Online") or [see the test cases](https://tio.run/##y0rNyan8/19b7@Hu7oe7dj5q3Pr/4c5VEO6ORdVAIa7Dy5WOTnq4c8b//9FcnNHRRjrGsToKhrE6nJycygrRhrGcGvl5qQqZeSmpFakpmliUGAGVVKUW5aOoMdQx0oGoM4IbpQNSWZqXnZdfngdWZKJjimwQUDYvNbMkI7UILKtrrGMK1IJsAhbH6JqbmADNMDY211EwMTLQUdA1swTqAdqM0234tZBuCZq7TYxAipAx1A/YwwCbakNMg2P/A4MTGKSG5sBQAVqvA3IH2F1AXaZmAA) (slightly modified to run as a function)
Full program, takes input as `index`, `array`, `value` on the command line.
Outputs `[1]` for one-indexed, `[2]` for zero-indexes `[1, 2]` for unknown and `[]` for neither
## How it works
```
+.ịẹ⁵ - Main link. Takes index on left and array on right
 .    - Yield 0.5
+     - Add to index
  ị   - Yield [array[index], array[index+1]]
   ẹ⁵ - Return the indices of the value in that array
```
[Answer]
# x86 (with MMX) machine code, 9 bytes
(Same machine code works in 64-bit and 32-bit modes; 16-bit mode doesn't have scaled-index addressing modes.)
2 boolean compare results from `array[index-1] == element` and `array[index] == element` can be concatenated to produce a 2-bit return value: one or the other set means we can tell that it's 0 (first) or 1 (second) indexed. Neither set means "neither", both set means "unknown". Apparently we don't consider it ambiguous if the expected element is also present somewhere else in the array; "neither" is only a fallback that we don't have to consider if 0-indexed or 1-indexed explains the observation.
So we only need to look at 2 elements at `index-1` and `index`, e.g. with a packed-compare of those 2 elements in parallel. That's exactly what [MMX `pcmpeqd mm1, mm2/m64`](https://www.felixcloutier.com/x86/pcmpeqb:pcmpeqw:pcmpeqd) does.
Array pointer in EDI/RDI, index in EDI/RSI, expected element in mm0 (in the low 32-bit element), retval in mm0
```
  line  offset   machine            NASM source
    #             code
     1                         compare_at_index:
     2 00000000 0F62C0             punpckldq   mm0, mm0                 ; broadcast expected
     3 00000003 0F7644B7FC         pcmpeqd     mm0, [rdi + rsi*4 - 4]   ; compare integers at array[i-1, i]
     4 00000008 C3                 ret
  size = 9 bytes
```
Return values, as a SIMD vector of 2 32-bit dword elements `[low, high]` (shown in memory order, not Intel's usual notation of highest element first):
* `[-1, 0]` means 0-indexed, only the first matched
* `[0, -1]` means 1-indexed
* `[-1, -1]` means "unknown"; both matched
* `[0, 0]` means "neither"; neither matched
(Untested but I'm confident this works, and writing a test harness would be significantly more work for asm. SIMD packed compares are a pretty normal thing to work with.)
If you wanted to compact that return value into a scalar integer bitmap, that costs 3 bytes for [`pmovmskb eax, mm0`](https://www.felixcloutier.com/x86/pmovmskb) (`0F D7 C0`) which would give you a `0x0F` / `0xF0` / `0xFF` / `0x00` result in EAX.
(If this was an XMM register, we could use `movmskps` to get 1 bit from each 4-byte element, instead of 4. Or `movmskpd` to get 2 bits total from a 16-byte vector. But SSE2 instructions on XMM registers are 1 byte longer than MMX, so even using 64-bit array elements wouldn't let us keep the code-size the same. Also, SSE2 would require a 16-byte memory operand to be aligned unless you use a separate `movups` load instruction, although AVX allows `vpcmpeqq xmm0, xmm0, [rdi+rsi*8-8]` with no alignment requirement.)
Most standard calling conventions expect you to use `emms` after using MMX registers, but I'm considering a hypothetical system where it's normal to pass around integers in MMX registers, never returning the FPU to x87 mode.
If you wanted the expected-element to arrive in an integer register, say EDX, you could use `0F 6E C2` `movd mm0, edx` before punpckldq. Unfortunately, `vpbroadcastd xmm0, edx` requires AVX512 with its longer EVEX encoding, and only works for 16-byte XMM registers not 8-byte MMX. If we took the element as a stack arg, `pshufw mm0, [rsp+8], 0b0100_0100` is 6 bytes total, same as movd+punpckldq. 2 register args with the rest on the stack is a pretty normal calling convention, especially for 32-bit mode (e.g. `__fastcall`, but that would want `ret 4` callee pops. So maybe `gcc -m32 -mregparm=2` with `[esp+4]`). Not that we need to justify our calling convention as being a standard one.
[Answer]
# [Pyth](https://github.com/isaacg1/pyth), 11 bytes
```
xE,@QJE@QtJ
```
[Test suite](http://pythtemp.herokuapp.com/?code=xE%2C%40QJE%40QtJ&test_suite=1&test_suite_input=%5B2%2C3%5D%0A2%0A1%0A%5B2%2C3%5D%0A3%0A1%0A%5B1%2C+2%2C+2%2C+3%5D%0A2%0A2%0A%5B4%2C5%5D%0A17%0A1%0A%5B-3%2C+5%2C+2%5D%0A5%0A2%0A%5B-744%2C+1337%2C+420%2C+-69%5D%0A-69%0A3%0A%5B-744%2C+1337%2C+420%2C+-69%5D%0A420%0A3%0A%5B-744%2C+1337%2C+420%2C+-69%5D%0A-744%0A3%0A%5B42%2C+42%2C+42%2C+42%2C+42%5D%0A42%0A2%0A%5B42%2C+42%2C+42%2C+42%2C+42%5D%0A56%0A1&debug=0&input_size=3)
---
Takes input in the form:
```
list
value
index
```
Translation of [caird coinheringaahing](https://codegolf.stackexchange.com/users/66833/caird-coinheringaahing)['s Jelly answer](https://codegolf.stackexchange.com/a/219851/78186).
[Answer]
# [R](https://www.r-project.org/), 26 bytes
```
function(a,i,n)a[0:1+i]==n
```
[Try it online!](https://tio.run/##hY7BCsIwDIbvPkWOLaawJu2K4p5EPIxBoZcKos9f02WIXhykkH7/R/gfLcPFtfyqy7Pcq5mxYLXzdTj7Y7lNU23ZLIYQ2CJ4BLKHX8AKerROx/TxAkJUzycljgX1fNXiBlMQ0zMnhEADghtPIrAuO4r8dq9IshWinn0/LRLoTy7142jbGw "R – Try It Online")
Inputs array `a`, index `i`, value `n`.
Outputs a boolean pair: `F T = 0`, `T F = 1`, `T T = unknown`, `F F = either`.
Full program for the same byte count, inputs in the order of `i n a` merged into a single vector:
## [R](https://www.r-project.org/), 26 bytes
```
a=scan();a[2:3+a[1]]==a[2]
```
[Try it online!](https://tio.run/##hY5LCsMgEED3PcUsHTqB6piEfjxJcCFCIBsL/axKz27HGELpogEF572HzC2PcGlgfKb4mK5JBZoo0T2G5FaGURUYEOGVgytS4TkM5sT7MGjvnZPB5/duVFEZAkYCTWDwB3AFRc2nYLN2lqCtne4raVhQ8XPWLrC3UmrmnsCaA0HTHSXg@thIZNr8RcyykCnu@9ZFrPnjZf22w/wB "R – Try It Online")
[Answer]
# [APL (Dyalog Unicode)](https://www.dyalog.com/), ~~15~~ 13 bytes
Saved 2 bytes thanks to Kamil Drakari
```
{⍵=⍺⍺[⍺,⍺+1]}
```
[Try it online!](https://tio.run/##SyzI0U2pTMzJT///P@1R24TqR71bbR/17gKiaCDWAWJtw9ja//@NFTQOrTc3MVEwNDY2VzAxMlA4tN7MUiFNE0I/6p2rEJValK@bmZeSWpGawmUEUm@sYKpgBFJjqoACQKr981LhioGGmxgpICOgHiAJUxual52XX56HXZ2pGVydX2pmSUZqEQA "APL (Dyalog Unicode) – Try It Online")
Call it with `index (array f) value)`. Returns `0 1` if it's zero-indexed, `1 0` if it's one-indexed, `1 1` if it's unknown, and `0 0` if it's neither.
```
{⍵=⍺⍺[⍺,⍺+1]}
      [     ]   ⍝ Index into
    ⍺⍺          ⍝ the array (the left operand)
       ⍺        ⍝ at the given index (the left argument) (one-indexed)
        ,       ⍝ and (parentheses would have been better, but , saves a byte)
         ⍺+1    ⍝ index+1 (zero-indexed)
 ⍵=             ⍝ Compare the value (right argument) to this 2-element vector
```
[Answer]
# [MATL](https://github.com/lmendo/MATL), 5 bytes
```
tQh)=
```
Inputs are: index, array, value. Outputs are `1 0` for one-indexed, `0 1` for zero-indexed, `1 1` for unknown, `0 0` for neither.
[Try it online!](https://tio.run/##y00syfn/vyQwQ9P2/39DrmgjHQXjWC4jAA) Or [verify all test cases](https://tio.run/##y00syfmf8L8kMEPT9r9LyH9DrmgjHQXjWC4jLjjTGMiJNtRRMAIjmJyJjoJpLJehOUhS1xjIAcrGcpkCVUfrmpsAZQ2Njc11FEyMDHQUdM0sY7mABG5JIAuPTqAoyBoTI5AoMgZpBDsGi4ypGQA)
(Also for 5 bytes: `FT+)=`).
### Explanation
```
t    % Implicit input: index. Duplicate
Q    % Add 1
h    % Concatenate
)    % Implicit input: array. Apply index
=    % Implicit input: value. Test for equality. Implicit display
```
[Answer]
# [Perl 5](https://www.perl.org/) -`apl`, 40 bytes
```
$_=1*($F[$i=<>]!=($t=<>)).($F[$i-1]==$t)
```
[Try it online!](https://tio.run/##K0gtyjH9/18l3tZQS0PFLVol09bGLlbRVkOlBMjQ1NSDCOoaxtraqpRo/v9vpGDMZchlxAWhjblMjBSQEFDCxAhTzNTsX35BSWZ@XvF/XV9TPQNDg/@6iQU5AA "Perl 5 – Try It Online")
Input is on three lines:
```
Space separated list of numbers
index
target value
```
| Output | Meaning |
| --- | --- |
| 0 | Zero-indexed |
| 11 | One-indexed |
| 01 | Unknown |
| 1 | Neither |
 
[Answer]
# [Japt](https://github.com/ETHproductions/japt), 8 bytes
```
gVôJ)®¥W
```
[Try it online!](https://tio.run/##y0osKPn/Pz3s8BYvzUPrDi0N//8/2lBHwQiMjGMhLAA "Japt – Try It Online") or [check all test cases](https://tio.run/##lU9LCsIwEN33FLMVJpBJ0hYpXsCdi5hCyMKFFATBhVfq1pUnqAeLkzZCrSIIyWPC@@TN6XC5xsJ21LiN7VTTMurGMsrY7R/37Wq4Db2L7dFFX3ivEHRAIEBQwACeUIaA75SeKIk0UcTq8SSBmnuzwCCU2Uv1y5xzhWaSLdlaLr4VtWE3aV0jGCURRLUOqcI4LYr8EPPzj2SmFjWNSqr5zYXNx7LflGn1spplFgHEefcE)
Outputs `[true, false]` for one-indexed, `[false, true]` for zero-indexed, `[true, true]` for unknown, and `[false, false]` for neither. Takes inputs in the order `array, index, value`.
Explanation:
```
gVôJ)®¥W    
 Vô         # Create an array starting at input 2...
   J)       # ...And ending -1 integers later
g           # Get the values from input 1 at those indices (0-indexed)
     ®      # Replace each value with:
      ¥W    #  Is it equal to input 3?
```
[Answer]
# [C (gcc)](https://gcc.gnu.org/), ~~42~~ 40 bytes
Saved 2 bytes thanks to [att](https://codegolf.stackexchange.com/users/81203/att)!!!
```
f(l,i,e)int*l;{e=l[i]==e|2*(l[i-1]==e);}
```
[Try it online!](https://tio.run/##jZRtj5swDMff8yksJCToBY1nyji2F9M@RYumioZbNMZVTaVV6/jqYwmJKWQ96RBExv@fY@o6bvyXphnH1u0II9Rj/WXTlTdadTtWVxX9E21cYfqhfPHKYTy5E0LECtyDmwXial/PIP3AqqAE9sxLeHpi3qTJ63QWYuvaDneONnHZZ5uA/dG2PQIyj1dagyXDfx5Y73qW2lQ6LpRfvnXBroYKbhGBeCgX/vANf6T8IYFoutdqrNSEQLryJ8rvx0IQYSst1VqeiLAwjnMCSRQQ8LNixWXv5PJ3clv9rZHUl8@KKt6msJIbjSpSl5VgHdGI0IjRSNBI0cjQyNHYolHc8ykP1/k4@01fW1en9T7o9w06CKyI0CRCk4hMIjKJ2CRik0hMIjGJ1CRSk8hMIjOJ3CRyk9iaxNYkCpMoPLPSbG551fVqjfGWHjOE3k@PAvKp8UULYjNO3Sk7Kc0WwfR6os2FHufwcNohWOQNlEcHNd8P541YafODnlWUvb9@jfbX4ot4UjkMFu@xrePuU6U/0qsIk7NlMp@xPvgt9wLNnmkESRqH1HwSOrGVPg0TUJdLHRjK7KFMUaYPZS5kHKZrpcdA/jiv/IVzbU0AJ@jOXux6Enl673@o3jlHUeYKnCP4n@Tq8H0vyswIUNFbZP4zeFVda73DYA3j36btDi989H/9Aw "C (gcc) – Try It Online")
Inputs a pointer to the array, the index, and the test element.  
Returns \$2\$ for \$1\$-indexed, \$1\$ for \$0\$-indexed, \$3\$ for unknown, and \$0\$ for neither.
[Answer]
# Java, 44 bytes
```
a->i->v->a[i]==v?a[i-1]==v?1:2:a[i-1]==v?3:4
```
Returns:
* 1, if unknown
* 2, if zero-indexed
* 3, if one-indexed
* 4, if neither
[Try it online!](https://tio.run/##rY4/T8MwEMX3fIobE5Skyh@EZNMgFiQGxFAxRRlM6hS36TlyLqlClc8eTAntxIDgZOnePZ9/flvRi2C73k1q32hDsLVz2JGqw6rDkpTG8Io7TtO91qqEshZtC09C4dEBW7PdkiDbeq3WsLeX7oqMwk1egDCb1vva/ayHmXmrkPLCh0eks2X1CwozPDfSCNImy6BaTiLIVJD1QSZyVSyX/Z3tQXRSEYvZZUpYOvHzR4tFxKDDHeoDcogZvEujOSQMNEoOKQOUit6kOb9YDS3Jfag7Chsbnmp0q1A0TT24KA9wCnyM/WT0ZjeaxX1rk7ux5/H/YiW/ZkU@xKdzQcZ/jJf61z/Ei26@YaMzTh8)
[Answer]
# [PowerShell](https://github.com/TryItOnline/TioSetup/wiki/Powershell), 38 36 35 bytes
Takes three arguments: the array to index into, the index to test, and the number to test for. Outputs 0 or 1 for 0 or 1 based indexing, respectively, outputs 0 and 1 for unknown, and outputs nothing for neither.
```
param($a,$b,$c)0,1|?{$a[$b--]-eq$c}
```
[Try it online!](https://tio.run/##tZPRaoMwFIbvfYog2aY0lkZty5AwoWywm22svSulqEtZi1ZnlA2sz@6SqG0v5oSOBSXJye93/hw5SfxJU/ZOw7CCG6IAPooq8VIv0qCHoI9goI8QPtwV0FtC3zBWBv2AQVkJZanAjLJs5jHKAAGuJr93CzmJsd0neSYW4tDVTAQsHWFk6kcF/UpokNE3qcB1vET9CKsDMepHYARM@XCQ2emFX7ofZSMwFm7wtIPSjzAszuB2hJfx5XUxpjY3gy1rioBtjhAwJrc6spCYLq5UF5Sv/8Epj19cRdsUsPNX1NP@28/9gYnRePK7SUVX4II3BSMidOqPw1UhN0955NOU4LLOC2VSBFsUgethE1oP22CtTCnLw4zn0q7hBrhSVSeFLA8CyhhRG5HKm1Q9MtVaJF0NyPJlPstZFkfP/o4fr9ziRpzckDN7g4Ezb5At23kU@YhWG@a3UZdQg2tjF2/3KgKqvlJL/bhzXqWPkyHnvr3gma9SKZtiHR7iNPIyY@H5Ia2@AQ "PowerShell – Try It Online")
# [PowerShell](https://github.com/TryItOnline/TioSetup/wiki/Powershell), 33 bytes
This version has completely unintuitive output, but still works. Outputs 1 for 0-based, 0 for 1-based, 0 and 1 for neither, and nothing for unknown
```
param($a,$b,$c)0,1|?{$c-$a[$b--]}
```
[Try it online!](https://tio.run/##tZNda8IwFIbv@ytCyWaLJ2I/VEYJK8gGu9nG9E5E2i4yxa81LRvU/naXpK16sdKhLLQkOefte56ckt32i8X8g61WBzynGhIjO@yCOFgbOAAcAo7MLlj7@wxHBAcTHBIyzQ9Sl2s4YTwZBpxxRJFvqK/9TE1yLDa7NJELmfQNG5BjggW2eVSw7x2LEvauFN0inkOzhVNjYTVbWIBs9Qgju5al2ccF1JMo1qDuOPAHGuIIG4EjWXqX94UMXMFjOc4AkGt3AZH@nQkOyOniTtWZivU/kIr4NY10bel3/sqWulf8318MLej1GyE1U8NjcS84lWVOV2R/k6nNc7oOWUytvCiNVV3AlRvFs04ZmnWqYKGMGU9XiShn3OI58pWqKIp5GkWMc6qXIp2wT/3oqRciRdWmk9fRMOXJdv0SLkV66mctmWnRM7x22xuVlpW39yTrUaMAFqfRJ9jAM7LcLjY6IN2c6rl53HlviuME5D1UBzzjyrW8bNb@cRuvg4SMg3DFDj8 "PowerShell – Try It Online")
[Answer]
# [Charcoal](https://github.com/somebody1234/Charcoal), 9 bytes
```
Ｅ²⁼ζ§θ⁻ηι
```
[Try it online!](https://tio.run/##S85ILErOT8z5/z@gKDOvRMM3sUDDSEfBtbA0MadYo0pHwbHEMy8ltUKjUEfBNzOvtFgjQ0chUxMErP//j47WNTcx0VEwNDY211EwMTLQUdA1s4zVUTAG82L/65blAAA "Charcoal – Try It Online") Link is to verbose version of code. Output key:
```
Neither  0-indexed   1-indexed   Unknown
         -                       -
                     -           -
```
Explanation:
```
 ²          Literal `2`
Ｅ           Map over implicit range (i.e. `0`, `1`)
       η    Second input
      ⁻     Subtract
        ι   Current value
    §       Indexed into
     θ      First input
  ⁼         Equals
   ζ        Third input
            Implicitly print
```
[Answer]
# [J](http://jsoftware.com/), 13 bytes
```
1 :'=u{~],<:'
```
[Try it online!](https://tio.run/##hY9BS8NAFITv@RWDl00hCdndpMHF9aDgSTyItxJKaF9ppSbSjSAK/vX4Nk0gpUVh9x1mvpl9@9pdJWIDayAQIYXhGye4f3586CSMsB/fP2V0Y0Q3C57uEixUBF0uZAlrocDzFmhqinf1mj5p3UOSSyy@6NCcyCkb9gLs1VVVixYt7fcD6htq2rVbOgQBrbYNxAu5lkFHznDmjara4b1yTgyA748NbxUqaGxmkEfdr8O6PtdHXvIYPDV29RlZIMyQT0LDIznCpeapJpnhneX8ms0iyyC1LpCptJeY0ycV3viHO/Z55E9QjoW8rML0nH0on19iZPcL "J – Try It Online")
Thanks to [user's APL answer](https://codegolf.stackexchange.com/a/219861/15469) for suggesting the idea of using a J adverb to emulate a 3-argument function
The solution is an adverb `f` that operates like this:
```
<expected value> (<array> f) <index>
```
Return value key:
```
1 0 = zero-indexed
0 1 = one-indexed
1 1 = can't tell
0 0 = neither
```
* `=` Does the expected value equal...
* `],<:` The index, catted with "index - 1"
* `u{~` Both taken from the given array? (In J, within an adverb definition, `u` is the canonical name given to "the noun or verb being modified")
[Answer]
# [Python 2](https://docs.python.org/2/), 32 bytes
```
lambda l,i,n:[l[i]==n,l[i-1]==n]
```
[Try it online!](https://tio.run/##hY9NCoMwEIXXeoosFUYwPyoVcpI0C0srBmwqYik9fTpOilho6SJk8t43bybTcxluXoReH8PYXU/njo3gwLdmNM5q7QHvgq@VDY/BjRfG2zQhBmbt/HRfsjxNptn5hfUZGTmwOWRGAJMWGAeGleE2T/eaRK0kLQJvJ1amRIZMBayKDbxBnbQCeyvkIl5t4UWjEOdSIqkERhT1wdIkLLZxvyl6/c8iJ26ixOruT9xJff7hG4U/qmrKeQE "Python 2 – Try It Online")
Outputs a two-element list of Booleans for whether 0-indexing and 1-indexing are consistent with the input.
[Answer]
# [Wolfram Language (Mathematica)](https://www.wolfram.com/wolframscript/), ~~25~~ 24 bytes
```
Sign[#2[[#;;#+1]]-#3]^2&
```
[Try it online!](https://tio.run/##hY6xCsIwFEX3fkUg0MUXMC9pSylKP0FwDBGKWO3QDtIt5NvjS6KggwoJ5N5zCHce1ttlHtbpPIRxF47TdTEcjeFdxzfSWsGVPWEZDvdpWY3j3Iv9SAZwIGLLvu9d4RwCUx6YBIYePrJKOYJ0YosvSwOrsiWbVAhFTaJRqnLXaPKkUg0wjVtgom6Jq@fjp0Hp3x9E8haM6P3mERq/Yxpe1b7w4QE "Wolfram Language (Mathematica) – Try It Online")
Input `[index, array, value]`. Returns `{0,1}` for 1-indexed, `{1,0}` for 0-indexed, `{0,0}` for both, and `{1,1}` for neither.
[Answer]
# [jq](https://stedolan.github.io/jq/), 22 bytes
Inputs as: `[index, array, value]`.
Output key: `true,false` for 1-indexed, `false,true` for 0-indexed, `true,true` for unknown, `false,false` for 0-indexed.
```
.[1][.[0]|.-1,.]==.[2]
```
[Try it online!](https://tio.run/##yyr8/18v2jA2Wi/aILZGT9dQRy/W1lYv2ij2//9oQ51oIx0F41gdo1gA "jq – Try It Online") or [Try all testcases!](https://tio.run/##fU47DsMwCN17Cg7wjALYsTrkJIgLdOueuzu4qZQOVSRAvJ/g9R6DXcLZl9i5CDi2jV1jDBe4giyg8biAJVAkJv3UpVdQC0g/DcUSpiPQkrAkek2HmHVQ1QVU1mdgjhs5t9t0sue5qpP/7Rn@PvZHa2sc)
## Explanation
```
.[1]                    # Index the array by the indices:
    [.[0]               #    * The index
         |.-1,.]        #    * Prepended with the index - 1
                ==      # Vectorizing equality:
                  .[2]  # With the value
```
[Answer]
# [Rust](https://www.rust-lang.org/), 31 bytes
```
|a:&[_],i,v|(a[i]==v,a[i-1]==v)
```
[Try it online!](https://tio.run/##jZHfasIwFMav16c480IaSGVNqjKlgzF8Ar0rRYqmGFZTSVM3/PPs3UmEtU4HhsJJvu93Tr82uq5MsypVZWAxmy@WH@/z2XwC/cTvJ5KzlEJdyYOggAeSQoyOB7jQZhQ4@iEFRuityFvRIu6xFrviIwrDCx@OWzXgKCN3wYcdYxxhR8j5mELEXigEo1eEuNs8guHpoWnodEKyqUvJLHYrY/jhCOV06nm5gm0mlU/g6LBCGMghbk7ZpJ8sUyrp/uRniUzjeE@xBqHdkcay2G5LXmrwM/zjFPYEpOpczEAaoX0yWJU7Kda/L7Frm5nVBvK28eg9uZx5VlR4f64QiN9gp6UyhXr2e0pIsxG6h9mvWKPrv2ipRCDVWnyLdYtb7v7kg9Dlf/yd6bX6VOWXcuTZfdLZOzc/ "Rust – Try It Online")
Port of [Arnauld's JavaScript answer](https://codegolf.stackexchange.com/a/219850/85922). Returns
```
(false, false) => "neither"
(false, true) => "one-indexed"
(true, false) => "zero-indexed"
(true, true) => "unknown"
```
I had to include the `:&[_]` part for the code to compile, but I have the feeling that it can be optimized somehow.
[Answer]
# [Julia](http://julialang.org/), 18 bytes
```
l*i*r=l[i:i+1].==r
```
[Try it online!](https://tio.run/##jVFLTsMwEN37FKOIRVImVRwnjUAye84QskDUFQbLqRJXVFwDiRWn4yJhJrVEC0XCsuWZ997M8@dp5@y93E@TW9jFoF1rr@2l7JZaD1PvDWhoJRadeDVDz0mBshM7/@z7F38gKffGhkczHHgSi2DGMHIq0rZEUB1KLDMAfQNAXY9QFVHuT7BEKOdJJAeRjYYkqBBqrpNNpKI3Ubkijmq4sj4xy5uK6qRSDUJVFgj56qpDhbSd2v8lpPh/DQn/da6qZNHx4hNWZ@52RiixXv3oSO@76QdIA5oMrIf5sQXQcGiRfyHMGUe3PizT@WuzGbMbhjWYOeOxHawPzqfJ58cbJAiBvaLauPGs8P1biJDchdTst@YhmDVcmCyJtX4teE1f "Julia 1.0 – Try It Online")
overloads the `*` operator, expecting `array*index*result`
Outputs `[1,0]` for one-indexed, `[0,1]` for zero-indexed, `[0,0]` for neither and `[1,1]` for unknown
[Answer]
# [GolfScript](http://www.golfscript.com/golfscript/), 11 bytes
```
~].~==\~(==
```
[Try it online!](https://tio.run/##S8/PSStOLsosKPn/vy5Wr87WNqZOw9b2/39Dc4VoEwXTWAVDAA "GolfScript – Try It Online")
[Answer]
# [Ruby](https://www.ruby-lang.org/), 30 bytes
```
->(a,i,v){[a[i]==v,a[i-1]==v]}
```
returns:
* `[true, false]`, if zero-indexed
* `[false, true]`, if one-indexed
* `[true, true]`, if unknown
* `[false, false]`, if neither
[Try it online!](https://tio.run/##lZDfCoIwFIfve4oD3SicRW5T6cJeRLywnCTFDEn7R8@@ztRIaF40Nraxfefjd5p2dzdlYtjWy7HCzn@meVplSdIh7Sywp@xlzl652uenk5dyBJEhBAjc98ExlgC1VqzShbqpYuEixSz5UE3tQK2tn7YAd6gJbfVR11c9oSRCOAiD2GkkSqvqclDNhGKCMFIMpvAXnA3IYknKQIgYQfI1Aos2VEX0B1tnPuA8SrcR/VtKL4Q6Q0puf0/XEFd@OutuqIui9obRlxpd5g0 "Ruby – Try It Online")
]