Exemple #1
0
        public int MaxPatternMatches(List <string> source)
        {
            var maxMatches = 0;

            for (var i = 0; i < 4; i++)
            {
                var newMatch = this.CountOfPattern(source.ToList());

                if (newMatch > maxMatches)
                {
                    maxMatches = newMatch;
                }

                source = source.Rotate();
            }

            source = source.ReverseAll();
            for (var i = 0; i < 4; i++)
            {
                var newMatch = this.CountOfPattern(source.ToList());

                if (newMatch < maxMatches)
                {
                    maxMatches = newMatch;
                }

                source = source.Rotate();
            }

            return(maxMatches);
        }
        public void Benchmark_Rotate_List()
        {
            int repetitions = 2000000;

            List <int> seq;

            seq = new List <int>(new int[100]);

            seq.Rotate(2); // Force JIT.

            DateTime startTime = DateTime.Now;

            for (int r = 0; r < repetitions; r++)
            {
                seq.Rotate(2);
            }
            PrintResult("seq<int>[100].Rotate(2)", repetitions, (DateTime.Now - startTime).TotalSeconds);

            startTime = DateTime.Now;
            for (int r = 0; r < repetitions; r++)
            {
                seq.Rotate(3);
            }
            PrintResult("seq<int>[100].Rotate(3)", repetitions, (DateTime.Now - startTime).TotalSeconds);

            List <Cls> seq1 = new List <Cls>(100);

            for (int i = 0; i < 100; ++i)
            {
                seq1.Add(new Cls());
            }

            startTime = DateTime.Now;
            for (int r = 0; r < repetitions; r++)
            {
                seq1.Rotate(3);
            }
            PrintResult("seq<Cls>[100].Rotate(3)", repetitions, (DateTime.Now - startTime).TotalSeconds);

            List <Str> seq2 = new List <Str>(100);

            for (int i = 0; i < 100; ++i)
            {
                seq2.Add(new Str());
            }

            startTime = DateTime.Now;
            for (int r = 0; r < repetitions; r++)
            {
                seq2.Rotate(3);
            }
            PrintResult("seq<Str>[100].Rotate(3)", repetitions, (DateTime.Now - startTime).TotalSeconds);
        }
Exemple #3
0
    static void Main()
    {
        List <char> chars = new List <char>();

        for (int i = 65; i < 75; ++i)
        {
            chars.Add((char)i);
        }

        var r1 = chars.Rotate(10);    // A B C D E F G H I J
        var r2 = chars.Rotate(1);     // B C D E F G H I J A
        var r3 = chars.Rotate(101);   // B C D E F G H I J A
        var r4 = chars.Rotate(102);   // C D E F G H I J A B

        Console.ReadLine();
    }
Exemple #4
0
        public ResultsView(List <int> score, Room room)
        {
            InitializeComponent();

            Room = room;

            int rotate = room.Users.Select(i => i.Name).ToList().IndexOf(App.User.Name) >> 1 & 1;

            string win = (score[rotate] > score[1 - rotate])? "Pobijedili" : "Izgubili";

            Victory.Text = $"{win} ste"; //todo nerijeseno

            foreach (var(text, pts) in Score.Zip(score.Rotate(rotate)))
            {
                text.Text = pts >= Consts.BelotValue? "Belot" : pts.ToString();
            }

            foreach (var(text, user) in Users.Zip(room.Users.Rotate(rotate * 2)))
            {
                text.Text = user.Name;
            }

            Discord.Info = new DiscordRPC.RichPresence()
            {
                Details = win,
                State   = $"{Score[0].Text} - {Score[1].Text}"
            };
        }
Exemple #5
0
            static IList<PointF> GetBezierArcPoints(IBezierCurve e)
            {
                List<PointF> points = new List<PointF>(100);
                Angle angle = e.Data.Angle;
                var x = e.Data.X;
                var y = e.Data.Y;
               
                if (e.EndAngle > 179)
                {
                    var pts = Geometry.GetBezier4Points(x, y, e.Data.Rx, e.Data.Ry, e.StartAngle, 179);
                    Geometry.GetBezierPoints(4, ref points, pts);
                    pts = (Geometry.GetBezier4Points(x, y, e.Data.Rx, e.Data.Ry, 179, e.EndAngle));
                    Geometry.GetBezierPoints(4, ref points, pts);
                }
                else
                {
                    var pts = Geometry.GetBezier4Points(x, y, e.Data.Rx, e.Data.Ry, e.StartAngle, e.EndAngle);
                    Geometry.GetBezierPoints(4, ref points, pts);
                }
                IList<PointF> Points = points;

                if (angle.Valid)
                    Points = points.Rotate(angle);

                if (!e.IsArc)
                    Points.Insert(0, new PointF(e.Data.Cx, e.Data.Cy));

                return Points;
            }
Exemple #6
0
        public static void RotateWithPositionsGreaterThanItemsCount()
        {
            var items = new List <string> {
                "a", "b", "c", "d", "e", "f", "g", "h", "i"
            };

            Assert.That(() => items.Rotate(items.Count + 5, RotateDirection.Positive), Throws.TypeOf <ArgumentException>());
        }
Exemple #7
0
        public static void RotateWithZeroPositions()
        {
            var items = new List <string> {
                "a", "b", "c", "d", "e", "f", "g", "h", "i"
            };

            Assert.That(() => items.Rotate(0, RotateDirection.Positive), Throws.TypeOf <ArgumentException>());
        }
        public void Test_Rotate_List()
        {
            List <int> seq;

            seq = new List <int>(new int[] { 0, 1 });
            seq.Rotate(0);
            Assert.AreEqual(new int[] { 0, 1 }, seq);

            seq = new List <int>(new int[] { 0, 1 });
            seq.Rotate(1);
            Assert.AreEqual(new int[] { 1, 0 }, seq);

            seq = new List <int>(new int[] { 0, 1, 2 });
            seq.Rotate(1);
            Assert.AreEqual(new int[] { 2, 0, 1 }, seq);

            seq = new List <int>(new int[] { 0, 1, 2 });
            seq.Rotate(2);
            Assert.AreEqual(new int[] { 1, 2, 0 }, seq);

            seq = new List <int>(new int[] { 0, 1, 2, 3 });
            seq.Rotate(1);
            Assert.AreEqual(new int[] { 3, 0, 1, 2 }, seq);

            seq = new List <int>(new int[] { 0, 1, 2, 3 });
            seq.Rotate(2);
            Assert.AreEqual(new int[] { 2, 3, 0, 1 }, seq);

            seq = new List <int>(new int[] { 0, 1, 2, 3 });
            seq.Rotate(3);
            Assert.AreEqual(new int[] { 1, 2, 3, 0 }, seq);


            seq = new List <int>(new int[] { 0, 1, 2, 3, 4, 5, 6 });
            seq.Rotate(1);
            Assert.AreEqual(new int[] { 6, 0, 1, 2, 3, 4, 5 }, seq);

            seq = new List <int>(new int[] { 0, 1, 2, 3, 4, 5, 6 });
            seq.Rotate(2);
            Assert.AreEqual(new int[] { 5, 6, 0, 1, 2, 3, 4 }, seq);

            seq = new List <int>(new int[] { 0, 1, 2, 3, 4, 5, 6 });
            seq.Rotate(3);
            Assert.AreEqual(new int[] { 4, 5, 6, 0, 1, 2, 3 }, seq);

            seq = new List <int>(new int[] { 0, 1, 2, 3, 4, 5, 6 });
            seq.Rotate(4);
            Assert.AreEqual(new int[] { 3, 4, 5, 6, 0, 1, 2 }, seq);

            seq = new List <int>(new int[] { 0, 1, 2, 3, 4, 5, 6 });
            seq.Rotate(5);
            Assert.AreEqual(new int[] { 2, 3, 4, 5, 6, 0, 1 }, seq);

            seq = new List <int>(new int[] { 0, 1, 2, 3, 4, 5, 6 });
            seq.Rotate(6);
            Assert.AreEqual(new int[] { 1, 2, 3, 4, 5, 6, 0 }, seq);
        }
Exemple #9
0
        public void RotateTest()
        {
            var list = new List <string> {
                "Orange", "Potato", "Banana", "Milk"
            };

            list.Rotate(3);
            Assert.AreEqual("Milk", list[0]);
        }
Exemple #10
0
        public static void RotatePositiveWithGCDGreaterThan1()
        {
            var items = new List <string> {
                "a", "b", "c", "d", "e", "f", "g", "h", "i"
            };

            items.Rotate(3, RotateDirection.Positive);
            Assert.That(items, Is.EqualTo(new List <string> {
                "g", "h", "i", "a", "b", "c", "d", "e", "f"
            }));
        }
Exemple #11
0
        public static void RotateWithOneItem()
        {
            var items = new List <string> {
                "a"
            };

            items.Rotate(1, RotateDirection.Positive);
            Assert.That(items, Is.EqualTo(new List <string> {
                "a"
            }));
        }
Exemple #12
0
        public static void RotateWithPositionEqualToItemsCount()
        {
            var items = new List <string> {
                "a", "b", "c", "d", "e", "f", "g", "h", "i", "j"
            };

            items.Rotate(10, RotateDirection.Positive);
            Assert.That(items, Is.EqualTo(new List <string> {
                "a", "b", "c", "d", "e", "f", "g", "h", "i", "j"
            }));
        }
Exemple #13
0
        public static void RotateNegative()
        {
            var items = new List <string> {
                "a", "b", "c", "d", "e", "f", "g", "h", "i", "j"
            };

            items.Rotate(7, RotateDirection.Negative);
            Assert.That(items, Is.EqualTo(new List <string> {
                "h", "i", "j", "a", "b", "c", "d", "e", "f", "g"
            }));
        }
Exemple #14
0
        public string GetSecondCalibrationCommonds()
        {
            PosePositions.Clear();
            TouchPoints.Clear();

            var commonds = new List <BaseCommand>();

            var lengths = new[] { 70, 80, 90, 100, 110, 120, 130 };   // coordinate_x
            var rotates = new[] { 90, 100, 110, 120, 130, 140, 150 }; // step

            var coor_Z = (int)ArmPositionCalculator.SharedInstance.ToCoordinate(ArmPositionCalculator.SharedInstance.ProbbedPose).Item3;


            var tapDistance = CommandHelper.GetTapDistance();

            for (var i = 0; i < lengths.Length; i++)
            {
                var length = lengths[i];
                var rotate = rotates[i];
                var pose   = ArmPositionCalculator.SharedInstance.ToPose(new Tuple <double, double, double>(length, 0, coor_Z));
                var x      = pose.X - tapDistance;
                var y      = pose.Y - tapDistance;

                commonds.Add(new PoseCommand(x, y, 0));
                commonds.Tap();
                commonds.WaitForTouch();

                commonds.TouchInSameRadius(new List <int> {
                    rotate, -2 * rotate
                });

                commonds.Rotate(rotate);
            }

            commonds.Reset();

            commonds.Add(new DoneCommand(TaskNameCalibration));

            commonds.Add(new PauseCommand(30, -1));

            if (commonds.Count <= 0)
            {
                return(string.Empty);
            }

            JsonSerializerSettings settings = new JsonSerializerSettings {
                TypeNameHandling = TypeNameHandling.Auto
            };
            string serialized = JsonConvert.SerializeObject(commonds, settings);

            return(serialized);
            //List<Base> deserializedList = JsonConvert.DeserializeObject<List<Base>>(Serialized, settings);
        }
Exemple #15
0
        public void Rotate_ListOfInts_Rotates()
        {
            var input = new List <int> {
                1, 2, 3, 4, 5, 6
            };
            var expected = new List <int> {
                4, 5, 6, 1, 2, 3
            };

            input = input.Rotate(3).ToList();

            Assert.AreEqual(input, expected);
        }
Exemple #16
0
        // Resample to required length then rotate to get first point at 0 radians, scale to 1x1 and finally center the path to (0,0)
        public static List <Vector2> Pack(List <Vector2> positions, int samplesCount)
        {
            List <Vector2> locals = ProjectListToDefinedCount(positions, samplesCount);

            float angle = GetAngleBetween(locals.Center(), positions[0]);

            locals = locals.Rotate(-angle);

            locals.ScaleToReferenceWorld();
            locals.CenterToOrigin();

            return(locals);
        }
Exemple #17
0
        public static float Search(List <Vector2> current, List <Vector2> target, float a, float b, float epsilon)
        {
            float          x1          = ReductionFactor * a + (1 - ReductionFactor) * b;
            List <Vector2> rotatedList = current.Rotate(x1);
            float          fx1         = rotatedList.DistanceTo(target);

            float x2 = (1 - ReductionFactor) * a + ReductionFactor * b;

            rotatedList = current.Rotate(x2);
            float fx2 = rotatedList.DistanceTo(target);

            do
            {
                if (fx1 < fx2)
                {
                    b           = x2;
                    x2          = x1;
                    fx2         = fx1;
                    x1          = ReductionFactor * a + (1 - ReductionFactor) * b;
                    rotatedList = current.Rotate(x1);
                    fx1         = rotatedList.DistanceTo(target);
                }
                else
                {
                    a           = x1;
                    x1          = x2;
                    fx1         = fx2;
                    x2          = (1 - ReductionFactor) * a + ReductionFactor * b;
                    rotatedList = current.Rotate(x2);
                    fx2         = rotatedList.DistanceTo(target);
                }
            }while (Math.Abs(b - a) > epsilon);

            float min = Math.Min(fx1, fx2);

            return(1.0f - 2.0f * min / Diagonal);
        }
        public static float Search(List<Vector2> current, List<Vector2> target, float a, float b, float epsilon)
        {
            float x1 = ReductionFactor * a + (1 - ReductionFactor) * b;
            List<Vector2> rotatedList = current.Rotate(x1);
            float fx1 = rotatedList.DistanceTo(target);

            float x2 = (1 - ReductionFactor) * a + ReductionFactor * b;
            rotatedList = current.Rotate(x2);
            float fx2 = rotatedList.DistanceTo(target);

            do
            {
                if (fx1 < fx2)
                {
                    b = x2;
                    x2 = x1;
                    fx2 = fx1;
                    x1 = ReductionFactor * a + (1 - ReductionFactor) * b;
                    rotatedList = current.Rotate(x1);
                    fx1 = rotatedList.DistanceTo(target);
                }
                else
                {
                    a = x1;
                    x1 = x2;
                    fx1 = fx2;
                    x2 = (1 - ReductionFactor) * a + ReductionFactor * b;
                    rotatedList = current.Rotate(x2);
                    fx2 = rotatedList.DistanceTo(target);
                }
            }
            while (Math.Abs(b - a) > epsilon);

            float min = Math.Min(fx1, fx2);

            return 1.0f - 2.0f * min / Diagonal;
        }
Exemple #19
0
        public static int WhichCircularElfGetsThePresents(int numberElves)
        {
            var elves = new List <int>(Enumerable.Range(1, numberElves));

            while (elves.Count > 1)
            {
                var elvesAway = (int)(elves.Count / 2);

                elves.RemoveAt(elvesAway);

                elves = elves.Rotate(1);
            }

            return(elves.First());
        }
        public void Rotate()
        {
            var example = new List <int> {
                1, 2, 3, 4
            };
            List <int> rotated = example.Rotate(1).ToList();

            CollectionAssert.AreEqual(new List <int> {
                4, 1, 2, 3
            }, rotated);

            example = new List <int> {
                1, 2, 3, 4, 5
            };
            rotated = example.Rotate(-2).ToList();
            CollectionAssert.AreEqual(new List <int> {
                3, 4, 5, 1, 2
            }, rotated);
        }
 public Cube BuildCube()
 {
     var numberOfFaces = 6;
      var facelets = new List<Facelet>(3 * 3 * numberOfFaces);
      facelets.AddRange(BuildFacelets("Orange", Colors.Orange));
      facelets.Rotate(Directions.Right, 90);
      facelets.AddRange(BuildFacelets("Green", Colors.Green));
      facelets.Rotate(Directions.Right, 90);
      facelets.AddRange(BuildFacelets("Red", Colors.Red));
      facelets.Rotate(Directions.Right, 90);
      facelets.AddRange(BuildFacelets("Blue", Colors.Blue));
      facelets.Rotate(Directions.Up, 90);
      facelets.AddRange(BuildFacelets("White", Colors.White));
      facelets.Rotate(Directions.Up, 180);
      facelets.AddRange(BuildFacelets("Yellow", Colors.Yellow));
      facelets.Rotate(Directions.Right, -90);
      var cube = new Cube(facelets);
      facelets.ForEach(f => f.Build(cube));
      return cube;
 }
Exemple #22
0
        //**********************************************************************************************************************************************************************************************
        //**********************************************************************************************************************************************************************************************
        //**********************************************************************************************************************************************************************************************

        /// <summary>
        /// Extract the contour.
        /// TODO: probably should have this passed in from the puzzle, since it already does this. It was done this way because the contours don't correspond to the correct pixel locations in this cropped version of the image.
        /// </summary>
        private void extract_edges()
        {
            Bitmap bwImg = PieceImgBw.Bmp;
            _logHandle.Report(new LogEventInfo(PieceID + " Extracting edges"));

            if (corners.Size != 4) { return; }

            VectorOfVectorOfPoint contours = new VectorOfVectorOfPoint();
            CvInvoke.FindContours(new Image<Gray, byte>(bwImg), contours, null, RetrType.List, ChainApproxMethod.ChainApproxNone);
            bwImg.Dispose();
            if (contours.Size == 0)
            {
                _logHandle.Report(new LogEventError(PieceID + " No contours found."));
                return;
            }

            int indexLargestContour = 0;                // Find the largest contour
            double largestContourArea = 0;
            for(int i = 0; i < contours.Size; i++)
            {
                double contourAreaTmp = CvInvoke.ContourArea(contours[i]);
                if(contourAreaTmp > largestContourArea) { largestContourArea = contourAreaTmp; indexLargestContour = i; }
            }

            VectorOfPoint contour = contours[indexLargestContour];

            VectorOfPoint new_corners = new VectorOfPoint();
            for (int i = 0; i < corners.Size; i++)      //out of all of the found corners, find the closest points in the contour, these will become the endpoints of the edges
            {
                double best = 10000000000;
                Point closest_point = contour[0];
                for (int j = 0; j < contour.Size; j++)
                {
                    double d = Utils.Distance(corners[i], contour[j]);
                    if (d < best)
                    {
                        best = d;
                        closest_point = contour[j];
                    }
                }
                new_corners.Push(closest_point);
            }
            corners = new_corners;

            if (PluginFactory.GetGeneralSettingsPlugin().SolverShowDebugResults)
            {
                Bitmap colorImg = PieceImgColor.Bmp;
                Image<Rgb, byte> edge_img = new Image<Rgb, byte>(colorImg);
                for (int i = 0; i < corners.Size; i++) { CvInvoke.Circle(edge_img, Point.Round(corners[i]), 2, new MCvScalar(255, 0, 0), 1); }
                _logHandle.Report(new LogEventImage(PieceID + " New corners", edge_img.Bitmap));
                colorImg.Dispose();
                edge_img.Dispose();
            }

            List<int> sections = find_all_in(contour, corners);

            //Make corners go in the correct order
            Point[] new_corners2 = new Point[4];
            int cornerIndexUpperLeft = -1;
            double cornerDistUpperLeft = double.MaxValue;
            for (int i = 0; i < 4; i++)
            {
                new_corners2[i] = contour[sections[i]];
                double cornerDist = Utils.DistanceToOrigin(contour[sections[i]]);
                if(cornerDist < cornerDistUpperLeft)
                {
                    cornerDistUpperLeft = cornerDist;
                    cornerIndexUpperLeft = i;
                }
            }
            new_corners2.Rotate(-cornerIndexUpperLeft);
            corners.Push(new_corners2);
            sections.Rotate(-cornerIndexUpperLeft);

            Edges[0] = new Edge(PieceID, 0, PieceImgColor, contour.GetSubsetOfVector(sections[0], sections[1]), _logHandle, _cancelToken);
            Edges[1] = new Edge(PieceID, 1, PieceImgColor, contour.GetSubsetOfVector(sections[1], sections[2]), _logHandle, _cancelToken);
            Edges[2] = new Edge(PieceID, 2, PieceImgColor, contour.GetSubsetOfVector(sections[2], sections[3]), _logHandle, _cancelToken);
            Edges[3] = new Edge(PieceID, 3, PieceImgColor, contour.GetSubsetOfVector(sections[3], sections[0]), _logHandle, _cancelToken);
        }
Exemple #23
0
            public RoundedBox( float x,  float y,  float w,  float h,  float conerRadius,  Angle angle = default(Angle),  bool positiveLocation = false) : this()
            {
                ID = Factory.NewID(Name);
                X = x;
                Y = y;
                Width = w;
                Height = h;

                if (positiveLocation)
                {
                    if (X < 0)
                    {
                        Width += X;
                        X = 0;
                    }
                    if (Y < 0)
                    {
                        Height += Y;
                        Y = 0;
                    }
                }

                CornerRadius = conerRadius;
                Angle = angle.AssignCenter(this);

                var pts = new List<PointF>(50);

                Geometry.GetBezierPoints(4, ref pts,
                    new PointF[]
                    {
                        new PointF(X, Y + CornerRadius),
                        new PointF(X, Y),
                        new PointF(X + CornerRadius, Y)
                    });
                Geometry.GetBezierPoints(4, ref pts,
                    new PointF[]
                    {
                        new PointF(X + Width - CornerRadius, Y),
                        new PointF(X + Width, Y),
                        new PointF(X + Width, Y + CornerRadius)
                    });

                Geometry.GetBezierPoints(4, ref pts,
                   new PointF[]
                   {
                        new PointF(X + Width, Y + Height - CornerRadius),
                        new PointF(X + Width, Y + Height),
                        new PointF(X + Width - CornerRadius, Y + Height)
                   });

                Geometry.GetBezierPoints(4, ref pts,
                  new PointF[]
                  {
                        new PointF(X + CornerRadius, Y + Height),
                        new PointF(X, Y + Height),
                        new PointF(X, Y + Height - CornerRadius)
                  });

                if (Angle.Valid)
                    points = pts.Rotate(Angle);
                else
                    points = pts;
            }
Exemple #24
0
        static void Main(string[] args)
        {
            // Generate list of primes less than or equal to 5000
            List <int> primes       = ACM.GeneratePrimes(5000);
            List <int> primesFaster = ACM.GeneratePrimesParallel(5000);

            List <int> factors = ACM.GetPrimeFactors(38);  // [2, 19]

            int        fact     = 88;
            List <int> factors2 = fact.GetPrimeFactors(); // [2, 2, 2, 11]

            int gpf = 4997.GreatestPrimeFactor();         // 263

            // Parse input strings
            List <int>    nums    = "1 2 3 4 5 6 7 8 9 10".ToIntegerList();
            List <string> strings = "apple banana carrot".ToStringList();

            int    num  = "1".ToInteger();
            long   num2 = "2".ToLong();
            double val  = "6.5".ToDouble();

            // Reverse a string
            String s = "taco";

            s = s.Reverse();  // "ocat"

            // Turn an int into a different arbitrary base (binary = 2, octal = 8, hex = 16)
            string output = 42.ToBase(2);                          // 101010
            string roman  = 57.ToRoman();                          // LVII

            string everything  = ACM.ConvertBase("101010", 2, 10); // 42
            string everything2 = "101010".ConvertBase(2, 10);      // 42

            // one hundred and twenty-three million four hundred and fifty-six thousand seven hundred and eighty-nine
            string numberwords = 123456789.ToWords();

            int solution = "2 + (3 * 4)".Evaluate();  // 14

            string longest = "apple car banana grapefruit".ToStringList().OrderByDescending(sp => sp.Length).First();

            string a = "the cat in the hat", b = "I left the cat in the garage";
            string common = ACM.LongestCommonSubstring(a, b);  // "the cat in the "

            // Generates all possible substrings of a string
            List <string> allSubstrings = "i love cats".FindAllSubstrings().ToList();
            string        prefix        = "the cat in the hat:the cat loves me:the cat eats mice".ToStringList(":").ShortestCommonPrefix(); // "the cat"


            // Greatest common divisor (biggest number that divides 12 and 8)
            int gcd = ACM.GreatestCommonDivisor(12, 8);  // 4

            // Least common multiple (first number that is a multiple of a and b)
            int lcm = ACM.LeastCommonMultiple(2, 7);  // 14

            // Check if two lists contain indentical elements (order matters)
            List <int> aq = 123456789.ToIntegerList(); // [1,2,3,4,5,6,7,8,9]
            List <int> bq = 123456789.ToIntegerList(); // [1,2,3,4,5,6,7,8,9]
            List <int> cq = 987654321.ToIntegerList(); // [9,8,7,6,5,4,3,2,1]

            bool equals  = aq.SequenceEqual(bq);       // true because both lists have same numbers in same sequence
            bool equals2 = aq.SequenceEqual(cq);       // false, same numbers but different order
            bool equals3 = aq.All(k => cq.Contains(k)) && aq.Count == cq.Count;


            List <int> digits = 12345.ToIntegerList();
            int        least  = digits.Min();

            // Rotate a list
            List <int> rotateLeft  = nums.Rotate(2);
            List <int> rotateRight = nums.Rotate(-2);

            // Generate permutations of a list
            List <int> plist = 1234.ToIntegerList();

            var permutations = plist.Permute().ToList();

            foreach (var permutation in permutations)
            {
                List <int> perm = permutation.ToList();
            }

            List <int> blist      = 12344321.ToIntegerList();
            bool       increasing = blist.IsIncreasing(0, 3);

            int revint = 12345.Reverse();

            bool res = 123457789.ToIntegerList().IsIncreasing();
        }
Exemple #25
0
 public KeylessScale CreateMode(int shift)
 {
     return(new KeylessScale(intervals.Rotate(shift)));
 }
Exemple #26
0
 public void Rotate(double theta)
 {
     shape       = shape?.Rotate(SwinGame.PointAt(0, 0), theta);
     BoundingBox = BoundingBox?.Rotate(pos, theta);
 }
Exemple #27
0
 public SurfaceComponentGeometry ShiftBoundaries(int shiftAmount)
 {
     boundaries = boundaries.Rotate(shiftAmount).ToList();
     return(this);
 }
Exemple #28
0
 /// <summary>
 /// Rotates the alphabet, wrapping the end or first items as necessary
 /// </summary>
 /// <param name="offset">The amount of rotation to apply</param>
 public void Rotate(int offset)
 {
     _items.Rotate(offset);
 }