I noticed that there are several instances where the two numbers are combined, and it seems that they are on the line boundaries in each line, starting from the fourth line and further.
I found that if you add a space character at the beginning of each line, starting from the fifth, that is:
59 73 41 52 40 09 26 53 06 34 10 51 87 86 81 61 95 66 57 25 68 90 81 80 38 92 67 73 30 28 51 76 81 18 75 44 ...
Numbers are processed correctly:
39> euler67:solve(). [59,73,41,52,40,9,26,53,6,34,10,51,87,86,81,61,95,66,57,25, 68,90,81,80,38,92,67,73,30|...]
It also works if you add a space at the beginning of the first four lines.
This is more of a workaround than a real solution, but it works. I would like to figure out how to set the format string for io: fread in such a way that we would not need to do this.
UPDATE Here is a workaround that will not force you to modify the file. This assumes that all digits are two characters (<100):
read_file(File, Data) -> case io:fread(File, "", "~d") of {ok, [N] } -> if N > 100 -> First = N div 100, Second = N - (First * 100), read_file(File, [First , Second | Data]); true -> read_file(File, [N | Data]) end; eof -> lists:reverse(Data) end.
Basically, the code catches any of the numbers, which are the concatenation of two lines of a new line and divide them into two parts.
Again, this is kludge, which implies a possible error in io: fread, but that should do it.
UPDATE AGAIN The above will work only for two-digit inputs, but since the example packs all the digits (even those 10) into a two-digit format, which will work for this example.