Back to General discussions forum
In general, the problems have the input form of like this. First referring to the number of inputs and then the data itself. I always ignore the number of the data part Is this effects the correctness of the code or not?
In this type of problems my code is usually like this (using python)
file = open("text.txt","r")
for line in file:
a,b,c = int(line.split(" ")[0]), ...
...
I always ignore the number of input. Is this can make a problem in the future when I wanted to get a certificate?
Hello!
It doesn't matter :)
The amount of input data is given usually because in some languages it is easier detect the end of input and in some harder. So generally just your answer matters. As about certificates - it only matters that your solutions exist, are relevant to the task (i.e. not some random code) and are not copied from somewhere :)
I also may add that:
file = open("text.txt","r")
it usually makes sense to read input directly from console - in such case solution may be executed just from the site using buttons below solution form (and when running locally, data could be copy-pasted into console).
Though if you are convenient with reading from file (or storing input as a multiline string in the code itself) - it's ok!
Oh, that's a relief. It's generally easier for me to use files but sometimes I just copy and paste the data to an array or run a test code as you referred
Thanks a lot! :)
Hello, can you tell me why in Python input().split()
reads only the 1st line of the problem input? Thank you!
Mihai:
That's what input does: https://docs.python.org/3/library/functions.html#input
If you want to read more lines, you might want to loop.