commit 2f658420eb793828bca7c89283405db3f0f297a6 Author: thanhtl Date: Thu Nov 27 17:28:40 2025 +0700 Add count.py diff --git a/count.py b/count.py new file mode 100644 index 0000000..5ef7c0c --- /dev/null +++ b/count.py @@ -0,0 +1,24 @@ +# Mục đích là tìm dãy số thiếu trong dải number trong files numbers.txt +# file name: find_missing_numbers.py + +def find_missing_numbers(filename, start=1, end=4384): + # Read all numbers from file + with open(filename, "r") as f: + numbers = set() + for line in f: + line = line.strip() + if line.isdigit(): # ensure it's a number + numbers.add(int(line)) + + # Generate full valid range + full_range = set(range(start, end + 1)) + + # Find what is missing + missing = sorted(full_range - numbers) + + return missing + + +# Example usage: +missing_numbers = find_missing_numbers("numbers.txt") +print("Missing numbers:", missing_numbers)