This is for Python.
When using python and reading files, I am using a different method than what the guide says:
My method for paint:
with open("paint.in") as f: lines = f.readlines() #my algorithm(code) ans = open("paint.out","w") ans.write(str(len(total))) ans.close()
But the file reading the guide uses is:
import sys sys.stdin = open("paint.in", "r") sys.stdout = open("paint.out", "w") #guide algorithm(code) for i in range(len(cover)): ans += cover[i] print(ans)
Is one of these methods for reading files faster than another or are they the same speed?