Esempio n. 1
0
        public void WhenThenFromFile(string fileName, int expected)
        {
            var s = @"C:\Users\ali.abdoli\source\repos\AlgorithmHackerrank\AlgorithmHackerrank.Tests\Sorting\" + fileName;
            //var expectedDir = @"C:\Users\ali.abdoli\source\repos\AlgorithmHackerrank\AlgorithmHackerrank.Tests\"+ fileName;

            var reader = new StreamReader(s);
            //var expectedReader = new StreamReader(expectedDir);

            var algorithm = new FraudulentActivityNotifications();

            string[] nd = reader.ReadLine().Split(' ');

            int n = Convert.ToInt32(nd[0]);

            int d = Convert.ToInt32(nd[1]);


            int[] expenditure = Array.ConvertAll(reader.ReadLine().Split(' '),
                                                 expenditureTemp => Convert.ToInt32(expenditureTemp));


            int result = algorithm.ActivityNotifications(expenditure, d);

            Assert.AreEqual(expected, result);
        }
Esempio n. 2
0
        //[TestCase(new[] { 3, 2, 1 }, 2)]
        //[TestCase(new[] { 4, 3, 2, 1 }, 2.5)]
        //[TestCase(new[] { 1, 2, 3, 4, 5, 6 }, 3.5)]
        //[TestCase(new[] { 4, 3, 2, 6, 8 }, 4)]
        //[TestCase(new[] { 1, 1, 2, 6, 6, 9 }, 4)]
        //[TestCase(new[] { 2, 10, 21, 23, 23, 38, 38 }, 23)]
        //[TestCase(new[] { 2, 10, 21, 23, 23, 38, 38, 1027892 }, 23)]
        public void FindMedianTest(int[] input, double expected)
        {
            var algorithm = new FraudulentActivityNotifications();
            var buckets   = input.OrderBy(x => x).ToList();
            var result    = FraudulentActivityNotifications.FindMedian(buckets, input.Count());

            Assert.AreEqual(expected, result);
        }
        public void Test2()
        {
            FraudulentActivityNotifications notifs = new FraudulentActivityNotifications();
            var actual   = notifs.activityNotifications(new int[] { 1, 2, 3, 4, 4 }, 4);
            var expected = 0;

            Assert.Equal(expected, actual);
        }
        public void Test1()
        {
            FraudulentActivityNotifications notifs = new FraudulentActivityNotifications();
            var actual   = notifs.activityNotifications(new int[] { 2, 3, 4, 2, 3, 6, 8, 4, 5 }, 5);
            var expected = 2;

            Assert.Equal(expected, actual);
        }
        public void Test3()
        {
            FraudulentActivityNotifications notifs = new FraudulentActivityNotifications();

            string inputArray = File.ReadAllText("C:\\Users\\s_vithala\\Desktop\\fraudnotifTestcase.txt");

            int[] expenditure = Array.ConvertAll(inputArray.Split(' '), expenditureTemp => Convert.ToInt32(expenditureTemp));

            var actual   = notifs.activityNotifications(expenditure, 30000);
            var expected = 0;

            Assert.Equal(expected, actual);
        }
Esempio n. 6
0
        public void WhenThen(string input, int expected)
        {
            var algorithm = new FraudulentActivityNotifications();
            var reader    = new StringReader(input);

            string[] nd = reader.ReadLine().Split(' ');

            int n = Convert.ToInt32(nd[0]);

            int d = Convert.ToInt32(nd[1]);

            int[] expenditure = Array.ConvertAll(reader.ReadLine().Split(' '),
                                                 expenditureTemp => Convert.ToInt32(expenditureTemp));
            int result = algorithm.ActivityNotifications(expenditure, d);

            Assert.AreEqual(expected, result);
        }
Esempio n. 7
0
        public static void Main()
        {
            // SockMerchant.Run();
            // CountingValleys.Run();
            // JumpingOnTheClouds.Run();
            // RepeatedString.Run();
            // HourglassTwoDimArray.Run();
            // LeftRotationArray.Run();
            // NewYearChaos.Run();
            // MinimumSwaps2.Run();
            // ArrayManipulation.Run();
            // HashTablesRansomNote.Run();
            // TwoStrings.Run();
            // SherlockAndAnagrams.Run();
            // CountTriplets.Run();
            // FrequencyQueries.Run();
            // BubbleSort.Run();
            // MarkAndToys.Run();
            // SortingComparator.Run();
            FraudulentActivityNotifications.Run();

            Console.ReadLine();
        }