diff --git a/challenges/a-phone-code/README.md b/challenges/a-phone-code/README.md new file mode 100644 index 0000000..c79a61a --- /dev/null +++ b/challenges/a-phone-code/README.md @@ -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. diff --git a/challenges/a-phone-code/solutions/.gitkeep b/challenges/a-phone-code/solutions/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/challenges/a-phone-code/test/1/input.txt b/challenges/a-phone-code/test/1/input.txt new file mode 100644 index 0000000..61837bb --- /dev/null +++ b/challenges/a-phone-code/test/1/input.txt @@ -0,0 +1,5 @@ +4 +00209 +00219 +00999 +00909 \ No newline at end of file diff --git a/challenges/a-phone-code/test/1/output.txt b/challenges/a-phone-code/test/1/output.txt new file mode 100644 index 0000000..d8263ee --- /dev/null +++ b/challenges/a-phone-code/test/1/output.txt @@ -0,0 +1 @@ +2 \ No newline at end of file diff --git a/challenges/a-phone-code/test/2/input.txt b/challenges/a-phone-code/test/2/input.txt new file mode 100644 index 0000000..9a4ddea --- /dev/null +++ b/challenges/a-phone-code/test/2/input.txt @@ -0,0 +1,3 @@ +2 +1 +2 \ No newline at end of file diff --git a/challenges/a-phone-code/test/2/output.txt b/challenges/a-phone-code/test/2/output.txt new file mode 100644 index 0000000..c227083 --- /dev/null +++ b/challenges/a-phone-code/test/2/output.txt @@ -0,0 +1 @@ +0 \ No newline at end of file diff --git a/challenges/a-phone-code/test/3/input.txt b/challenges/a-phone-code/test/3/input.txt new file mode 100644 index 0000000..78aaa49 --- /dev/null +++ b/challenges/a-phone-code/test/3/input.txt @@ -0,0 +1,4 @@ +3 +77012345678999999999 +77012345678901234567 +77012345678998765432 \ No newline at end of file diff --git a/challenges/a-phone-code/test/3/output.txt b/challenges/a-phone-code/test/3/output.txt new file mode 100644 index 0000000..3cacc0b --- /dev/null +++ b/challenges/a-phone-code/test/3/output.txt @@ -0,0 +1 @@ +12 \ No newline at end of file