Note that there are some explanatory texts on larger screens.

plurals
  1. POChallenging way of counting entries of a file dynamically
    primarykey
    data
    text
    <p>I am facing a strange question, which despite of trying many times, i am not able to find the logic and proper code to the problem. </p> <p>I have a file in the format below: </p> <pre><code>aa:bb:cc dd:ee:ff 100 ----------&gt;line1 aa:bb:cc dd:ee:ff 101 ----------&gt;line2 dd:ee:ff aa:bb:cc 230 ----------&gt;line3 dd:ee:ff aa:bb:cc 231 ----------&gt;line4 dd:ee:ff aa:bb:cc 232 ----------&gt;line5 aa:bb:cc dd:ee:ff 102 ----------&gt;line6 aa:bb:cc dd:ee:ff 103 ----------&gt;line7 aa:bb:cc dd:ee:ff 108 ----------&gt;line8 dd:ee:ff aa:bb:cc 233 ----------&gt;line9 gg:hh:ii jj:kk:ll 450 ----------&gt;line10 jj:kk:ll gg:hh:ii 600 ----------&gt;line11 </code></pre> <p>My program should read the file line by line. In the first line and second line, corresponding column1 and column2 values are equal. Third column is the sequence number which is not the same for any two lines.<br> Since line1 and line2 are same except, their sequence numbers differ by value of only 1, i should read those two lines first and write their count as 2 to an output file. If we observe, line 6 and line 7 are same as line 1 and line 2, having consecutive sequence numbers, but the line numbers line3, line4, line5 having different column 1 and column 2 entries came in between them. Hence lines(1&amp;2) and lines(6&amp;7) should not be grouped all together. So, in the output file, i should get result like 2 3 2 1 1 1 1. And one more thing is, lines 7 and 8 are differed by sequence number more than 1. Hence, line 8 should be counted as a separate entry, not together with lines 6 and 7 though lines 6,7,8 has same first two columns.<br> I hope most people understood the question. If not, i will clarify anything on the question.<br> As you can see this is a very complicated problem. I tried using dictionary as that is the only data structure i know, but no logic works. Please help me solve this problem. </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload