public static Automaton MakeInterval(int min, int max, int digits) { var a = new Automaton(); var x = Convert.ToString(min); var y = Convert.ToString(max); if (min > max || (digits > 0 && y.Length > digits)) { throw new ArgumentException(); } var d = digits > 0 ? digits : y.Length; var sb1 = new StringBuilder(); for (var i = x.Length; i < d; i++) { _ = sb1.Append('0'); } _ = sb1.Append(x); x = sb1.ToString(); var sb2 = new StringBuilder(); for (var i = y.Length; i < d; i++) { _ = sb2.Append('0'); } _ = sb2.Append(y); y = sb2.ToString(); ICollection <State> initials = new List <State>(); a.Initial = Between(x, y, 0, initials, digits <= 0); if (digits <= 0) { var pairs = (from p in initials where a.Initial != p select new StatePair(a.Initial, p)).ToList(); a.AddEpsilons(pairs); a.Initial.AddTransition(new Transition('0', a.Initial)); a.IsDeterministic = false; } else { a.IsDeterministic = true; } a.CheckMinimizeAlways(); return(a); }