1
1
mirror of https://github.com/theoludwig/programming-challenges.git synced 2025-05-13 23:22:49 +02:00

feat(challenges): add a-phone-code

This commit is contained in:
Théo LUDWIG 2025-05-13 23:09:32 +02:00
parent 643989cc44
commit 070ac30ec3
Signed by: theoludwig
GPG Key ID: ADFE5A563D718F3B
8 changed files with 40 additions and 0 deletions

View File

@ -0,0 +1,25 @@
# a-phone-code
Created by [@theoludwig](https://github.com/theoludwig) on 13 May 2025.
## Instructions
Polycarpus has n friends in Tarasov city. Polycarpus knows phone numbers of all his friends: they are strings s1, s2, ..., sn. All these strings consist only of digits and have the same length.
Once Polycarpus needed to figure out Tarasov city phone code. He assumed that the phone code of the city is the longest common prefix of all phone numbers of his friends. In other words, it is the longest string c which is a prefix (the beginning) of each si for all i. Help Polycarpus determine the length of the city phone code.
### Input
The first line of the input contains an integer n — the number of Polycarpus's friends. The following n lines contain strings — the phone numbers of Polycarpus's friends. It is guaranteed that all strings consist only of digits and have the same length from 1 to 20, inclusive. It is also guaranteed that all strings are different.
### Output
Print the number of digits in the city phone code.
## Source
[Codeforces - A. Phone Code](https://codeforces.com/problemset/problem/172/A)
## Examples
See the `test` folder for examples of input/output.

View File

@ -0,0 +1,5 @@
4
00209
00219
00999
00909

View File

@ -0,0 +1 @@
2

View File

@ -0,0 +1,3 @@
2
1
2

View File

@ -0,0 +1 @@
0

View File

@ -0,0 +1,4 @@
3
77012345678999999999
77012345678901234567
77012345678998765432

View File

@ -0,0 +1 @@
12