-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathProblem -04.py
45 lines (27 loc) · 955 Bytes
/
Problem -04.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# Problem -04
def readLines(file_path: str) -> list:
with open(file_path, "r") as file:
lines: list = file.readlines()
return lines
def writeLines(file_path: str, lines: list) -> None:
with open(file_path, "w") as file:
file.writelines("\n".join(lines))
def main():
from math import sqrt
fileInput = [line.replace("\n", "") for line in readLines("task4_input.txt")]
fileOutput = []
squre_num_count = 0
for line in fileInput:
if line == "0 0":
break
a, b = tuple(map(int, line.split(" ")))
for number in range(a, b + 1):
squre_root = sqrt(number)
if squre_root - int(squre_root) == 0.0:
squre_num_count += 1
fileOutput.append(squre_num_count)
squre_num_count = 0
fileOutput = [str(i) for i in fileOutput]
writeLines("task4_output.txt", fileOutput)
if __name__ == "__main__":
main()