J
J
Julia2014-01-28 13:29:44
Python
Julia, 2014-01-28 13:29:44

With what loop to implement string comparison?

On some forum I saw a task for freelance, the project had already been closed, but I was very interested in how the task was being solved.
The bottom line is that the file contains many lines of the following content:

t1 1 2 3 
t1 4 5 2
t1 2 3 4
t2 0 2 2

And the output is a file with the result:
t1 2 2 3
t2 1 1 1

That is, lines with the same beginning are compared:
t1 1 2 3 
t1 4 5 2
t1 2 3 4

And in response, the line number is written where the largest number in the index is.
Can you please explain how to solve this?
It is very interesting how this is implemented.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question