text:
Where will the gem-picking robot end up?
Related puzzle: Pathfinder (available on Puzzle Picnic)
Background
A robot is standing on a cell of a rectangular grid, where each cell has one or more gems except for the one with the robot. The robot can move to a horizontally or vertically adjacent cell in one step, and it picks up one gem from the cell it steps on.
The robot is programmed with which cell to choose for its next step, based on the number of gems each adjacent cell contains. The program is in the form of a > b > c > ... > z, which means that the robot prefers to move into the cell with a gems, followed by one with b gems, and so on. Any such program contains positive integers from 1 to n exactly once, where n is the length of the program. The robot will never move into any cell with no gems.
If there are multiple highest-priority cells around the robot, or all the cells around it are empty, it will get stuck at that point.
For example, if its program is 1 > 3 > 2 (meaning, it prefers the cell with only one gem the most, followed by the one with 3 gems, and then 2 gems) and the current state looks like this (R is the robot, the numbers are gems):
0 3 2
2 R 1
1 2 3

Then it will choose the cell on its right because 1 has the highest priority. Assuming the cell with R is empty, it will continue moving down, left, left, right, right, then get stuck since the cells around it have no gems left.
0 3 2     0 3 2     0 3 2     0 3 2     0 3 2     0 3 2     0 3 2
2 R 1 --> 2 0 R --> 2 0 0 --> 2 0 0 --> 2 0 0 --> 2 0 0 --> 2 0 0
1 2 3     1 2 3     1 2 R     1 R 2     R 1 2     0 R 2     0 0 R
       R         D         L         L         R         R

Using the 1 > 3 > 2 program, it will get stuck at any of the following cases:
0 R 0  # all adjacent cells are empty
2 0 1
1 2 2

3 1 0  # there are two 1s around the robot, so it can't decide where to go
2 R 1
1 0 2

Challenge
Given the initial state of the entire grid and the robot's program, find the position (horizontal and vertical coordinates) in the grid where the robot will eventually get stuck.
The initial state contains the numbers between 1 and 9 inclusive, except for a single 0 which denotes the initial position of the robot. The program is guaranteed to contain all positive numbers that appear in the grid, and the program is always valid (contains each of 1 to the maximum value on the grid exactly once).
You can take the input (grid and program) in any suitable format, and output the coordinates in any sensible way.
Standard code-golf rules apply. The shortest code in bytes wins.
Test cases
In the example I/O provided, the program has the highest precedence coming first, and the coordinates are 1-based.
Grid:
0 2 1
3 3 2
1 1 3
Program: 3 1 2
Result: 2nd row, 3rd column (Path: DRDRUUD)

Grid: (one row)
0 3 2 3 1 4 4
Program: 4 2 3 1
Result: 1st row, 7th column (Path: RRLRRRRRLRLRLR)

Grid:
0 1 3
3 1 3
2 1 2
Program: 3 1 2
Result: 3rd row, 3rd column (Path: DRRULRDD)

Grid:
2 3 1 2 1
2 0 3 2 2
1 1 3 1 1
Program: 1 3 2
Result: 2nd row, 4th column (Path: DLUUDURRDDRRUULD)

Same grid as above, Program: 3 2 1
Result: 2nd row, 2nd column (Stuck at zero moves)

Python 2, 205 198 bytes
def s(g,w,r):
 p=g.index(0)
 while 1:
    a=[((r+[0]).index(v),n)for n,v in enumerate(g)if(abs(n-p)in[1,w])>(p-n)%w*(p/w!=n/w)];m,n=min(a)
    if~-sum(k[0]==m<len(r)for k in a):return p/w,p%w
    p=n;g[p]-=1

-6 bytes thanks to @ovs
-1 byte thanks to @user202729
Try it online!
Take the input grid as a flattened list with width also passed. Outputs 0-indexed (x,y) coordinates of the final position (I doubt index in the flattened list would be acceptable).
Explanation:
# Function of flattened grid g, width w, pRiorities r
def s(g,w,r):
    # starting position p
    p = g.index(0)
    while 1:
        a = [
            # pair (priority rank of the cell, cell id)
            # priority rank is n for v=0
            ((r+[0]).index(v),n)
            # for each adjacent cell id n with v gems
            for n,v in enumerate(g) if abs(n-p) in [1,w] and (p%w==n%w or p/w==n/w)
        ];
        # min comparison is done by tuple, so it selects one with minimum priority rank
        # m = min priority rank; n = corresponding cell id
        m,n = min(a)
        if sum( # how many adjacent cells
            k[0]==m # have priority rank equal to m
            <len(r) # and the cell value is not 0
            for k in a
        ) ^ 1: # If this count is not 1, then the robot is stuck; return
            return(p/w, p%w)
        # Otherwise, continue with updated position,
        p = n;
        # and take one gem
        g[p] -= 1

The if condition in the list comprehension can be written as if abs(n-p)in[1,w]>0==(p-n)%w*(p/w-n/w) and you don't need the brackets in the return statement.

Try it online!

Near the end it has p = s(g,h,w,r) which results in TypeError: s() takes exactly 3 arguments (4 given). To fix it change it to s(g,w,r)

if(abs(n-p)in[1,w])>(p-n)%w*(p/w!=n/w) is another byte shorter. (if(p-n)%w*(p/w-n/w)==0<abs(n-p)in[1,w] also works)

@blademan9999 Fixed

if x^1 = if x!=1 = if x-1 = if~-x?

Charcoal, 70 bytes
≔⪪Ｓ¹θＷＳ⊞υι≔⪫υ¶ηＰη…η⌕η0≔ＥＫＶ⌕θιυＷ⁼¹№υ⌈υ«Ｍ✳⁻χ⊗⌕υ⌈υＰＩ⊖ＫＫ≔ＥＫＶ⌕θκυ»≔⟦ⅈⅉ⟧υ⎚Ｉυ

Try it online! Link is to verbose version of code. Takes input as the program in ascending order of priority and then the newline-terminated grid and outputs 0-indexed coordinates. Explanation:
≔⪪Ｓ¹θ

Input the program as separate characters.
ＷＳ⊞υι≔⪫υ¶η

Input the grid.
Ｐη…η⌕η0

Print the grid without moving the cursor, then print the part up to the 0 so that the cursor is now at the starting cell.
≔ＥＫＶ⌕θιυ

Get the priorities of the neighbours of the starting cell (or -1 for directions that lie outside the grid).
Ｗ⁼¹№υ⌈υ«

Repeat while there is exactly one neighbouring cell of highest priority.
Ｍ✳⁻χ⊗⌕υ⌈υ

Move to that neighbour.
ＰＩ⊖ＫＫ

Decrement its value.
≔ＥＫＶ⌕θκυ

Get the priorities of the neighbours of the new cell (or -1 for illegal directions).
»≔⟦ⅈⅉ⟧υ

Capture the final position.
⎚Ｉυ

Clear the grid and output the position.

JavaScript (ES7),  142  130 bytes
Expects (program)(matrix), with highest precedence coming first for the program. Returns [column, row], both 0-indexed.
p=>m=>(g=(a,X,Y)=>a.some(k=>m.map((r,y)=>r.map((v,x)=>(X-x)**2+(Y-y)**2-1|v^k||(H=x,V=y,n--)),n=1)|!n)?g(p,H,V,m[V][H]--):[X,Y])``

Try it online!
Commented
p => m => (             // p[] = program, m[] = matrix
g = (                   // g is a recursive function taking:
  a,                    //   a[] = list of possible neighbor values,
                        //         from most to least preferred
  X, Y                  //   (X, Y) = current position
) =>                    //
  a.some(k =>           // for each value k in a[]:
    m.map((r, y) =>     //   for each row r[] at position y in m[]:
      r.map((v, x) =>   //     for each value v in r[]:
        (X - x) ** 2 +  //       compute the squared distance
        (Y - y) ** 2    //       between (X, Y) and (x, y)
        - 1 |           //       abort if it's not equal to 1
        v ^ k ||        //       or v is not equal to k
        (               //       otherwise:
          H = x, V = y, //         save (x, y) in (H, V)
          n--           //         decrement n
        )               //
      ),                //     end of inner map()
      n = 1             //     start with n = 1
    )                   //   end of outer map()
    | !n                //   yield a truthy value if n = 0
  ) ?                   // end of some(); if truthy:
    g(                  //   do a recursive call to g:
      p,                //     using a[] = p[]
      H, V,             //     using (X, Y) = (H, V)
      m[V][H]--         //     decrement the cell at (H, V)
    )                   //   end of recursive call
  :                     // else:
    [ X, Y ]            //   we're stuck: return (X, Y)
)``                     // initial call to g with a[] = ['']

Because g is first called with a = [''] and both X and Y undefined, the test on the squared distance is disabled (because it's always NaN'ish) and v ^ k is equal to 0 only if v == 0. So the first recursive call is triggered on the 0 cell as expected.

C (gcc), 289 \$\cdots\$ 246 243 bytes
Saved a whopping 37 41 43 46 bytes thanks to ceilingcat!!!
q;c;v;s;d;i;b;u;r;f(g,e,w,p,n)int*g,*p;{r=wcslen(g);for(c=d=0;c-n&&!d;!d&c<n&&--g[r=s])for(c=n,b=4;b--;d=v?q<c?c=q,s=u,0:q>c?d:1:d)for(i=~-(b&2)*(b&1?1:w),v=g[u=r+i]*(u>=0&u<e)*(r%w|~i&&r%w-w+1|i-1),q=0,i=n;i--;)q+=v-p[i]?0:i;*g=r/w;g[1]=r%w;}

Try it online!
Inputs the grid as a flat array, the length of that array, the grid width, the program as an array of integers and the length of the program.
Returns the robot's final position (as zero-based row and column) by storing them in the first two positions of the grid.
Before golfing
new_rank;current_rank;new_value;current_pos;has_doubled;i;news_bits;new_pos;robot_pos;
f(grid,grid_end,grid_width,prog,prog_end)int*grid,*prog;{
    for(robot_pos=0;grid[robot_pos];++robot_pos);
    for(current_rank=has_doubled=0; current_rank!=prog_end && has_doubled == 0;) {
        for(current_rank=prog_end,news_bits=0; news_bits<4; ++news_bits) {
            i = (news_bits&2 - 1)*(news_bits&1?1:grid_width);
            new_pos = robot_pos + i;
            new_value = new_pos >= 0 && new_pos < grid_end?grid[new_pos]:0;
            if((robot_pos%grid_width == 0 && i == -1) ||
               (robot_pos%grid_width == grid_width-1 && i == 1))
                new_value = 0;
            for(i = 0; i < prog_end; ++i)
                if(new_value == prog[i])
                    new_rank = i;
            if(new_value > 0 && new_rank == current_rank) {
                has_doubled = 1;
            }
            if(new_value > 0 && new_rank < current_rank) {
                current_rank = new_rank;
                current_pos = new_pos;
                has_doubled = 0;
            }
        }
        if (has_doubled == 0 && current_rank < prog_end) {
            robot_pos = current_pos;
            --grid[robot_pos];
        }
    }
    grid[0]=robot_pos/grid_width;
    grid[1]=robot_pos%grid_width;
}

Suggest b&1?:w instead of b&1?1:w

J, 109 bytes
Takes in the program on the left, the grid on the right, and returns the 1-based end position.
($-_2&u)@((](r@|.~d{.@/:])`[@.(]2=/@{./:~)[i.(d=:(,-)=i.2){::])^:_)0(]|.~u=:$@]#:(i.~,))_1(r=:-1$!.0~$)@,._,]

Try it online!
How it works
Because I didn't want to handle 3 arguments (program + grid + current position) as this is awkward in tacit J definitions, this approach shifts the grid around with the upper left tile having the robot. A fix point _2 to reconstruct the end position is in the padding.
 _1(r=:…)@,._,]

Pad with _ on the top, and _1 on the left.
 r=:-1$!.0~$

This subtracts one from the top left tile. That makes the _1 to a _2, and as we'll use this later again, assign this function to r.
 0(]|.~u=:$@]#:(i.~,))

This is a bit longer than needed, but in this version we can assign x u y to find the position of x in the grid y. Here we use it to shift the grid so the 0 is at the top left – later we'll use it to search for the _2.
 (…)^:_

Until the output of … does not change, i.e. until the robots moves:
 (d=:(,-)=i.2)

The 4 directions, saved as d.
 (d=:…){::]

Get the numbers at the directions, e.g. 0 0 3 1.
 [i.

Find their position in the program with non-found numbers like 0 _ _1 having program length + 1, e.g. with 1 2 3: 3 3 2 0.
 ](…)`[@.(]2=/@{./:~)

If the first 2 items of the sorted indices 0 2 3 3 -> 0 2 are equal, return the grid (stop moving), otherwise …
 r@|.~d{.@/:]

Sort the directions based on the indices. Take the first one, shift the grid by it and call r to subtract 1 from the top left, i.e. the robots takes a gem.
 ($-_2&u)@

After the robot stopped moving, find the _2 and subtract its position from the grid size to get the final result.

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


text:
The shortest way to find one unique value when all other values are the same
In this question at Code Review they tried to find the fastest way to return the unique element in an array where all the elements are the same except one. But what is the shortest code that accomplish the same thing?
Goal
Find the unique element in an array and return it.
Rules

The input array will contain only integer, strictly positive numbers, so you can use 0 as the end of the input if your language needs it.
The size of the array will be at least 3 and will have a finite size. You can limit the size of the array to any limit your language has.
Every element in the array will be the same, except for one which will be different.
You must output the value (not the position) of the unique element in any standard format. You can output leading or trailing spaces or newlines.
You can take the input array in any accepted format.

Examples
Input                   Output
------------------------------
[ 1, 1, 1, 2, 1, 1 ]      2
[ 3, 5, 5, 5, 5 ]         3
[ 9, 2, 9, 9, 9, 9, 9 ]   2
[ 4, 4, 4, 6 ]            6
[ 5, 8, 8 ]               5
[ 8, 5, 8 ]               5
[ 8, 8, 5 ]               5

Winner
This is code-golf, so may the shortest code for each language win!

Do we assume the input array contains a unique element and others are the same?

@Amessihel yes, you don't need to check that, it is assumed.

The title feels too long for such a simple operation. Suggested: Odd one out

@LuisMendo nice title, the thing is that I just wanted to use the same title as the original question at Code Review but changing "fastest" with "shortest". :-)

Suggest adding testcases [8, 8, 5] and [5, 8, 8] since there isn't one were the last element is unique and 3 element arrays are a corner cases in themselves.

is [3] allowed as output for [3,7,7]

@Tornado547 outputting a value as a singleton list is allowed under current consensus

Python 3, 27 bytes
lambda x:min(x,key=x.count)

Try it online!

R, 24 bytes
a=scan();a[a!=median(a)]

Try it online!

Alas for the lack of a built-in mode function.

JavaScript (ES6),  32  27 bytes
Saved 5 bytes thanks to @xnor
a=>a.sort()[0]+a.pop()-a[1]

Try it online!
How?
a.sort() sorts the input array in lexicographical order. We know for sure that this is going to put the unique element either at the first or the last position, but we don't know which one:
[ x, ..., y, ..., x ].sort() -> [ y, x, ..., x ] or [ x, x, ..., y ]

Either way, the sum of the first and the last elements minus the 2nd one gives the expected result:
[ y, x, ..., x ] -> y + x - x = y
[ x, x, ..., y ] -> x + y - x = y

We could also XOR all of them:
a=>a.sort()[0]^a.pop()^a[1]

Try it online!

Here's a bit of a different strategy that I think works: TIO

@xnor This is much better indeed!

x86-16 machine code, 14 bytes
Binary:
00000000: 498d 7c01 f3a6 e305 4ea6 7401 4ec3       I.|.....N.t.N.

Listing:
49          DEC  CX             ; only do length-1 compares
8D 7C 01    LEA  DI, [SI+1]     ; DI pointer to next value
F3 A6       REPE CMPSB          ; while( [SI++] == [DI++] );
E3 05       JCXZ DONE           ; if end of array, result is second value
4E          DEC  SI             ; SI back to first value
A6          CMPSB               ; [SI++] == [DI++]?
74 01       JE   DONE           ; if so, result is second value
4E          DEC  SI             ; otherwise, result is first value
        DONE:
C3          RET                 ; return to caller

Callable function, input array in [SI], length in CX.  Result in [SI].
Explanation:
Loop through the array until two different adjacent values are found.  Compare the first to the third value.  If they are the same, the "odd value out" must be the second, otherwise it is the first.
Example:
Input [ 1, 1, 1, 2, 1, 1 ], reduce until different adjacent values are found a = [ 1, 2, 1, 1 ]. If a[0] == a[2] then result is a[1], otherwise result is a[0].
Tests using DOS DEBUG:

lea di, [si+1] is the same size but saves instructions.  IDK if we could justify taking the array length as "max index", avoiding the dec cx.  It's not an "interesting" saving, just calling-convention wanking, so not worth updating your test-result images.  And hard to justify; it's so standard to do pointer+length even in asm.  Nice idea overall to use rep cmpsb this way.

05AB1E, 2 bytes
ʒ¢

Try it online!
Since 1 is the only truthy integer in 05AB1E, we can just filter (ʒ) on the ¢ount.
There is also the Counter-Mode builtin, which returns the least frequent element in a list at the same bytecount:
.m

Try it online!

Stax also has a built-in, but it outputs a code point...

When I read the challenge just yet I had ¢Ï in mind, which is basically the same approach as your first. Didn't think about the least frequent builtin, but that's indeed a nice alternative. :)

@KevinCruijssen thats neat, I had the same idea, but couldn't find Ï in the documentation. Maybe I just need to read all commands descriptions at some point ;).

Haskell, 32 bytes
f(x:y)|[e]<-filter(/=x)y=e|1<3=x

Try it online!
Explanation
The code, expanded with variables renamed to be more descriptive.
f (first:rest)
 | [unique] <- filter (/=first) rest = unique
 | 1 < 3 = first

(first:rest) is a pattern match on a list that destructures it into its first element (first) and the list without the first element (rest).
Each line with a | at the front is a case in the function (known as "guards" in Haskell). The syntax looks like functionName args | condition1 = result1 | condition2 = result2 .... There are two cases:

[unique] <- filter (/=first) rest. This asserts that filter (/=first) rest produces a list containing only one element, which we name unique. filter (/=first) rest filters out all elements in rest not equal to first. If we are in this case, then we know that unique is the unique element, and we return it.
1 < 3. This asserts that 1 is less than 3. Since it's always true, this is a "fallthrough" case. If we reach it, we know that there are at least 2 elements not equal to the first element, so we return first.

Bash  + coreutils, 12 bytes
sort|uniq -u

Try it online!

APL (Dyalog Extended), 5 bytes
⍸1=¯⍸

Try it online!
Regular Dyalog APL 18.0 has ⍸⍣¯1, but it doesn't work here because it requires the input array to be sorted, unlike Extended's ¯⍸ which allows unsorted input arrays.
How it works
⍸1=¯⍸  ⍝ Input: a vector N of positive integers
       ⍝ (Example: 4 4 6 4)
   ¯⍸  ⍝ Whence; generate a vector V where V[i] is the count of i in N
       ⍝ (¯⍸ 4 4 6 4 → 0 0 0 3 0 1)
 1=    ⍝ Keep 1s intact and change anything else to zero (V1)
       ⍝ (1= 0 0 0 3 0 1 → 0 0 0 0 0 1)
⍸      ⍝ Where; generate a vector W from V1, where i appears V1[i] times in W
       ⍝ (⍸ 0 0 0 0 0 1 → 6)

Octave / MATLAB, 19 bytes
@(x)x(sum(x==x')<2)

Try it online!
How it works
@(x)                  % Define a function of x
          x==x'       % Square matrix of all pairwise comparisons (non-complex x)
      sum(     )      % Sum of each column
                <2    % Less than 2? This will be true for only one column
    x(            )   % Take that entry from x

this is the same byte count if you were to port the R answer @(x)x(x!=median(x))

@Giuseppe Good idea! And then @(x)x(x~=mode(x)) is two bytes shorter. You should post that yourself

I can't believe I didn't think of that myself!! Thanks!

Octave, 17 bytes
@(x)x(x!=mode(x))

Try it online!
2 bytes golfed thanks to Luis Mendo!

Ruby, 18 bytes
->a{a-[a.sort[1]]}

Try it online!
The unique element will always be the largest or smallest, so remove all copies of the second element.

Wolfram Language (Mathematica), 21 19 17 bytes
f[c=a_...,b_,c]=b

Try it online!

also Tally[#][[1, 1]] & for 18

@Kai Tally lists elements in order of first appearance. That function is equivalent to #[[1]]&. (besides that, it also contains redundant whitespace)

oops you're right, didn't test enough, I thought it would sort them by the number of times they appear. White space was inserted when I copied it out of mma

Jelly, 3 bytes
ḟÆṃ

Explanation: ḟ (probably) removes all elements that are not the most common element (returned by Æṃ). I don't know why isn't the result a single-element list (perhaps it's a feature I didn't know about?), but that makes this even better.
Try it online!

The result of the Link ḟÆṃ is a single-element-list, it's just that when a full-program is run which results in a single-element-list the printed output is what would be printed if that single-element were the result. (i.e. 2RWWW just prints [1,2] rather than [[[[1,2]]]].

J, 10 8 bytes
1#.|//.~

Try it online!
How it works
 1#.|//.~  input:                  1 1 1 2 1
      /.~  group by itself:        1 1 1 1
                                   2
    |/     insert | (remainder) into both groups:
                   1 | 1 | 1 | 1 = 0
                   2             = 2
 1#.       sum:                    2

R, 25 bytes
a=sort(scan());a[a!=a[2]]

Try it online!
Sort the input, giving a. Now a[2] is one of the repeated values. Keep only the element not equal to a[2].
This ends up 4 bytes shorter than my best shot with a contingency table:
names(which(table(scan())<2))

How do you know that a[2] is one of the repeated values and not the unique value? After sorting, the unique value must be either the first or last element. But couldn't a[2] be the last element?

@Stef a[2] is the second element (R uses 1-based indexing), and the array of guaranteed to have at least 3 elements.

Thanks! I didn't know that R used 1-indexing.

Pyth, 4 bytes
-1 byte thanks to @FryAmTheEggman
ho/Q

Try it online!
Explanation
 o   : Order implicit input
  /Q : by count of the element
h    : then take the first element

PowerShell, 23 bytes
$args-ne($args|sort)[1]

Try it online!
Takes input by splatting. We apply a filter to the original array getting rid of the dupes by sorting it and taking the 2nd element.

omg - ($args|group|where count -eq 1).name doesn't even come close :(

and $args|group|? c* -eq 1|% n* too

T-SQL, 40 bytes
Input is a table variable
DECLARE @ table(v int)
INSERT @ values(1),(1),(2),(1)

SELECT*FROM @
GROUP BY v
HAVING SUM(1)=1

Another variation
T-SQL, 54 bytes
DECLARE @ table(v real)
INSERT @ values(1),(1),(2),(1)

SELECT iif(max(v)+min(v)<avg(v)*2,min(v),max(v))FROM @

This is so straightforward and logical in SQL. Nice!

@640KB thanks for your comment. I added a more obscure solution as well, it is a bit longer unfortunately . However this syntax could be converted to other languages and hopefully allow short answers

Brachylog, 4 bytes
oḅ∋≠

Try it online!
Takes a list and returns a singleton list.
Explanation
oḅ∋≠  Input is a list, say [4,4,3,4].
o     Sort: [3,4,4,4]
 ḅ    Blocks of equal elements: [[3],[4,4,4]]
  ∋   Pick a block: [3]
   ≠  This block must have distinct elements (in this case, must have just one).
      Output it implicitly.

RAD, 13 bytes
⍵[1⍳⍨+/⍵∘=¨⍵]

The lack of a need for {} in this language really helps.
Try it online!
Explanation
⍵[1⍳⍨+/⍵∘=¨⍵]
     +/⍵∘=¨⍵  count of each element's # of occurrences
  1⍳⍨         first occurrence of a 1
⍵[          ] the argument at that index

K (ngn/k), 8 6 bytes
Solution:
*<#'=:

Try it online!
Explanation:
*<#'=: / the solution
    =: / group the input
  #'   / count length of each
 <     / sort ascending
*      / take the first

Extra:

-2 bytes thanks to ngn by dropping the lambda

*<#'=: is valid too

Ah nice, I was trying to get it to work without the lambda, will update!

Haskell, 30 bytes
f(x:y)|elem x y=f$y++[x]|1>0=x

Try it online! Footer stolen from coles answer.
If the first element is not in the remaining list, return it, otherwise rotate it to the end and try again.

Wolfram Language (Mathematica), 19 bytes
Tr[#/.Median@#->0]&

Inspired by Kirill L.'s R submission
Try it online!
Finds the median, replaces its occurrences in the list with 0, and sums the list.

Husk, 3 2 bytes
-1 byte thanks to Razetime!
◄=

Try it online!

2 bytes

Vyxal, 3 bytes
Ċ↓h

Try it Online!
Explained
Ċ↓h
Ċ     # Get the counts of all items
 ↓    # Get the smallest item based on last item
  h   # Output the head of that list

Also, according to code-golf's statistics, only a small percentage of people who view my answers actually upvote them. So if you enjoy this answer, consider upvoting, it's free, and you can change your mind at any time (given you have ≥2k rep). Enjoy the answer.

Julia 1.0, 24 bytes
~d=d[@.sum(==(d),[d])<2]

Try it online!

Thunno 2, 2 bytes
Ṁo

Note that output as a singleton list is a default.
Explanation
Ṁo  # Implicit input
 o  # Remove all instances of                       from the input
Ṁ   #                         the mode of the input
    # Implicit output

Screenshot

ATOM, 15 chars, 18 bytes
Code:
*2>($1$1==*)

Usage:
[1,1,1,2,1,1] INTO *2>($1$1==*)

Try it live here
Explanation:
The ATOM language implicitly treats the expression as a function, where * is the parameter.
Therefore, it interprets the expression as
[1,1,1,2,1,1] 2>($1$1==*)

The  operator is an array filter, which takes an array on the left, and a function on the right. The expression to the right is implicitly parsed into a function.  Therefore, it is searching the values in the input array for all values where the following returns true
2>($1$1==*)

The  operator is array length, so it is searching for elements in the original input where ($1$1==*) evaluates to an array of length 1 i.e. the unique element.
The first $1 looks for the variable on the stack at index 1, which is the original array (index 0 is the element in the array that is being iterated through, since we are inside the where operator).
Another  operator is performed on the array. $1==* is now parsed to a new function, and $1 refers to the variable on the stack at index 1, which is the number being iterated through in the outer . The * refers to the immediate stack variable, which is the number being iterated through in the inner . Matches are returned, so if there are multiple instances of a number in the original array, the resulting array will be of length greater than or equal to 2. As such, only the unique element in the array will satisfy the 2>($1$1==*) clause.

Welcome to CGCC! And excellent answer! It can even detect multiple unique values!

Uiua, 4 bytes
⊗1⍘⊚

Try it!
⊗1⍘⊚
  ⍘⊚  # inverse where, i.e. how many times does each element occur?
⊗1    # index of 1

AWK, 34 bytes
{a[$0]++?c=$0:b+=$0}END{print b-c}

Attempt This Online!
Takes positive integers separated by newlines. Let's call the unique number u and duplicates d.

{a[$0]++?c=$0:b+=$0}: Executed for each line. $0 contains the number on the line.

a is used as a dict that counts the occurrences of each number. a[$0]++ increments the count, and evaluates to falsy if it was encountered the first time, truthy otherwise.
b+=$0 is run exactly twice, when each of u and d is read the first time. Therefore, b is equal to u+d at the end.
c=$0 is run for the rest of the time, and $0 in this case is always d.

END{print b-c} is run after all inputs are processed. b-c is u, and it is printed.

33 bytes: a[$0]++?$0=b-$0:b+=$0{}END{print}

Gaia, 2 bytes
C⌡

Not a built-in!
C is "count occurrences in list" and ⌡ is "find the smallest by".
(the footer is "evaluate" and "call the function above", Gaia doesn't seem to evaluate input by default)
Try it online!

If Gaia does not evaluate input by default, shouldn't you include that in the answer? Note all the R answers that need to do a scan().

@Charlie This submission is a function, not a full program (for some reason, Gaia actually calls lines of code functions)

I typically include the e in my Gaia answers, as I feel it's more correct; e↑ always felt like such a gray area to me. I don't think I would have thought of using ⌡ for this though, this is pretty neat!

Wolfram Language (Mathematica), 27 bytes
Keys@Select[Counts@#,#<2&]&

Try it online!

Java (JDK), 62 bytes
int f(int[] a){Arrays.sort(a);return a[0]+a[a.length-1]-a[1];}

Try it online!
Thanks to JollyJoker for correct way.
Original completely own failing dumb#ss solution:
int f(int[] a){Arrays.sort(a);return a[0];}

Nice try, but fails the 1st test case: on [ 1, 1, 1, 2, 1, 1 ] results 1 instead of the required 2.

a[0]<a[1]?a[0]:a[a.length-1]

or a[0]+a[a.length-1]-a[1]

Thanks for the input. Trying to play with the Big Bois always makes me look like an #ss. I guess the "New contributor" tag kind of saved me from rougher comments hehe.

Suggest int[]a instead of int[] a

PHP, 46 45 bytes
fn($i)=>array_flip(array_count_values($i))[1]

Try it online!
Could maybe be golfed more using a custom solution, but the straightforward one is quite short already: returns the first value that is counted one time. Works with any type of value. If only PHP array functions were not prefixed with array_!
EDIT: saved 1 byte thanks to @640KB now uses array_flip, meaning that it still works for any value type but this time gets the last value counted one time

Yes, darn those long and redundant function names.  Turns out it's 45 bytes if you use array_flip() instead of array_search() though!

@640KB nice one! I actually didn't know about array_flip, makes sense!

Python 3, 56 39 bytes
lambda x:[i for i in x if x.count(i)<2]

Try it online!

Lambdafication gives 39 bytes. (Singleton list is a valid output format by default.)

You don't need to convert the input to a set, since it doesn't matter how many times you uselessly count the multiple element.

Arn, 12 bytes
BØ├┤ÅöÀ&iG£3

Explanation
Unpacked: $v{(${=v})#<2}
$ Filter
  v{ block with index named v
    ( Start expression
      $ Filter
        { block with index named _
          =v Is current item equal to v
        }
    )
    # Length
    <2 Is less than 2
  }

Output implicit, input on one line split by spaces

Excel, 14 bytes
Put the numbers in column A, and enter this formula in another column
=UNIQUE(A:A,,1

Per the community meta, you can actually drop the trailing ) for -1 byte as excel will auto correct it to be there for you :)

Huh, I somehow forgot/didn't know about UNIQUE() when I did this one. Anyway, you can replace TRUE with 1.

@Calculuswhiz good point, thanks. Lol I typed this on my phone so I didn’t even test it first.

C GCC, 40 bytes
f(int*a){a=*a^*++a?a[-(*a==a[1])]:f(a);}

Try it online!
Thanks to xibu for -5 bytes!
Thanks to ceilingcat for -2 bytes!

-5 Bytes by replacing return with an assignment and reordering the code a bit.

@xibu that's amazing. I had no idea we could replace return with an assignment!

C (gcc), 39 bytes
f(int*a){a=*a-*++a?a[*a--!=a[2]]:f(a);}

Try it online!

f(int*a){      // function taking a 0-terminated array pointer.

 a=            // return using eax register trick.
 *a-*++a?      // compare current item with next item :
 a[*a--!=a[2]] // if different we move the pointer by the result of comparing the next item,
:f(a);         // if not we recursively call on the incremented pointer.
}

Desmos, 169 105 37 25 bytes
-12 bytes thanks to @Yousername
f(l)=l.max+l.min-l.median

Try it on Desmos!

25 bytes: f(x)=x.min+x.max-x.median

@Yousername median is smart

Ruby 2.7, 15 bytes
p$*.tally.key 1

Takes in the array of chars as input from the arguments $* passed to it.

Ruby 2.7, 18 bytes
->a{a.tally.key 1}

The following is the screenshot of SoloLearn code playground, which uses Ruby 2.7,

C (gcc), 48 46 44 bytes
-2 thanks to @ceilingcat
f(int*a){*a=*a-a[-1]?a[-(*a==a[1])]:f(a+1);}

Try it online!

Zsh, 22 bytes
<<<${@:#${${(o)@}[2]}}

Try it online!
:#Removes all elements matching the [2]nd element of the (o)rdered array, and <<<prints.

Rust, 45 bytes
A closure that takes a mutable slice and returns the outlier.
|s:&mut[u8]|{s.sort();s[0]^s[1]^s[s.len()-1]}

Attempt This Online!
Explanation:
|s:&mut[u8]|{ // Take a mutable slice
  s.sort();   // Sort the slice. This means that
              // the outlier is now either the first or last
              // element, and every element in between must be common.
  s[0]^s[1]^s[s.len()-1]
  // Since the slice must have at least three elements,
  // the first, second and last number must have distinct indices.
  // One of these three is the outlier, and the other two are equal.
  // Xoring two equal numbers yields zero, and xoring zero with a
  // number n yields n. The operation is commutative and associative.
  // Thus, by xoring the three relevant numbers we obtain the outlier.

  // We could have also subtracted the second element since we know
  // it can't be the outliner, but this both looks less cool
  // and gives overflow problems when not using signed integers.
}

R, 36 bytes
n=scan();while(sd(n[-T]))T=T+1;n[+T]

Try it online!
Iterates over the indices, calculating the standard deviation of the array with the associated element removed; when the standard deviation is 0, the removed element is the unique value.
This isn't the shortest by a long shot, but it's a neat little R approach.

It's being a wild R battle, but this is a nice idea. :-)

R, 30 29 bytes
Edit: -1 byte thanks to Giuseppe, but still a long way to go to catch the current leading R solution...
y=table(scan());names(y[y<2])

Try it online!
Outputs a character string containing the value of the lonely element.
Edit: just realized that this is a worse version of the solution that Robin Ryder already discarded...

Wolfram Language (Mathematica) 17  29 28 bytes
Code corrected due to comment by @att:
SortBy[Tally[#],Last][[1,1]]&

theorist managed to shave off one byte with this:
Cases[Tally@#,{_,1}][[1,1]]&

Fails when the unique element is the first element.

Yes,  Good catch! (I corrected the code.)

Also (saves 1 byte): Cases[Tally@#,{_,1}][[1,1]]&

C (gcc), 68 \$\cdots\$ 59 58 bytes
Saved a byte thanks to ceilingcat!!!
c;d;f(l,n)int*l;{for(c=0;--n;)l[n]-*l?d=n:(c=1);n=l[d*c];}

Try it online!
Inputs a pointer to an array of integers and its length.
Returns the unique element.
How
We initialises a flag, c, to zero and go through all the elements starting at the last through to the second. We use the first element as a test value. When we find an element different from the first we cache its index in d. If an element is the same as the first, we set c to one. After looping we know that the first element is unique if c is still zero. Otherwise d is the index of the unique element.

@ceilingcat Interesting how the extra braces are worth it - thanks! :-)

Retina, 26 25 bytes
.+
*
O`
,A2,-2`
+`_¶_
¶
_

Try it online! Link includes test suite that converts from a comma-separated list to a newline-separated list for ease of use. Uses @xnor's algorithm. Edit: Saved 1 byte thanks to @FryAmTheEggman pointing out that I didn't need to remove the newlines before counting the _s. Explanation:
.+
*

Convert to unary.
O`

Sort.
,A2,-2`

Drop all entries except the first two and the last.
+`_¶_
¶

Subtract the second value from the sum of the first and last. Well, sort of. All this guarantees is that there are no _s left in between the newlines, so the number of remaining _s is the desired result, but without actually specifying where they are.
_

Count the remaining _s as a decimal integer.

I think you can save a byte doing the subtraction with a loop replacing _¶_ with ¶. I tried to save bytes by making the list always 3 elements by using deduplicate stages, but it didn't work out.

@FryAmTheEggman Thanks; for some reason I thought I had to delete the ¶s...

Assembly (as, x64, Linux), 142 bytes (455 bytes code)
This runs on Linux only (for the syscalls) and only respects integers as bytes (input in ASCII).
.intel_syntax noprefix
.text
.global _start
_start:
mov cx,0
r:
lea rbx,a
lea rsi,i
mov rdi,0
mov rdx,2
mov rax,0
push rcx
syscall
pop rcx
mov al,[rsi]
cmp cx,0
je s
cmp cx,1
je t
cmp cx,2
je v
cmp al,[rbx]
jne p
jmp w
s:
mov [rbx],al
inc cx
jmp r
t:
inc cx
cmp al,[rbx]
je r
inc rbx
jmp s
v:
cmp al,[rbx]
je r
mov [rbx+1],al
w:
inc rbx
p:
mov rsi,rbx
mov rdx,1
mov rdi,1
mov rax,1
syscall
mov rdi,0
mov rax, 60
syscall
.data
a:
.byte 0,0
i:
.byte 0,0,0

Try it online!

Output seems to be the opposite than expected. For [0 1 0] it returns 0 rather than 1.

I also saw this on tio but it actually works on my computer. Nevertheless I linked tio to at least make the rest triable :-(

Functionality aside, you can compact the code by removing newlines here and there (labels can share a line with a mnemonic). Also, mov [rbx+1],al inc rbx can be changed to inc rbx mov [rbx],al. 438 bytes

x86 answers can be scored by their assembled byte count. https://codegolf.meta.stackexchange.com/questions/12339/how-are-bytes-counted-in-assembly?noredirect=1&lq=1

Thanks for the hint, I'll correct that as soon as I'm not on mobile.

@gastropner is it possible to leave out the space after a label name?

Welcome to CGCC! I'd also highly recommend reading Tips for golfing in x86 as it has lots of very helpful information. As said in post shared above, it's often more advantageous to submit your machine code answer as a function using either a known ABI or your own custom calling convention. That way the main logic is easier to see, more portable and should be much shorter. If you submit as machine code, I'd encourage including the listing with inline comments as well.

Japt, 4 bytes
ü l1

Try it
Groups (and sorts) by value and then filters items of length 1.

Dyalog APL, 15 14 bytes
{⍵[⊃⍋+/⍵∘.=⍵]}

-1 byte thanks to @streetster
Try it online!
Explanation
{⍵[⊃⍋+/⍵∘.=⍵]}
     +/⍵∘.=⍵  - a list of the number of occurences of each element
   ⊃⍋         - grab the first index
 ⍵[         ] - extract that element

Can you add an explanation to the solution? Is there any part of my k solution that can help to golf this?

I don't think there's any part of the K solution that will help, but I will surely add an explanation!

Can you use 'grade up' to get something like this K solution? {x@*<+/x=\:x} - rather than checking for equality with 1, get indices to sort ascending and take the first?

Tacit form: ⊢⊃⍨∘⊃∘⍋1⊥∘.=⍨ (TIO) Not so pretty, but saves a byte.

C (gcc), 50 42 bytes
f(int*b,int*e){b=(*b^*e--?:f(b,e)^*e)^*e;}

Try it online!

MY, 17 bytes
ωω9Ġ'ƒ⇷(⍉Σ1=⍸ω@⍰←

Try it online!
Explanation
ωω9Ġ'ƒ⇷(⍉Σ1=⍸ω@⍰←
ωω                  push the argument twice
  9Ġ'               push "=" in the codepage
     ƒ              turn it into a function
      ⇷             keeping the left argument the same, and mapping over each element
       (            apply that
        ⍉           transpose
         Σ          sum (now we have how many times each element occurs)
          1=        whether the elements are 1
            ⍸       the indeces of that
             ω@     the actual element
               ⍰    it's in an array, so pick a random element from it (since theres only one)
                ←   output

Io, 38 bytes
method(x,x unique sum-x average round)

Try it online!
Explanation
                                       // x = [1,1,2,1,1,1]
method(x,                            )
         x unique                      // Uniquified x: [1,2]
                  sum                  // Sum:          3
                      x average        // Average of x: 1.1666666666666667
                                round  // Round to the closest integer: 1
                     -                 // Minus: 3-1 = 2

Io, 44 bytes
The built-in solution.
method(x,x uniqueCount map(reverse)min last)

Try it online!
Explanation
                                             // e.g. x = [1,2,1,1,1,1]
method(x,                                  ) // Method (taking x):
         x uniqueCount                       // Uniquified counts.   [[1,5],[2,1]]
                       map(reverse)          // Put counts in front. [[5,1],[1,2]]
                                   min       // The one with the smallest count. [1,2]
                                       last  // Return the current item. 2

Io, 44 bytes
(Comparison answer, if I just ported Arnauld's solution anyway)
method(x,x sortInPlace()first+x pop-x at(1))

Try it online!

Retina 0.8.2, 17 bytes
O`
^(.*¶)\1+

1G`

Try it online! Link includes test suite that converts from a comma-separated list to a newline-separated list for ease of use. Explanation:
O`

Sort the input lines so that the unique line is now either first or last.
^(.*¶)\1+

If the first two lines are identical then remove them and all following identical lines.
1G`

Take the first remaining line.

Very nice! I had held off posting for a while because I felt like I was missing something, glad to see there was something better out there after all :)

Python 2, 47 bytes
i=sorted(input())
print(i[0],i[-1])[i[0]==i[1]]

Try it online!
A long way from the shortest Python answer but just another way of doing it.

Brain-Flak, 112 bytes
(()){{}({}<{({}<>)<>}<>>){({}<>)<>}<>(({}[({})])<({}({}))>)((){[()]<{{}({}<(({}[({})])<({}{})>)<>{}>)<>}>}{})}<>

Try it online!
Explanation
Very broadly speaking this cycles the list until the first two elements are unequal.  Then it deletes the front element until the second two elements are the same.  Once that is done it outputs whatever is on the front.
Ok that wasn't quite true.  I said

Then it deletes the front element until the second two elements are the same

But it actually deletes the 1st and the 3rd elements until ...
This doesn't actually make a difference to the output though, to see why let's look at the cases.  First the easy cases with more than 3 elements
b a a a a ...

In this case the second two elements are equal (a = a) so it stops and outputs b.
a b a a a ...

In this case the second two elements are unequal (a /= b) so it removes the first and third elements.
b a a ...

Now we are back to the first case.
Now for the cases with three elements.
b a a

In this case the second two elements are equal (a = a) so it stops and outputs b.
a b a

In this case the second two elements are unequal (a /= b) so it removes the first and third elements.
b

Now we want to run the check again, but there is only one element.  Luckily Brain-Flak pads the bottom of the stack with zeros so this is really the same as
b 0 0

And we assumed input was positive b /= 0 so we are back to the case above.

So that works fine but why do we do it?
The thing about Brain-flak is that in order to do any non trivial checks with an element we need to pop it from the stack.  That means that if we want to do things in place, like check if one element is equal to another, we need to pop those things and put them back.  So here we save bytes by not putting the third element back when we are checking equality.
This saves us two bytes.

Lua, 43 bytes
t=arg table.sort(t)print(t[1]+t[#t]-t[2]|0)

Try it online!
Returning method stolen from Arnauld's solution.

Alternate Solution, 49 Bytes:
t=arg table.sort(t)print(t[t[1]<t[2]and 1or#t]|0)

Notes
Lua's table indexing starts at 1, and boolean logic generally returns the value rather than an actual bool.

-1: snippets are not allowed. In JS answer you are referring to a function is declared and a is a name of its argument. This is not the case for your answer, which does not declare callable function and uses variables for input and output, which is not allowed as well.

Sorry, was not familiar with the rules when I first started. Fixed to make it a full program.

Great! Turned -1 into +1 now. Also, just learnt that |0 can be used to convert numbers to integers (I knew about //1, but this is new for me). P.S.: it's recommended to use https://tio.run to provide examples. It also provides code in format that can be directly copied as a Codegolf.SE answer.

Perl 5 -p, 30 bytes
s/\d+//;$_=s/\b$&\b//g?$_+0:$&

Try it online!
Perl 5 -a, 31 bytes
//,(1-grep$_==$',@F)||say for@F

Try it online!
Perl 5 -a, 33 bytes
1-(@b="@F"=~/\b$_\b/g)||say for@F

Try it online!

Note that in the input every element must be the same except one, so [1 2 3 4 4 3 1 1] would not be a valid input.

Changed my test case, but it doesn't really matter to the code.  It finds the unique element either way.

Charcoal, 8 bytes
ＩΦθ⁼¹№θι

Try it online! Link is to verbose version of code. Works by filtering out elements whose count is not 1. (Singleton list output is allowed by default, although Charcoal's output for a singleton list looks like that of a bare string anyway.) Explanation:
  θ         Input list
 Φ          Filtered where
     №      Count of
       ι    Current element
      θ     In input list
   ⁼¹       Equals literal `1`
Ｉ           Cast to string
            Implicitly print

Python 3, 49 bytes
def f(n):n.sort();return (n[0],n[-1])[n[0]==n[1]]

Try it online!

Why are you sorting the input outside your code? (you may not assume the input is sorted because there are test cases where it is not) Also, this does not work correctly even for the test case included in your TIO link...

@my pronoun is monicareinstate Thank you, for mentioning my blunder, and i corrected the code

The second option is wrong. This still doesn't work: Try it online!

@mypronounismonicareinstate sorry, I oversight it. Edited the code, now it works perfect

JavaScript (61 60 bytes)
My first attempt in this community, so there's room for improvement:
x=>{[a,b,c]=x.filter((e,i)=>x[i-1]!=e);return !c&&x[1]-a?a:b}
x=>{[a,b,c]=x.filter((e,i)=>x[i-1]!=e);return!c&&x[1]-a?a:b}

Try it online!
Explanation:
x.filter((e,i)=>x[i-1]!=e)

The array is filtered to remove any element that is the same as array[index - 1].
These are then unpacked into variables [a,b,c].
The three scenarios are 1) [same, unique, same] 2) [unique, same] 3) [same, unique]
return !c&&x[1]-a?a:b

If c is undefined, i.e. the unique element was on the end of the array - and if 'a' (which is by now either array[0] or array[last element - 1]) is not equal to array[1], then a is the unique element. Otherwise, we have scenario 1 or 3, either way - return 'b'

Welcome to the wonderful world of code golf! I look forward to seeing more of your posts!

Also, -1 byte by removing the space between return and !

Thanks, not sure how I missed that whitespace lol.

jq, 11 bytes
.-[sort[1]]

Try it online!
Explanation
.           # The input
 -          # With all occurances of ... removed:
  [sort     #    The sorted input
       [1]] #    's second item

For input [9, 6, 6] it fails to return 9.

@Charlie I hope it is fixed now.

Factor, 28 23 bytes
[ histogram keys last ]

Try it online!
Get the last (second) key in the histogram of the input, which will always have the smaller count.

Raku, 25 bytes
{.BagHash.invert.Hash{1}}

Try it online!

Scala, 85 bytes
Try it online!
def f(x:Seq[Int])=x.groupBy(identity).mapValues(_.length).filter(_._2 == 1).keys.head

This Scala code defines a function f that takes a sequence of integers x as input, and returns the unique element in the sequence.
Here's a breakdown of what the function does:

x.groupBy(identity) groups the elements in the sequence x by their identity (i.e., their value), returning a map where the keys are the distinct values in x, and the values are arrays of elements in x with that value.
.mapValues(_.length) transforms the values in the map to their length, i.e., the number of elements in x with that value.
.filter(_._2 == 1) filters the key-value pairs in the map to keep only those where the value (i.e., the count of elements with that value in x) is equal to 1.
.keys returns the keys (i.e., the distinct values in x) of the filtered map as a set.
.head returns the first (and only) element of the set, which is the unique element in x.

So the entire function finds the unique element in x by grouping its elements by their value, counting the elements with each value, filtering for the value with count 1, and returning it.

TI-BASIC, 10 9 bytes
min(Ans)max(Ans)/median(Ans

Takes input in Ans.

Vyxal 3, 4 bytes
SġⁿL

Try it Online!
Sorts the array, groups by adjacent items and takes the minimum by length

HBL, 10.5 bytes
+(1.)('1.)(<(1.2
)(%.

Try it!
Port of Arnauld's answer.
-3 bytes thanks to @DLosc!
Explanation:
Helper function:
+(1.)('1.)(<(1.2
+                 # Add:
 (1.)             # The first element of arg1
     ('1.)        # The last element of arg1
          (<      # Negate below:
            (1.2  # The second element of arg1

Main function:
)(%.
 (%.  # Sort arg1
)     # Call the function above

Created with the help of Luminespire.

@DLosc Thanks! Also, I've added the explanation.

Scala, 28 27 bytes
a=>a.minBy(x=>a.count(x==))

It finds the minimum number in the list according to the number of occurrences in that same list, since the odd one out will only have 1 occurrence.
Try it in Scastie

Japt -m, 4 bytes
ü l1

Try it
ü       sort and group
  l1    take lenght 1 result

Retina, 24 bytes
N`
L0`^(\d+)(?!¶\1)|\d+$

Try it online!
This works by sorting the input (one number per line) and then outputting the first number if it is different from the second, and otherwise outputting the last number.
The test case code was taken from Neil's Retina answer which uses an arithmetic method to determine the answer after sorting.

You inspired me to write an answer which could be backported to Retina 0.8.2, and was shorter to boot!

Google Sheets, 28
Closing parens already discounted.

Column A is input.
B1 - =SORT(A:A)
B2 - =FILTER(B:B,B:B<>B2)

Excel 2016, 35

Column A is input.
B1 - =MAX(A:A)
B2 - =IF(MODE(A:A)-B1,B1,MIN(A:A))

If the mode is the same as the max, then it's the min, otherwise max.

Burlesque, 8 bytes
psf:<][~

Try it online!
Explanation:
ps       # Parse input string as a block
  f:     # Frequency list - returns block of blocks with format {frequency value}
    <]   # Take the minimum block, in this case calculated based on the first element (frequency)
      [~ # Take the last element (value)
         # Implicitly output

C# 42 Bytes
r.GroupBy(a=>a).First(a=>a.Count()==1).Key

Welcome to the site.  Are you sure C# requires all that whitespace?  If it doesn't, removing it could be a easy way to shorten this.

@AdHocGarfHunter Thanks! You're right. Have edited it further

Also if I understand the code correctly groups can't be size zero?  So <2 should be a shorter way of checking ==1.  If you want tips for golfing in C# from someone who actually knows C# we have a tips page for the language.

Pyth - 6 bytes
I'm not quite sure why this doesn't return an array.
f!t/QT

Explanation
f!t/QT
f!t/QTQ implicit Q added
f     Q filter on each element T of input for
   /QT  number of times t appears in input
  t     minus 1
 !      is equal to zero

Made me chuckle a bit.

Postgresql, 51 bytes
SELECT unnest($1::int[])GROUP BY 1HAVING count(*)=1

Takes input as an integer array. Outputs as a row containing the unique value. If there is more than one unique value, it returns all of them in unspecified order.
If the type is specified in the extended query protocol or a function parameter, it can be reduced to 44 bytes
SELECT $1.unnest GROUP BY 1HAVING count(*)=1

[Python 3], 39 bytes
lambda x:x[[*map(x.count, x)].index(1)]

Guessing by the header, it looks like you copied the post from TIO then removed the link. I suggest to fix the post by copying the whole content back.

I had taken the format from https://codegolf.stackexchange.com/a/207741/97553 but it is different from my code.

Well yes, as Bubbler said you deleted the link and didn't replace it with anything can you at least fix the header and optionally add a link to somewhere you can test this, such as TIO?

GolfScript, 6 bytes
~$.1=-

Try it online!
~        # Parse the input to an array
 $       # Sort the array
  .1=    # Get the second number in the array, this will always be the repeated number
     -   # Remove all copies of the repeated number

Pyt, 3 bytes
ĐṀ\

Try it online!
Đ        implicit input (S); duplicate on top of stack
 Ṁ       get median (m) (I never got around to fixing a bug in the mode operator, but they do the same thing here)
  \      take the set difference between S and m; implicit print

Arturo, 33 bytes
$=>[t:tally&|select[k,v]->v=1t\0]

Try it

><> (Fish), 29 bytes
!!vr:r@:&=&$?$n;
 ~>:@$:@=0$.

Try it

Go, 105 bytes
func(N[]int)int{m,o:=make(map[int]int),0
for _,n:=range N{m[n]++}
for k,v:=range m{if v<2{o=k}}
return o}

Attempt This Online!

Java (JDK), 65 bytes
Not the best Java answer, but still really close using a Stream approach.
l->l.stream().reduce(0,(a,b)->l.indexOf(b)!=l.lastIndexOf(b)?a:b)

Try it online!

Kotlin, 40 24 bytes
{minBy{r->count{r==it}}}

Try it online!
It doesn't seem to have a count function where you can simply pass the lambda parameter.
-16 bytes thanks to Seggan

you can omit the IntArray part as lambdas on CGCC can have types inderred if needed

Labyrinth, 34 bytes
? }:=
? $ :
: } {
} : +;=$!@
${?"=

Try it online!
Examines windows of size 3 until a window with two different numbers is found, and then XORs the three numbers to get the answer.
Given a window of a b c, the test is done by checking if (a^b) + (b^c) is nonzero. It is trivially zero if a == b == c, and we can be sure that it is strictly positive (and therefore nonzero) when a != b (i.e. (a^b) != 0) or b != c (i.e. (b^c) != 0) since all the input values are positive.
Also, a redundant work is saved by keeping an XORed value in the stack across iterations.
Intro:  ??:}${
??   take two numbers from input [a b]
:}   copy 2nd input to aux.stack [a b | b]
$    XOR                         [a^b | b]
{    pull 2nd input back         [a^b b]

Loop:  ?:}$}:=:{+=   [a^b b] -> [b^c c]
?      take next number from input [a^b b c]
:}     backup c                    [a^b b c | c]
$      XOR                         [a^b b^c | c]
}:     move b^c and copy a^b       [a^b a^b | b^c c]
=:{    swap tops, copy, pull       [a^b b^c b^c a^b | c]
+      add; keep going if zero     [a^b b^c a^b+b^c | c]
=      swap tops                   [... b^c c | ...]

End:  ;=$!@  [a^b b^c a^b+b^c | c]
;=    drop and swap tops   [a^b c | ...]
$!@   print a^b^c and halt

YASEPL, 46 32 30 bytes
=a=1'±" "=d¥0,1`1!+=e¥a,1}3,d<

enter in numbers seperated by a space and nothing else (like 4 4 4 6 4 4)
explanation
=a=1'±" "=d¥0,1`1!+=e¥a,1}3,d<           packed
=a                                       declare increment variable "a"
  =1'                                    get user input and set it to "1"
     ±" "                                split "1" by every space
         =d¥0,1                          get the first item from "1"
               `1        }3,d            while e == d...
                 !+                      increment a by one
                   =e¥a,1                get item at "1" index "a" and set it to "e"
                             <           print variable "e" when finished

Scala 3, 28 bytes
l=>l.minBy(x=>l.count(_==x))

Attempt This Online!

SmileBASIC 4, 43 bytes
1  RSORT I:IF I[0]-I[1]GOTO@0
2  ?MIN(I)@0?MAX(I)

Receives array input through I[]. The first value printed is the answer, other printed values are to be ignored. Works by reverse-sorting the list of integers (from largest to smallest values) and comparing the zeroth and first elements. If their difference is non-zero, then the odd one out is the larger value (MAX(I)); otherwise, the odd one out is the smaller value (MIN(I)).

gbz80 machine code, 11 bytes
Function that takes the list pointed to by hl and returns in a. Requires zero-terminator.
46 23 2A B8 28 FC 4E B9 C0 78 C9

Disassembly:
Search:
    ld b, [hl]
    inc hl
.loop:
    ld a, [hl+]
    cp b
    jr z, .loop
; this is for if the first two are different.
    ld c, [hl]
    cp c
    ret nz
    ld a, b
    ret

C, 66 Bytes
u(int*a){int*i=a;for(;!(*a-*i);++i);return*a-a[1]&&*a-a[2]?*a:*i;}

We iterate over the array until we find an element that's different from the first one, then return the first element if it's different from both the second and the third, otherwise the element that the loop stopped at.
The following optimizations were made:

Dereferencing a pointer is shorter than indexing an array. Since the elements of an array are stored together, we can use a pointer as an iterator, letting us write *i instead of a[i]. Similarly, we can always write *a instead of a[0].
For the sake of conditionals, a-b is equivalent to a==b since every nonzero integer evaluates to true.
The return type defaults to int so we don't need to specify it.
Ternary operators are shorter than if-conditions, and in this case, it's possible to only use one check. The drawback is that the for-loop gets executed even if it isn't needed.

Welcome to Code Golf Stack Exchange!

source: Stack Exchange

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

sort: votes


text:
Checkerboard the Matrix
Task
Given a matrix, your program/function should output a row-equivalent matrix in checkerboard form ( \$A_{ij}=0\$ if and only if \$i+j\$ is odd).
Two matrices are defined to be row-equivalent if and only if one can be obtained from the other by a sequence of elementary row operations (EROs), where each ERO consists of performing one of the following moves:

Swapping two rows
Multiplying one row by a nonzero rational constant
Adding a rational multiple of one row to another row

Since there are multiple possible outputs for each input, please include a way to verify that the output is row-equivalent to the input, or explain enough of your algorithm for it to be clear that the output is valid.
Example
Input:
2 4 6 8
0 2 0 4
1 2 5 4

Subtracting row 2 from row 3 yields
2 4 6 8
0 2 0 4
1 0 5 0

Subtracting double row 2 from row 1 yields
2 0 6 0
0 2 0 4
1 0 5 0

That is one possible output. Another possible matrix output is
1 0 3 0
0 1 0 2
1 0 4 0,

which is also row-equivalent to the given matrix and is also in checkerboard form.
Constraints

The given matrix will have at least as many columns as rows and contain only integers (your output may use rational numbers, but this is not strictly necessary since you can multiply by a constant to obtain only integers in the output).
You may assume that the rows of the matrix are linearly independent
You may assume that it is possible to express the given matrix in checkerboard form

Input and output may be in any reasonable format that unambiguously represents an m×n matrix.
Sample Test Cases
Each input is followed by a possible output.
1 2 3
4 5 5
6 5 4

1 0 1
0 1 0
1 0 2

1 2 3
4 5 5
2 0 -1

1 0 1
0 1 0
1 0 2

2 4 6 8
0 2 0 4
1 2 5 4

1 0 3 0
0 1 0 2
1 0 4 0

1 2 3 2 5
6 7 6 7 6
1 2 1 2 1

1 0 1 0 1
0 1 0 1 0
1 0 2 0 3

3  2  1  10 4  18
24 31 72 31 60 19
6  8  18 9  15 7
8  4  8  20 13 36

3 0 1 0 4 0
0 1 0 5 0 9
2 0 6 0 5 0
0 8 0 9 0 7

3  2  1  10 4  18
24 31 72 31 60 19
0  4  16 -11 7 -29
8  4  8  20 13 36

3 0 1 0 4 0
0 1 0 5 0 9
2 0 6 0 5 0
0 8 0 9 0 7

1 0 0 0 -2
0 1 0 1 0
0 0 1 0 2

3 0 1 0 -4
0 2 0 2 0
5 0 3 0 -4

Related:

Create a checkerboard matrix
Reduced Row-Echelon Form of a Matrix

Great challenge! It might be nice to have a sample case where an existing 0 needs to become non-zero in the final output.

@HyperNeutrino Good idea. I also added a separate one with a negative entry.

Is it always possible for a row-equivalent checkerboard matrix to be created?

@user "You may assume that it is possible to express the given matrix in checkerboard form." For a matrix with linearly independent rows and at least as many rows as columns, it is always possible (express the matrix in reduced row echelon form, then add odd rows to odd rows and even rows to even rows). If there are fewer rows than columns, checkerboarding requires more care.

@fireflame241 do you have a reference implementation for this?

@Razetime I think this works.

Congratulations on winning the Trickiest Challenge category for Best of 2020 (https://codegolf.meta.stackexchange.com/q/20638/68942) for this challenge! I will be awarding a +500 bounty for this award. Which answer would you like it to be given to?

@HyperNeutrino Interesting category, and I'm surprised no one has answered this question yet. The bounty should go to https://codegolf.stackexchange.com/a/209201/68261

MATLAB - 114 129 bytes
function n=c(m)
n=rref(m);l=size(n,1);for i=1:l
e=1.5+.5*(-1)^i:2:l;N=n(e,:);n(e,:)=N+repmat(n(i,:),length(e),1).*max(N).^2;end

Try it online
For a given nxm matrix, there are three forms of the rref of the matrix.

The identity matrix (with optional all-zero columns) (m>=n)
Full rank matrix where columns that do not contain a row-leading 1 can have any value (m>n)
Identity matrix with zero rows on the bottom (m<n)

1 and 3 are easily made into a checkerboard by looping through each row and adding every odd/even row (which would have the 1s in the appropriate places)
for 2, however, it is impossible to make a checkerboard matrix unless the matrix is already a checkerboard. This is because the columns that have nonzero values can never be reduced because there is no column with a row-leading 1, and any ERO would add a value in another space that would ruin the checkerboard pattern. I'm certain there's a more rigorous explanation but linear algebra is not easy.

Welcome to Code Golf, and nice first answer! Is it possible to edit in a link to an online testing environment so that others can test your program? For example, while it doesn't have Matlab, Try it online does host Octave

@ChartZBelatedly weren't you giving a bounty on answers to good old unanswered questions? Does this answer qualify?

@Wasif Not quite, mine is for questions with a score of less than 15. This one by JoKing however, I think this answer would qualify for

Poor answerer ;-(

"You may assume that the rows of the matrix are linearly independent," which means that form 3 cannot happen. That might provide an opportunity for further golfing.

As a heads-up, I edited your answer with a link to Octave on TIO, which claims that an extra ;end; is necessary to compile, but I am not familiar with MATLAB. WIth that modification, all original test cases correctly produce a checkerboard matrix, but c([3  2  1  10 4  18; 24 31 72 31 60 19; 0  4  16 -11 7 -29; 8  4  8  20 13 36]) c([1 0 0 0 -2; 0 1 0 1 0; 0 0 1 0 2]) adds 2 to -2 and puts a 0 in the bottom-right entry, when it should be non-zero. Maybe instead of adding each odd row to every other odd row, you might have to test with adding a multiple of the row. Good luck fixing that!

I have added a potential fix. By multiplying by the square of the maxima of each row, that should help prevent any cancellations. It adds more bytes but it makes a more robust answer. Besides, MATLAB isn't some esolang for golfing and no one else has posted so I win!

Python3, 941 bytes:
from math import*
E=enumerate
Z=zip
T=lambda x:[i>0 for i in x]
lcm=lambda a,b:abs((a*b)//gcd(a,b))
U=lambda i,r,m:m[:i]+[r]+m[i+1:]
G=lambda r:all(r[i+1]for i,a in E(r)if a==0 and i+1<len(r))
v=lambda m:all(not any(r[not i%2::2])and all(r[i%2::2])for i,r in E(m))
S=lambda m:sum(sum(not i for i in b)for b in m)
def f(m):
 q,Q=[m],0
 while q:
  if v(m:=q.pop(0)):return m
  for x,a in E(m):
   for y,b in E(m):
    if x<y:
     if all(j.count(0)==len(j)//2 and G(j)for j in m):q+=[m[:x]+[b]+m[x+1:y]+[a]+m[y+1:]]
     for c in[1,-1]:
      if 0 in(R:=[j+k*c for j,k in Z(a,b)]):
       if T(b)!=T(R):q+=[U(y,R,m)]
       if T(a)!=T(R):q+=[U(x,R,m)]
      for j,k in Z(a,b):
       if j and k:
        L=lcm(j,k);A=[i*(L//j)for i in a];B=[i*(L//k)for i in b]
        if 0 in(R:=[J+K*c for J,K in Z(A,B)])and T(b)!=T(R):
         if(n:=S(u:=U(y,R,m)))>Q:Q=n;q+=[u]
        if 0 in R and T(a)!=T(R):
         if(n:=S(u:=U(x,R,m)))>Q:Q=n;q+=[u]

Try it online!
A breadth-first, basic brute force approach.


text:
Play a Game of Minigolf
Background
I feel that for a site named code-golf we have a shockingly little amount of golf being played. Let's fix that.
Challenge
Determine whether the hole of a minigolf course can be reached after exactly a certain number of movements and whether it can be reached at all.
How to play
Inputs are an integer "power level" and an ASCII art minigolf course. The ball starts on the X (capital) and the hole is an O (capital). The walls of the course are made of the characters + | - \ and /. The characters + | and - rotate the direction of the ball 180 degrees and the characters \ and / rotate the direction 90 degrees as you would expect. When a ball hits the wall it enters the wall for that turn and then leaves the next turn.
Launch the ball in each of the four cardinal directions from the starting X.

If the ball enters the hole after exactly the power level moves, then output truthy.
If the ball could make it to the hole given a different power level, then output mediumy.
If the ball cannot enter the hole regardless of the power level, output falsy.

Rules

This is code-golf so shortest answer in bytes wins.
Assume only valid input will be given.
All input strings will be rectangular. (All rows will be the same length)
Assume that there is no way to escape the course and leave the edge of the string.
No solution will require the ball to be in the same place facing the same direction twice.
Standard loopholes disallowed.
Only a string or a list of strings is acceptable for the course input.
Output can be any three distinct values.
The ball will never hit the characters | or - "end-on."

Example
11
   -----+
  /   X |
 | +----+
 | |
 |O|
 +-+

This is true. If the ball starts heading east it will be on the wall after two movements.
   -----+
  /   X o<- ball right here. movements:2
 | +----+
 | |
 |O|
 +-+

It will then change directions until it hits the corner
   -----+
  o   X | movements:8
 | +----+
 | |
 |O|
 +-+

Now it is heading south and will end in the hole after 11 moves. Note that 13 would also be true as the ball could bounce off of the bottom wall and into the hole. Other valid power levels for this course are 7 and 9.
Test Cases
All answers validated using this java code: https://github.com/Dragon-Hatcher/CodeGolfMiniGolf/tree/master/MinigolfCodeGolf/src
power
course
output

11
   -----+
  /   X |
 | +----+
 | |
 |O|
 +-+

truthy

10
    +---+
    | X |
    +---+
 +-+
 |O|
 +-+

falsy

25

      ---------
     /     X   \
    +++-------+ |
    | |       | |
    |O|       | |
    | \-------/ |
     \         /
      ---------

truthy

2

 +-+
 |X|
 | |
 | |
 |O|
 +-+

mediumy

34

      +------+
      |/    \|
      | +--+ |
      |X|  | |
  +---+ +--+ |
  |    O    /|
  +---+ +----+
      +-+

true

Hi and welcome to Code golf! One point: Only a string is acceptable for the course input limiting the input this way, assuming you mean a string with carriage returns as opposed to a list/array of strings,  is discouraged.

Okay good to know I've changed the rules

Great! One other point: Get your input from the standard input usually answers can be either full programs or functions (which may get their input from parameters).

Thanks, I fixed it.

It would be better to just not mention any rules about how to get input, and let the default input rules apply.

Do the characters '|' and '-' rotate the ball 180-degrees when they are hit 'end-on'?  Or, can we assume that this will never be possible for input golf-courses?

Suggested test-case: https://tio.run/##M/n/38iQSwEIdHV1FRRALH0gjlHg0gbxgaCGq0ZBwR8sDmJFgBWAZMEaFP7/BwA (passes through the hole 4 times in different directions)

@DominicvanEssen You can assume the ball will never hit them end on.

The fact that the ball can "pass over" the hole without going in tripped me up; could you maybe mention this explicitly in the post, perhaps with regards to test case 3?

APL (Dyalog Unicode), 146 115 bytes
{(∨/+⍺⊃⊢)∨⌿↑{'O'=1↓⊃¨⊢∘(((⊢,⍉∘⊖∘⌽¨)1⌽¨⊂,⊂∘⍉)⊃⍨1⌈¯2+'X O\/'⍳⊃)\(4×≢,⍵)⍴⊂⍵}¨({¯1+⊃⊃⍸'X'=⍵}⌽⍉)⍣2¨(⊢,⌽∘⊖¨)(⊂,⊂∘⍉)⍵,⍳≢⍵}

-31 bytes (!) thanks to @Bubbler (combining transformations; simplifying iteration end condition; smaller details)
Try it online!
Outputs 2 for truthy, 1 for mediumy, and 0 for falsy.
Similarly to my solution to Solve the Halting Problem for Modilar SNISP, this moves the grid around the ball location, so the ball is always in the top-left, moving right. This might not be the best strategy (as opposed to storing a pointer position and direction) in this case because the ball doesn't always start from the top-left moving right, so I spend many bytes rotating and aligning the grid.
Details
Append 1,2,3,4,...,n to the input grid.
This prevents symmetric grids from comparing equal after some sequence of moves
⍵,⍳≢⍵

We must be careful here and elsewhere in the code that we do not affect
the angle of / and \. Using a simple reflection ⌽ to reverse direction
should change / to \, but the reflection of the character '/' is '/'.
Conveniently, APL matrix reflection operators are visually sensible:

⌽ reflects across a vertical line: swaps / and \
⊖ reflects across a horizontal line: swaps / and \
⍉ (transpose) reflects across the main diagonal: no change

Thus we must use an even total number of ⌽ and ⊖ in all transforms.
Obtain all 4 starting directions/rotations:
(⊢,⌽∘⊖¨)(⊂,⊂∘⍉)

Shift each grid so that 'X' is in the top left
(Shifts 'X' to the left edge twice, transposing the matrix in between)
{(¯1+⊃⊃⍸'X'=⍵)⌽⍉⍵}⍣2¨

For each starting grid, beginning with the starting grid, repeat 4×#coordinates (= max # of states) times...
\(4×≢,⍵)⍴⊂⍵

...move by one step:
(((⊢,⍉∘⊖∘⌽¨)1⌽¨⊂,⊂∘⍉)⊃⍨1⌈¯2+'X O\/'⍳⊃)
  ⍝ Get the ID of the entry: `X`, ` `, or `O`:1, `\`:2, `/`:3, `|`,`+`, or `-`:4
  ⍝ We can consider |, +, and - as the same because we are always travelling
  ⍝ horizontally (albeit on a rotated grid), and these all do the same action
  1⌈¯2+'X O\/'⍳⊃
  ⍝ Get the corresponding grid position after the move
  ((⊢,⍉∘⊖∘⌽¨)1⌽¨⊂,⊂∘⍉)⊃⍨

1 if there exists a move history whose final move's top-left element is O, and add another 1 if there exists a move history where the ⍺-th move has top-left element equal to O.
(∨/+⍺⊃⊢)∨⌿↑{'O'=1↓⊃¨

Actually I think this works. This is why I included the phrase "No solution will require the ball to be in the same place facing the same direction twice." This means that you don't have to consider looping around the whole course.

@JonathanAllan Fixed both problems. "until 4 Os" suffices since the ball cannot pass over the hole more than 4 times. Also, I was padding with repeats of the original path ⍴ if it was shorted, which caused excess 1s, so padding with 0s via ↑ works properly

@user197974 I edited a few seconds before you posted your comment. Since there are 4 directions, the ball can loop around the whole course (see my suggested test case on the original post).

@fireflame241 good catch let me whip up a test case.

Whenever I think of the grid-altering approach, I get lost with handling obstacles properly. Nice job. Meanwhile, I could bring it down to 115 bytes.

JavaScript (Node.js),  170 ... 147  145 bytes
Expects (n)(a), where n is an integer and a is an array of strings. Returns 3 for truthy, 0 for falsy or 1 for mediumy.
n=>a=>(g=(d,y=a.findIndex(r=>~(x=r.search`X`),j=n))=>+(a+a+1)[~j]?D&&g(--D):!(k=Buffer(a[y+=(d-2)%2])[x+=~-d%2]*5%26%5)*-~!--j|g(d^4-k&3,y))(D=3)

Try it online!
How?
We use the following compass for the directions:
  1
0 + 2
  3

Which means that we have \$dx=(d-1)\bmod 2\$ and \$dy=(d-2)\bmod 2\$, assuming that the sign of the modulo is the sign of the dividend.
With this setup, we want to update \$d\$ to:

\$(d\operatorname{XOR}2)\$ for a 180° turn (bouncing on either -, + or |)
\$(d\operatorname{XOR}1)\$ for a 90° turn when bouncing on a \
\$(d\operatorname{XOR}3)\$ for a 90° turn when bouncing on a /

We use the following formula to convert any board character of ASCII code \$n\$ to \$k\in[0..4]\$:
$$k=((n\times5)\bmod 26)\bmod 5$$
The great thing about this formula is that the value that \$d\$ must be XOR'ed with when going through a character is immediately given by \$4-k\$ (except O which is turned into \$4\$).
 char. | code | *5  | %26 | %5 | 4-k
-------+------+-----+-----+----+-----
  ' '  |   32 | 160 |   4 |  4 |  0
  'X'  |   88 | 440 |  24 |  4 |  0
  'O'  |   79 | 395 |   5 |  0 |  4
  '/'  |   47 | 235 |   1 |  1 |  3
  '\'  |   92 | 460 |  18 |  3 |  1
  '|'  |  124 | 620 |  22 |  2 |  2
  '-'  |   45 | 225 |  17 |  2 |  2
  '+'  |   43 | 215 |   7 |  2 |  2

Commented
n => a => (                   // n = number of moves; a[] = array of strings
  g = (                       // g is a recursive function using:
    d,                        //   d = current direction
    y = a.findIndex(r =>      //   y = index of the row r[] in a[]
      ~(x = r.search`X`),     //       which contains an 'X' at position x
      j = n                   //   j = move counter, initialized to n
    )                         //
  ) =>                        //
    +(a + a + 1)[~j] ?        //   if j is negative and we have visited at
                              //   least more than twice the total number of
                              //   cells in a[]:
      D &&                    //     if D is not equal to 0:
        g(--D)                //       do a recursive call with D - 1
    :                         //   else:
      !(k =                   //     compute k:
        Buffer(               //       get the ASCII code at (x + dx, y + dy)
          a[y += (d - 2) % 2] //       add dy to y
        )[x += ~-d % 2]       //       add dx to x
        * 5 % 26 % 5          //       apply the formula described above
      ) *                     //     k = 0 means that we've reached the hole,
      -~!--j                  //     in which case we yield 1 if j != 0
      |                       //     or 2 if j = 0 (j is first decremented)
      g(d ^ 4 - k & 3, y)     //     update d and do a recursive call
)(D = 3)                      // initial call to g with d = D = 3

Great explanation as always

Nice! How did you construct/find the equation k = ((n * 5) mod 26) mod 5?

@Quelklef I wrote a small script to find (p,m0,m1) tuples such that n*p%m0%m1 is a surjective function from the set of ASCII codes to the set of bouncing behaviors. One of the tuples caught my eye because it was not only giving correct unique IDs but could also almost directly provide the correct XOR values. It was a fortunate, unexpected result.

Python 3, 384 378 bytes
def l(d,r,m,i,c,p):
 m+=[[d]+p];p[1]+=(d-1)*(~d%2);p[0]-=(d-2)*(d&1);s=r"/\-|+OX ".index(c[p[1]][p[0]])
 if s<2:d+=(s^d&1)*2+1;d%=4
 if 1<s<5:d+=2;d%=4
 if s==5:r+=[i]
 if [d]+p in m:return r
 return l(d,r,m,i+1,c,p)
def f(c,v):
 i=c.index("X");i2=c.index("\n");p=[i%(i2+1),i//i2];c=c.split("\n");r=[];
 for d in range(4):r+=l(d,[],[],1,c,p)
 print([[1,0],[2,2]][v in r][r==[]])

Try it online!
Edit: Saved 6 Bytes thanks to Ad Hoc Garf Hunter's suggestion.
Takes input c = string, v = power level
Outputs 0 for falsy, 1 for mediumly and 2 for truthy
This is my first codegolf submission, so there's most likely a better way but I tried best:
Explanation:
Note: Directions are encoded as an integer, where 0 = North, 1 = East, 2 = South, 3 = West
def l(d,r,m,i,c,p):                       # d:=direction, r:=result, m:=moves
                                          # i:=steps, c:=course, p:=position
    m += [[d]+p]                          # add direction and position as a move
    p[1] += (d-1)*(~d%2)                  # if direction is even move up or down
    p[0] -= (d-2)*(d&1)                   # if direction is odd move to the left or to the right
    s = r"/\-|+OX ".index(c[p[1]][p[0]])  # get next token as an int
    if s<2:                               # case "/" or "\"
        d += (s^d&1)*2+1                  # rotate either 270 or 90 degrees, depending on
                                          # whether the direction is odd or even
                                          # flip the condition depending if "/" or "\"
        d%=4                              # correct direction in case of overflow
    if 1 < s < 5:                         # edge hit
        d += 2                            # rotate 180 degrees
        d %= 4                            # if direction overflows
    if s == 4:                            # case "O"
        r+=[i]                            # add number of steps to result list
    if [d]+p in m:                        # if move was already made
        return r                          # return result
    return l(d,r,m,i+1,c,p)               # call next step

def f(c,v):                                             # c is the string, v the power level
    i = c.index("X")                                    # getting the index of the "X"
    i2 = c.index("\n")                                  # getting the width of the course
    p = [i % (i2+1), i // i2]  # transforming it to a [x,y] position
    c = c.split("\n")                                   # splitting the string into a list
                                                        # so it can be accessed via [y][x]
    r = []
    for d in range(4):                                  # the 4 starting directions
        r += l(d,[],[],1,c,p)                           # starting the loop with the init values
    print(2 if v in r else 0 if r == [] else 1)         # if the power level is in the list
                                                        # output 2
                                                        # if the list is empty (hole could not be reached)
                                                        # output 0
                                                        # else output 1

Welcome to the site.  I think you can save bytes by using boolean indexing instead of if else.  e.g. a if b else c is shorter as [c,a][b].

Scala, 298 bytes
l=>s=>{def h(d:Int,c:(Int,Int),p:Int,r:Set[Any]):Int={val x=(c._1+(d-2)%2,c._2+(d-1)%2)
val a=s(x._2)(x._1)
if(a==79)if(p==1)1 else math.max(0,h(d,x,p-1,r+(c->d)))else if(!r(x->d))h(d^(4-5*a%26%5),x,p-1,r+(c->d))else-1}
0 to 3 map(h(_,s.map(_ indexOf'X').zipWithIndex.find(_._1>=0)get,l,Set()))max}

Try it online!
I used the brilliant formula Arnauld used in their answer, but it's still a pretty large amount of code.
Outputs -1 for false, 0 for mediumy, and 1 for truthy.
Prettier version:
//l is the power level, s is the golf course, split on \n
l => s => {
  //h is a recursive helper function
  //dir is the direction, c is the (x,y) coordinates of the ball,
  //p is the power level, and seen is a set holding a tuple of all the coordinates and directions
  //(In reality, seen is a Set[((Int,Int),Int)], but I was lazy)
  def h(dir: Int, c: (Int, Int), p: Int, seen: Set[Any]): Int = {
    //The new position
    val x = (c._1 + (dir - 2) % 2, c._2 + (dir - 1) % 2)
    //The character at the new position
    val a = s(x._2)(x._1)
    if (a == 79) {  //Found the hole!
      if (p == 1) 1 //Power level is right
      else math.max(0, h(dir, x, p - 1, seen + (c->d))) //Power level is right
    } else if (seen(x, d)) -1 //We're just looping around, it's never going to work
    else h(dir ^ (4 - 5 * a % 26 % 5), x, p - 1, seen + (c -> d)) //Go on to the next move
  }
  //Try out every direction
  (0 to 3).map(h(d =>
    d,
    s.map(_.indexOf('X')).zipWithIndex.find(_._1 >= 0).get, //The start coordinate
    l,
    Set()
  )).max
}

Charcoal, 94 bytes
ＷＳ⊞υι≔⪫υ¶ηＰη…η⌕ηX≔⟦⟧υＦ⁴«≔⟦⟧ζＷ¬№ζ⟦ⅈⅉι⟧«⊞ζ⟦ⅈⅉι⟧Ｍ✳⊗ι≡ＫＫO⊞υＬζ\≦⁻³ι/≔﹪⁻⁵ι⁴ι¿№+|-ＫＫ≔﹪⁺²ι⁴ι»»⎚ＦυＰ=№υＮ

Try it online! Link is to verbose version of code. Takes input as the course and power level separated by a blank line, and outputs - for correct power level, = for incorrect power level, and nothing for an impossible course. Explanation:
ＷＳ⊞υι

Input the course until the blank line is reached.
≔⪫υ¶ηＰη

Join the lines back together and print the course without moving the cursor.
…η⌕ηX

Print the course up to the X, which leaves the cursor at the start.
≔⟦⟧υ

Start keeping track of the working power levels.
Ｆ⁴«

Loop over all orthogonal directions.
≔⟦⟧ζ

Start keeping track of visited positions. (Because I really need a repeat...until loop here, this is slightly golfier than just comparing the current position with the initial position. I also need the number of steps anyway.)
Ｗ¬№ζ⟦ⅈⅉι⟧«

Repeat until we're at a previous position and direction. (This can only happen when we get back to our starting point and direction, since the other saved positions can only be reached from there.)
⊞ζ⟦ⅈⅉι⟧

Save the current position and direction.
Ｍ✳⊗ι

Move in the current direction. (In Charcoal, direction 0 is to the right, increasing by 45 degrees anticlockwise each time, so that e.g. 6 is down. Since we're not interested in diagonals, I work in multiples of right angles and double them for the Move command.)
≡ＫＫ

Switch on the character under the cursor.
O⊞υＬζ

If it's an O then save the power level (i.e. number of steps) needed to get here.
\≦⁻³ι

If it's a \ then XOR the direction with 3, which here is simply equivalent to subtracting it from 3, as Charcoal has no XOR operator.
/≔﹪⁻⁵ι⁴ι

If it's a / then XOR the direction with 1, which is equivalent to subtracting from 5 modulo 4.
¿№+|-ＫＫ≔﹪⁺²ι⁴ι

Otherwise if it's any other wall then XOR the direction with 2, which is equivalent to adding 2 modulo 4.
»»⎚

Clear the canvas once all directions have been considered.
ＦυＰ=

If it was possible to get the ball in the hole then output a =.
№υＮ

But if the input power level was correct then change that to a -.

JavaScript (Node.js), 240 bytes
(g,P,w=g.indexOf('\n')+1,f=(d,i=g.indexOf('X'),p=P,a=[],c=g.replace(/-|\|/g,'+')[i],s=Math.sign(d),q=w+1-d/s)=>a.includes(k=''+[i,d])?0:!p&&c=='O'?3:c=='O'|f((d=c=='/'?-s*q:c=='\\'?s*q:c=='+'?-d:d),i+d,p-1,[...a,k]))=>f(1)|f(-1)|f(w)|f(-w);

Returns 3 for truthy, 1 for mediumy, and 0 for falsey.
Try it online!
Nice question!
I'm not super happy with my result, but I did learn a cool trick in the meantime: you can save some bytes by replacing
(a1,a2)=>{x=f(a1,a2);return g(x)}

with
(a1,a2,x=f(a1,a2))=>g(x)


text:
Slowing Down Sped Up Videos
Summary
Videos which are sped up every time a particular word is said exist for everything from the Bee Movie to the classic Rick Roll. The goal for this challenge is to figure out how much you'd have to slow down the sped-up video in order to match the duration of the original video.
For example, the original Bee Movie has a duration of 95 minutes. The sped up version is 5:40 or ~5.667 minutes. 95/5.667 = 16.76. We'd have to play the sped up version 16.76x slower in order for the overall duration to match the original movie.
Inputs
Your program must take in 3 inputs:

The duration of the original video (Bee Movie was 95 minutes)
The speedup factor per occurence (Bee Movie was 15% or .15)
A list of timestamps of occurrences (Bee movie has more than I care to look up/list)

The exact way these are passed in is flexible: 3 separate parameters is my default assumption, but if you want to take in a single list of values and pop the duration/speedup factor off the front that's fine, or take a single string in JSON or whatever format floats your boat, etc.
For the duration: seconds, minutes, or some builtin duration type are all fine.
For the speedup factor of the bee movie, any of 15, .15, or 1.15 could be used to represent the 15% speedup.
You can assume the occurrences are ordered in the most convenient manner, but there can be duplicate values (such as multiple characters talking over one another in a movie).
Output
A scaling factor to make the durations of the original and sped-up video match. The exact format is flexible.
Examples
{"duration": 10, "speedup-factor": 2, "occurrences": [1,2,3,4,5,6,7,8,9]} -> {"slowdown-factor": 5.004887585532747}
{"duration": 500, "speedup-factor": 1.15, "occurrences": [1,2,3, ..., 497, 498, 499]} -> {"slowdown-factor": 65.21739130434779}
{"duration": 100, "speedup-factor": 3, "occurrences": [0]} -> {"slowdown-factor": 3}
{"duration": 100, "speedup-factor": 3, "occurrences": [0, 0, 0]} -> {"slowdown-factor": 27}
{"duration": 100, "speedup-factor": 100, "occurrences": [99.99]} -> {"slowdown-factor": 1.0000990098}

Notes: First two generated programmatically with 100/(sum(1/(2**i) for i in range(10))) and 500/(sum(1/(1.15**i) for i in range(500))). 4th example: 3 * 3 * 3 = 27x speedup, occurring right at the start of the video. Last example calculated by hand with 100/(99.99 + .01/100)
Note
I've kept most of the examples fairly simple, but I believe they cover all the relevant edge cases (a program which solves all of them should be totally correct). If I've left things ambiguous or difficult to parse, let me know and I'll add comments!

Welcome to the site! This is a good first attempt at writing a challenge, but I've edited the markdown slightly just to improve the final look. Feel free to change anything you don't like. Note that we require challenges to have a objective scoring criteria, which you are missing. The standard is [tag:code-golf] (shortest code wins), but there are a number available. (cont.)

(cont.) Furthermore, I'd highly recommend posting your next challenge in the Sandbox first, so that you can get feedback on potential issues your challenge ideas may have

Is this meant to be code golf (shortest code wins)?

Yes it is supposed to be code golf!

I have submitted challenges in the past (though it appears I accidentally made a new account somehow: I thought it was linked to my google account) and participated in the sandbox. It has been a while though, and I guess I was overconfident in my (rusty) question asking ability. I will use the sandbox in the future!

You can merge duplicate accounts if you need to

The first test case isn't matching up with my code, which gives 5.00488758553. Maybe I'm misunderstanding something. It seems to be that sped up video is about 2 seconds, since the segments takes 1,1/2,1/4,... seconds each, requiring a slowdown factor of about 5 given the 10-second original.

@xnor I'm with you on that one. It seems that the first two test cases calculate the duration of the sped-up film, but the later ones actually calculate original duration / sped-up duration

@xnor You're absolutely right. I will update the test cases.

Python 2, 47 bytes
lambda m,r,l:m/reduce(lambda u,x:u/r+x-x/r,l,m)

Try it online!
Takes timestamps sorted in descending order.
The idea is to compute the video duration as a polynomial in the inverse speedup rate 1/r using Horner's method with coefficients given by the sorted timestamps. This avoids needing to explicitly take the differences of consecutive timestamps. We then divide the duration of the original video by the resulting duration to get the desired slowdown factor.
53 bytes
f=lambda m,r,l:l==[]or r/(l.pop()*(r-1)/m+1/f(m,r,l))

Try it online!
An attempt to write the function fully recursively. While the new duration itself has a clean recursive expression, we want to get the slowdown factor which divides the original duration by the new duration, and this is messier to express recursively.

Fantastic! Horner's method is the type of trick I was hoping to learn about when posting the challenge. Avoiding taking the differences is something I didn't know would be possible!

Jelly, 10 bytes
;ŻIṚḅ⁵İ¤÷@

A full program accepting timestamps original-duration speedup-factor which prints the necessary slowdown-factor.
Try it online!
How?
Get a list of the durations of film separated by the occurrences (including any zero-length segments), reverse and convert from base slowdown-factor (where this slowdown-factor is the inverse of the given speedup-factor), then divide the original-duration by that.
;ŻIṚḅ⁵İ¤÷@ - Main link: timestamps S, original-duration T
;          - concatenate (T) to (S) -> S+[T]
 Ż         - prefix with a zero (the start of the film) -> [0]+S+[T]
  I        - deltas -> [S[1]-0, S[2]-S[1], ..., S[n]-S[n-1], T-S[n]]
   Ṛ       - reverse -> [T-S[n], S[n]-S[n-1], ..., S[2]-S[1], S[1]-0]
       ¤   - nilad followed by link(s) as a nilad:
     ⁵     -   3rd argument = speedup-factor
      İ    -   inverse -> 1/speedup-factor - call this F
    ḅ      - convert from base -> (T-S[n])×F^(n)+(S[n]-S[n-1])×F^(n-1)+...+(S[2]-S[1])×F^1+(S[1]-0)×F^0
         @ - using swapped arguments (with implicit right argument T):
        ÷  -   division -> T/((T-S[n])×F^(n)+(S[n]-S[n-1])×F^(n-1)+...+(S[2]-S[1])×F^1+(S[1]-0)×F^0)
           - implicit print

Would it help at all to take input in descending order instead of ascending?

I don't think it would help

In which encoding does this take only 10 bytes?

@NiklasMertsch Jelly has a custom code page (as linked in the header).

Haskell, 32 bytes
m%r=(m/).foldr(\x u->u/r+x-x/r)m

Try it online!
Port of my Python answer.

APL (Dyalog Unicode) 18.0, 15 bytes
÷⊥⍥÷∘(⊃÷2-/,∘0)

Try it online!
J, 16 bytes
#.&.:%{.%2-/\,&0

Try it online!
Inline tacit functions that take the speedup on the left, and duration,occurrences on the right in descending order.
Both code use the same algorithm:
÷⊥⍥÷∘(⊃÷2-/,∘0)
    ∘(        )  On the right argument,
           ,∘0   Append zero
        2-/      Take pairwise differences
      ⊃÷         Divide each number above by the head
                 (division by zero is handled by system setting ⎕DIV←1,
                 which gives 0.)
 ⊥⍥÷             Take reciprocal of both args and do base conversion
÷                Take reciprocal of that

#.&.:%{.%2-/\,&0
\----/\--------/  2-train, so apply the right part on the right arg
             ,&0  Append zero
         2-/\     Take pairwise differences
      {.%         Divide each number above by the head
                  (division by zero gives built-in infinity,
                  whose reciprocal is again zero.)
  &.:%            Apply % (reciprocal) to both args
#.                Base conversion
  &.:%            Undo %, which is the same as applying % again

J, 20 bytes
Takes the speedup on the left, and the occurrences, length on the right. Calculates the speedup factor.
{:@]%%@[#.2-/\0|.@,]

Try it online!
How it works
 {:@]%%@[#.2-/\0|.@,] 2 f 50 100
               0   ,] prepend 0:   0 50 100
                |.@   reverse:     100 50 0
           2-/\       differences: 50 50
      %@[             1/n:         0.5
         #.           to base:     75
 {:@]                 last element:100
     %                100/75:      1.3333

Is there a way to append 0 instead of prepending 0 in order to eliminate the "reverse" step (You can assume input is provided in descending order instead of ascending in that case)? I tried playing around with your code in the online editor, but it wasn't as simple as I hoped (swapping ] and the 0, and everything else I tried ended with Syntax Errors).

0,~] would append 0 (and then you'd need {. in the front to take the first element). But other answers reverse the occurrences list for the base-conversion, too, so I'll keep it this way.

It seems like some do and some don't: xnor's python answer takes it in descending order for example. You can of course keep it however you prefer for any reason though!

05AB1E, 15 11 bytes
-4 bytes thanks to @KevinCruijssen's port of @JonathanAllan's Jelly answer
ª0š¥RIzβ¹s/

Try it online!

I didn't get the correct output with the test case: 100, [0], 3. This program outputs 33.3, vs the correct answer of 3.

Yeah you're right @stevenjackson121 the initial examples for the question were wrong and I had originally written what I have now updated it to be, but it didn't meet the first few examples. I was a bit surprised that it didn't, and assumed I'd misunderstood the question, but then was too busy to look. Here's an updated version with my original solution

A port of JonathanAllan's Jelly answer is 11 bytes: ª0š¥RIzβ¹s/, where the middle part DgÝIsm/O in your answer is replaced with RIzβ.

R, 49 bytes
function(d,f,o)d/diff(c(0,o,d))%*%f^-c(0,seq(!o))

Try it online!
Takes the original duration, the speedup factor, and the ocurrences.
Calculates the time between each occurrence diff(c(0,o,d)), then multiplies them with the appropriate speedup factors f^-c(0,seq(!o)) and sums them as a dot product %*%. Finally divides d by that result.

Wolfram Language (Mathematica), 35 33 bytes
s#/Fold[#/s+#2&,{##}-{##2,0}]&

Try it online!
Takes input as f[s][d,o], where o is a sequence of arguments in decreasing order.

Pyth, 14 bytes
chQu+c-GHeQHEh

Try it online!
Port of @xnor's answer to Pyth
Explanation
chQu+c-GHeQHEh
 hQ             : First element from first input
c               : divided by
   u            : value got by reducing from left to right
            E   : the second input
             h  : with default value as first input
                : on lambda G, H:
      -GH       :    G - H
     c   eQ     :    divided by second element from first input
    +      H    :    plus H

Io, 49 bytes
Port of xnor's Python answer.
method(m,r,l,m/l prepend(m)reduce(u,x,u/r+x-x/r))

Try it online!

05AB1E, 18 bytes
¤UćV0š¥εyYNm/}OXs/

Explaination:
¤UćV0š¥εyYNm/}OXs/
¤U                       Extract tail and save duration in X
  ćV                     Extract head and save speedup factor in Y
    0š                   Prepand 0 to the timestamps list
      ¥                  Deltas
       ε     }           map
        y                foreach element
         YNm             factor ** index of element
            /            element / (factor ** index of element) => this will be the duration of this section
              O          sum all up
               Xs        push duration before the result
                 /       division

Input:
A list of numbers in the format: [speedup_factor, ... timestamps_in_minutes ... , duration_in_minutes]
Output:
How much we need to slow down in minutes.
Try it online!

C (gcc), 74 69 bytes
Saved 5 bytes thanks to ceilingcat!!!
float f(d,s,o,n,a)float*o,s,a;{for(a=d;n--;)a=a/s+o[n]-o[n]/s;s=d/a;}

Try it online!
Port of xnor's Python answer.