<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-GB">
	<id>https://wiki.kram.nz/index.php?action=history&amp;feed=atom&amp;title=SE251Ex%3ADifferencing</id>
	<title>SE251Ex:Differencing - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.kram.nz/index.php?action=history&amp;feed=atom&amp;title=SE251Ex%3ADifferencing"/>
	<link rel="alternate" type="text/html" href="https://wiki.kram.nz/index.php?title=SE251Ex:Differencing&amp;action=history"/>
	<updated>2026-05-20T11:18:54Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.45.3</generator>
	<entry>
		<id>https://wiki.kram.nz/index.php?title=SE251Ex:Differencing&amp;diff=9789&amp;oldid=prev</id>
		<title>Mark: 7 revision(s)</title>
		<link rel="alternate" type="text/html" href="https://wiki.kram.nz/index.php?title=SE251Ex:Differencing&amp;diff=9789&amp;oldid=prev"/>
		<updated>2008-11-03T05:21:04Z</updated>

		<summary type="html">&lt;p&gt;7 revision(s)&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;== A simple differencing tool ==&lt;br /&gt;
&lt;br /&gt;
=== Prerequisites ===&lt;br /&gt;
* You need to know how to read from files using a java.io.Reader implementation - if you don&amp;#039;t, do [[SE251Ex:File_Reverser]] first.&lt;br /&gt;
* Also, it would help a lot if you have already completed [[SE251Ex:Set_Operations]] and [[SE251Ex:Chain]].&lt;br /&gt;
&lt;br /&gt;
=== Description ===&lt;br /&gt;
Write a simple differencing tool that takes in two files, A and B, and outputs all lines in A that B doesn&amp;#039;t contain and conversely all lines in B that A doesn&amp;#039;t contain. For example, say file &amp;#039;&amp;#039;A.txt&amp;#039;&amp;#039; contains the following lines:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Hello there.&lt;br /&gt;
You&amp;#039;re reading file A.&lt;br /&gt;
Nice hair,&lt;br /&gt;
Aye Aye.&lt;br /&gt;
Hello there.&lt;br /&gt;
Good bye.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
And file &amp;#039;&amp;#039;B.txt&amp;#039;&amp;#039; contains the following lines:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Hello there.&lt;br /&gt;
You&amp;#039;re reading file B.&lt;br /&gt;
Nice hair,&lt;br /&gt;
Hello hello.&lt;br /&gt;
Good bye.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then the output of the program will be something like:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
-- Lines unique to A.txt:&lt;br /&gt;
You&amp;#039;re reading file A.&lt;br /&gt;
Aye Aye.&lt;br /&gt;
-- Lines unique to B.txt:&lt;br /&gt;
You&amp;#039;re reading file B.&lt;br /&gt;
Hello hello.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that lines are considered equivalent if they contain exactly the same sequence of characters - e.g. although there are two occurrences of &amp;quot;Hello there.&amp;quot; in A.txt they are essentially considered as one.&lt;br /&gt;
&lt;br /&gt;
Exactly how the user specifies the file names is up to you: you can do it either by prompting through the console, or through command line arguments.&lt;br /&gt;
&lt;br /&gt;
=== Tips ===&lt;br /&gt;
Realise this is effectively a set difference problem. The basic idea is to convert the lines from both files into the respective sets and compute the difference.&lt;br /&gt;
&lt;br /&gt;
=== Optional requirements ===&lt;br /&gt;
Optionally, ensure that the order in which the unique lines are presented is consistent with the order in which they appear in the original file. In other words, below shouldn&amp;#039;t happen because the line &amp;quot;You&amp;#039;re reading file A&amp;quot; comes before &amp;quot;Aye Aye.&amp;quot; inside A.txt; likewise &amp;quot;You&amp;#039;re reading fileB&amp;quot; comes before &amp;quot;Hello hello&amp;quot; inside B.txt:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
-- Lines unique to A.txt:&lt;br /&gt;
Aye Aye.&lt;br /&gt;
You&amp;#039;re reading file A.&lt;br /&gt;
-- Lines unique to B.txt:&lt;br /&gt;
Hello hello.&lt;br /&gt;
You&amp;#039;re reading file B.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
To do this you may want to utilise the &amp;#039;&amp;#039;Chain&amp;#039;&amp;#039; data structure from [[SE251Ex:Chain]], which is in one way a special kind of Set that retains the ordering in which elements were added.&lt;br /&gt;
&lt;br /&gt;
== Discussion ==&lt;br /&gt;
Here you can ask questions and discuss stuff&lt;/div&gt;</summary>
		<author><name>Mark</name></author>
	</entry>
</feed>