[Question]
  [
My first code golf question post! Hope u like it ;-)
The task is simple. Write either an stdin-stdout program or a function. Input is a 2D array which contains only either characters or the integer `0`. You are allowed to replace the integers with the character `'0'` or `null` instead in any language (kudos to @SuperStormer for suggesting the "any" part) if you think it makes the problem easier or allows for decreasing code length.
Each element of the array contains `0`, `'>'`, `'<'`, `'^'`, `'v'`, or `'x'`. You play golf in the grid by starting at the indices `(0,0)`, and then moving in the direction indicated by the arrows. There is always an arrow at `(0,0)`. `0` is the no-op. The code stops when you get to `'x'`, the golf hole.
Each of the arrows that you encounter represents a stroke in golf. However, obviously not all arrows will be used. Your mission is to find how many strokes you did before you get to the hole.
TL;DR: Find the number of arrows in your path from `(0,0)` to `'x'`.
Examples:
```
[['>',0,0,'v','<'],[0,'>','x','<',0]]
> 0 0 v <
0 > x < 0
```
gives `3`.
```
[['v',0,'>','v',0,0,0],[0,0,0,'>','v',0,0],['>',0,'^',0,'v',0,0],['>',0,0,0,'x','<','<'],[0,0,0,0,0,0,'^']]
v 0 > v 0 0 0
0 0 0 > v 0 0
> 0 ^ 0 v 0 0
> 0 0 0 x < <
0 0 0 0 0 0 ^
```
gives `8`.
You do not need to consider handling cases which do not correspond to the input requirements.
Example code: (Python 3.8, 149 bytes, and yeah I'm so noob...)
```
def f(g):
    x=y=r=0
    while 1:
        if(n:=g[x][y])=='x':return r
        if n:a,b=(0,1)if n=='>'else(0,-1)if n=='<'else(-1,0)if n=='^'else(1,0);r+=1
        x+=a;y+=b
```
Have fun golfing!
Additional note: Changing the input values to things like "12345" is allowed if you are able to take advantage of language features by doing so. However you must mark your answer and the input code you used if you choose to do so ;-)
Additional additional note: Thanks to Unrelated String for this. "The next stroke taken is always the closest in the direction".
  
[Answer]
# JavaScript (ES6), 67 bytes
Expects a matrix filled with `0` for no-op and the ASCII codes of the other characters.
```
f=(m,x=y=0)=>(q=m[y][x])-120&&(q?c=q:0)/c+f(m,x+c%3-1,y+=~-c%5%3-1)
```
[Try it online!](https://tio.run/##fY7baoNAEIbvfYq5ibOLqzUNvSkZQ@hjyBZka5KWeJZFb/LqdneTWATpwMAc/vnm/8l01qn2u@7DsvrKp@lErBADjRRzSlhDRTrKdJA83L7Gvs@ag6LmPeYvKjhZYaA2u3ArxoBuodq82YZPfd71QFAAJWBUUZHVrLVN60ptSw2@DzpSl6z9MI@PPeMmPE9VZVdd8@hanZnlsNQDSDFBATG4RI0C9yiFXbiBWeLghlYgPfkPSN9B7kb/Qe3dDJw/LUV3wdMKfuJsZ1UwUx7WFp7X0hCd9@kX "JavaScript (Node.js) ‚Äì Try It Online")
---
# JavaScript (ES6), 62 bytes
Using the custom mapping of `<^>vx0` to `[-1,0,1,2,3,4]`.
```
f=(m,x=y=0)=>(q=m[y][x])-3&&(q<3&&(c=q,1))+f(m,x+c%2,y+=~-c%2)
```
[Try it online!](https://tio.run/##fY5NCoMwEIX3niII1QSjpO3WyRV6AIkg/hSL8Z8QN726NVaLC@nihcm8xzfvlahkSPuyHf26yfJ5LgBLqmECRoDjDmQ0iUgL4t8dB3eheVPo6JUQrzBJL73c6OTB218GMo/5MCJAEgFHix/IpMW9@fTrqMxohzFXmtlBWWe5fhRYEeSjhUgsK23qoanyoGqe2LBwZCEUudylLtukFoWuoKthFsbU69IEhCX@gNQG4RuI/XQAstPQFtirxIc6p4Fde7Xw7MRR8bf7/AE "JavaScript (Node.js) ‚Äì Try It Online")
[Answer]
# Excel (ms365), ~~119~~, 116 bytes
-3 Bytes thanks to @[JosWooley](https://codegolf.stackexchange.com/questions/263013/code-golf-for-golf/263022?noredirect=1#comment576209_263022)
[![enter image description here](https://i.stack.imgur.com/3tpGK.png)](https://i.stack.imgur.com/3tpGK.png)
[![enter image description here](https://i.stack.imgur.com/PxkDD.png)](https://i.stack.imgur.com/PxkDD.png)
Formula in `I1`:
```
=Z(A1,A1,0)
```
---
**Explaination**:
`Z()` refers to a custom function:
```
=LAMBDA(i,s,c,LET(y,IF(i=0,s,i),IF(i="x",c,Z(OFFSET(i,SWITCH(y,"^",-1,"v",1,),SWITCH(y,"<",-1,">",1,)),y,c+(i>0)))))
```
This is a recursive `LAMBDA()` with 3 parameters:
* The starting cell as 'i';
* The starting direction as 's';
* The starting count as 'c', being zero at the 1st iteration.
If the current cell ('i') equals 'x' the recursion stops and the function will output the current value of 'c'.
If the current cell <> 'x' this means we need to call `Z()` and use the new cell as 'i' which is acquired via `OFFSET()` using the current direction. The 's' will always be equal to the 'y' parameter found while we need to add one to our counter 'c'.
[Answer]
# [Python](https://www.python.org), 82 bytes
*-12 bytes thanks to Jonathan Allan*
```
f=lambda g,w,a=0,x=0:(n:=g[x])<119and(n>0)+f(g,w,a:=[a,n%3+n//14%3*w+~w][n>0],x+a)
```
[Attempt This Online!](https://ato.pxeger.com/run?1=m72soLIkIz9vweI025ilpSVpuhY3A3ISc5NSEhXSdcp1Em0NdCpsDaw08qxs06MrYjVtDA0tE_NSNPLsDDS10zTAaqxsoxN18lSNtfP09Q1NVI21yrXrymOjgUpidSq0EzWh5p5KV7BViDYz0lEwACNDQwsdBTMIGyRqaGQA5cdyFRRl5pVogMw31dTkygBpBCuHKYWywYgLzkKT41KAWmZpgrAQVQbqEpjNZiimwZGlCcJFGTrmmlAfLVgAoQE)
[Takes input as a flattened list of codepoints, plus the width of a row.](https://codegolf.meta.stackexchange.com/a/17117)
[Answer]
# [Charcoal](https://github.com/somebody1234/Charcoal), 43 bytes
```
Ôº∑Ôº≥‚äûœÖŒπÔº∞‚™´œÖ¬∂‚âî‚Å∞Œ∏Ôº∑‚åïx <v>^Ôº´Ôº´¬´Ôº¶‚Äπ¬πŒπ¬´‚âî‚äóŒπœÜ‚â¶‚äïŒ∏¬ªÔº≠‚ú≥œÜ¬ª‚éöÔº©Œ∏
```
[Try it online!](https://tio.run/##LY5Ba8MwDIXP9q8QOcmQQXdeCIyWQcsCgV1HwEuUxsyzU9vJCqO/3bPbCISe3oNP6ifpeit1jL@T0gR4NPMSPoJT5oxCQLv4CZcSlHjhzaKDmlMS8GSVyXbxaQqRolfv1dngroRL2jbUmzIDFleo1rorSmiJvhNSwB9no3WA7@Q9Pmf23WMb5GCXL00DKlHCmGiMNXLesqPpHf2QCTQ8TrEbZ41dCQ/KUR@UNTjmh258r0k6TLK9f7yXPuAlRTGuUK8AwFNnwWvo4DEBrlWV/VQdj0@r/gc "Charcoal ‚Äì Try It Online") Link is to verbose version of code. Takes input as a list of newline-terminated strings of spaces, arrows and an `x`. Explanation:
```
Ôº∑Ôº≥‚äûœÖŒπÔº∞‚™´œÖ¬∂
```
Copy the input to the canvas without moving the cursor.
```
‚âî‚Å∞Œ∏
```
Start with `0` strokes.
```
Ôº∑‚åïx <v>^Ôº´Ôº´¬´
```
Repeat until the ball goes in the hole.
```
Ôº¶‚Äπ¬πŒπ¬´
```
If the current character is an arrow, then...
```
‚âî‚äóŒπœÜ
```
... change the current direction, and...
```
‚â¶‚äïŒ∏
```
... increment the number of strokes.
```
¬ªÔº≠‚ú≥œÜ
```
Move the cursor in the current direction.
```
¬ª‚éöÔº©Œ∏
```
Output the final count.
[Answer]
# [Rust](https://www.rust-lang.org), 189 bytes
```
|a|{let(mut c,mut d)=((0,0),(0,0,0));loop{d=match a[c.0 as usize][c.1 as usize]{60=>(0,-1,d.2+1),62=>(0,1,d.2+1),94=>(-1,0,d.2+1),118=>(1,0,d.2+1),120=>break d.2,_=>d};c=(c.0+d.0,c.1+d.1)}}
```
[Attempt This Online!](https://ato.pxeger.com/run?1=XZBLboMwEIb3nMLNprYyIBulhASZHgRZlctDRQESgb0poRfphkV7jB4kt-kQkjSqxprx_9nzsD-_WtuZ8fRYNKTWZUMZ6R2nyg0ptkVDk8SG0VpFT4q5sQ2J_LamcMPTz1Efe7xFa2tICpPPmKSUA2cweYwsqvb7Q5_JWpv0jegk9TjRHbFd-Z4rVOJP9QGXMea5AjLPXwoGgX8GN71ZocZjfgVChEjugY81Xttc7wgSeJFxNkSppNh2mXkcsCFGwYbh8oiPyHEObdmYqnmgi377PCyAFPhmLI1lAx_mDZqC5BzvICIUHAdD949NhuNAMK1b7myblVL4N85linGc4y8)
Hate needing to do explicit type conversions from signed to unsigned.
Takes input as ASCII character codes.
# [Rust](https://www.rust-lang.org), ~~147~~ 143 bytes
```
|a,b|{let(mut c,mut d)=(0,(0,0));loop{d=match a[c as usize]%9{6=>(-1,d.1+1),8=>(1,d.1+1),4=>(-b,d.1+1),1=>(b,d.1+1),3=>break d.1,_=>d};c+=d.0}}
```
[Attempt This Online!](https://ato.pxeger.com/run?1=VY9LboMwEIb3nGIaqZLdDJGdkBSCTA-CUGUeVlCBRGB3UcIZeoBuWLSHym1qmjRN9f-amW9m5MfHZ2s6PZ4eVAO1LBtCoXecqtCgtqohsfHD1TrBsivfCupGxgfxZbRy_dP7UWJ67O0qqY2GDKeYU0EYWjNKw2q_P_S5qKXOdiDjDGQHZjoouQ_6jYiIyzFf8Dmn6Fu6gjeN0l_ilq6wElHaFvIFLOOziPIhzOYiX7BhuDzrNXScQ1s2umruyKzfPg0zBEVizn1kuFniufjTTcuWDAPPhn-dSXxp4ce3CrwEH-1Pncvt43jO3w)
Same as above but takes input as a flattened array and length
[Answer]
# [Vyxal](https://github.com/Vyxal/Vyxal), 225 [bitsv1](https://github.com/Vyxal/Vyncode/blob/main/README.md), 28.125 bytes
```
00"¬£{?¬•·πò√ûi:\x‚â†|¬®^√∑N":‚àë¬¨√ü_:&+}!‚Äπ
```
[Try it Online!](https://vyxal.pythonanywhere.com/?v=1#WyI9IiwiIiwiMDBcIsKjez/CpeG5mMOeaTpcXHjiiaB8wqhew7dOXCI64oiRwqzDn186Jit9IeKAuSIsIiIsIltbJz4nLCcwJywnMCcsJ3YnLCc8J10sWycwJywnPicsJ3gnLCc8JywnMCddXSJd)
Less of a mess than before. Takes `0`s as `"0"`
## Explained
```
00"¬£{?¬•·πò√ûi:\x‚â†|¬®^√∑N":‚àë¬¨√ü_:&+}_!¬≠‚Å°‚Äã‚Äé‚Äé‚Å™‚Å°‚Å™‚Å†‚Å™‚Å°‚Å™‚Äè‚Å†‚Äé‚Å™‚Å°‚Å™‚Å†‚Å™‚Å¢‚Å™‚Äè‚Å†‚Äé‚Å™‚Å°‚Å™‚Å†‚Å™‚Å£‚Å™‚Äè‚Å†‚Äé‚Å™‚Å°‚Å™‚Å†‚Å™‚Å§‚Å™‚Äè‚Äè‚Äã‚Å°‚Å†‚Å°‚Äå‚Å¢‚Äã‚Äé‚Äé‚Å™‚Å°‚Å™‚Å†‚Å™‚Å¢‚Å°‚Å™‚Äè‚Å†‚Äé‚Å™‚Å°‚Å™‚Å†‚Å™‚Å§‚Å£‚Å™‚Äè‚Äè‚Äã‚Å°‚Å†‚Å°‚Äå‚Å£‚Äã‚Äé‚Äé‚Å™‚Å°‚Å™‚Å†‚Å™‚Å¢‚Å£‚Å™‚Äè‚Å†‚Äé‚Å™‚Å°‚Å™‚Å†‚Å™‚Å¢‚Å§‚Å™‚Äè‚Å†‚Äé‚Å™‚Å°‚Å™‚Å†‚Å™‚Å£‚Å°‚Å™‚Äè‚Å†‚Äé‚Å™‚Å°‚Å™‚Å†‚Å™‚Å£‚Å¢‚Å™‚Äè‚Äè‚Äã‚Å°‚Å†‚Å°‚Äå‚Å§‚Äã‚Äé‚Äé‚Å™‚Å°‚Å™‚Å†‚Å™‚Å¢‚Å¢‚Å™‚Äè‚Äè‚Äã‚Å°‚Å†‚Å°‚Äå‚Å¢‚Å°‚Äã‚Äé‚Äé‚Å™‚Å°‚Å™‚Å†‚Å™‚Å£‚Å£‚Å™‚Äè‚Å†‚Äé‚Å™‚Å°‚Å™‚Å†‚Å™‚Å£‚Å§‚Å™‚Äè‚Å†‚Äé‚Å™‚Å°‚Å™‚Å†‚Å™‚Å§‚Å°‚Å™‚Äè‚Å†‚Äé‚Å™‚Å°‚Å™‚Å†‚Å™‚Å§‚Å¢‚Å™‚Äè‚Äè‚Äã‚Å°‚Å†‚Å°‚Äå‚Å¢‚Å¢‚Äã‚Äé‚Äé‚Å™‚Å°‚Å™‚Å†‚Å™‚Å§‚Å£‚Å™‚Äè‚Äè‚Äã‚Å°‚Å†‚Å°‚Äå‚Å¢‚Å£‚Äã‚Äé‚Äé‚Å™‚Å°‚Å™‚Å†‚Å™‚Å§‚Å§‚Å™‚Äè‚Å†‚Äé‚Å™‚Å°‚Å™‚Å†‚Å™‚Å¢‚Å°‚Å°‚Å™‚Äè‚Äè‚Äã‚Å°‚Å†‚Å°‚Äå‚Å¢‚Å§‚Äã‚Äé‚Äè‚Äã‚Å¢‚Å†‚Å°‚Äå‚Å£‚Å°‚Äã‚Äé‚Äé‚Å™‚Å°‚Å™‚Å†‚Å™‚Å¢‚Å°‚Å¢‚Å™‚Äè‚Å†‚Äé‚Å™‚Å°‚Å™‚Å†‚Å™‚Å¢‚Å°‚Å£‚Å™‚Äè‚Å†‚Äé‚Å™‚Å°‚Å™‚Å†‚Å™‚Å¢‚Å°‚Å§‚Å™‚Äè‚Äè‚Äã‚Å°‚Å†‚Å°‚Äå‚Å£‚Å¢‚Äã‚Äé‚Äé‚Å™‚Å°‚Å™‚Å†‚Å™‚Å¢‚Å¢‚Å°‚Å™‚Äè‚Å†‚Äé‚Å™‚Å°‚Å™‚Å†‚Å™‚Å¢‚Å¢‚Å¢‚Å™‚Äè‚Å†‚Äé‚Å™‚Å°‚Å™‚Å†‚Å™‚Å¢‚Å¢‚Å£‚Å™‚Äè‚Äè‚Äã‚Å°‚Å†‚Å°‚Äå‚Å£‚Å£‚Äã‚Äé‚Äé‚Å™‚Å°‚Å™‚Å†‚Å™‚Å¢‚Å¢‚Å§‚Å™‚Äè‚Å†‚Äé‚Å™‚Å°‚Å™‚Å†‚Å™‚Å¢‚Å£‚Å°‚Å™‚Äè‚Äè‚Äã‚Å°‚Å†‚Å°‚Äå‚Å£‚Å§‚Äã‚Äé‚Äé‚Å™‚Å°‚Å™‚Å†‚Å™‚Å¢‚Å£‚Å¢‚Å™‚Äè‚Å†‚Äé‚Å™‚Å°‚Å™‚Å†‚Å™‚Å¢‚Å£‚Å£‚Å™‚Äè‚Å†‚Äé‚Å™‚Å°‚Å™‚Å†‚Å™‚Å¢‚Å£‚Å§‚Å™‚Äè‚Äè‚Äã‚Å°‚Å†‚Å°‚Äå‚Å§‚Å°‚Äã‚Äé‚Äè‚Äã‚Å¢‚Å†‚Å°‚Äå‚Å§‚Å¢‚Äã‚Äé‚Äé‚Å™‚Å°‚Å™‚Å†‚Å™‚Å¢‚Å§‚Å¢‚Å™‚Äè‚Å†‚Äé‚Å™‚Å°‚Å™‚Å†‚Å™‚Å¢‚Å§‚Å£‚Å™‚Äè‚Äè‚Äã‚Å°‚Å†‚Å°‚Äå¬≠
00"¬£                             # ‚Äé‚Å°Put the list [0, 0] into the register. The register will act as the current character pointer
    {         |                  # ‚Äé‚Å¢While:
      ¬•·πò√ûi                       # ‚Äé‚Å£  Indexing the register
     ?                           # ‚Äé‚Å§  Into the input
          :\x‚â†                   # ‚Äé‚Å¢‚Å°  Does not give "x" (leaving an extra copy of the retrieved character)
              |                  # ‚Äé‚Å¢‚Å¢Do:
               ¬®^                # ‚Äé‚Å¢‚Å£  Convert the retrieved character to the offsets that character represents. E.g. > maps to [1, 0] as it indicates incrementing the x coordinate.
# ‚Äé‚Å¢‚Å§Characters not in "^<>v" are mapped to [0,0]
                 √∑N"             # ‚Äé‚Å£‚Å°  Due to a goofy logic bug, ^ and v have their y-offset inverted, so un-invert it
                    :‚àë¬¨          # ‚Äé‚Å£‚Å¢  Check whether the sum of the offsets is not 0 (i.e. that the character is indeed a direction arrow)
                       √ü_        # ‚Äé‚Å£‚Å£  If it isn't a direction arrow, ignore the direction of the character. Otherwise, leave the offsets on the stack
                         :&+     # ‚Äé‚Å£‚Å§  Add whatever offset is on the top of the stack (either a new arrow or the previous direction) to the register. This leaves a copy on the stack.
# ‚Äé‚Å§‚Å°This act of leaving the copy on the stack is how the number of arrows is determined. Every time an arrow is encountered, it's direction is pushed permanently to the stack.
                             _!  # ‚Äé‚Å§‚Å¢Remove the last item (which will be "x" due to the nature of the while loop stopping with an extra copy) and then push the length of the stack.
üíé
```
Created with the help of [Luminespire](https://vyxal.github.io/Luminespire).
[Answer]
# [Racket](https://racket-lang.org/), 233 bytes
```
(display(let P([L(read)][x 0][y 0][X 0][Y 0][H 0][a add1])(match(list-ref(list-ref L y)x)['x H]['>(P L(a x)y 1 0(a H)a)]['<(P L(- x 1)y -1 0(a H)a)]['^(P L x(- y 1)0 -1(a H)a)]['v(P L x(a y)0 1(a H)a)][_(P L(+ x X)(+ y Y)X Y H a)])))
```
[Try it online!](https://tio.run/##VY1PC4JAEMXvfYoXHZwhhPUunj148KgsGkMaRQZhEruf3mbtj8Rj3zzmx7wd5Xjtp3m3Hd@BusvjPoinoZ9Qki1o7KXjxjqYxvpgVbA6WB5MIF2XNEw3mY5nGi6PKR770y@ggGfHNnLIGxtlVKIggWOPBEZTzqL9UbqAGA6JoviPtYHBKdUjNkpX9vww0W8MVnBY@vbaV7EOj5or1MihkJnnmegJgwzBVbwBLeG7CotMQ6vvbxHkkCJdT95qmV8)
Input is a two-dimensional [list](https://docs.racket-lang.org/guide/pairs.html) of [symbols](https://docs.racket-lang.org/guide/symbols.html):
```
((> > 0 0 0 v)
 (v < 0 ^ < 0)
 (0 ^ 0 0 > V)
 (> 0 v 0 x <)
 (0 0 > 0 ^ 0))
```
(That is, you don't need to use double quotes. Racket lists use parentheses `()` instead of brackets `[]` and don't use commas `,`.)
Output is displayed on STDOUT. If the ball hits the edges, the program crashes with an `index too large` error.
---
## Changelog
1. Removed `#!racket` (`-9` bytes). Thanks a lot [@SuperStormer](https://codegolf.stackexchange.com/users/70761/superstormer)!
---
## Explanation
Our program consists of a recursive function. At the initial run, we receive inputs and configure the initial variables. Note that for the golfed version I added an extra variable `a` that is shorthand for `add1`. It isn't necessary for the explanation.
```
(let program ([lst (read)] [x 0] [y 0] [dx 0] [dy 0] [hits 0])
  ...)
```
* `lst` is the [input list](https://docs.racket-lang.org/reference/reader.html#%28part._parse-pair%29).
* `x` and `y` are the indices at which the ball is currently at.
* `dx` and `dy` are the directions that the ball is traveling to.
	+ Used when a `0` or any unrecognizable symbol is seen.
* `hits` are the number of hits/strokes that have occurred.
We then use [Racket's `match` statement](https://docs.racket-lang.org/guide/match.html) to determine the action we must do. The first argument of the `match` statement is the symbol we are matching to. To get the current symbol we can think of the two-dimensional list as a table of rows and columns. Each row is selected with the `y` variable and inside of the row are columns which are selected with the `x` variable.
```
(let program ([lst (read)] [x 0] [y 0] [dx 0] [dy 0] [hits 0])
  (match (list-ref (list-ref lst y) x)
    ...))
```
In the body of the `match` statement, we have our cases. The cases are in the for of `[if-match? do-this]`. If the symbol is an `x`, we return the number of `hits`. If it is an arrow, we rerun the program with modified arguments. If is anything else (`_` in the statement), we rerun the program, but we set `x` and `y` according to `dx` and `dy` respectively.
```
(let program ([lst (read)] [x 0] [y 0] [dx 0] [dy 0] [hits 0])
  (match (list-ref (list-ref lst y) x)
    ['x hits]
    ['> (program lst (add1 x) y 1 0 (add1 hits))]
    ['< (program lst (- x 1) y -1 0 (add1 hits))]
    ['^ (program lst x (- y 1) 0 -1 (add1 hits))]
    ['v (program lst x (add1 y) 0 1 (add1 hits))]
    [_ (program lst (+ x dx) (+ y dy) dx dy hits)]))
```
To display the results, we surround the `let` statement with a `display` statement.
```
(display
  (let program (...)
    ...))
```
## Conclusion
This was a fun code golf to solve! I learnt something new in the process (the `match` statement) and got a new view on how to see two-dimensional lists (rows and columns).
Hope you all have an amazing week further!
[Answer]
# [C (clang)](http://clang.llvm.org/), 61 bytes
Expects an array containing `0`, `'>'`, `'<'`, `'^'`, `'v'`, or `'x'`
```
d;f(*a,m){d=*a?:d;return'x'-d?!!*a+f(a+d%3+d/14%3*m+~m,m):0;}
```
[Try it online!](https://tio.run/##bVDbasMwDH2OvkLtCMrF3bp1Y1D38iG7gBsnraF2R5qGQcl@PVOc0YbRByOfo6Ojg7JJtldu27ZaFlGihI3Pepmo9VzLMq9OpaNvmuj1aJSotIhUqsNZqh8en8NZYtMfy/r5VDbtnXHZ/qRzXBwrbQ73uxVAfTAaqvxYRcZVyN7YVdsXF8MZgq@S/0U0DvW7GwvkBQJtHEtoALgDVhkXdT5e3c2ptw9cIoOAViRwiv5RTYIWJJj2kFuc21MdhqARuLlO1j3tZfXVpZcGQ/hfMthLn3TZfaN9cfjLMYh367Ebp5QAgb8Y3@FF4BNfoscbga9MdZdpfwE "C (clang) ‚Äì Try It Online")
## Explanation
`a` tracks our current position, `m` is the side length of the array, and `d` is the direction we're going (which changes anytime `a != 0`). In each call to `f()` we update the value of `a` going one step in the direction of `d`.
## Commented
```
d;        // int d;
f(*a,m){  // function f() takes a pointer to int (a) and an int (m)
d=*a?:d;  // if *a != 0 then d = *a
return    //
 'x'-d?   // if d != 'x':
  !!*a+   //  add one if we're changing direction (*a != 0)
   f(...) //  to the result of calling f() recursively
 :        // else
  0;}     //  we're at the end (return 0)
```
[Answer]
# x86 assembly (Linux), 19 bytes
This solution is a bit cheeky on the input.
It expects a pointer to a M√óN 2d array with the following symbols:
* `0` -> `0`
* `x` -> `-128`
* `<` -> `-1`
* `>` -> `1`
* `^` -> `-M`
* `v` -> `M`
Which is, of course, the offset in bytes to the next element in the pointed-to direction, allowing us to just add the values. As the dimensions of the golf field is encoded into the field itself, we cannot have fields with rows larger than 127 bytes.
If the row length is a limitation, just design the field to use all the columns you'd like. Who wants a square golf course anyway?
```
; int golf(char *ptr) __attribute__((fastcall));
00000000 <golf>:
   0:   83 c8 ff                or     $0xffffffff,%eax ; int result = -1
                                                        ; do {
00000003 <loop>:
   3:   80 39 00                cmpb   $0x0,(%ecx)      ;   if (*ptr) {
   6:   74 04                   je     c <skip>
   8:   0f be 11                movsbl (%ecx),%edx      ;     int step = *ptr;
   b:   40                      inc    %eax             ;     result++;
                                                        ;   }
0000000c <skip>:
   c:   01 d1                   add    %edx,%ecx        ;   ptr += step;
   e:   83 fa 80                cmp    $0xffffff80,%edx ; } while (step != -128)
  11:   75 f0                   jne    3 <loop>
  13:   c3                      ret                     ; return result;
```
I can save an additional byte by making the input an array of ints rather than chars, but (to me) that violates the rule that:
> 
> [The input array] contains only either characters or the integer 0.
> 
> 
> 
I admit the distinction may be pointless when dealing with assembly.
[Try it online!](https://tio.run/##rVRNj5swED3jXzFKsgIqiIBtlSjttreeK@2xTZExDsvWAYRNyqrqX286tvlI1Bx6WFkg/MYz82b8BiolP2biJSwYO5@X8FgWFVVdy3fQVRI3PIeyUlDU4uCxJ9rCm0PJRe5DmlKl2jLrFE9TzztQqRgVwvffk7XivSLrQtSZMJ5Ev3bEqVtYhXEAd5z2RNR1gxg7NhmsogC8O856nzjPHOSPsiHOsT5JDGBx7ZT3xCkrZt31GXSneW4s2s56E07oJMl29HiuOOhcxGm5Iud1ThUlsmOMS4kB1lSysoTFF4qtyL9VC3KgpdAdmG2fEbE2xeLUNGBHls5X96MbQATmcU9u4H5w9xo3e7S5vcG0fY/RshfFIQ4iXO@CMB6RKIgDQxhbE4FJ0XJDTdRVAfeIJFNSwKwnm9VkOM0MTJYh@8Tq@sz@krX73Z2Y37JPMYYqLqu79WC8qcpNoKvamFqjudBohi/7EWrkH1SvsS@X3ZpXuDG9uezWllzL70jLimDbtIj1t@fDL93Fn22puCdVXncqsPKe7taHhwcYrgE@weLRigXvH3ZWDCgP3AWwQbUvb8dKrmIl/xsLNdq1FUT4Db8J0ZSxtqaTTyjnrCeKS5XGCAlOYWI8qR8n0E6csQ9KHq0aGoQ/DgeOixknHL@hYF@D9YlfTRUCsHo7DK7dbcYQZmeGOjPzqXCa@21kmSYT0@Q1mSavypQ4Pf6ZbHDr19TNcMr8M/6wg6CFPIfH@@Qv "Assembly (gcc, x64, Linux) ‚Äì Try It Online")
[Answer]
# Java 8, ~~129~~ ~~119~~ ~~118~~ ~~117~~ 116 bytes
```
m->{int c=0,p=0,l=m[0].length,d=0,t=0;for(;t<120;p+=d>99?l:d>93?-l:d/62*2-1)d=(t=m[p/l][p%l])>0?t+0*c--:d;return~c;}
```
-1 byte thanks to *@ceilingcat*.
Uses ‚êÄ-bytes (`'\0'`) instead of `0` for the no-ops.  
Input as a character-matrix.
[Try it online.](https://tio.run/##fVJNb4MwDL33V1hIk2AtNOukSeOrmnbaYd1hR6BSBllLFwIKhnWq2F/vDKXVLpusxLHzrPfsZMdbbu@yj2MqeV3DM8/VYQKQKxT6nacCVn04JCA10y3XURIlUFgepbsJbTVyzFNYgYLgWNjhYYAGbFbRkkERscSRQm1wO8sogwHz3ktteujfLJhXTYMsvL9fSpfc7dImP79bXC/sGysLTKTyai6TqLqSiRWyJU7ZdWrbbuZpgY1W36nXHb1eRtW8SZIxqmnLPIOCmjFfUedqEyXcOjXSc7dcA4oaH3ktwAUlPuEMOxhhzGLW@rGKWbj3Y2bMwGjp3PZ5MnXyY6wIvib8Jeht7/tn2MnWRjfSA7x@1SgKp2zQqYgTpTKNJ1U16IIxTPUP0FnwBdN3kfeFz5zE7yG49OTIXInatJyCV@MAXBfLR3q9B635l@VgORwuD@q6NIT/2I2XBk8ap8pJzV@81n9l4103fJbu@AM)
**Explanation:**
```
m->{                  // Method with char-matrix parameter and integer return-type
  int c=0,            //  Arrow-counter, starting at 0
      p=0,            //  Position, starting at {0,0}
      l=m[0].length,  //  Width of the input-matrix
      d=0,            //  Direction, starting initialized at anything
                      //  (since the cell at {0,0} is guaranteed to contain an arrow)
      t=0;            //  Current character, starting at 0
  for(;t<120          //  Loop until the current character is 'x':
      ;               //    After every iteration:
       p+=            //     Update the position by increasing by:
          d>99?       //      If the direction is 'v':
               l      //       Increase by the matrix-width: {x,y}‚Üí{x,y+1}
          :d>93?      //      Else-if the direction is '^':
                -l    //       Decrease by the matrix-width: {x,y}‚Üí{x,y-1}
          :           //      Else (the direction is '>' or '<'):
           d/62*2-1)  //       If the direction is '>': increase by 1: {x,y}‚Üí{x+1,y}
                      //       If the direction is '<': decrease by 1: {x,y}‚Üí{x-1,y}
    d=(t=m[p/l][p%l]) //   Set `t` to the value of the current position
      >0?             //   If `t` is an arrow (or 'x'):
         t            //    Update the direction to this `t`
         +0*c--       //    And decrease the arrow-counter by 1
        :             //   Else:
         d;           //    Keep the direction the same
  return~c;}          //  After the loop, return -c-1 as result,
                      //  where the -1 is to subtract 'x', since it isn't an arrow
```
[Answer]
# Swift, ~~166~~ ~~157~~ ~~135~~ 129 bytes
```
{var x=0,y=0,u=0,v=0,s=0
while 0<1{let i=$0[y][x]
if i>119{return s}
if i>0{(u,v)=i>63 ?(0,i>95 ?1:-1):(i-61,0)
s+=1}
x+=u
y+=v}}
```
Inspired by [@mousetail's Rust answer](https://codegolf.stackexchange.com/a/263018/106545). Takes a 2D array of ASCII values.  
[Try it on SwiftFiddle!](https://swiftfiddle.com/qtf36l6wrffgbd5ffycuvs66oy)
Explanation:
```
{ (arr: [[Int]]) -> Int in
  // Create some working variables.
  var x = 0
  var y = 0
  var dx = 0
  var dy = 0
  var strokes = 0
  // Swift has no dedicated 'loop' keyword
  while true {
    let currentValue = arr[y][x]
    // Swift uses switch/case rather than match, so these ifs are shorter
    if currentValue > 119 {
      // It must be 120, 'x'
      return strokes
    }
    if currentValue > 0 {
      (dx, dy) = currentValue > 63
        ? // It may be 'v' or '^'
          // 'v' = 118, '^' = 94
          (dx: 0, dy: currentValue > 95 ? 1 : -1)
        : // It may be '<' or '>'
          (dx: currentValue - 61, dy: 0)
      strokes += 1
    }
    y += dy
    x += dx
  }
}
```
It might be possible to further optimize those ifs.
Original answer:
```
{a in var c=(0,0),d=(0,0,0)
var i:Int{a[c.0][c.1]}
while 0<1{if i>119{return d.2}
if i>0{if i>63{d.1=0
d.0=i>95 ?1:-1}else{d.0=0
d.1=i-61}
d.2+=1}
c.0+=d.0
c.1+=d.1}}
```
* -9 by using a constant inside the loop rather than a computed local outside it
* -22 by using several variables rather than tuples
* -6 by combining the assignments to `u` and `v` into a single statement
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E/wiki/Commands), ~~37~~ 32 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage)
```
√á[¬¨–ΩZ<#¬©ƒÄi¬º¬ÆU}¬©√Ä¬Æ‚Ç¨√Å¬Æ√Å¬Æ‚Ç¨√Ä)X11%√®}¬æ
```
Uses `0` like in the challenge description.
[Try it online](https://tio.run/##yy9OTMpM/f//cHv0oTUX9kbZKB9aeaQh89CeQ@tCaw@tPNxwaN2jpjWHGw@tA2EQs0EzwtBQ9fCK2kP7/v@PjlYqU9Ix0FGyU9KBsIAwVicaTCOLAsVAPKBYHJhEEwWrrgCqtgFjuAlQmTil2FgA) or [verify all test cases](https://tio.run/##yy9OTMpM/V@m5JlXUFpipaCkU3lot46Sf2kJhGtf@f9we/ShNRf2RtkoH1p5pCHz0J5D60JrD6083HBo3aOmNYcbD60DYRCzQTPC0FD18IraQ/v@6xzaZq93aOv/6OhoJTslHQMgVCpT0lGyUYrViQaygWJKFWC@jkFsrI4CUFkZSBlYogyiwQCs1ABVFCgGMVApTglqKLIoWDXUYJhlCAjUExsbCwA).
**Explanation:**
Since 05AB1E lacks a multidimensional index builtins, I instead rotate the entire matrix, so the cell at coordinate `{0,0}` will always contain the current value.
```
√á           # Convert all characters in the (implicit) input-matrix to codepoint
            # integers (0s remain 0s)
 [          # Start an infinite loop:
  ¬¨         #  Push the first row (without popping the matrix)
   –Ω        #  Pop this list and push its first value
    Z       #  Push its maximum digit (without popping the value)
     <      #  Decrease it by 1
      #     #  Pop this maxDigit-1, and if it's 1: stop the infinite loop
            #  (which is only the case for 'x'=120)
  ¬©         #  Store the current value in variable `¬Æ` (without popping the value)
   ƒÄi   }   #  Pop the value, and if it's NOT 0:
     ¬º      #   Increase counter `¬æ` by 1 (starts initially at 0)
      ¬ÆU    #   And store `¬Æ` in variable `X`
  ¬©         #  Store the current matrix in variable `¬Æ` now (without popping the matrix)
   √Ä        #  Rotate its rows once towards the left
  ¬Æ         #  Push the matrix `¬Æ` again
   ‚Ç¨√Å       #  Rotate the values in each of its rows once towards the right
  ¬Æ√Å        #  Similar, but rotate its rows once towards the right
  ¬Æ‚Ç¨√Ä       #  Similar, but rotate the values in each of its rows once towards the left
     )      #  Wrap all four rotated matrix into a list
      X     #  Push the current direction codepoint-integer `X`
       11%  #  Modulo-11
          √® #  (0-based) modular index it into the list of four matrices
 }¬æ         # After the infinite loop: push counter `¬æ`
            # (which is output implicitly as result)
```
* `√á`+`Z<` is `[-1,8,5,7,5,1]` for `[0,"^",">","v","<","x"]` respectively (only `1` is truthy in 05AB1E);
* `√á`+`11%4%` (the `4%` is implicit due to modular indexing) is `[2,3,0,1]` for `["^",">","v","<"]` respectively.
[Answer]
**Ruby - 165 characters**
No deviations from the rules. Uses `0` as the no-op. You can test the code [here](https://tio.run/##ZY5fC4IwFMXf76e41cMeXKCv4bXPETIh/4SatOEylOyz2@ZGCDG2nf3OuYf1Qz4tCglTQEzZi/GQs4Rxp8wS3Bqr3BoOW2Bwtp7/xjozmpl43dsqb2ZMgFg0b3jLRz7Rz4JOSoWlhML8TaWNSFsBeV9d79jcsCAyvWDVjkLw5MXm2d4ZA9MEIzl4jk7HCKpO@1jiYzEzkdBEHfSxRwk6ICeagEZoA5rsa1HDU@P@IgesryUe3vqDupZPvdsvXw).
```
s,i,j,x,y=0,0,0,0,0
loop do
c = p[i][j]
break if c=='x'
if c!=0
if c=='v'||c=='^'
y=0
x=c=='v'?1:-1
elsif c=='>'||c=='<'
x=0
y=c=='>'?1:-1
end
s+=1
end
i+=x
j+=y
end
```
The readable version:
```
par_5 = [
  ['v',0,'>','v',0,0,0],
  [0,0,0,'>','v',0,0],
  ['>',0,'^',0,'v',0,0],
  ['>',0,0,0,'x','<','<'],
  [0,0,0,0,0,0,'^']
]
strokes = 0
i = 0
j = 0
i_inc = 0
j_inc = 0
loop do
  shot = par_5[i][j]
  if shot == 'x'
    break
  end
  
  unless shot == 0
    if shot == 'v' || shot == '^'
      j_inc = 0
      i_inc = shot == 'v' ? 1 : -1
    elsif shot == '>' || shot == '<'
      i_inc =  0
      j_inc = shot == '>' ? 1 : -1
    end
    strokes += 1
  end
  i += i_inc
  j += j_inc
end
puts "You had #{strokes} shots!"
```
**Output:**
`You had 8 shots!`
[Answer]
# [Desmos](https://www.desmos.com/calculator), 118 bytes
Expects an array in variable `A` and a number in variable `n` (explained later).
**Code in ticker**
```
\left\{0<v<120:k->k+1\right\},f(\left\{v=60:-1,v=62,v=94:-n,v=118:n,v=0:d\right\})
```
**Everything else**
```
i=1
d=0
k=0
v=A[i]
f(x)=d->x,i->i+x
```
[Try it on Desmos!](https://www.desmos.com/calculator/4bisr2gsaa)
---
**Input, explained**
Desmos neither supports characters nor multidimensional arrays, so input is instead recieved as a 1D array `A` containing the rows of the matrix, along with an integer `n` containing the length of a row. For example, the test case
```
[['>', 0,  0, 'v','<'],
 [ 0, '>','x','<', 0 ]]
```
Turns into
```
n=5
A=[62,0,0,118,60,0,62,120,60,0]
```
To speed things up you can use [this conversion tool](https://tio.run/##RUzLasMwELzrK4Y9SVCMIZdSooC/Iw8ItkwFykpIIiSEfLurjRPKsLPMg0n3@ht5853yssw5XlDuBf6SYq4odfKsGBa9Ghrvj2qOGcGzg@c1/lFYDft6XXYpnEen6cD0RWS6koKvmkCmNWUrONZSFS1zo2yJIVPA0J1TcjzpHn5uobWgnuBCcYh50qMxKmXPVc/E9sHPAw/2MTzJLMsVPXYQblAv/mi1a3xq968EN2yxfTdXnP4A) to automagically convert the input format for you.
After you enter your input into the program (see the "testcases" folder), reset the variables (run the action at the bottom of the page), and then start the ticker to run the program.
Once the program finishes, the result should be stored in `k`.
**Program code, explained**
Program code:
```
i=1                 pointer to current position
d=0                 direction of travel
k=0                 number of arrows
v=A[i]              shorthand for current value under the pointer
f(x)=d->x,i->i+x    change the direction and also increment the pointer in that direction
```
Ticker code (prettified for readability):
```
{0<v<120:k->k+1},f({v=60:-1,v=62,v=94:-n,v=118:n,v=0:d})
{0<v<120:k->k+1},                                           increment k if this is an arrow
                 f({                                  })    change the direction to...
                    v=60:-1,                                ...left if '<'
                            v=62,                           ...right if '>'
                                 v=94:-n,                   ...up if '^'
                                         v=118:n,           ...down if `v`
                                                 v=0:d      ...no change if 0
```
As a result of the fact that `i` points to a 1D array, the row number of `i` can be changed by adding/subtracting `n`, which is why the direction changes to `¬±n` for `'^'` and `'v'`.
[Answer]
# [Perl 5](https://www.perl.org/), 104 bytes
```
while(($_=$p[$i][$j])ne"x"){$i+=$b=/v/?1:/\^/?-1:/0/?$b:0;$j+=$d=/>/?1:/</?-1:/0/?$d:0;$t++if$_}print$t
```
```
@p = (
  ['v',0,'>','v',0,0,0],
  [0,0,0,'>','v',0,0],
  ['>',0,'^',0,'v',0,0],
  ['>',0,0,0,'x','<','<'],
  [0,0,0,0,0,0,'^']
);
#@p=(['>',0,0,'v','<'],[0,'>','x','<',0]);
while(($_=$p[$i][$j])ne"x"){
    $i+=$b=/v/?1:/\^/?-1:/0/?$b:0;
    $j+=$d=/>;/?1:/<;/?-1:/0/?$d:0;
    $t++if$_
}
print$t
```
[Try it online!](https://tio.run/##ZY3RCoMwDEWfl68QF2hFR93DXtSq/@GqIHOsIlJEnDD27V2tsgmjpAn35N6oZuguWufK4Q4FxynIRIIwICkJ1sk8ESzAjnuwyotg5NL@/8B6ZuNJbO2jNlgSAV4Mx1xx@jUtSXa92E5uEaEwq/B8yK6hFCuOqkApCmyF1zfu7HovOKD0OdacTSw7R@xasuxkesgyrKMwNrw1/MZZannyw7cVj74v71jBG9Qg@xFH0PoD "Perl 5 ‚Äì Try It Online")
]