User:Jeff/BinaryPad

Problem Statement
You awake one morning from uneasy dreams to find that your best friend, Gregor, has transformed in his bed into a gigantic insect. By the frantic waving of his antennae, you deduce that he wants you to build a huge three-button pad in the shape of a circle. The buttons will each take up one third of the pad, and will be labeled A, B, and C. A is on the bottom, B on the upper left (clockwise from A), and C is on the upper right (counter-clockwise from A)  http://www.topcoder.com/contest/problem/lt/binarypad.png When Gregor wants to say something to you, he'll first convert the message to binary in his head. Then he'll climb onto the pad, starting at the A button. If the first digit in his binary message is 1, he would move clockwise onto button B. If the first digit is instead a 0, he would move counter-clockwise onto button C.  He repeats in this fashion, moving clockwise (B, C, A, B, C, A, ...) for each 1 and counter-clockwise (C, B, A, C, B, A, ...) for each 0, until his message is finished.

Given a String presses, indicating which buttons Gregor pressed, return a String representing the binary message he communicated.

Constraints

 * presses will contain between 1 and 50 characters, inclusive.
 * presses will only contain the characters 'A', 'B', and 'C'.
 * No two adjacent characters of presses will be the same.
 * The first character of presses will be either 'B' or 'C'.

Analyses

 * Problem Set Analysis & Opinion (10/15/02) - by lbackstrom

Solutions

 * Problem writer's solution (Java) - by LunaticFringe