Missing project files

A healthy open-source project has a few standard files. Check a project's file list against them.

What to build

A program that lists which of four standard files a project lacks.

Requirements

  • The four expected files, in this order, are README.md, LICENSE, CONTRIBUTING.md and CODE_OF_CONDUCT.md. Names are case-sensitive.
  • For each missing file print missing: NAME.
  • Finally print COUNT file(s) to add, where COUNT is how many are missing (0 if none).

Input

The first line has n (1 to 100). Each of the next n lines is a file name.

Output

One missing: line per missing file, then the count line.

Constraints

1 ≤ n ≤ 100.

Example

Input:

5
README.md
LICENSE
setup.py
src/app.py
tests/test_app.py

Output:

missing: CONTRIBUTING.md
missing: CODE_OF_CONDUCT.md
2 file(s) to add

Why it works

A name is missing exactly when it is not among the given names, so one membership test per expected file gives the answer, and the order comes from the order of the expected list.

Examples

Example 1 · Input
5
README.md
LICENSE
setup.py
src/app.py
tests/test_app.py
Expected output
missing: CONTRIBUTING.md
missing: CODE_OF_CONDUCT.md
2 file(s) to add
Example 2 · Input
4
README.md
LICENSE
CONTRIBUTING.md
CODE_OF_CONDUCT.md
Expected output
0 file(s) to add

Prompts inside input() are ignored when checking, so input("n: ") is fine.

Hints

Hint 1

Read n, then n names with input().strip().

Hint 2

Loop over the four expected names in the given order and test each with "in".

Hint 3

Count the missing ones and print the count line at the end.

Solution

Show one correct solution (try it yourself first)
expected = ["README.md", "LICENSE", "CONTRIBUTING.md", "CODE_OF_CONDUCT.md"]
n = int(input())
names = [input().strip() for _ in range(n)]
count = 0
for name in expected:
    if name not in names:
        print("missing:", name)
        count += 1
print(f"{count} file(s) to add")

▶ Open this solution in the compiler, then press Visualize to watch it run step by step

Lesson: What open source is →