Example #1
0
        public void Question_5_1_BasicCases()
        {
            int n        = BinaryHelpers.IntFromBinary("11111111");
            int m        = BinaryHelpers.IntFromBinary("101");
            int i        = 2;
            int j        = 4;
            int expected = BinaryHelpers.IntFromBinary("11110111");

            Validate(expected, n, m, i, j);

            i        = 0;
            j        = 2;
            expected = BinaryHelpers.IntFromBinary("11111101");
            Validate(expected, n, m, i, j);

            n        = BinaryHelpers.IntFromBinary("10101010");
            m        = BinaryHelpers.IntFromBinary("1000");
            j        = 3;
            expected = BinaryHelpers.IntFromBinary("10101000");
            Validate(expected, n, m, i, j);

            i        = 4;
            j        = 7;
            expected = BinaryHelpers.IntFromBinary("10001010");
            Validate(expected, n, m, i, j);
        }
Example #2
0
        public void Question_5_3_BasicCases()
        {
            var n        = BinaryHelpers.IntFromBinary("010101010101");
            var expected = 3;

            Validate(expected, n);

            n        = BinaryHelpers.IntFromBinary("000000000");
            expected = 1;
            Validate(expected, n);

            n        = BinaryHelpers.IntFromBinary("110110110111011");
            expected = 6;
            Validate(expected, n);

            n        = BinaryHelpers.IntFromBinary("11011011011001111001111");
            expected = 5;
            Validate(expected, n);

            n        = BinaryHelpers.IntFromBinary("1010100110101011");
            expected = 4;
            Validate(expected, n);
        }