TopCoder problem "AccessChanger" used in SRM 269 (Division II Level One)



Problem Statement

    

You are converting old code for a new compiler version. Each "->" string should be replaced by ".", but this replacement shouldn't be done inside comments. A comment is a string that starts with "//" and terminates at the end of the line.

You will be given a String[] program containing the old code. Return a String[] containing the converted version of the code.

 

Definition

    
Class:AccessChanger
Method:convert
Parameters:String[]
Returns:String[]
Method signature:String[] convert(String[] program)
(be sure your method is public)
    
 

Constraints

-program will have between 1 and 50 elements, inclusive.
-Each element of program will contain between 1 and 50 characters, inclusive.
-Each character in program will have ASCII value between 32 and 127, inclusive.
 

Examples

0)
    
{"Test* t = new Test();", 
 "t->a = 1;", 
 "t->b = 2;", 
 "t->go(); // a=1, b=2 --> a=2, b=3"}
Returns: 
{"Test* t = new Test();",
"t.a = 1;",
"t.b = 2;",
"t.go(); // a=1, b=2 --> a=2, b=3" }
1)
    
{"---> // the arrow --->",
 "---",
 "> // the parted arrow"}
Returns: {"--. // the arrow --->", "---", "> // the parted arrow" }
2)
    
{"->-> // two successive arrows ->->"}
Returns: {".. // two successive arrows ->->" }

Problem url:

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

Problem stats url:

http://www.topcoder.com/tc?module=ProblemDetail&rd=8002&pm=4830

Writer:

Andrew_Lazarev

Testers:

PabloGilberto , brett1479 , Olexiy

Problem categories:

String Manipulation