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.
Xare perpendicularly intersecting cuts. Each has a length of 1.
^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:
- 0.50, if no other already made cuts are neighboring them,
- 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.
- 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!
#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@-┘
A-┐ ┌--┐ ┌-┐ ┌--┐ C-┐ ┌--┐ ┌-┐ ┌--┐ ^ | | | | | | | ^ | | | | | | | └-+-+--┘ └-+-+--┘ └-+-+--┘ └-+-+--┘ | | B | | | D | └-┘ ^-┘ └-┘ ^-┘
#-# A X X \ @ @-# v
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┐ <---------------┘
\$^1\$ If needed, replace this with a set of your choice.