TopcoderArchive
Archive
Algorithm problem

ColorNegative

Problem statement, definition, constraints, and public examples.

Problem Statement

You are given a list of colors as a String[]. We want to apply a negative filter to the colors: Each color must become its negative. Given colors return a String[] such that: for each i, the i-th element of the result should be equal to the negative of the i-th element of colors

The colors are represented by their English names, there are 12 possibilities for each color. The following contains the 12 color names on the left and the name of the respective negative color on the right:

Color          Negative
---------------------------
Black          White
White          Black
Red            Cyan
Cyan           Red
Yellow         Blue
Blue           Yellow
Green          Pink
Pink           Green
Light Gray     Dark Gray
Dark Gray      Light Gray
Orange         Light Blue
Light Blue     Orange

Definition

Class:
ColorNegative
Method:
negativeThem
Parameters:
String[]
Returns:
String[]
Method signature:
String[] negativeThem(String[] colors)
(be sure your method is public)

Notes

  • The input and the output are case sensitive.

Constraints

  • colors will contain between 1 and 50 elements, inclusive.
  • Each element of colors will be one of the 12 colors listed in the problem statement.

Examples

  1. {"Black"}
    Returns: {"White" }
  2. {"Red", "Light Blue", "Dark Gray"}
    Returns: {"Cyan", "Orange", "Light Gray" }
  3. {"Pink", "White", "Pink", "Orange" }
    Returns: {"Green", "Black", "Green", "Light Blue" }
  4. { "Light Gray", "Dark Gray" }
    Returns: {"Dark Gray", "Light Gray" }
Back to all problems