zad A04
This commit is contained in:
parent
1060b283bf
commit
5f91662b8e
44
TaskA04/run.py
Normal file
44
TaskA04/run.py
Normal file
@ -0,0 +1,44 @@
|
||||
import numbers
|
||||
import os
|
||||
|
||||
DIR = os.path.dirname(__file__)
|
||||
DIGITS = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "0"]
|
||||
|
||||
|
||||
def join_path(filename: str) -> str:
|
||||
return os.path.join(DIR, filename)
|
||||
|
||||
|
||||
def in_set(letter, set) -> bool:
|
||||
for i in set:
|
||||
if i == letter:
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
with open(
|
||||
join_path("polish_wiki_excerpt.in"), "r", newline="", encoding="utf8"
|
||||
) as file:
|
||||
text = file.readlines()
|
||||
|
||||
numbers = []
|
||||
for ind, line in enumerate(text):
|
||||
numbers_line = []
|
||||
i = 0
|
||||
while i < len(line):
|
||||
number = []
|
||||
if in_set(line[i], DIGITS):
|
||||
number.append(line[i])
|
||||
for j in range(i + 1, len(line)):
|
||||
if line[j].isdigit():
|
||||
number.append(line[j])
|
||||
else:
|
||||
i += len(number) - 1
|
||||
break
|
||||
numbers_line.append(int("".join(number)))
|
||||
i += 1
|
||||
|
||||
if len(numbers_line) != 0:
|
||||
print(*numbers_line, sep=" ")
|
||||
numbers.append(numbers_line)
|
||||
# print(len(phrase_array_slow))
|
Loading…
Reference in New Issue
Block a user