T
Ted Flethuseo
HI everyone,
I am wondering how would you make a program to find a list of things
from a file as efficiently as possible. So I have this file that gives
the rank of the following pairs:
pair -- rank
4,2 -- 1
4,5 -- 2
6,8 -- 3
8,2 -- 4
and I have another file that lists how it predicted the order of this
pairs.
pair
8,2
6,8
4,5
4,2
I need to add to this file the corresponding ranks, preferably without
scanning the file more than once.
So I grab the file of pairs and make it an array like this:
array = []
File.foreach("pairs.txt") do |line|
array << line
end
but then I'm not sure how to best proceed to search that file for the
respective ranks and return them, without scanning the file more than
once
Any help appreciated,
Ted.
I am wondering how would you make a program to find a list of things
from a file as efficiently as possible. So I have this file that gives
the rank of the following pairs:
pair -- rank
4,2 -- 1
4,5 -- 2
6,8 -- 3
8,2 -- 4
and I have another file that lists how it predicted the order of this
pairs.
pair
8,2
6,8
4,5
4,2
I need to add to this file the corresponding ranks, preferably without
scanning the file more than once.
So I grab the file of pairs and make it an array like this:
array = []
File.foreach("pairs.txt") do |line|
array << line
end
but then I'm not sure how to best proceed to search that file for the
respective ranks and return them, without scanning the file more than
once
Any help appreciated,
Ted.