Compare commits
3 Commits
a60eb42516
...
2ae8dfabdc
Author | SHA1 | Date | |
---|---|---|---|
|
2ae8dfabdc | ||
|
9f9d0ec887 | ||
|
d6a99fbae7 |
41
TaskE00/run.py
Normal file
41
TaskE00/run.py
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
import re
|
||||||
|
|
||||||
|
FILE_NAME = "test"
|
||||||
|
|
||||||
|
MODE = "test"
|
||||||
|
|
||||||
|
|
||||||
|
def is_correct(line: str):
|
||||||
|
looking_pattern = re.compile(r"^-?(0|[1-9]\d*[05])$")
|
||||||
|
|
||||||
|
if re.search(looking_pattern, line):
|
||||||
|
return "yes"
|
||||||
|
else:
|
||||||
|
return "no"
|
||||||
|
|
||||||
|
|
||||||
|
if MODE == "test":
|
||||||
|
with open(FILE_NAME + ".in", "r", newline="", encoding="utf8") as file:
|
||||||
|
text = [line.rstrip() for line in file.readlines()]
|
||||||
|
|
||||||
|
with open(FILE_NAME + ".exp", "r", newline="", encoding="utf8") as file:
|
||||||
|
expected = [line.rstrip() for line in file.readlines()]
|
||||||
|
|
||||||
|
out: list[str] = []
|
||||||
|
for line in text:
|
||||||
|
out.append(is_correct(line))
|
||||||
|
|
||||||
|
for ind, found in enumerate(out):
|
||||||
|
if found == expected[ind]:
|
||||||
|
print(found)
|
||||||
|
else:
|
||||||
|
print("ERROR")
|
||||||
|
|
||||||
|
elif MODE == "input":
|
||||||
|
line = input("Enter a line: ")
|
||||||
|
|
||||||
|
# Check if the line is an acronym and print 'yes' or 'no'
|
||||||
|
if is_correct(line) == "yes":
|
||||||
|
print("yes")
|
||||||
|
else:
|
||||||
|
print("no")
|
41
TaskE01/run.py
Normal file
41
TaskE01/run.py
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
import re
|
||||||
|
|
||||||
|
FILE_NAME = "test"
|
||||||
|
|
||||||
|
MODE = "test"
|
||||||
|
|
||||||
|
|
||||||
|
def is_correct(line: str):
|
||||||
|
looking_pattern = re.compile(r"^\d*(00|25|50|75)$")
|
||||||
|
|
||||||
|
if re.search(looking_pattern, line):
|
||||||
|
return "yes"
|
||||||
|
else:
|
||||||
|
return "no"
|
||||||
|
|
||||||
|
|
||||||
|
if MODE == "test":
|
||||||
|
with open(FILE_NAME + ".in", "r", newline="", encoding="utf8") as file:
|
||||||
|
text = [line.rstrip() for line in file.readlines()]
|
||||||
|
|
||||||
|
with open(FILE_NAME + ".exp", "r", newline="", encoding="utf8") as file:
|
||||||
|
expected = [line.rstrip() for line in file.readlines()]
|
||||||
|
|
||||||
|
out: list[str] = []
|
||||||
|
for line in text:
|
||||||
|
out.append(is_correct(line))
|
||||||
|
|
||||||
|
for ind, found in enumerate(out):
|
||||||
|
if found == expected[ind]:
|
||||||
|
print(found)
|
||||||
|
else:
|
||||||
|
print(f"ERROR: expected - {expected[ind]}, found - {found}")
|
||||||
|
|
||||||
|
elif MODE == "input":
|
||||||
|
line = input("Enter a line: ")
|
||||||
|
|
||||||
|
# Check if the line is an acronym and print 'yes' or 'no'
|
||||||
|
if is_correct(line) == "yes":
|
||||||
|
print("yes")
|
||||||
|
else:
|
||||||
|
print("no")
|
@ -22,7 +22,7 @@ Jeśli napis spełnia tak określony warunek, należy wypisać na
|
|||||||
standardowym wyjściu 'yes', w przeciwnym razie — 'no'.
|
standardowym wyjściu 'yes', w przeciwnym razie — 'no'.
|
||||||
|
|
||||||
For each string check, if the string is NIP number written in
|
For each string check, if the string is NIP number written in
|
||||||
xxx-xxx-xx-xx bądź xxx-xx-xx-xxx format. You don't need to consider a checksum.
|
xxx-xxx-xx-xx or xxx-xx-xx-xxx format. You don't need to consider a checksum.
|
||||||
If the string fulfills the condition, you should print 'yes' on the
|
If the string fulfills the condition, you should print 'yes' on the
|
||||||
standard output and 'no' otherwise.
|
standard output and 'no' otherwise.
|
||||||
|
|
||||||
|
41
TaskE03/run.py
Normal file
41
TaskE03/run.py
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
import re
|
||||||
|
|
||||||
|
FILE_NAME = "test"
|
||||||
|
|
||||||
|
MODE = "test"
|
||||||
|
|
||||||
|
|
||||||
|
def is_correct(line: str):
|
||||||
|
looking_pattern = re.compile(r"^\d{3}-\d{3}-\d{2}-\d{2}$|^\d{3}-\d{2}-\d{2}-\d{3}$")
|
||||||
|
|
||||||
|
if re.search(looking_pattern, line):
|
||||||
|
return "yes"
|
||||||
|
else:
|
||||||
|
return "no"
|
||||||
|
|
||||||
|
|
||||||
|
if MODE == "test":
|
||||||
|
with open(FILE_NAME + ".in", "r", newline="", encoding="utf8") as file:
|
||||||
|
text = [line.rstrip() for line in file.readlines()]
|
||||||
|
|
||||||
|
with open(FILE_NAME + ".exp", "r", newline="", encoding="utf8") as file:
|
||||||
|
expected = [line.rstrip() for line in file.readlines()]
|
||||||
|
|
||||||
|
out: list[str] = []
|
||||||
|
for line in text:
|
||||||
|
out.append(is_correct(line))
|
||||||
|
|
||||||
|
for ind, found in enumerate(out):
|
||||||
|
if found == expected[ind]:
|
||||||
|
print(found)
|
||||||
|
else:
|
||||||
|
print(f"ERROR: expected - {expected[ind]}, found - {found}")
|
||||||
|
|
||||||
|
elif MODE == "input":
|
||||||
|
line = input("Enter a line: ")
|
||||||
|
|
||||||
|
# Check if the line is an acronym and print 'yes' or 'no'
|
||||||
|
if is_correct(line) == "yes":
|
||||||
|
print("yes")
|
||||||
|
else:
|
||||||
|
print("no")
|
41
TaskE04/run.py
Normal file
41
TaskE04/run.py
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
import re
|
||||||
|
|
||||||
|
FILE_NAME = "test"
|
||||||
|
|
||||||
|
MODE = "test"
|
||||||
|
|
||||||
|
|
||||||
|
def is_correct(line: str):
|
||||||
|
looking_pattern = re.compile(r"^((555-\d{3}-\d{3})|(555 \d{3} \d{3}))$")
|
||||||
|
|
||||||
|
if re.search(looking_pattern, line):
|
||||||
|
return "yes"
|
||||||
|
else:
|
||||||
|
return "no"
|
||||||
|
|
||||||
|
|
||||||
|
if MODE == "test":
|
||||||
|
with open(FILE_NAME + ".in", "r", newline="", encoding="utf8") as file:
|
||||||
|
text = [line.rstrip() for line in file.readlines()]
|
||||||
|
|
||||||
|
with open(FILE_NAME + ".exp", "r", newline="", encoding="utf8") as file:
|
||||||
|
expected = [line.rstrip() for line in file.readlines()]
|
||||||
|
|
||||||
|
out: list[str] = []
|
||||||
|
for line in text:
|
||||||
|
out.append(is_correct(line))
|
||||||
|
|
||||||
|
for ind, found in enumerate(out):
|
||||||
|
if found == expected[ind]:
|
||||||
|
print(found)
|
||||||
|
else:
|
||||||
|
print(f"ERROR: expected - {expected[ind]}, found - {found}")
|
||||||
|
|
||||||
|
elif MODE == "input":
|
||||||
|
line = input("Enter a line: ")
|
||||||
|
|
||||||
|
# Check if the line is an acronym and print 'yes' or 'no'
|
||||||
|
if is_correct(line) == "yes":
|
||||||
|
print("yes")
|
||||||
|
else:
|
||||||
|
print("no")
|
41
TaskE29/run.py
Normal file
41
TaskE29/run.py
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
import re
|
||||||
|
|
||||||
|
FILE_NAME = "test"
|
||||||
|
|
||||||
|
MODE = "test"
|
||||||
|
|
||||||
|
|
||||||
|
def find_fitting(line):
|
||||||
|
acronym_pattern = re.compile(r"^(?!\d)\w+$")
|
||||||
|
|
||||||
|
if re.search(acronym_pattern, line):
|
||||||
|
return "yes"
|
||||||
|
else:
|
||||||
|
return "no"
|
||||||
|
|
||||||
|
|
||||||
|
if MODE == "test":
|
||||||
|
with open(FILE_NAME + ".in", "r", newline="", encoding="utf8") as file:
|
||||||
|
text = [line.rstrip() for line in file.readlines()]
|
||||||
|
|
||||||
|
with open(FILE_NAME + ".exp", "r", newline="", encoding="utf8") as file:
|
||||||
|
expected = [line.rstrip() for line in file.readlines()]
|
||||||
|
|
||||||
|
out: list[str] = []
|
||||||
|
for line in text:
|
||||||
|
out.append(find_fitting(line))
|
||||||
|
|
||||||
|
for ind, found in enumerate(out):
|
||||||
|
if found == expected[ind]:
|
||||||
|
print(found)
|
||||||
|
else:
|
||||||
|
print("ERROR")
|
||||||
|
|
||||||
|
elif MODE == "input":
|
||||||
|
line = input("Enter a line: ")
|
||||||
|
|
||||||
|
# Check if the line is an acronym and print 'yes' or 'no'
|
||||||
|
if find_fitting(line) == "yes":
|
||||||
|
print("yes")
|
||||||
|
else:
|
||||||
|
print("no")
|
Loading…
Reference in New Issue
Block a user