Created
December 10, 2020 01:35
-
-
Save omargfh/f4b1674c7cb8b24d95a3ea5c4e6c1614 to your computer and use it in GitHub Desktop.
CS50 PSET6 Check50 Alternative
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import re | |
with open("makefile", "r") as file: | |
data = file.read().split('\n') | |
i, error = 1, 0 | |
for argument in data: | |
pattern = re.compile(r'(?:as\s)(python)(\sdna.py\sdatabases/[a-zA-Z]+\.csv\ssequences/[0-9]+\.txt)') | |
command = pattern.finditer(argument) | |
namept = re.compile(r'(No\s)?[a-zA-Z]+\.$') | |
name = namept.search(argument) | |
name = name.group(0).replace(".", "") | |
for arg in command: | |
command = arg.group(1) + "3" + arg.group(2) | |
stream = os.popen(command) | |
output = stream.read() | |
if output.rstrip("\n").lower() != name.rstrip("\n").lower(): | |
print("error at", i) | |
error += 1 | |
i += 1 | |
if error is 0: | |
print("No errors detected!") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Run your program as python dna.py databases/small.csv sequences/1.txt. Your program should output Bob. | |
Run your program as python dna.py databases/small.csv sequences/2.txt. Your program should output No match. | |
Run your program as python dna.py databases/small.csv sequences/3.txt. Your program should output No match. | |
Run your program as python dna.py databases/small.csv sequences/4.txt. Your program should output Alice. | |
Run your program as python dna.py databases/large.csv sequences/5.txt. Your program should output Lavender. | |
Run your program as python dna.py databases/large.csv sequences/6.txt. Your program should output Luna. | |
Run your program as python dna.py databases/large.csv sequences/7.txt. Your program should output Ron. | |
Run your program as python dna.py databases/large.csv sequences/8.txt. Your program should output Ginny. | |
Run your program as python dna.py databases/large.csv sequences/9.txt. Your program should output Draco. | |
Run your program as python dna.py databases/large.csv sequences/10.txt. Your program should output Albus. | |
Run your program as python dna.py databases/large.csv sequences/11.txt. Your program should output Hermione. | |
Run your program as python dna.py databases/large.csv sequences/12.txt. Your program should output Lily. | |
Run your program as python dna.py databases/large.csv sequences/13.txt. Your program should output No match. | |
Run your program as python dna.py databases/large.csv sequences/14.txt. Your program should output Severus. | |
Run your program as python dna.py databases/large.csv sequences/15.txt. Your program should output Sirius. | |
Run your program as python dna.py databases/large.csv sequences/16.txt. Your program should output No match. | |
Run your program as python dna.py databases/large.csv sequences/17.txt. Your program should output Harry. | |
Run your program as python dna.py databases/large.csv sequences/18.txt. Your program should output No match. | |
Run your program as python dna.py databases/large.csv sequences/19.txt. Your program should output Fred. | |
Run your program as python dna.py databases/large.csv sequences/20.txt. Your program should output No match. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment