Connection Status:
Competition Arena > Billboard
TCI '02 Round 3 · 2002-10-23 · by chogyonim · String Manipulation
Class Name: Billboard
Return Type: String[]
Method Name: enlarge
Arg Types: (string, vector<string>)
Problem Statement

Problem Statement

An electronic billboard is supposed to display large letters by using several lightbulbs per letter. Given a message, and how each enlarged letter looks as a 5x5 arrangement of lightbulbs, return the enlarged message.

The enlarged representation of the letters will be in a String[] with each element formatted as follows (quotes added for clarity):

"<letter>:*****-*****-*****-*****-*****"

Where <letter> is a single uppercase letter [A-Z], and each * is either the character '#' (representing a lit lightbulb) or a period ('.') (representing an unlit lightbulb). Each group of 5 (delimited by a dash, '-') represents a row in the 5x5 representation of the letter. So, "T:#####-..#..-..#..-..#..-..#.." means that the 5x5 representation of 'T' is:

"#####"
"..#.."
"..#.."
"..#.."
"..#.."

Return the enlarged message as a 5-element String[], with each element representing one row of lightbulbs (where element 0 is the top row). Leave 1 (one) column of periods ('.') between each adjacent pair of letters in the enlarged message.

Constraints

  • message will contain between 1 and 10 characters, inclusive.
  • each character of message will be an uppercase letter [A-Z].
  • letters will contain between 1 and 10 elements, inclusive.
  • each element of letters will be exactly 31 characters in length.
  • each element of letters will be formatted as (quotes added for clarity): ":*****-*****-*****-*****-*****", where is a single uppercase letter [A-Z] (inclusive) representing the letter being enlarged, and each * is either the character '#' or a period.
  • every letter appearing in message will have an enlarged representation in letters.
  • each letter represented in letters will be unique.
Examples
0)
"TOPCODER"
{"T:#####-..#..-..#..-..#..-..#.."
,"O:#####-#...#-#...#-#...#-#####"
,"P:####.-#...#-####.-#....-#...."
,"C:.####-#....-#....-#....-.####"
,"D:####.-#...#-#...#-#...#-####."
,"E:#####-#....-####.-#....-#####"
,"R:####.-#...#-####.-#.#..-#..##"}
Returns: { "#####.#####.####...####.#####.####..#####.####.",  "..#...#...#.#...#.#.....#...#.#...#.#.....#...#",  "..#...#...#.####..#.....#...#.#...#.####..####.",  "..#...#...#.#.....#.....#...#.#...#.#.....#.#..",  "..#...#####.#......####.#####.####..#####.#..##" }
1)
"DOK"
{"D:####.-#...#-#...#-#...#-####."
,"O:#####-#...#-#...#-#...#-#####"
,"K:#...#-#..#.-###..-#..#.-#...#"}
Returns: { "####..#####.#...#",  "#...#.#...#.#..#.",  "#...#.#...#.###..",  "#...#.#...#.#..#.",  "####..#####.#...#" }
2)
"RANDOMNESS"
{"S:##.##-#####-#.#.#-#.#.#-####."
,"N:#####-#####-#####-#####-#####"
,"R:#####-#####-##.##-#####-#####"
,"A:.....-.....-.....-.....-....."
,"D:#.#.#-.#.#.-#.#.#-.#.#.-#.#.#"
,"O:#####-#...#-#.#.#-#...#-#####"
,"E:#....-.#...-..#..-...#.-....#"
,"M:#....-.....-.....-.....-....."
,"X:#...#-.#.#.-..#..-.#.#.-#...#"}
Returns: { "#####.......#####.#.#.#.#####.#.....#####.#.....##.##.##.##",  "#####.......#####..#.#..#...#.......#####..#....#####.#####",  "##.##.......#####.#.#.#.#.#.#.......#####...#...#.#.#.#.#.#",  "#####.......#####..#.#..#...#.......#####....#..#.#.#.#.#.#",  "#####.......#####.#.#.#.#####.......#####.....#.####..####." }

Note that the letter X is defined but never used.

3)
"ABCDE"
{"A:..#..-.#.#.-#####-#...#-#...#","B:####.-#...#-####.-#...#-####.","C:#####-#....-#....-#....-#####","D:####.-#...#-#...#-#...#-####.","E:#####-#....-####.-#....-#####"}
Returns: { "..#...####..#####.####..#####",  ".#.#..#...#.#.....#...#.#....",  "#####.####..#.....#...#.####.",  "#...#.#...#.#.....#...#.#....",  "#...#.####..#####.####..#####" }
4)
"SKINNY"
{"S:..##.-.#...-..#..-...#.-.##..","K:.#.#.-.##..-.#...-.##..-.#.#.","I:.###.-..#..-..#..-..#..-.###.","N:.#.#.-.###.-.###.-.###.-.#.#.","Y:.#.#.-.#.#.-..#..-..#..-..#.."}
Returns: { "..##...#.#...###...#.#...#.#...#.#.",  ".#.....##.....#....###...###...#.#.",  "..#....#......#....###...###....#..",  "...#...##.....#....###...###....#..",  ".##....#.#...###...#.#...#.#....#.." }

Submissions are judged against all 25 archived test cases, of which 5 are shown here. Case numbers match the judge’s.

Coding Area

Language: C++17 · define a public class Billboard with a public method vector<string> enlarge(string message, vector<string> letters) · 25 test cases · 2 s / 256 MB per case

Submitting as anonymous