The name formatter
Description
Discuss (12 comments)
In pretty much every website, there are forms to fill up your name information. Users don't all capitalize their names consistently, so the website typically formats them while processing the form. The purpose of this puzzle is to format a list of names.
The input file is structured as follows:
Example:
For each name you should print its corresponding formatted version:
For the previous example, the expected output is:
Input Specifications
Your program must take a single command line argument: the name of a file.The input file is structured as follows:
- The first line contains the number n of names
- The following n lines each contain a name, a name can have 1 to 3 components
- A 1 component name is a family name, ex: CLEOPATRA
- A 2 component name is a first name followed by a family name, ex: Albert EINSTEIN
- A 3 component name is either a particle name (Leonardo da VINCI) or a name with a middle initial (John F. KENNEDY)
Example:
5 CLEOpatra AISHWARYA rai jOHn f. KeNNeDy leonardo DA Vinci tyleR durdeN
Output Specifications
The output result should printed on the standard output.For each name you should print its corresponding formatted version:
- The first name must start with an uppercase letter and be followed by lowercase letters
- The middle initial must be uppercase
- The family name must be uppercase
- The particle must be lower (the da in da VINCI)
For the previous example, the expected output is:
CLEOPATRA Aishwarya RAI John F. KENNEDY Leonardo da VINCI Tyler DURDEN
Scoring
The score is proportional to the size of you program. Every character counts, including spaces, tabs and newlines. The more compact your program, the higher your score. If your program uses more than 1000 chars, it will score 0 points.© CoderCharts - All Rights Reserved
| Type | Puzzle | Pass | 949 | Fail | 77 | ||
| Scoring | Language | Level | Easy | Points | 100 | ||
| Tags | characters, formatting, words | ||||||
Unit Tests
| Name | CPU Unit | Memory Unit |
|---|---|---|
Small100 names to format |
||
Medium200 names to format |
||
Large300 names to format |
Confirm that you want to switch languages
Your current edits will be lost.
Confirm that you wish to load a previous submission
Your current edits will be lost.