TopcoderArchiveVisit Topcoder
SRM26 Oct 2005
SRM 269

AccessChanger

Problem statement, definition, constraints, and public examples.

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

  1. {"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" }
  2. {"---> // the arrow --->",
     "---",
     "> // the parted arrow"}
    Returns: {"--. // the arrow --->", "---", "> // the parted arrow" }
  3. {"->-> // two successive arrows ->->"}
    Returns: {".. // two successive arrows ->->" }
Back to all problems