Double or Add

Problem #118

Tags: puzzle

Who solved this?

Previous:Desert Escape Next:Multiply or Add


Jack and Jill are playing a game. Jack chooses some positive integer n at random, and then Jill must construct that number with the following rules:

For example if Jack imagines the number 13, then Jill can perform a sequence of actions to the number 2 which yields the desired number:

2 -> 3 -> 6 -> 12 -> 13

If we refer to the Doubling as action A and the Addition as action B, then we can describe this sequence with the string:

BAAB

Problem Statement

Input Data
First line will be Q, the quantity of testcases.
Q lines will then follow, each with a single integer n being the number that Jack has chosen.

Answer
Should consist of Q space-separated strings corresponding the to the sequence of actions taken by Jill to produce the number n, starting from 2.

Example

input data:
2
13
1234

answer:
BAAB AABABAABAAABA
You need to login to get test data and submit solution.