TopCoder problem "BrickMystery" used in TCHS SRM 27 (Division I Level One)



Problem Statement

    

In the process of constructing a computer science building at a university, it was decided that a hidden message would be included in the brick patterns.

Each character in the message will be represented by a row of nine slots. Each slot will either contain a brick or remain empty. The first and last slots in a row will always be empty. The other seven slots will represent the character's 7-bit ASCII value in binary (most significant digit first), with empty slots where a binary 1 would be written.

Additionally, for increased aesthetic value, a character with ASCII value zero is added before and after the message .

The characters will be arranged sequentially from the top: the first character in the topmost row, the second right below it, etc.

Given a String message, return the pattern as a String[], where each String represents one row and each character in the strings is either 'x' (empty) or '.' (brick). The rows in the return should be ordered top to bottom.

 

Definition

    
Class:BrickMystery
Method:createPattern
Parameters:String
Returns:String[]
Method signature:String[] createPattern(String message)
(be sure your method is public)
    
 

Constraints

-message will contain between 0 and 50 characters, inclusive.
-Each character in message will have ASCII value between 32 and 126, inclusive.
 

Examples

0)
    
"L"
Returns: {"x.......x", "xx..xx..x", "x.......x" }
The ASCII value of the uppercase letter L is 76, which is 1001100 in binary. This translates to "x..xx.." in our code.
1)
    
"P=NP?"
Returns: 
{"x.......x",
"xx.x....x",
"x.xxxx.xx",
"xx..xxx.x",
"xx.x....x",
"x.xxxxxxx",
"x.......x" }
2)
    
""
Returns: {"x.......x", "x.......x" }

Problem url:

http://www.topcoder.com/stat?c=problem_statement&pm=7331

Problem stats url:

http://www.topcoder.com/tc?module=ProblemDetail&rd=10651&pm=7331

Writer:

lovro

Testers:

PabloGilberto , brett1479 , Olexiy

Problem categories:

String Manipulation