Connection Status:
Competition Arena > Cyberline
SRM 187 · 2004-03-16 · by Rustyoldman · String Parsing
Class Name: Cyberline
Return Type: String
Method Name: lastCyberword
Arg Types: (string)
Problem Statement

Problem Statement

As managing editor of BadCyberPoetry.net you find to your dismay that you must follow through on your threat to replace your "Editor of Conventionally Structured Poetry" with a very small shell script (or something to that effect).

The first part of this project is to build a method that returns the last cyberword of a cyberline of cybertext, in a form that is convenient for rhyme testing. Since this is bad cyber poetry, words may contain symbols other than letters.

A "cyberword" may contain letters, numbers, the hyphen (minus) character '-' and the '@' character (quotes for clarity). Cyberwords must contain at least one character that is a letter, number or '@'. Isolated hyphens or strings of hyphens alone are not cyberwords. Any other character is considered punctuation or white space and causes a cyberword break.

Cyberlines may contain cyberwords, punctuation, and spaces in any order, so the last cyberword may not be at the end of the cyberline. The cyberword you return should have all hyphens removed to simplify rhyme testing.

For example: In the string "Zowie: This is a line of##cyber-poetry## !",
"cyberpoetry" is returned.

Constraints

  • cyberline will consist of between 1 and 50 characters inclusive.
  • cyberline consists of letters ('a'-'z' and 'A'-'Z'), digits ('0'-'9'), the space character and ".,()?!<>#&$%_=+;:/~|{}-@" (quotes for clarity) in any order.
  • cyberline will contain at least one character which is a letter ('a'-'z' or 'A'-'Z'), digit ('0'-'9'), or '@'
Examples
0)
"Zowie: This is a line of##cyber-poetry## !"
Returns: "cyberpoetry"

This is the example from above.

1)
"2-b|!2-b -- ?"
Returns: "2b"
2)
"if then{}; elseif schmelshif();"
Returns: "schmelshif"
3)
"~y?"
Returns: "y"
4)
"y#/ y#: !!! y~#keys&h4x-h4x-h4x?"
Returns: "h4xh4xh4x"

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

Coding Area

Language: C++17 · define a public class Cyberline with a public method string lastCyberword(string cyberline) · 28 test cases · 2 s / 256 MB per case

Submitting as anonymous