TopcoderArchiveVisit Topcoder
SRM13 Dec 2012
SRM 571

FoxAndGame

Problem statement, definition, constraints, and public examples.

Problem Statement

Fox Ciel is playing the popular game 'Cut the Rope' on her smartphone. The game has multiple stages, and for each stage the player can gain between 0 and 3 stars, inclusive. You are given a String[] result containing Fox Ciel's current results: For each stage, result contains an element that specifies Ciel's result in that stage. More precisely, result[i] will be "---" if she got 0 stars in stage i, "o--" if she got 1 star, "oo-" if she got 2 stars and "ooo" if she managed to get all 3 stars. Return the total number of stars Ciel has at the moment.

Definition

Class:
FoxAndGame
Method:
countStars
Parameters:
String[]
Returns:
int
Method signature:
int countStars(String[] result)
(be sure your method is public)

Constraints

  • result will contain between 1 and 50 elements, inclusive.
  • Each element in result will be one of "---", "o--", "oo-", "ooo".

Examples

  1. {"ooo",
     "ooo"}
    Returns: 6
    There are two stages. In each of them, Ciel got all three stars. Together, she now has 3+3 = 6 stars.
  2. {"ooo",
     "oo-",
     "o--"}
    Returns: 6
    This time the answer is 3 + 2 + 1 = 6.
  3. {"ooo",
     "---",
     "oo-",
     "---",
     "o--"}
    Returns: 6
  4. {"o--",
     "o--",
     "o--",
     "ooo",
     "---"}
    Returns: 6
  5. {"---",
     "o--",
     "oo-",
     "ooo",
     "ooo",
     "oo-",
     "o--",
     "---"}
    Returns: 12
  6. {"---",
     "---",
     "---",
     "---",
     "---",
     "---"}
    Returns: 0
  7. {"oo-"}
    Returns: 2
Back to all problems