A particular business card design can only accommodate up to three phone numbers.
Assume the phone numbers are always formatted as 10 digits with dashes. For example:
There are only 2 lines to accommodate 3 phone numbers.
If (and only if) all 3 phone numbers contain a value, then the mobile and office numbers must appear on the first line, and the fax must appear on the second line, like this:
Mobile: 456-789-1234 Office: 987-654-3210
If (and only if) one of the 3 phone numbers does not contain a value, then the remaining 2 numbers must appear on their own line, like this:
The example above assumes the Office number is the empty field. But if the Mobile number was the empty field then it would look like this:
And if the Fax number was the empty field, then it would look like this:
If 2 of the 3 numbers are empty, then return just the one remaining number.
So given all of the possible phone number combinations, we have:
M O F
What is the most efficient code block that can return up to 3 phone numbers but follow the format rules above?
(Assume the 3rd number cannot just wrap to the second line)