Tracking changes

  • 20
  • Locked
Read 2 file names from the console: file1 and file2. Both files contain text, but file2 is an updated version of file1. Some of the lines are still the same. You need to create a merged version of the lines by writing them to the lines list. The ADDED and REMOVED labels can't be used consecutively—t
You can't complete this task, because you're not signed in.
Comments (16)
  • Popular
  • New
  • Old
You must be signed in to leave a comment
Andrei Level 20
5 February, 10:53
Alright baybay, here we go!
Andrei Level 20
8 February, 08:32
Didn't even finish the first one so far, lol.
Andrei Level 20
10 February, 11:57
Finally done with the first one, but I had to resort to Mentor solution because even with the support from fellow CodeGymmers I was not able to fully understand the program requirements. Anyway, on to the next one.
MoJo Level 22, Cairns, Australia
18 January, 13:16
Be sure that the mark (the place where you stream is currently reading) is on the right place. If one line is removed or added and the next one has to be the same again there's going to be a displacement for the rest of the lines: a a b c -> b removed c d -> next line is the same but only if you account for the displacement... ... I used the [reader].mark() and [reader].reset() calls for this.
Andrei Level 20
8 February, 08:46
But why should I use this when I can read whole lines and use some kind of switch to compare the 2 lines through the various situations? Or do you think it isn't possible switching the lines or comparing them somehow?
Andrei Level 20
8 February, 09:31
Nevermind, I don't think using switch would work.
Nyerges Ferenc Level 23, Bükkábrány, Hungary
14 November 2020, 16:42
Hell yeah, accepted my 6th attempt - it's been one of the toughest ones so far. I'm the 235th passing that :-) My advice for the ones working on it: use both samples as unittests and fight till it gives the expected output.
AlfredW Level 23, Denver, United States
26 October 2020, 15:00
So in their example data they have several instances of repeated lines. One which is added and then later removed. Line 0 is added and then later removed. Line 4 is removed and then later added. This is confusing me. I have been able to get your Tiger story to work with the correct output. But then when I feed this in I don't get good results. It seems that if the lines are truly unique I get good results but I still cannot verify.
Andrei Level 20
8 February, 09:30
Yeah, I don't understand that either.
Guadalupe Gagnon Level 37, Tampa, United States
14 September 2020, 14:56
File two is the updated file and the results should be based off of how file2 differs from file1. (If items are in file2 that are not in file1 that means they've been ADDED, while items that are in file1 and not in file2 have been REMOVED.) An example for everyone, lets say you had two files where file one contained: line one is going to be the same line two is going to be removed line three is going to be the same line four is going to be removed line five is going to be the same line seven is going to be the same line nine is going to be the same and file two contained: line one is going to be the same line three is going to be the same line five is going to be the same line six is going to be added line seven is going to be the same line eight is going to be added line nine is going to be the same In the above two file you can see that lines 2 and 4 are in file one and not in file two, this means they have been REMOVED. Lines 6 and 8 are not in file1 but are in file2, meaning they have been ADDED. The expected results would mean the ArrayList "lines" would contain: [LineItem{SAME - line one is going to be the same} LineItem{REMOVED - line two is going to be removed} LineItem{SAME - line three is going to be the same} LineItem{REMOVED - line four is going to be removed} LineItem{SAME - line five is going to be the same} LineItem{ADDED - line six is going to be added} LineItem{SAME - line seven is going to be the same} LineItem{ADDED - line eight is going to be added} LineItem{SAME - line nine is going to be the same}] Also try removing lines nine from both file and make sure that the results include the eighth line. Remember that Codegym has given parameters in that there are no empty lines in the validation test files and also ADDED and REMOVED can not be used consecutively, they must always be separated by a SAME. Both of these restrictions help when figuring out a solution.
Guadalupe Gagnon Level 37, Tampa, United States
10 November 2020, 16:06
add a toString() method to the LineItem class to output the results properly. I used:
public String toString() {
   return String.format("LineItem{%s - %s}", type, line);
}
In the above example.
Bart De Lepeleer Level 29, Belgium
12 December 2020, 20:02
Thx for the Sample files, that helped :)
2 June 2020, 17:53
This is an absolute NIGHTMARE! I got my to pass, but GOD knows whats going on. Anyone care to share a really good example of this?
Ulan Mukanbetov Level 26, Bishkek, Kyrgyzstan
29 September 2019, 11:18
I lost 3 days for this task. oh my god! It turns out, when you save a text in Notepad, it automaticly add a symbol of encoding at the end of file, so you cant see it at all, when you open the file. I used Sublime and resave it.
Zoltán R Level 26, Budapest, Hungary
24 September 2019, 20:36
what is wrong with this?
Andrei Level 20
5 February, 10:52
yes