Esempio n. 1
0
    void Start()
    {
        alpha = 29;

        myOtherClass = new Part2();
        myOtherClass.FruitMachine(alpha, myOtherClass.apples);
    }
Esempio n. 2
0
        public static void Solve()
        {
            var customsDeclarationFormsYesses = File.ReadAllText("D6/Input.txt");

            Console.WriteLine("D6P1 answer: " + Part1.Solve(customsDeclarationFormsYesses));
            Console.WriteLine("D6P2 answer: " + Part2.Solve(customsDeclarationFormsYesses));
        }
Esempio n. 3
0
        public void Test1(string inputFile, int expected)
        {
            var input  = Program.Read(inputFile);
            var output = Part2.Run(input);

            output.ShouldBe(expected);
        }
 public override int GetHashCode()
 {
     return(Part1.GetHashCode() ^
            Part2.GetHashCode() ^
            Part3.GetHashCode() ^
            Part4.GetHashCode());
 }
Esempio n. 5
0
        public static void Solve()
        {
            var bagRules = File.ReadAllText("D7/Input.txt");

            Console.WriteLine("D7P1 answer: " + Part1.Solve(bagRules));
            Console.WriteLine("D7P2 answer: " + Part2.Solve(bagRules));
        }
Esempio n. 6
0
        public static void Solve()
        {
            var boardingPassPartitions = File.ReadAllLines("D5/Input.txt");

            Console.WriteLine("D5P1 answer: " + Part1.Solve(boardingPassPartitions));
            Console.WriteLine("D5P2 answer: " + Part2.Solve(boardingPassPartitions));
        }
Esempio n. 7
0
    void Update()
    {
        //Rotate Sky
        RenderSettings.skybox.SetFloat("_Rotation", Time.time * 1.2f);

        //Particle System Control
        if (Input.GetKeyDown("p"))

        {
            partbool = !partbool;

            if (partbool)
            {
                Part1.SetActive(true);
                Part2.SetActive(true);
            }
            else
            {
                Part1.SetActive(false);
                Part2.SetActive(false);
            }
        }

        //exit on escape
        if (Input.GetKeyDown(KeyCode.Escape))
        {
            Application.Quit();
            Debug.Log("Exit");
        }
    }
Esempio n. 8
0
        public void TestCalculateSum()
        {
            int[] arr    = new int[] { 0, 1, 2, 3, 4, 5 };
            int   result = Part2.CalculateSum(arr);

            Assert.AreEqual(15, result);
        }
Esempio n. 9
0
        public void TestCalculateSumOfNegative()
        {
            int[] arr    = new int[] { 0, 1, -2, 3, -4, 5 };
            int   result = Part2.CalculateSumOfNegative(arr);

            Assert.AreEqual(-6, result);
        }
    void array()
    {
        array1 = new Part1[array1size];
        for (int i = 0; i < array1.Length; i++)
        {
            array1[i] = new Part1();
        }
        array1[0] = boatstatus.Turn1;
        array1[1] = boatstatus.Turn2;
        //array1[2] = boatstatus.Turn3;

        array2 = new Part2[array2size];
        for (int i = 0; i < array2.Length; i++)
        {
            array2[i] = new Part2();
        }
        array2[0] = boatstatus.Body1;
        array2[1] = boatstatus.Body2;
        array2[2] = boatstatus.Body3;

        array3 = new Part3[array3size];
        for (int i = 0; i < array3.Length; i++)
        {
            array3[i] = new Part3();
        }
        array3[0] = boatstatus.Ancor1;
        array3[1] = boatstatus.Ancor2;
        array3[2] = boatstatus.Ancor3;
        array3[3] = boatstatus.Ancor4;
    }
Esempio n. 11
0
 public void TestOneToN()
 {
     int[] result = Part2.OneToN(5);
     CollectionAssert.AreEqual(new int[] { 1, 2, 3, 4, 5 }, result);
     int[] result2 = Part2.OneToN(7);
     CollectionAssert.AreEqual(new int[] { 1, 2, 3, 4, 5, 6, 7 }, result2);
 }
Esempio n. 12
0
 public static void Run()
 {
     //Part1.PlayGame(4, 8).Dump("21a sample (739785): ");
     Part1.PlayGame(8, 5).Dump("21a (597600): ");
     //Part2.PlayGame(4, 8).Dump("21b sample (444356092776315): ");
     Part2.PlayGame(8, 5).Dump("21b (634769613696613): ");
 }
Esempio n. 13
0
    public static void Main()
    {
        var input = File.ReadAllLines("Input.txt");

        Part1.Solve(input);
        Part2.Solve(input);
    }
Esempio n. 14
0
    public static void Main()
    {
        Part1.Run();
        Part2.Run();

        Console.ReadKey();
    }
Esempio n. 15
0
    void Start()
    {
        alpha = 29;

        myOtherClass = new Part2();
        myOtherClass.FruitMachine (alpha, myOtherClass.apples);
    }
Esempio n. 16
0
        public static void Solve()
        {
            var passwordsAndPolicies = File.ReadAllLines("D2/Input.txt");

            Console.WriteLine("D2P1 answer: " + Part1.Solve(passwordsAndPolicies));
            Console.WriteLine("D2P2 answer: " + Part2.Solve(passwordsAndPolicies));
        }
Esempio n. 17
0
        public static void Solve()
        {
            var passwordsAndPolicies = File.ReadAllText("D3/Input.txt");

            Console.WriteLine("D3P1 answer: " + Part1.Solve(passwordsAndPolicies, new Step(3, 1)));
            Console.WriteLine("D3P2 answer: " + Part2.Solve(passwordsAndPolicies));
        }
Esempio n. 18
0
 public void TestSetAllValuesToN()
 {
     int[] arr = new int[] { 0, 1, -2, 3, -4, 5 };
     Part2.SetAllValuesToN(arr, 3);
     CollectionAssert.AreEqual(new int[] { 3, 3, 3, 3, 3, 3 }, arr);
     Part2.SetAllValuesToN(arr, 4);
     CollectionAssert.AreEqual(new int[] { 4, 4, 4, 4, 4, 4 }, arr);
 }
Esempio n. 19
0
        public static void Solve()
        {
            var numbers = File.ReadAllLines("D1/Input.txt")
                          .Select(int.Parse)
                          .ToArray();

            Console.WriteLine("D1P1 answer: " + Part1.Solve(numbers, NeededSum));
            Console.WriteLine("D1P2 answer: " + Part2.Solve(numbers, NeededSum));
        }
Esempio n. 20
0
 public void TestDoubleEachNumberSecond()
 {
     //Arrange
     int[] arr2 = new int[] { 5, 4, 3, 2, 1, 0 };
     //Act
     Part2.DoubleEachNumber(arr2);
     //Assert
     CollectionAssert.AreEqual(new int[] { 10, 8, 6, 4, 2, 0 }, arr2);
 }
Esempio n. 21
0
 public void TestDoubleEachNumberFirst()
 {
     //Arrange
     int[] arr = new int[] { 0, 1, 2, 3, 4, 5 };
     //Act
     Part2.DoubleEachNumber(arr);
     //Assert
     CollectionAssert.AreEqual(new int[] { 0, 2, 4, 6, 8, 10 }, arr);
 }
Esempio n. 22
0
 // Start is called before the first frame update
 void Start()
 {
     PointsArray = GameObject.FindGameObjectsWithTag("SpawnPoint");
     rbP0        = Part0.GetComponent <Rigidbody2D>();
     rbP1        = Part1.GetComponent <Rigidbody2D>();
     rbP2        = Part2.GetComponent <Rigidbody2D>();
     TextBar     = GameObject.FindGameObjectWithTag("ScoreText");
     ScoreBar    = TextBar.GetComponent <Text>();
     StartCoroutine("SpeedUp", 1f);
 }
Esempio n. 23
0
        public void SplitPart(string Part1FileName, string Part2FileName, int Dim = 0)
        {
            var       Slice = SplittingPlane(Dim);
            STLReader Part1;
            STLReader Part2;

            SplitPart(Slice, out Part1, out Part2);
            Part1.WriteToFile(Part1FileName);
            Part2.WriteToFile(Part2FileName);
        }
Esempio n. 24
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = Part1.GetHashCode();
         hashCode = (hashCode * 397) ^ Part2.GetHashCode();
         hashCode = (hashCode * 397) ^ Part3.GetHashCode();
         return(hashCode);
     }
 }
Esempio n. 25
0
    static async System.Threading.Tasks.Task Main(string[] args)
    {
        //Part 1
        Console.WriteLine("===PART 1===");
        await Part1.Run(args);

        //Part 2
        Console.WriteLine("===PART 2===");
        await Part2.Run(args);
    }
Esempio n. 26
0
        public void Test(int mass, int expectedFuel, int expectedTotalFuel)
        {
            var fuel = Part2.Fuel(mass);

            fuel.ShouldBe(expectedFuel);

            var total = Part2.TotalFuel(fuel);

            total.ShouldBe(expectedTotalFuel);
        }
Esempio n. 27
0
    boat(Part1 part1_, Part2 part2_, Part3 part3_)
    {
        part1 = part1_;
        part2 = part2_;
        part3 = part3_;

        power         = part1_.power + part2_.power + part3_.power;
        weight        = part1_.weight + part2_.weight + part3_.weight;
        movementspeed = part1_.movementspeed + part2_.movementspeed + part3_.movementspeed;
        strength      = part1_.strength + part2_.strength + part3_.strength;
    }
Esempio n. 28
0
        public void MultipleSources()
        {
            using (var container = new RhetosTestContainer())
            {
                container.Resolve<ISqlExecuter>().ExecuteSql(new[] { "DELETE FROM TestReport.Document" });
                var repository = container.Resolve<Common.DomRepository>();

                var d1 = new Document { ID = Guid.NewGuid(), Name = "d1" };
                var d2 = new Document { ID = Guid.NewGuid(), Name = "d2" };
                var d3 = new Document { ID = Guid.NewGuid(), Name = "d3" };
                var d4 = new Document { ID = Guid.NewGuid(), Name = "d4" };
                repository.TestReport.Document.Insert(new[] { d1, d2, d3, d4 });

                var s11 = new Part1 { ParentID = d1.ID, Name = "A s11" };
                var s12 = new Part1 { ParentID = d2.ID, Name = "A s12" };
                var s13 = new Part1 { ParentID = d1.ID, Name = "A s13" };
                var s14 = new Part1 { ParentID = d3.ID, Name = "A s14" };
                var s15 = new Part1 { ParentID = d4.ID, Name = "B s15" };
                repository.TestReport.Part1.Insert(new[] { s11, s12, s13, s14, s15 });

                var s21 = new Part2 { ParentID = d1.ID, Name = "s21" };
                var s22 = new Part2 { ParentID = d3.ID, Name = "s22 xx" };
                var s23 = new Part2 { ParentID = d3.ID, Name = "s23 xxx" };
                var s24 = new Part2 { ParentID = d3.ID, Name = "s24 x" };
                var s25 = new Part2 { ParentID = d4.ID, Name = "s25" };
                repository.TestReport.Part2.Insert(new[] { s21, s22, s23, s24, s25 });

                var reportData = repository.TestReport.MultipleSourcesReport.GetReportData(
                    new MultipleSourcesReport { Part1Prefix = "A" });

                var reportDump = string.Join("|", reportData.Select(group =>
                    string.Join(", ", group.Select(item => ((dynamic)item).Name))));

                const string expectedReport1 = "d3, d2, d1|s24 x, s22 xx, s23 xxx, s21|A s14, A s13, A s12, A s11";
                const string expectedReport2 = "d3, d1, d2|s24 x, s22 xx, s23 xxx, s21|A s14, A s13, A s12, A s11"; // Order of d1 and d2 is not defined.

                Console.WriteLine("Report result: " + reportDump);
                Console.WriteLine(expectedReport1);
                Console.WriteLine(expectedReport2);

                Assert.IsTrue(
                    new[] { expectedReport1, expectedReport2 }.Contains(reportDump),
                    "Report result should be one of the expected results.");
            }
        }
            public ISolver getSolver(int part)
            {
                ISolver Solver;

                switch (part)
                {
                case 1:
                    Solver = new Part1();
                    break;

                case 2:
                    Solver = new Part2();
                    break;

                default:
                    throw new Exception("Wrong part.");
                }

                return(Solver);
            }
Esempio n. 30
0
 public void NextLVL()
 {
     CurrentLVL++;
     AmmoRemaining = 3;
     if (CurrentLVL == 2)
     {
         Part1.SetActive(false);
         Part2.SetActive(true);
         Part3.SetActive(false);
     }
     if (CurrentLVL == 4)
     {
         Part1.SetActive(false);
         Part2.SetActive(false);
         Part3.SetActive(true);
     }
     if (CurrentLVL == 7)
     {
         SceneManager.LoadScene(2);
     }
 }
Esempio n. 31
0
        public override ValidationResult InsureeNumber(string insureeNumber)
        {
            if (insureeNumber.Length != 9)
            {
                return(new ValidationResult("Invalid CHF ID"));
            }
            String Chfid;
            int    Part1, Part2;

            Part1 = int.Parse(insureeNumber.ToString()) / 10;
            Part2 = Part1 % 7;

            Chfid = insureeNumber.Substring(0, 8) + Part2.ToString();
            if (insureeNumber.Equals(Chfid))
            {
                return(ValidationResult.Success);
            }
            else
            {
                return(new ValidationResult("Invalid CHF ID"));
            }
        }
Esempio n. 32
0
        static void Main(string[] args)
        {
            int taskNumber;

            while (true)
            {
                Console.Write("Enter the number of task you want to check (0 - exit): ");
                if (Int32.TryParse(Console.ReadLine(), out taskNumber))
                {
                    switch (taskNumber)
                    {
                    case 0:
                        return;

                    case 1:
                        Part1.DoIt("input.txt", "output.txt");
                        break;

                    case 2:
                        Part2.DoIt();
                        break;

                    case 3:
                        Part3.DoIt();
                        break;

                    default:
                        Console.WriteLine("Incorrect task number");
                        break;
                    }
                }
                else
                {
                    Console.WriteLine("Can not resolve the task number");
                }
            }
        }
 public Part8([BundleImport] Part1 part, [BundleImport] Part2 part2)
 {
     _part = part;
     _part2 = part2;
 }
Esempio n. 34
0
        static void Main(string[] args)
        {
            Part1a parta = null;
            Particle1a rbesta = null;
            /* part b stuff */
            Part1b partb = null;
            int brun = 0; // track runs
            Particle rbest = null; // run best

            while (true)
            {
                Console.WriteLine("===============================================================");
                Console.WriteLine("ECE457A - ASSIGNMENT 3");
                Console.WriteLine("Shweta Aladi, Bilal Arshad, Pooja Sardesai");
                Console.WriteLine("===============================================================\n");
                Console.WriteLine("Select the assignment question:");
                Console.WriteLine("[A] Camelback Function (PSO)");
                Console.WriteLine("[B] Sphere Function (PSO)");
                Console.WriteLine("[C] Travelling Salesman Problem (ACO)");
                Console.WriteLine("[Q] Quit");
                char a = Console.ReadLine().ToLower().ToCharArray()[0];

                switch (a)
                {
                    case 'a':
                        rbesta = null;
                        Console.WriteLine("Choose from the following variations: "
                            + "\n   [x] Regular PSO with Global Best"
                            + "\n   [y] Regular PSO with Local Best"
                            + "\n   [a] Inertia Weight Velocity with Global Best"
                            + "\n   [b] Vmax with Global Best"
                            + "\n   [c] Constriction Factor Velocity with Global Best"
                            + "\n   [d] Inertia Weight Velocity with Local Best"
                            + "\n   [e] Vmax with Local Best"
                            + "\n   [f] Constriction Factor Velocity with Local Best"
                            + "\n   [g] Random Number Seed Variation (10x)");

                        Char a1 = Console.ReadLine().ToLower().ToCharArray()[0];

                        for (int i = 0; i < 10; i++)
                        {
                            parta = new Part1a(30, 10000, 2.5, 2.5, a1);
                            Particle1a solution = parta.RunPSO();
                            if (rbesta == null || rbesta.GetFitness() > solution.GetFitness())
                            {
                                rbesta = solution;
                            }
                        }
                        Console.WriteLine("\nBest Solution");
                        Console.WriteLine(rbesta.toString());
                        break;
                    case 'b':
                        // print options
                        Console.WriteLine("Choose from the following variations: "
                            + "\n   [x] Regular PSO with Global Best"
                            + "\n   [y] Regular PSO with Local Best"
                            + "\n   [a] Inertia Weight Velocity with Global Best"
                            + "\n   [b] Vmax with Global Best"
                            + "\n   [c] Constriction Factor Velocity with Global Best"
                            + "\n   [d] Inertia Weight Velocity with Local Best"
                            + "\n   [e] Vmax with Local Best"
                            + "\n   [f] Constriction Factor Velocity with Local Best"
                            + "\n   [g] Random Number Seed Variation (10x)");

                        Char b1 = Console.ReadLine().ToLower().ToCharArray()[0];
                        // run part 1b - need to add switch based on b1
                        for (int x = 0; x < 10; x++)
                        {
                           partb = new Part1b(30, 10000, 2.5, 2.5, b1);
                            Particle new_best = partb.RunSwarm();

                            // store run best
                            if (rbest == null)
                            {
                                rbest = new_best;
                            }
                            else if (Math.Abs(rbest.GetFitness()) > Math.Abs(new_best.GetFitness()))
                            {
                                rbest = new_best;
                            }
                            brun++; // run partb
                        }
                        Console.WriteLine("\nRun: " + brun.ToString()
                            + "\nOption: " + b1);
                        rbest.Print(brun);

                        break;

                    case 'c':
                        Part2 p2 = new Part2();
                        p2.RunPart2();
                        break;
                    case 'q':
                        Console.WriteLine("Exiting...");
                        return;
                    default:
                        Console.WriteLine("Invalid selection");
                        break;
                }
            }
        }