# Code (Mini) Golf

## Pyth, 27 bytes

.Am<sXsd"_\ /"[1_4Z5)Q._C.z


Demonstration

This code does something very clever and not at all type-safe with X. Check it out below.

Explanation:

.Am<sXsd"_\ /"[1_4Z5)Q._C.z
Implicit: Z = 0, Q = eval(input())
Q is the initial power.
.z    Take all input, as a list of lines.
C      Transpose, giving all columns.
._       Form all prefixes.
m                            Map over the prefixes.
sd                       Concatenate the prefix.
X  "_\ /"[1_4Z5)          Change '_' to 1, '\' to -4, ' ' to 0, and '/' to 5.
In particular, 'U' is left unchanged.
If all elements were numbers,
this results in the total change in power.
If there was a 'U', it results in a string.
<                 Q         If the previous result was a number, this compares
it with the initial input to see if the ball is
still rolling.
If the previous result was a string, this slices off
the first Q characters, which always has a truthy
result.
.A                             Test whether all of the prefixes mapped to a thruthy
result.


import Data.List
g"_"=1
g"/"=5
g _= -4
f n=all(>0).scanl(-)n.map g.fst.span(/="U").(>>=words).transpose.lines


Usage example:

*Main> f 27 "      ____       ____ _   \n   __/    \\     /    U \\  \n__/        \\   /        \\_\n            \\_/           "
True
*Main> f 26 "      ____       ____ _   \n   __/    \\     /    U \\  \n__/        \\   /        \\_\n            \\_/           "
False


How it works:

                            lines  -- split into list of lines at nl
transpose   -- transpose
(>>=words)       -- turn each line into words (i.e. remove spaces)
fst.span(/="U")        -- take all words up to but excluding "U"
map g                     -- turn each word into the speed modifier
scanl(-)n                      -- build list of partial sums starting with n
--   note: speed modifiers are negative so we
--   use (-) with scanl to build sums
all(>0)                            -- return true if all sums are greater than 0


Edit: @user81655 found 2 bytes to save. Thanks!

## Ruby, 104 87 characters

->s,t{t.lines.map(&:bytes).transpose.map{|o|(c=o.max)==85||s<0?break: s+=c*3%14-6}
s>0}


Sample run:

2.1.5 :001 > track = '      ____       ____ _
2.1.5 :002'>    __/    \     /    U \
2.1.5 :003'> __/        \   /        \_
2.1.5 :004'>             \_/
2.1.5 :005'> '
=> "      ____       ____ _   \n   __/    \\     /    U \\  \n__/        \\   /        \\_\n            \\_/           \n"

2.1.5 :006 > ->s,t{t.lines.map(&:bytes).transpose.map{|o|(c=o.max)==85||s<0?break: s+=c*3%14-6};s>0}[27, track]
=> true

2.1.5 :007 > ->s,t{t.lines.map(&:bytes).transpose.map{|o|(c=o.max)==85||s<0?break: s+=c*3%14-6};s>0}[26, track]
=> false