示例#1
0
        private static void TestBraceExpansionII()
        {
            BraceExpansionII instance = new BraceExpansionII();

            IList <string> res;

            res = instance.Solution("n{{c,g},{h,j},l}a{{a,{x,ia,o},w},er,a{x,ia,o}w}n");

            //["ncaaiawn","ncaan","ncaaown","ncaaxwn","ncaern","ncaian","ncaon","ncawn","ncaxn","ngaaiawn","ngaan","ngaaown","ngaaxwn","ngaern","ngaian","ngaon","ngawn","ngaxn","nhaaiawn","nhaan","nhaaown","nhaaxwn","nhaern","nhaian","nhaon","nhawn","nhaxn","njaaiawn","njaan","njaaown","njaaxwn","njaern","njaian","njaon","njawn","njaxn","nlaaiawn","nlaan","nlaaown","nlaaxwn","nlaern","nlaian","nlaon","nlawn","nlaxn"]
            ShowResult.Show(res);

            res = instance.Solution("a,n{{c,g},{h,j},l}a{{a,{x,ia,o},w},er,a{x,ia,o}w}n");

            //["a,ncaaiawn","a,ncaan","a,ncaaown","a,ncaaxwn","a,ncaern","a,ncaian","a,ncaon","a,ncawn","a,ncaxn","a,ngaaiawn","a,ngaan","a,ngaaown","a,ngaaxwn","a,ngaern","a,ngaian","a,ngaon","a,ngawn","a,ngaxn","a,nhaaiawn","a,nhaan","a,nhaaown","a,nhaaxwn","a,nhaern","a,nhaian","a,nhaon","a,nhawn","a,nhaxn","a,njaaiawn","a,njaan","a,njaaown","a,njaaxwn","a,njaern","a,njaian","a,njaon","a,njawn","a,njaxn","a,nlaaiawn","a,nlaan","a,nlaaown","a,nlaaxwn","a,nlaern","a,nlaian","a,nlaon","a,nlawn","a,nlaxn"]
            ShowResult.Show(res);

            res = instance.Solution("{{a,{x,ia,o},w},er,a{x,ia,o}w}");

            ShowResult.Show(res); //["a","aiaw","aow","axw","er","ia","o","w","x"]

            // next
            res = instance.Solution("{a,{a,{x,ia,o},w}er{n,{g,{u,o}},{a,{x,ia,o},w}},er}");

            //["a","aera","aerg","aeria","aern","aero","aeru","aerw","aerx","er","iaera","iaerg","iaeria","iaern","iaero","iaeru","iaerw","iaerx","oera","oerg","oeria","oern","oero","oeru","oerw","oerx","wera","werg","weria","wern","wero","weru","werw","werx","xera","xerg","xeria","xern","xero","xeru","xerw","xerx"]
            ShowResult.Show(res);

            res = instance.Solution("{a{x,ia,o}w,{n,{g,{u,o}},{a,{x,ia,o},w}},er}");

            ShowResult.Show(res); //["a","aiaw","aow","axw","er","g","ia","n","o","u","w","x"]

            res = instance.Solution("{a,b}c{d,e}f");

            ShowResult.Show(res); //["acdf","acef","bcdf","bcef"]

            res = instance.Solution("{a,b}{c,{d,e}}");

            ShowResult.Show(res); //["ac","ad","ae","bc","bd","be"]

            res = instance.Solution("{{a,z},a{b,c},{ab,z}}");

            ShowResult.Show(res); //["a","ab","ac","z"]
        }
示例#2
0
 static void Main(string[] args)
 {
     ShowResult.Show();
     Console.ReadKey();
 }
示例#3
0
        private static void TestSmallestRange(CodeTimer codeTimer)
        {
            SmallestRange instance = new SmallestRange();

            var list = new List <IList <int> >()
            {
                new List <int>()
                {
                    1, 2, 3, 4
                },
                new List <int>()
                {
                    1, 2, 3
                },
                new List <int>()
                {
                    4, 5, 6
                }
            };

            instance.HelperShow(list, new StringBuilder(), 0);

            ShowResult.Show(instance.Simple(list));

            ShowResult.Show(instance.Simple(new List <IList <int> >()
            {
                new List <int>()
                {
                    4, 10, 15, 24, 26
                },
                new List <int>()
                {
                    0, 9, 12, 20
                },
                new List <int>()
                {
                    5, 18, 22, 30
                }
            }));

            var data = JsonConvert.DeserializeObject <IList <IList <int> > >(
                "[[11,38,83,84,84,85,88,89,89,92],[28,61,89],[52,77,79,80,81],[21,25,26,26,26,27],[9,83,85,90],[84,85,87],[26,68,70,71],[36,40,41,42,45],[-34,21],[-28,-28,-23,1,13,21,28,37,37,38],[-74,1,2,22,33,35,43,45],[54,96,98,98,99],[43,54,60,65,71,75],[43,46],[50,50,58,67,69],[7,14,15],[78,80,89,89,90],[35,47,63,69,77,92,94]]");

            int[] res = null;

            var codeTimerResult = codeTimer.Time(1, (() => { res = instance.Simple(data); }));

            ShowResult.ShowMulti(new Dictionary <string, object>()
            {
                { nameof(codeTimerResult), codeTimerResult },
                { nameof(res), res }
            });

            codeTimerResult = codeTimer.Time(1, (() => { res = instance.Simple(data); }));

            ShowResult.ShowMulti(new Dictionary <string, object>()
            {
                { nameof(codeTimerResult), codeTimerResult },
                { nameof(res), res }
            });

            codeTimerResult = codeTimer.Time(1, (() => { res = instance.Solution(data); }));

            ShowResult.ShowMulti(new Dictionary <string, object>()
            {
                { nameof(codeTimerResult), codeTimerResult },
                { nameof(res), res }
            });

            codeTimerResult = codeTimer.Time(1, (() => { res = instance.Solution(data); }));

            ShowResult.ShowMulti(new Dictionary <string, object>()
            {
                { nameof(codeTimerResult), codeTimerResult },
                { nameof(res), res }
            });
        }