# Count the length of head movement

Once upon a time I wanted to order custom tokens for a board game. They say they can do it, and then they present me their price list. I was confused because they charge per inch of head movement, and I have no idea how much will my tokens cost.

INPUT: a 2d grid:

• |,-,\,/ are straight cuts. Each has a length of 1.
• ┌,┐,└,┘ are 90 degree corner cuts. Each has length of 1.$$\^1\$$
• #,@ are 45 and 135 degree corner cuts respectively. Each has a length of 1.20.
• +,X are perpendicularly intersecting cuts. Each has a length of 1.
• >,v,<,^ are the cut ends. Each has a length of:
• 1.50, if the arrow points at the diagonal cut,
• 1, if the arrow points at the beginning of next cut,
• 0.50 otherwise.
• ABC...UVWYZabc...xyz are the cut start points given in that order. They have a length of:
• 1.50, if if the cut begins next to the diagonal cut,
• 1 otherwise.

OUTPUT: Distance that a head will move with up to 2 significant digits.

Assume that:

• The company doesn't count distance from resting position to starting point of the first cut,
• Each cut is made only once (intersections cut twice on the same character),
• All grids are valid,
• The head moves from the end of a cut to the beginning of another cut in a straight line.

Obviously no standard loopholes, and the shortest code in each language wins!

TEST CASES:




Output: 0

A> B>


Output: 4

A------v
^------B


Output: 16

A┌┐^
└┘└┘


Output: 7.5

#B┐
|\v
A<#


Output: 11.4 (Note: First the head cuts bottom-left triangle, then moves its head to the beginning of top-right triangle cut. 45 degree corners take continuations first instead of new cuts.)

A-@<--┐
^  \  |
└--B@-┘


Output: 21.15

A-┐ ┌--┐ ┌-┐ ┌--┐ C-┐ ┌--┐ ┌-┐ ┌--┐
^ | |  | | | |  | ^ | |  | | | |  |
└-+-+--┘ └-+-+--┘ └-+-+--┘ └-+-+--┘
| |      B |      | |      D |
└-┘      ^-┘      └-┘      ^-┘


Output: 138.41

 #-#
A X
X \
@ @-#
v


Output: 13.5

A> F> K> P> U> a>
B> G> L> Q> V> b>
C> H> M> R> W> c>
D> I> N> S> Y> d>
E> J> O> T> Z> e┐
<---------------┘


Output: 104.29

$$\^1\$$ If needed, replace this with a set of your choice.

• Can we use swap the 4 90 degree cut symbols for ASCII symbols (e.g. use 1,2,3,4) instead? Commented Dec 9, 2019 at 13:13
• You should explain what you mean by "next to a diagonal cut". I thought it'd mean adjacent to # or @ (since 45° and 135° lines are diagonals), but this doesn't fit with the test cases. Commented Dec 9, 2019 at 15:43
• The output is defined as the distance that the head moves, but there's almost no explanation of how the head moves. Each character is associated with a "value"; are those actually distances? "The head moves from the end of the first cut to the beginning of the second cut in a straight line"; is that specific to the first cut, or true for all pairs of consecutive cuts? Commented Dec 9, 2019 at 17:00