From df971366d8a768f0d12d65827f7354cc5b8de0e1 Mon Sep 17 00:00:00 2001 From: Gonzalo Diaz Date: Fri, 23 Aug 2024 16:21:52 -0400 Subject: [PATCH] [REFACTOR] JSON data load for unit tests. --- .../arrays/ctci_array_left_rotation.test.ts | 25 ++++---- .../ctci_array_left_rotation.testcases.json | 7 +++ .../arrays/minimum_swaps_2.test.ts | 6 +- .../arrays/minimum_swaps_2.testcases.json | 5 ++ .../arrays/new_year_chaos.test.ts | 18 +----- .../arrays/new_year_chaos.testcases.json | 27 +++++++++ .../count_triplets_1.big.testcases.json | 12 ++++ ... => count_triplets_1.small.testcases.json} | 0 .../count_triplets_1_bruteforce.test.ts | 27 +-------- .../count_triplets_1_optimized.test.ts | 18 +----- .../ctci-ransom-note.test.ts | 21 +------ .../ctci-ransom-note.testcases.json | 20 +++++++ .../two_strings.test.ts | 60 +------------------ .../two_strings.testcases.json | 57 ++++++++++++++++++ .../greedy_algorithms/luck-balance.test.ts | 43 +------------ .../luck-balance.testcases.json | 42 +++++++++++++ .../miscellaneous/flipping-bits.test.ts | 50 +--------------- .../flipping-bits.testcases.json | 54 +++++++++++++++++ 18 files changed, 246 insertions(+), 246 deletions(-) create mode 100644 src/hackerrank/interview_preparation_kit/arrays/ctci_array_left_rotation.testcases.json create mode 100644 src/hackerrank/interview_preparation_kit/arrays/minimum_swaps_2.testcases.json create mode 100644 src/hackerrank/interview_preparation_kit/arrays/new_year_chaos.testcases.json create mode 100644 src/hackerrank/interview_preparation_kit/dictionaries_and_hashmaps/count_triplets_1.big.testcases.json rename src/hackerrank/interview_preparation_kit/dictionaries_and_hashmaps/{count_triplets_1_testcases.json => count_triplets_1.small.testcases.json} (100%) create mode 100644 src/hackerrank/interview_preparation_kit/dictionaries_and_hashmaps/ctci-ransom-note.testcases.json create mode 100644 src/hackerrank/interview_preparation_kit/dictionaries_and_hashmaps/two_strings.testcases.json create mode 100644 src/hackerrank/interview_preparation_kit/greedy_algorithms/luck-balance.testcases.json create mode 100644 src/hackerrank/interview_preparation_kit/miscellaneous/flipping-bits.testcases.json diff --git a/src/hackerrank/interview_preparation_kit/arrays/ctci_array_left_rotation.test.ts b/src/hackerrank/interview_preparation_kit/arrays/ctci_array_left_rotation.test.ts index bbba4b0f..b47a9fec 100644 --- a/src/hackerrank/interview_preparation_kit/arrays/ctci_array_left_rotation.test.ts +++ b/src/hackerrank/interview_preparation_kit/arrays/ctci_array_left_rotation.test.ts @@ -3,36 +3,31 @@ import { logger as console } from '../../../logger'; import { rotLeft, rotLeftOne } from './ctci_array_left_rotation'; -const ROT_LEFT_ONE_TEST_CASES = [ - { numbers: [1, 2, 3, 4, 5], expected: [2, 3, 4, 5, 1] }, - { numbers: [2, 3, 4, 5, 1], expected: [3, 4, 5, 1, 2] }, - { numbers: [3, 4, 5, 1, 2], expected: [4, 5, 1, 2, 3] }, - { numbers: [4, 5, 1, 2, 3], expected: [5, 1, 2, 3, 4] }, - { numbers: [5, 1, 2, 3, 4], expected: [1, 2, 3, 4, 5] } -]; - -const ROT_LEFT_TEST_CASES = [ - { numbers: [1, 2, 3, 4, 5], d_rotations: 4, expected: [5, 1, 2, 3, 4] } -]; +import ROT_LEFT_ONE_TEST_CASES from './ctci_array_left_rotation.testcases.json'; describe('ctci_array_left_rotation', () => { it('rotLeftOne Test Cases', () => { expect.assertions(5); - ROT_LEFT_ONE_TEST_CASES.forEach((value) => { - const answer = rotLeftOne(value.numbers); + ROT_LEFT_ONE_TEST_CASES.forEach((test) => { + const input = test.numbers; + const answer = rotLeftOne(input); console.debug( - `rotLeftOne(${value.numbers.toString()}) solution found: ${answer.toString()}` + `rotLeftOne(${test.numbers.toString()}) solution found: ${answer.toString()}` ); - expect(answer).toStrictEqual(value.expected); + expect(answer).toStrictEqual(test.expected); }); }); it('rotLeft Test cases', () => { expect.assertions(1); + const ROT_LEFT_TEST_CASES = [ + { numbers: [1, 2, 3, 4, 5], d_rotations: 4, expected: [5, 1, 2, 3, 4] } + ]; + ROT_LEFT_TEST_CASES.forEach((value) => { const answer = rotLeft(value.numbers, value.d_rotations); diff --git a/src/hackerrank/interview_preparation_kit/arrays/ctci_array_left_rotation.testcases.json b/src/hackerrank/interview_preparation_kit/arrays/ctci_array_left_rotation.testcases.json new file mode 100644 index 00000000..aa06f8ae --- /dev/null +++ b/src/hackerrank/interview_preparation_kit/arrays/ctci_array_left_rotation.testcases.json @@ -0,0 +1,7 @@ +[ + {"numbers": [1, 2, 3, 4, 5], "expected": [2, 3, 4, 5, 1]}, + {"numbers": [2, 3, 4, 5, 1], "expected": [3, 4, 5, 1, 2]}, + {"numbers": [3, 4, 5, 1, 2], "expected": [4, 5, 1, 2, 3]}, + {"numbers": [4, 5, 1, 2, 3], "expected": [5, 1, 2, 3, 4]}, + {"numbers": [5, 1, 2, 3, 4], "expected": [1, 2, 3, 4, 5]} +] diff --git a/src/hackerrank/interview_preparation_kit/arrays/minimum_swaps_2.test.ts b/src/hackerrank/interview_preparation_kit/arrays/minimum_swaps_2.test.ts index 7ea33a9f..1b91aaf9 100644 --- a/src/hackerrank/interview_preparation_kit/arrays/minimum_swaps_2.test.ts +++ b/src/hackerrank/interview_preparation_kit/arrays/minimum_swaps_2.test.ts @@ -3,11 +3,7 @@ import { logger as console } from '../../../logger'; import { minimumSwaps } from './minimum_swaps_2'; -const TEST_CASES = [ - { title: 'Sample input 0', input: [4, 3, 1, 2], expected: 3 }, - { title: 'Sample input 1', input: [2, 3, 4, 1, 5], expected: 3 }, - { title: 'Sample input 2', input: [1, 3, 5, 2, 4, 6, 7], expected: 3 } -]; +import TEST_CASES from './minimum_swaps_2.testcases.json'; describe('minimum swaps 2', () => { it('minimumSwaps', () => { diff --git a/src/hackerrank/interview_preparation_kit/arrays/minimum_swaps_2.testcases.json b/src/hackerrank/interview_preparation_kit/arrays/minimum_swaps_2.testcases.json new file mode 100644 index 00000000..6a814023 --- /dev/null +++ b/src/hackerrank/interview_preparation_kit/arrays/minimum_swaps_2.testcases.json @@ -0,0 +1,5 @@ +[ + {"title": "Sample input 0", "input": [4, 3, 1, 2], "expected": 3}, + {"title": "Sample input 1", "input": [2, 3, 4, 1, 5], "expected": 3}, + {"title": "Sample input 2", "input": [1, 3, 5, 2, 4, 6, 7], "expected": 3} +] diff --git a/src/hackerrank/interview_preparation_kit/arrays/new_year_chaos.test.ts b/src/hackerrank/interview_preparation_kit/arrays/new_year_chaos.test.ts index 9974ce4a..3c708d9e 100644 --- a/src/hackerrank/interview_preparation_kit/arrays/new_year_chaos.test.ts +++ b/src/hackerrank/interview_preparation_kit/arrays/new_year_chaos.test.ts @@ -1,23 +1,9 @@ import { describe, expect, it } from '@jest/globals'; import { logger as console } from '../../../logger'; -import { minimumBribesTransform, TOO_CHAOTIC_ERROR } from './new_year_chaos'; +import { minimumBribesTransform } from './new_year_chaos'; -const TEST_CASES = [ - { title: 'Test Case 0-0', input: [2, 1, 5, 3, 4], expected: 3 }, - { - title: 'Test Case 0-1', - input: [2, 5, 1, 3, 4], - expected: TOO_CHAOTIC_ERROR - }, - { - title: 'Test Case 1-1', - input: [5, 1, 2, 3, 7, 8, 6, 4], - expected: TOO_CHAOTIC_ERROR - }, - { title: 'Test Case 1-2', input: [1, 2, 5, 3, 7, 8, 6, 4], expected: 7 }, - { title: 'Test Case 2', input: [1, 2, 5, 3, 4, 7, 8, 6], expected: 4 } -]; +import TEST_CASES from './new_year_chaos.testcases.json'; describe('new_year_chaos', () => { it('minimumBribes Test Cases', () => { diff --git a/src/hackerrank/interview_preparation_kit/arrays/new_year_chaos.testcases.json b/src/hackerrank/interview_preparation_kit/arrays/new_year_chaos.testcases.json new file mode 100644 index 00000000..5527c31e --- /dev/null +++ b/src/hackerrank/interview_preparation_kit/arrays/new_year_chaos.testcases.json @@ -0,0 +1,27 @@ +[ + { + "title": "Test Case 0-0", + "input": [2, 1, 5, 3, 4], + "expected": 3 + }, + { + "title": "Test Case 0-1", + "input": [2, 5, 1, 3, 4], + "expected": "Too chaotic" + }, + { + "title": "Test Case 1-1", + "input": [5, 1, 2, 3, 7, 8, 6, 4], + "expected": "Too chaotic" + }, + { + "title": "Test Case 1-2", + "input": [1, 2, 5, 3, 7, 8, 6, 4], + "expected": 7 + }, + { + "title": "Test Case 2", + "input": [1, 2, 5, 3, 4, 7, 8, 6], + "expected": 4 + } + ] diff --git a/src/hackerrank/interview_preparation_kit/dictionaries_and_hashmaps/count_triplets_1.big.testcases.json b/src/hackerrank/interview_preparation_kit/dictionaries_and_hashmaps/count_triplets_1.big.testcases.json new file mode 100644 index 00000000..f38639cd --- /dev/null +++ b/src/hackerrank/interview_preparation_kit/dictionaries_and_hashmaps/count_triplets_1.big.testcases.json @@ -0,0 +1,12 @@ +[ + { + "title": "Sample Test Case 2", + "input": [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], + "r": 1, + "expected": 161700 + } +] diff --git a/src/hackerrank/interview_preparation_kit/dictionaries_and_hashmaps/count_triplets_1_testcases.json b/src/hackerrank/interview_preparation_kit/dictionaries_and_hashmaps/count_triplets_1.small.testcases.json similarity index 100% rename from src/hackerrank/interview_preparation_kit/dictionaries_and_hashmaps/count_triplets_1_testcases.json rename to src/hackerrank/interview_preparation_kit/dictionaries_and_hashmaps/count_triplets_1.small.testcases.json diff --git a/src/hackerrank/interview_preparation_kit/dictionaries_and_hashmaps/count_triplets_1_bruteforce.test.ts b/src/hackerrank/interview_preparation_kit/dictionaries_and_hashmaps/count_triplets_1_bruteforce.test.ts index 54790605..2705b840 100644 --- a/src/hackerrank/interview_preparation_kit/dictionaries_and_hashmaps/count_triplets_1_bruteforce.test.ts +++ b/src/hackerrank/interview_preparation_kit/dictionaries_and_hashmaps/count_triplets_1_bruteforce.test.ts @@ -3,32 +3,7 @@ import { logger as console } from '../../../logger'; import { countTriplets } from './count_triplets_1_bruteforce'; -const SMALL_TEST_CASES = [ - { - title: 'Sample Test Case 0', - input: [1, 2, 2, 4], - r: 2, - expected: 2 - }, - { - title: 'Sample Test Case 1', - input: [1, 3, 9, 9, 27, 81], - r: 3, - expected: 6 - }, - { - title: 'Sample Test Case 1 (unsorted)', - input: [9, 3, 1, 81, 9, 27], - r: 3, - expected: 1 - }, - { - title: 'Sample Test Case 12', - input: [1, 5, 5, 25, 125], - r: 5, - expected: 4 - } -]; +import SMALL_TEST_CASES from './count_triplets_1.small.testcases.json'; describe('count_triplets_1', () => { it('countTriplets test cases', () => { diff --git a/src/hackerrank/interview_preparation_kit/dictionaries_and_hashmaps/count_triplets_1_optimized.test.ts b/src/hackerrank/interview_preparation_kit/dictionaries_and_hashmaps/count_triplets_1_optimized.test.ts index 8385adfb..ee82d24c 100644 --- a/src/hackerrank/interview_preparation_kit/dictionaries_and_hashmaps/count_triplets_1_optimized.test.ts +++ b/src/hackerrank/interview_preparation_kit/dictionaries_and_hashmaps/count_triplets_1_optimized.test.ts @@ -2,21 +2,9 @@ import { describe, expect, it } from '@jest/globals'; import { logger as console } from '../../../logger'; import { countTriplets } from './count_triplets_1_optmized'; -import SMALL_TEST_CASES from './count_triplets_1_testcases.json'; - -const BIG_TEST_CASES = [ - { - title: 'Sample Test Case 2', - input: [ - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 - ], - r: 1, - expected: 161700 - } -]; + +import SMALL_TEST_CASES from './count_triplets_1.small.testcases.json'; +import BIG_TEST_CASES from './count_triplets_1.big.testcases.json'; describe('count_triplets_1 (optimized)', () => { it('countTriplets small test cases', () => { diff --git a/src/hackerrank/interview_preparation_kit/dictionaries_and_hashmaps/ctci-ransom-note.test.ts b/src/hackerrank/interview_preparation_kit/dictionaries_and_hashmaps/ctci-ransom-note.test.ts index b09347b4..c7471252 100644 --- a/src/hackerrank/interview_preparation_kit/dictionaries_and_hashmaps/ctci-ransom-note.test.ts +++ b/src/hackerrank/interview_preparation_kit/dictionaries_and_hashmaps/ctci-ransom-note.test.ts @@ -3,26 +3,7 @@ import { logger as console } from '../../../logger'; import { checkMagazine } from './ctci-ransom-note'; -const TEST_CASES = [ - { - title: 'Sample Test Case 0', - magazine: ['give', 'me', 'one', 'grand', 'today', 'night'], - note: ['give', 'one', 'grand', 'today'], - expected: 'Yes' - }, - { - title: 'Sample Test Case 1', - magazine: ['two', 'times', 'three', 'is', 'not', 'four'], - note: ['two', 'times', 'two', 'is', 'four'], - expected: 'No' - }, - { - title: 'Sample Test', - magazine: ['two', 'two', 'times', 'three', 'is', 'not', 'four'], - note: ['two', 'times', 'two', 'is', 'four'], - expected: 'Yes' - } -]; +import TEST_CASES from './ctci-ransom-note.testcases.json'; describe('ctci_ransom_note', () => { it('checkMagazine test cases', () => { diff --git a/src/hackerrank/interview_preparation_kit/dictionaries_and_hashmaps/ctci-ransom-note.testcases.json b/src/hackerrank/interview_preparation_kit/dictionaries_and_hashmaps/ctci-ransom-note.testcases.json new file mode 100644 index 00000000..8f04948f --- /dev/null +++ b/src/hackerrank/interview_preparation_kit/dictionaries_and_hashmaps/ctci-ransom-note.testcases.json @@ -0,0 +1,20 @@ +[ + { + "title": "Sample Test Case 0", + "magazine": ["give", "me", "one", "grand", "today", "night"], + "note": ["give", "one", "grand", "today"], + "expected": "Yes" + }, + { + "title": "Sample Test Case 1", + "magazine": ["two", "times", "three", "is", "not", "four"], + "note": ["two", "times", "two", "is", "four"], + "expected": "No" + }, + { + "title": "Sample Test", + "magazine": ["two", "two", "times", "three", "is", "not", "four"], + "note": ["two", "times", "two", "is", "four"], + "expected": "Yes" + } +] diff --git a/src/hackerrank/interview_preparation_kit/dictionaries_and_hashmaps/two_strings.test.ts b/src/hackerrank/interview_preparation_kit/dictionaries_and_hashmaps/two_strings.test.ts index 5a2bc625..2a7b1447 100644 --- a/src/hackerrank/interview_preparation_kit/dictionaries_and_hashmaps/two_strings.test.ts +++ b/src/hackerrank/interview_preparation_kit/dictionaries_and_hashmaps/two_strings.test.ts @@ -3,70 +3,14 @@ import { logger as console } from '../../../logger'; import { twoStrings } from './two_strings'; -const TEST_CASES = [ - { - title: 'Example 1 and 2', - comparing: [ - { - s1: 'and', - s2: 'art', - expected: 'YES' - }, - { - s1: 'be', - s2: 'cat', - expected: 'NO' - } - ] - }, - { - title: 'Sample Test Case 0', - comparing: [ - { - s1: 'hello', - s2: 'world', - expected: 'YES' - }, - { - s1: 'hi', - s2: 'world', - expected: 'NO' - } - ] - }, - { - title: 'Sample Test Case 6', - comparing: [ - { - s1: 'wouldyoulikefries', - s2: 'abcabcabcabcabcabc', - expected: 'NO' - }, - { - s1: 'hackerrankcommunity', - s2: 'cdecdecdecde', - expected: 'YES' - }, - { - s1: 'jackandjill', - s2: 'wentupthehill', - expected: 'YES' - }, - { - s1: 'writetoyourparents', - s2: 'fghmqzldbc', - expected: 'NO' - } - ] - } -]; +import TEST_CASES from './two_strings.testcases.json'; describe('two_strings', () => { it('twoStrings test cases', () => { expect.assertions(8); TEST_CASES.forEach((testCase) => { - testCase.comparing.forEach((test) => { + testCase?.test.forEach((test) => { const answer = twoStrings(test.s1, test.s2); console.debug( diff --git a/src/hackerrank/interview_preparation_kit/dictionaries_and_hashmaps/two_strings.testcases.json b/src/hackerrank/interview_preparation_kit/dictionaries_and_hashmaps/two_strings.testcases.json new file mode 100644 index 00000000..90cd457f --- /dev/null +++ b/src/hackerrank/interview_preparation_kit/dictionaries_and_hashmaps/two_strings.testcases.json @@ -0,0 +1,57 @@ +[ + { + "title": "Example 1 and 2", + "test": [ + { + "s1": "and", + "s2": "art", + "expected": "YES" + }, + { + "s1": "be", + "s2": "cat", + "expected": "NO" + } + ] + }, + { + "title": "Sample Test Case 0", + "test": [ + { + "s1": "hello", + "s2": "world", + "expected": "YES" + }, + { + "s1": "hi", + "s2": "world", + "expected": "NO" + } + ] + }, + { + "title": "Sample Test Case 6", + "test": [ + { + "s1": "wouldyoulikefries", + "s2": "abcabcabcabcabcabc", + "expected": "NO" + }, + { + "s1": "hackerrankcommunity", + "s2": "cdecdecdecde", + "expected": "YES" + }, + { + "s1": "jackandjill", + "s2": "wentupthehill", + "expected": "YES" + }, + { + "s1": "writetoyourparents", + "s2": "fghmqzldbc", + "expected": "NO" + } + ] + } +] diff --git a/src/hackerrank/interview_preparation_kit/greedy_algorithms/luck-balance.test.ts b/src/hackerrank/interview_preparation_kit/greedy_algorithms/luck-balance.test.ts index a490af19..dc3b023b 100644 --- a/src/hackerrank/interview_preparation_kit/greedy_algorithms/luck-balance.test.ts +++ b/src/hackerrank/interview_preparation_kit/greedy_algorithms/luck-balance.test.ts @@ -3,48 +3,7 @@ import { logger as console } from '../../../logger'; import { luckBalance } from './luck-balance'; -const TEST_CASES = [ - { - title: 'Sample Test case 0', - k: 3, - contests: [ - [5, 1], - [2, 1], - [1, 1], - [8, 1], - [10, 0], - [5, 0] - ], - expected: 29 - }, - { - title: 'Sample Test case 1', - k: 5, - contests: [ - [13, 1], - [10, 1], - [9, 1], - [8, 1], - [13, 1], - [12, 1], - [18, 1], - [13, 1] - ], - expected: 42 - }, - { - title: 'Sample Test case 1', - k: 2, - contests: [ - [5, 1], - [4, 0], - [6, 1], - [2, 1], - [8, 0] - ], - expected: 21 - } -]; +import TEST_CASES from './luck-balance.testcases.json'; describe('luck-balance', () => { it('luckBalance test cases', () => { diff --git a/src/hackerrank/interview_preparation_kit/greedy_algorithms/luck-balance.testcases.json b/src/hackerrank/interview_preparation_kit/greedy_algorithms/luck-balance.testcases.json new file mode 100644 index 00000000..d0777d48 --- /dev/null +++ b/src/hackerrank/interview_preparation_kit/greedy_algorithms/luck-balance.testcases.json @@ -0,0 +1,42 @@ +[ + { + "title": "Sample Test case 0", + "k": 3, + "contests": [ + [5, 1], + [2, 1], + [1, 1], + [8, 1], + [10, 0], + [5, 0] + ], + "expected": 29 + }, + { + "title": "Sample Test case 1", + "k": 5, + "contests": [ + [13, 1], + [10, 1], + [9, 1], + [8, 1], + [13, 1], + [12, 1], + [18, 1], + [13, 1] + ], + "expected": 42 + }, + { + "title": "Sample Test case 1", + "k": 2, + "contests": [ + [5, 1], + [4, 0], + [6, 1], + [2, 1], + [8, 0] + ], + "expected": 21 + } +] diff --git a/src/hackerrank/interview_preparation_kit/miscellaneous/flipping-bits.test.ts b/src/hackerrank/interview_preparation_kit/miscellaneous/flipping-bits.test.ts index c496ba34..b9d3b57c 100644 --- a/src/hackerrank/interview_preparation_kit/miscellaneous/flipping-bits.test.ts +++ b/src/hackerrank/interview_preparation_kit/miscellaneous/flipping-bits.test.ts @@ -3,55 +3,7 @@ import { logger as console } from '../../../logger'; import { flippingBits } from './flipping-bits'; -const TEST_CASES = [ - { - title: 'Sample Test Case 0', - tests: [ - { - input: 2147483647, - expected: 2147483648 - }, - { - input: 1, - expected: 4294967294 - }, - { - input: 0, - expected: 4294967295 - } - ] - }, - { - title: 'Sample Test Case 1', - tests: [ - { - input: 4, - expected: 4294967291 - }, - { - input: 123456, - expected: 4294843839 - } - ] - }, - { - title: 'Sample Test Case 2', - tests: [ - { - input: 0, - expected: 4294967295 - }, - { - input: 802743475, - expected: 3492223820 - }, - { - input: 35601423, - expected: 4259365872 - } - ] - } -]; +import TEST_CASES from './flipping-bits.testcases.json'; describe('flipping bits', () => { it('flipping bits test cases', () => { diff --git a/src/hackerrank/interview_preparation_kit/miscellaneous/flipping-bits.testcases.json b/src/hackerrank/interview_preparation_kit/miscellaneous/flipping-bits.testcases.json new file mode 100644 index 00000000..86e90789 --- /dev/null +++ b/src/hackerrank/interview_preparation_kit/miscellaneous/flipping-bits.testcases.json @@ -0,0 +1,54 @@ +[ + { + "title": "Sample Test Case 0", + "tests": + [ + { + "input": 2147483647, + "expected": 2147483648 + }, + { + "input": 1, + "expected": 4294967294 + }, + { + "input": 0, + "expected": 4294967295 + } + ] + }, + { + "title": "Sample Test Case 1", + "tests": + [ + + { + "input": 4, + "expected": 4294967291 + }, + { + "input": 123456, + "expected": 4294843839 + } + ] + }, + { + "title": "Sample Test Case 2", + "tests": + [ + + { + "input": 0, + "expected": 4294967295 + }, + { + "input": 802743475, + "expected": 3492223820 + }, + { + "input": 35601423, + "expected": 4259365872 + } + ] + } +]