A coast-guard relay station receives short alert phrases from patrol boats and must compress each phrase into a single beacon code before it can be transmitted over a narrow-band radio channel. The station's encoding hardware follows a fixed procedure:
# in front of the core. If the beacon code (including the #) is longer than 100 characters, it is truncated by keeping only its first 100 characters.Given one alert phrase, output the beacon code the relay station would transmit (which may be an empty line if the transmission is aborted).
A single line containing the phrase: one or more words made only of lowercase English letters, separated by exactly one space, with no leading or trailing spaces.
Print a single line: the beacon code (this line may be empty if the core has fewer than 2 characters).
Example 1
Input
reef breach detected
Expected
#reefBreachDetected
Explanation
The words are "reef", "breach", "detected". The core is "reef" (kept lowercase as the first word) + "Breach" (first letter capitalized) + "Detected" (first letter capitalized) = "reefBreachDetected", which has 19 characters (>= 2), so the beacon code is "#reefBreachDetected".
Example 2
Input
x
Expected
(empty)Explanation
There is a single word "x". As the first word it stays lowercase, so the core is just "x", which has only 1 character (< 2). The station therefore aborts the transmission and the output is an empty line.
Ready to solve this?
Sign in to open the editor, run your code against the sample tests, and submit against the full test suite.
Sign in to solve →