Personnummer
InterviewTime limit1sMemory limit1024 MB
Convert a ten-digit Swedish personal identity number with a separator into twelve-digit YYYYMMDDXXXX form, using the separator to decide the birth century.
- Level
Easy3 of 10
- Topics
- Implementation, Math, String, Simulation
- Solved
- No attempts yet
Problem
Swedish personal identity numbers are usually written with ten digits in the format YYMMDD-XXXX. The first six digits are the person's date of birth, so a person with the identity number 781113-3285 was born on November 13, 1978. One detail many people do not know is that people over one hundred years old get a plus sign instead of a hyphen in their identity number. This is so they are not confused with people born exactly years later. For example, someone born in 1912 can have the identity number 121212+1212, while 121212-1212 belongs to someone born in 2012.
Write a program that reads an identity number in the format above and prints it in twelve-digit format, that is, YYYYMMDDXXXX. You may assume that the people in the input were born between 1840 and 2019. For simplicity, there will also be no people born in 1920.
Input
A single string of digits, hyphens, and plus signs, in the format above.
Output
Print a single string: the identity number from the input converted to twelve-digit format.