using System.Collections.Generic;
public static string A = "A";
public static string B = "B";
public static string C = "C";
public static string NULL = "null";
public static void Main()
lo.DisplayResult("Why is this not a transition but an exception?");
lo.Add(new OB{A,NULL,NULL});
lo.DisplayResult("<A,NULL> and <A,NULL,NULL> are considered equal as per your second comment.");
lo.Add(new OB{A,B,NULL,C});
lo.DisplayResult("As per your first comment");
lo.DisplayResult("Second and third OB are equal as per your first comment");
lo.DisplayResult("Why is this not a transition as per your fourth comment?");
public class LO : List<OB>
public void DisplayResult(string message = null)
Console.WriteLine("{0} : {1}",this,CountTransitions());
Console.WriteLine(message);
private int CountTransitions()
if(this.Any()== false || this.Count == 1) return 0;
var first = this.FirstOrDefault();
var last = this.LastOrDefault();
if(first.Count != 1 || last.Count != 1) return 0;
for(var i = 0; i < this.Count - 1; i++)
transitions = IsTransition(this[i],this[i+1]) ? transitions + 1 : transitions;
private bool IsTransition(OB lhs, OB rhs)
var lhsSet = new SortedSet<String>(lhs);
var rhsSet = new SortedSet<String>(rhs);
return lhsSet.SetEquals(rhsSet) == false;
public override string ToString()
return String.Join(" -> ", this.Select(x => x.ToString()));
public class OB : List<String>
public override String ToString()
return String.Format("[{0}]", String.Join(",", this));