Reformat · Medium
Clean up phone numbers
Phone numbers are typed in many ways: with spaces, dashes, brackets, a + or 00 in front.
Task
Write a prompt that writes each number as + followed by digits only.
Output format
one number per line, +<digits>
- Remove spaces, dashes, dots and brackets.
- A leading 00 means the same as +.
- A number with exactly 10 digits and no country code is a US number: put 1 in front.
Your prompt must contain {input}: it is replaced by each test case, just like the hidden tests in a hiring test.
Sample case 1
Input
+44 20 7946 0958
Output
+442079460958
Sample case 2
Input
0044-20-7946-0958 (212) 555-0187
Output
+442079460958 +12125550187
There are 4 test cases in all; the others are like hidden tests: work out what tricky inputs they might use!