Let's walk around the clock. We start at twelve o'clock and flip a
coin. If it comes up heads, we step forward by one hour. If it's tails,
we step one hour backward. We flip the coin a second time, but now we
step two hours forward in the case of heads, or two hours backward for
tails. On the third flip, we step three hours forward or backward on
the same principle. In general, then, the nth flip decides the
direction in which we step n hours: we move forward on heads,
and backward on tails.
You are given a String describing a sequence of coin
flips such that the nth character is either 'h', meaning that
the nth flip is heads, or 't' to signify that the nth
flip is tails. Return the hour at which we end up by following the
above procedure.
|