-= Puzzle 5: One Way City =-

Your fifth day at BitFlop Laboratories starts in disaster!

Appearently, someone changed everybody's password two days ago, meaning now none of the delivery drivers can log into their trucks anymore!

Unfortunately for you, you're the only one who still knows their password, so you are tasked with delivering the products to the customers yourself.

Your destination is One Way City, a place infamously known for their obsession with one-way streets.

Before you leave, you are granted a map of the city (your puzzle input).

The map is a grid of arrows, where each arrow represents the direction of the street at that location.

For example:

>>>>vvv>vv
>^>>>>>>>v
>>^<>vvv>v
^^^>>vv>^v
^<<<v>vv>v
^<>^<>v>v<
>^^<<<<<vv
^^^<^v<<>v
^v<^<<vvvv
^<^<<<<<<<

You begin in the top-left corner of the map.

From each street, you may only drive in the direction indicated by the arrow.

The first street you are in (top-left) is marked >, this means you have to drive to the street on the right of it.

After following four right-pointing streets, you arrive at a street marked v, forcing you to continue downward instead.

Eventually, you'll arrive at a street you've already visited. At that point, you've entered a loop and will never reach any new streets.

Your task is to determine how many distinct streets you visit before entering that loop.

For the example above, you visit 45 distinct streets before visiting a street you've already visited before.

Those streets are highlighted below:

>>>>v.....
..>>>>>>>v
>>^......v
^........v
^........v
^<......v<
>^......v.
^.......>v
^v<......v
^<^<<<<<<<

The streets are designed in such a way that no arrow ever points towards the outside of the grid. (You truly can never leave)

How many distinct streets do you visit before revisiting a street?

You must login to get your input and play!