 
 # PROBLEM:
 # Problem description here.
+# This template calculates the symmetric difference of multiple input sets.
 
 defmodule Script do
-  def print_arg(input) do
-    IO.puts("")
-    input
-    |> String.split(":")
-    |> Enum.with_index(1)
-    |> Enum.each(fn {v, i} -> IO.puts("  #{i}: #{v}") end)
+  # core problem logic
+  def symmetric_difference(args) do
+    args
+    |> Enum.reduce(&Kernel.++/2)
+    |> Enum.reduce(%{}, fn i, a -> Map.update(a, i, 1, &(&1 + 1)) end)
+    |> Enum.reduce([],
+      fn
+        {_, v}, a when 0 == rem(v, 2) -> a
+        {k, _}, a -> a ++ [k]
+      end
+    )
+  end
+
+  # reusable printing function
+  def print_set([]), do: IO.puts("  (no members)")
+  def print_set(set) do
+    IO.write("  ")
+    set
+    |> Enum.join(":")
+    |> IO.puts()
   end
 
   # main program logic
-  def run(input) do
-    IO.puts("Input:")
-    input
-    |> Enum.map(&print_arg/1)
+  def run(args) do
+    sets = args
+    |> Enum.map(&String.split(&1, ":"))
+    |> Enum.map(&Enum.uniq/1)
+    IO.puts("Input Sets:")
+    sets
+    |> Enum.each(&print_set/1)
+    IO.puts("Symmetric Difference:")
+    sets
+    |> symmetric_difference()
+    |> print_set()
+    IO.puts("")
   end
 
-  # fixed tests
+  # fixed test cases
   def test() do
     IO.puts("--- USAGE ---")
     main(["help"])
     IO.puts("")
-    IO.puts("--- TEST ---")
-    main(["apple:banana:cat:...", "dog"])
+    IO.puts("--- SIMPLE TESTS ---")
+    main(["a:b:c"])
+    main(["a:b:c", "a:b:c"])
+    main(["a:b:c", "d:e:f"])
+    IO.puts("")
+    IO.puts("--- TESTS ---")
+    main(["a:b:c", "c:d"])
+    main(["a:c:f:m:n", "b:c:j:k:m:n", "c:d:f:k"])
   end
 
   # program usage

  end
end

# fixed input
Script.main(["test"])

# command line input
#Script.main(System.argv)


    IO.puts("  #{:escript.script_name()} help")
    IO.puts("  #{:escript.script_name()} test")
    IO.puts("")
    IO.puts("Examples:")
    IO.puts("  #{:escript.script_name()} a:b:c c:d")
    IO.puts("  #{:escript.script_name()} a:c:f:m:n b:c:j:k:m:n c:d:f:k")
  end

  # entry point
  def main(args) do
    args = args |> Enum.map(&String.downcase/1)
    cond do
