18 lines
513 B
Python
18 lines
513 B
Python
|
import re
|
||
|
|
||
|
def check_equation(file_path):
|
||
|
pattern = r'^\s*(x|[1-9]\d*)\s*[\+\-\*\/]\s*(x|[1-9]\d*)\s*=\s*(x|[1-9]\d*)\s*$'
|
||
|
|
||
|
with open(file_path, 'r', encoding='utf-8') as file:
|
||
|
for line in file:
|
||
|
line = line.strip()
|
||
|
if re.match(pattern, line):
|
||
|
if line.count('x') == 1:
|
||
|
print('yes')
|
||
|
else:
|
||
|
print('no')
|
||
|
else:
|
||
|
print('no')
|
||
|
|
||
|
file_path = 'TaskE16/test.in'
|
||
|
check_equation(file_path)
|