Draw a Bumpy String

Mathematica, 93 83 68 64 bytes

(uses 0, not O)

Row[Column@Insert[{,},0,2-#]&/@Sign@Differences@LetterNumber@#]&

Explanation

LetterNumber@#

Gets the position in the alphabet of each characters of the input.

Sign@Differences@

Takes the difference between each consecutive elements, and takes the sign (-1 for negative/falling, 0 for 0/continuing, 1 for positive/rising)

Insert[{,},0,2-#]&

Inserts a 0 in a list of two Nulls, in the first position if rising, middle if continuing, and third position if falling.

Row[Column@ ... ]

Formats the output.


If the output could look different from the one in the question, the above code could be shortened to 41 bytes:

ListPlot@*Sign@*Differences@*LetterNumber

... which creates something like this (for "ABBCBA"):

enter image description here


MATL, 15, 14 bytes

dZSqtQtQv~79*c

Try it online!

Explanation:

They say a picture is worth a thousand words, so here is a beta online interpreter that shows you the value on top of the stack live as it updates. Note that it's still in beta, so you might need to hit run several times.

So first, we call dZS. d gives us the difference between each consecutive element, and ZS gives us the sign (-1, 0, or 1) of each element. So with 'HELLOWORLD' as input, after the first step we'll have:

-1  1  0  1  1 -1  1 -1 -1

Now, we just use q to decrement this and get:

-2  0 -1  0  0 -2  0 -2 -2

And then two times we duplicate the top of the stack and increment the array (tQ) After this we'll have

-2  0 -1  0  0 -2  0 -2 -2
-1  1  0  1  1 -1  1 -1 -1
0   2  1  2  2  0  2  0  0

Now all of the '0's are where we want to output a character. So, we join these three arrays into a matrix (v), and logically negate it (~). Then we multiply every value in the matrix by the ASCII value of 'O', (79*) and display it as a string with c.


Haskell, 63 bytes

f w=[do(e,y)<-zip w$tail w;max" "['o'|b e y]|b<-[(<),(==),(>)]]

Returns a list of three strings, representing the lines of output. Contains no subliminal messages.

dianne saved three bytes by using do notation and max instead of a list comprehension and last.