BASHASH - bashing around
Your task is to read text from standard input and count the occurrences of unique words that begin with a capital letter from the English alphabet and may (but are not required to) be followed by lowercase letters.
To make things a bit trickier, some words that we are interested in might be followed by exactly one of the following punctuation marks: “.”, “,”, “?” or “!”. For example, “Exquisite!” and “Surprised?” should be counted, while “Pardon?!” and “F.labbergasted” should not.
To simplify things, you don’t need to worry about which programming language to use — Bash is your only option.
Input
You will be given a text split across an unspecified number of lines on standard input.
Each line may contain any ASCII characters. You may assume that the number of lines will not exceed 50.
Note that the task refers to the entire text, so you must read all the lines before producing the output.
Output
You should write a single number that represents the number of words specified in the description.
Example
Input:Alas my L0ve, you do me wrong!
To cast mE Off Discourteously.
For. I? have, l0ved you so long,
Delighting In ?Your c>mpany.
Output: 8
Explanation:
In the given text, there are eight words that meet the criteria: 'Alas,' 'To,' 'Off,' 'Discourteously,' 'For,' 'I,' 'Delighting,' and 'In.'
Added by: | mello |
Date: | 2025-05-07 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | BASH |