/// <summary>
    /// Explanation :
    /// ScaleSolver class is the main class .
    /// The idea is verify that each note of each SetNoteInput is in scale with a key.
    /// If we verify this for each scale with a key (major scale or minor scale) then
    /// the result would be just all the scale key that contains all the notes as main notes.
    /// O(C * Notes.Length) time
    /// </summary>
    /// <param name="args"></param>
    public static void Main(string[] args)
    {
        try
        {
            // O(1) time -- because it is just one time and each ScalSolver initialization
            // execute the same sentences in the same order .
            ScaleSolver scaleSolver = new ScaleSolver();

            int C = int.Parse(Console.ReadLine());
            for (int i = 1; i <= C; i++)
            {
                try
                {
                    int    N      = int.Parse(Console.ReadLine());
                    string result = "";
                    if (N > 0)
                    {
                        var      line  = Console.ReadLine();
                        string[] Notes = line.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                        // O(Notes.Length) time -- because
                        var scaleSolverResult = scaleSolver.GetKeys(Notes);
                        if (scaleSolverResult.Length == 0)
                        {
                            result = "None";
                        }
                        else
                        {
                            result += scaleSolverResult[0];
                            for (int j = 1; j < scaleSolverResult.Length; j++)
                            {
                                result += " " + scaleSolverResult[j];
                            }
                        }
                    }
                    else
                    {
                        result = "MA MA# MB MC MC# MD MD# ME MF MF# MG MG# mA mA# mB mC mC# mD mD# mE mF mF# mG mG#";
                    }
                    string prefixString = "Case #" + i + ": ";
                    Console.WriteLine(prefixString + result);
                }
                catch (Exception exception)
                {
                    Console.WriteLine("Case #" + i + ": ");
                    Console.WriteLine(exception);
                }
            }
        }
        catch (Exception exception)
        {
            Console.WriteLine(exception);
        }
    }
Beispiel #2
0
        static void Main(string[] args)
        {
            ScaleSolver scaleSolver = new ScaleSolver();

            foreach (var majorScale in scaleSolver.majorScales)
            {
                Console.WriteLine(majorScale.Key + "   ");
                var nodes = majorScale.Value.Select((v, i) => new { v, i }).Where(v => v.v).Select((v) => scaleSolver.keys.First(n => n.Index == v.i));
                foreach (var node in nodes)
                {
                    Console.Write(node.Name + " ");
                }
                Console.WriteLine();
            }

            Console.ReadLine();
        }
Beispiel #3
0
 public static void Initializer(TestContext context)
 {
     scaleSolver = new ScaleSolver();
 }