Skip to content

Commit f2f1ace

Browse files
authored
Created: README.md for The Fiscal Code
1 parent 29ef076 commit f2f1ace

1 file changed

Lines changed: 57 additions & 0 deletions

File tree

L-A/0011 The Fiscal Code/README.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# The Fiscal Code
2+
**[Edabit Solution](https://edabit.com/challenge/Pa2rHJ6KeRBTF28Pg)**
3+
4+
Each person in Italy has an unique identifying ID code issued by the national tax office after the birth registration: the Fiscal Code ([Codice Fiscale](https://en.wikipedia.org/wiki/Italian_fiscal_code_card)).
5+
6+
Given an object containing the personal data of a person (name, surname, gender and date of birth) return the 11 code characters as a string following these steps:
7+
8+
-Generate 3 capital letters from the surname, if it has:
9+
10+
- At least 3 consonants then the first three consonants are used. (Newman -> NWM).
11+
- Less than 3 consonants then vowels will replace missing characters in the same order they appear (Fox -> FXO | Hope -> HPO).
12+
- Less than three letters then "X" will take the third slot after the consonant and the vowel (Yu -> YUX).
13+
14+
- Generate 3 capital letters from the name, if it has:
15+
16+
- Exactly 3 consonants then consonants are used in the order they appear (Matt -> MTT).
17+
- More than 3 consonants then first, third and fourth consonant are used (Samantha -> SNT | Thomas -> TMS).
18+
- Less than 3 consonants then vowels will replace missing characters in the same order they appear (Bob -> BBO | Paula -> PLA).
19+
- Less than three letters then "X" will take the the third slot after the consonant and the vowel (Al -> LAX).
20+
21+
- Generate 2 numbers, 1 letter and 2 numbers from date of birth and gender:
22+
23+
- Take the last two digits of the year of birth (1985 -> 85).
24+
- Generate a letter corresponding to the month of birth (January -> A | December -> T) using the table for conversion included in the code.
25+
- For males take the day of birth adding one zero at the start if is less than 10 (any 9th day -> 09 | any 20th day -> 20).
26+
- For females take the day of birth and sum 40 to it (any 9th day -> 49 | any 20th day -> 60).
27+
28+
### Examples:
29+
30+
```javascipt
31+
fiscalCode({
32+
name: "Matt",
33+
surname: "Edabit",
34+
gender: "M",
35+
dob: "1/1/1900"
36+
}) ➞ "DBTMTT00A01"
37+
38+
fiscalCode({
39+
name: "Helen",
40+
surname: "Yu",
41+
gender: "F",
42+
dob: "1/12/1950"
43+
}) ➞ "YUXHLN50T41"
44+
45+
fiscalCode({
46+
name: "Mickey",
47+
surname: "Mouse",
48+
gender: "M",
49+
dob: "16/1/1928"
50+
}) ➞ "MSOMKY28A16"
51+
```
52+
53+
**Notes:**
54+
- Code letters must be uppercase.
55+
- Date of birth is given in D/M/YYYY format.
56+
- The conversion table for months is already in the starting code.
57+
- Y is not a vowel.

0 commit comments

Comments
 (0)