Compare commits
1 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
bdb3f0a926 |
13
TaskA01/task01.py
Normal file
13
TaskA01/task01.py
Normal file
@ -0,0 +1,13 @@
|
||||
def find_hamlet(file_path):
|
||||
result = ""
|
||||
try:
|
||||
with open(file_path, 'r', encoding='utf-8') as file:
|
||||
for line_num, line in enumerate(file, start=1):
|
||||
if "Hamlet" in line:
|
||||
result += line
|
||||
except Exception as e:
|
||||
print(f"An error occurred: {e}")
|
||||
print(result)
|
||||
|
||||
find_hamlet("TaskA01\\simple.in")
|
||||
find_hamlet("TaskA01\\shakespeare.in")
|
16
TaskA02/task02.py
Normal file
16
TaskA02/task02.py
Normal file
@ -0,0 +1,16 @@
|
||||
def find_lines_with_pies(file_path):
|
||||
result = ""
|
||||
try:
|
||||
with open(file_path, 'r', encoding='utf-8') as file:
|
||||
for line_num, line in enumerate(file, start=1):
|
||||
words = line.strip().split()
|
||||
for word in words:
|
||||
if word.lower() == "pies":
|
||||
result += line
|
||||
break
|
||||
except Exception as e:
|
||||
print(f"An error occurred: {e}")
|
||||
print(result)
|
||||
|
||||
find_lines_with_pies("TaskA02/simple.in")
|
||||
find_lines_with_pies("TaskA02/polish_wiki_excerpt.in")
|
File diff suppressed because one or more lines are too long
19
TaskA03/task03.py
Normal file
19
TaskA03/task03.py
Normal file
@ -0,0 +1,19 @@
|
||||
def find_lines_with_date(file_path):
|
||||
result = ""
|
||||
try:
|
||||
with open(file_path, 'r', encoding='utf-8') as file:
|
||||
for line_number, line in enumerate(file, start=1):
|
||||
for i in range(len(line) - 6):
|
||||
if (
|
||||
line[i:i+2] == "19" and
|
||||
line[i+2:i+4].isdigit() and
|
||||
line[i+4:i+7] == " r."
|
||||
):
|
||||
result += line
|
||||
break
|
||||
except Exception as e:
|
||||
print(f"An error occurred: {e}")
|
||||
print(result)
|
||||
|
||||
find_lines_with_date("TaskA03/simple.in")
|
||||
find_lines_with_date("TaskA03/polish_wiki_excerpt.in")
|
File diff suppressed because one or more lines are too long
25
TaskA04/task04.py
Normal file
25
TaskA04/task04.py
Normal file
@ -0,0 +1,25 @@
|
||||
def find_max_digit_substrings(file_path):
|
||||
try:
|
||||
with open(file_path, 'r', encoding='utf-8') as file:
|
||||
for line in file:
|
||||
max_digit_substrings = []
|
||||
current_digits = ""
|
||||
|
||||
for char in line:
|
||||
if char.isdigit():
|
||||
current_digits += char
|
||||
else:
|
||||
if current_digits:
|
||||
max_digit_substrings.append(current_digits)
|
||||
current_digits = ""
|
||||
|
||||
if current_digits:
|
||||
max_digit_substrings.append(current_digits)
|
||||
|
||||
if max_digit_substrings:
|
||||
print(" ".join(max_digit_substrings))
|
||||
except Exception as e:
|
||||
print(f"An error occurred: {e}")
|
||||
|
||||
find_max_digit_substrings("TaskA04\simple.in")
|
||||
find_max_digit_substrings("TaskA04\polish_wiki_excerpt.in")
|
Loading…
Reference in New Issue
Block a user