Exemplo n.º 1
0
        static void Main(string[] args)
        {
            var inputPath  = Path.Combine(Directory.GetCurrentDirectory(), "inputs", "input1.txt");
            var fileStream = File.OpenRead(inputPath);
            var sumFinder  = new SumFinder(2020, fileStream);

            Console.WriteLine(sumFinder.GetResult());
            Console.ReadLine();
        }
Exemplo n.º 2
0
        private void FindNumEntryCompleted(object sender, EventArgs e)
        {
            targetNumber         = Convert.ToInt32(((Entry)sender).Text);
            ((Entry)sender).Text = null; //null값으로 TextChanged호출됨 !!

            SumFinder finder = new SumFinder();

            if (finder.FindIndex(ref intList, ref targetNumber, out int first, out int second))
            {
                OutputLabel.Text = "찾을 숫자 : " + targetNumber + "\n첫번째 숫자 : " + first + " 두번째 숫자 : " + second;
            }
Exemplo n.º 3
0
 internal override long FindValue(IEnumerable <long> input)
 {
     for (var i = 0; i < input.Count() - 25; ++i)
     {
         var res = SumFinder.Find(input.Skip(i).Take(25).ToList(), 2, input.ElementAt(i + 25));
         if (res.Count == 0)
         {
             return(input.ElementAt(i + 25));
         }
     }
     return(-1);
 }
Exemplo n.º 4
0
        protected void Result(int noOfItems, int sum, out string result)
        {
            var input = ReadRows($"Input.txt").Select(x => long.Parse(x)).ToList();

            var output = SumFinder.Find(input, noOfItems, sum);

            if (output.Count > 0)
            {
                result = ValuesMultiplicator.GetMathOperation(output);
                return;
            }

            result = "not found";
        }
Exemplo n.º 5
0
        public void Test132()
        {
            var result = new SumFinder().GetSumOfTwoMinimals(new int[] { 1, 3, 2 });

            Assert.AreEqual(result, 1 + 2);
        }
Exemplo n.º 6
0
        public void Test3Instead2()
        {
            var result = new SumFinder().GetSumOfTwoMinimals(new int[] { 4, 4, 4, 2, 1, 1 });

            Assert.AreEqual(result, 2);
        }
Exemplo n.º 7
0
        public void TestShakedSet()
        {
            var result = new SumFinder().GetSumOfTwoMinimals(new int[] { 5, 10, 3, -3, 2, 4 });

            Assert.AreEqual(result, -3 + 2);
        }
Exemplo n.º 8
0
        public void TestReversed()
        {
            var result = new SumFinder().GetSumOfTwoMinimals(new int[] { 5, 4, 3, 2, 1 });

            Assert.AreEqual(result, 1 + 2);
        }