Skip to content

Commit 639e77b

Browse files
authored
Merge pull request #2 from bbgrabbag/interview-prep
Interview prep
2 parents 82850c7 + 979e3e7 commit 639e77b

14 files changed

+257
-54
lines changed

README.md

Lines changed: 30 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,41 @@
1-
# V School Code Talk Challenges
1+
# V School Code Challenges
22

33
### About
4-
- A playground Node.js environment for testing and debugging pure, single functions.
4+
- A playground Node.js environment for testing and debugging pure functions.
55
- Useful for running local debugger and creating custom test cases for code puzzles from Edabit, Code Wars, etc.
66

77
### Getting Started
88
- `npm install`
9-
- `npm run test`
9+
- `npm run test` (See [Testing Single Challenges](#testing-single-challenges) for further configuration)
1010
- In VS Code, you can run the debugger using the Jest configuration called `Unit Test` listed in `.vscode/launch.json` file. Hotkey is F5. This will automatically read the `jest.config.js` file
11-
- Run `git checkout interview-prep` to try your hand at an existing set of challenges.
1211
- If you get stuck, solutions can be found by running `git checkout solutions`
1312

13+
### Testing Single Challenges
14+
- To run tests for all cases defined for a given challenge, set the property `globals.testSingleChallenge` within `jest.config.js` to the name of the file you wish to test as defined in `/challenges` (omit the `.js` extension). For example:
15+
```js
16+
// jest.config.js
17+
module.exports = {
18+
globals: {
19+
testSingleChallenge: "add_func"
20+
},
21+
//...
22+
}
23+
```
24+
- If no value for `globals.testSingleChallenge` is provided, all tests will run for all challenges by default.
25+
26+
### Testing Single Test Cases
27+
- To run a test on a single test case for a given challenge, set the property `globals.testSingleTestCase` within `jest.config.js` to the index of the test case you wish to try. The property `globals.testSingleChallenge` must also be defined. For example:
28+
```js
29+
// jest.config.js
30+
module.exports = {
31+
globals: {
32+
testSingleChallenge: "add_func",
33+
testSingleTestCase: 0
34+
},
35+
// ...
36+
}
37+
```
38+
1439
### Creating Custom Challenges
1540
- Within `/challenges` directory, create a file which contains a default export of the function you wish to test. For example:
1641
```js
@@ -37,37 +62,10 @@ module.exports = {
3762
}
3863
```
3964

40-
### Testing Single Challenges
41-
- To run tests for all cases defined for a given challenge, set the property `globals.testSingleChallenge` within `jest.config.js` to the name of the file you wish to test as defined in `/challenges` (omit the `.js` extension). For example:
42-
```js
43-
// jest.config.js
44-
module.exports = {
45-
globals: {
46-
testSingleChallenge: "add_func"
47-
},
48-
//...
49-
}
50-
```
51-
52-
### Testing Single Test Cases
53-
- To run a test on a single test case for a given challenge, set the property `globals.testSingleTestCase` within `jest.config.js` to the index of the test case you wish to try. The property `globals.testSingleChallenge` must also be defined. For example:
54-
```js
55-
// jest.config.js
56-
module.exports = {
57-
globals: {
58-
testSingleChallenge: "add_func",
59-
testSingleTestCase: 0
60-
},
61-
// ...
62-
}
63-
```
64-
6565
### Custom Tests
6666
- The default workflow in `main.test.js` may not work for some scenarios, so custom tests can be added to `custom.test.js`.
6767
- By default custom tests are switched off. To enable them, set the property `globals.skipCustomTests` within `jest.config.js` to `false`.
6868
- To run only custom tests, set the property `globals.runCustomTestsOnly` within `jest.config.js` to `true`. This will override the other settings.
6969

7070
### Author
71-
- Reach out to [Ben Turner](bbgrabbag@gmail.com) for any questions, bugs, or contribution requests.
72-
73-
### [Changelog](./changelog.md)
71+
- Reach out to [Ben Turner](bbgrabbag@gmail.com) for any questions, bugs, or contribution requests.

challenges/build_grid.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/**
2+
* @description - create a n X n array matrix containing a given character at each slot
3+
* @difficulty - 2/5
4+
*
5+
* @param {Number} n - integer > 0
6+
* @param {String} char
7+
* @returns {Array<String[]>} - 2d array matrix
8+
*
9+
* @example - buildGrid(1, 'x') // --> [['x']]
10+
* @example - buildGrid(3,'x') // --> [['x', 'x', 'x'],['x', 'x', 'x'], ['x', 'x', 'x']]
11+
*/
12+
13+
const buildGrid = (n, char) => {
14+
15+
}
16+
17+
module.exports = buildGrid;

challenges/char_count.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/**
2+
* @description - calculate the number of times a given character appears in a given string
3+
* @difficulty - 2/5
4+
*
5+
* @param {String} str
6+
* @param {String} char
7+
* @returns {Number}
8+
*
9+
* @example - charCount('abc', 'z') // --> 0
10+
* @example - charCount('aaaa', 'a') // --> 4
11+
*/
12+
13+
const charCount = (str, char) => {
14+
15+
}
16+
17+
module.exports = charCount;

challenges/check_for_numbers.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/**
2+
* @description - determine whether the array contains numbers
3+
* @difficulty - 1/5
4+
*
5+
* @param {Array} - array of values
6+
* @returns {Boolean}
7+
*
8+
* @example - checkForNumbers(['a','b', 2, {}]) // --> true
9+
* @example - checkForNumbers(['a','b','c', {}]) // --> false (array contains no numbers)
10+
*/
11+
12+
const checkForNumbers = (arr) => {
13+
14+
}
15+
16+
module.exports = checkForNumbers;

challenges/example.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

challenges/remove_chars.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/**
2+
* @description - remove all instances of given character from a string
3+
* @difficulty - 3/5
4+
*
5+
* @param {String} str
6+
* @param {String} char
7+
* @returns {String}
8+
*
9+
* @example - removeChar('abc', 'a') // --> 'bc'
10+
* @example - removeChar('aaaa', 'a') // --> ''
11+
*/
12+
13+
const removeChar = (str, char) => {
14+
15+
}
16+
17+
module.exports = removeChar;

challenges/shared_chars.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/**
2+
* @description - Given an array of strings, produce a single string that contains only the shared characters between all of them. Characters in output should be alphabetized
3+
* @constraints - Each string in the input array is equal length. Input array length is always >= 0. Input strings contain only lowercase alphabet letters [a-z].
4+
* @difficulty - 3/5
5+
*
6+
* @param {Array<String>} arr
7+
* @returns {String}
8+
*
9+
* @example - sharedChars(['abc','bcd','cde']) // --> 'c'
10+
* @example - sharedChars(['aaa','bbb','ccc']) // --> ''
11+
* @example - sharedChars(['xxx','xxx','xxx']) // --> 'x'
12+
* @example - sharedChars([]) // --> ''
13+
14+
*/
15+
16+
const sharedChars = (arr) => {
17+
18+
}
19+
20+
module.exports = sharedChars;

challenges/smallest_integer.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/**
2+
* @description - Return the smallest integer from an array
3+
* @constraints - Input array length is >= 1
4+
* @difficulty - 1/5
5+
*
6+
* @param {Array<Number>} arr
7+
* @returns {Number}
8+
*
9+
* @example - smallestInt([10, 9, 8, 0, 1, 2, 3]) // --> 0
10+
* @example - smallestInt([10]) // --> 10
11+
* @example - smallestInt([5, 4, 3, -2, -3, -4]) // --> -4
12+
13+
*/
14+
15+
const smallestInt = (arr) => {
16+
17+
}
18+
19+
module.exports = smallestInt;

challenges/valid_brackets.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/**
2+
* @description - determine whether given string has valid placement of brackets
3+
* @difficulty - 4/5
4+
*
5+
* @param {String} str
6+
* @returns {Boolean}
7+
*
8+
* @example - validBrackets('[[[') // --> false
9+
* @example - validBrackets('[]') // --> true
10+
* @example - validBrackets('[[][]][]') // --> true
11+
*/
12+
13+
const validBrackets = (str) => {
14+
15+
}
16+
17+
module.exports = validBrackets;

challenges/validate_dependency.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/**
2+
* @description - determine whether the list of tuples creates a valid dependency tree (no circular deps)
3+
* @difficulty - 5/5
4+
* s
5+
* @param {Array<[String, String]>} - array of tuples representing a dependency between two things represented as strings (i.e. ['A', 'B'] where B depends on A)
6+
* @returns {Boolean}
7+
*
8+
* @example - validateDependencies([['A','B'], ['B','C']]) // --> true
9+
* @example - validateDependencies([['A','B'], ['B','A']]) // --> false (B depends on A, which already depends on B, this is circular)
10+
*/
11+
12+
const validateDependencies = (deps) => {
13+
14+
}
15+
16+
module.exports = validateDependencies;

0 commit comments

Comments
 (0)