diff options
| author | Lubos Kolouch <lubos@kolouch.net> | 2023-07-10 18:56:53 +0200 |
|---|---|---|
| committer | Lubos Kolouch <lubos@kolouch.net> | 2023-07-10 18:56:53 +0200 |
| commit | a5f6057bc0293d12abb6ad6864a72196fa417d6e (patch) | |
| tree | 81803a2c40847151bbf0329a4bbc350a3758205a /challenge-166/lubos-kolouch/python/ch-2.py | |
| parent | d0829f697ac3fa9a5791db99ff1686b1acecc4c9 (diff) | |
| download | perlweeklychallenge-club-a5f6057bc0293d12abb6ad6864a72196fa417d6e.tar.gz perlweeklychallenge-club-a5f6057bc0293d12abb6ad6864a72196fa417d6e.tar.bz2 perlweeklychallenge-club-a5f6057bc0293d12abb6ad6864a72196fa417d6e.zip | |
feat(challenge-166/lubos-kolouch/perl,python/): Challenge 166 LK Perl Python
Diffstat (limited to 'challenge-166/lubos-kolouch/python/ch-2.py')
| -rw-r--r-- | challenge-166/lubos-kolouch/python/ch-2.py | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/challenge-166/lubos-kolouch/python/ch-2.py b/challenge-166/lubos-kolouch/python/ch-2.py new file mode 100644 index 0000000000..48996dd42e --- /dev/null +++ b/challenge-166/lubos-kolouch/python/ch-2.py @@ -0,0 +1,29 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +import os + + +def k_directory_diff(dirs): + all_files = set() + dir_files = {} + + for directory in dirs: + files = set(os.listdir(directory)) + all_files |= files + dir_files[directory] = files + + missing_files = {f: [] for f in all_files} + + for directory, files in dir_files.items(): + for file in all_files: + if file not in files: + missing_files[file].append(directory) + + for file, directories in missing_files.items(): + if directories: + print(file, "is missing in", ", ".join(directories)) + + +dirs = ["dir_a", "dir_b", "dir_c"] +k_directory_diff(dirs) |
