Skip to content

Commit 374ac3a

Browse files
SleeplessBytetejasbubane
authored andcommitted
Add exercise: resistor-color (#648)
And replace it in place of leap as core
1 parent 67906e5 commit 374ac3a

File tree

7 files changed

+172
-8
lines changed

7 files changed

+172
-8
lines changed

config.json

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,14 @@
1919
]
2020
},
2121
{
22-
"slug": "leap",
23-
"uuid": "7c8294ee-5924-4bf8-a72f-31d0e2d7d9a0",
22+
"slug": "resistor-color",
23+
"uuid": "53be6837-c224-45f1-bff3-d7f74d6285ce",
2424
"core": true,
2525
"unlocked_by": null,
2626
"difficulty": 1,
2727
"topics": [
28-
"booleans",
29-
"integers",
30-
"logic"
28+
"arrays",
29+
"strings"
3130
]
3231
},
3332
{
@@ -238,11 +237,23 @@
238237
"text_formatting"
239238
]
240239
},
240+
{
241+
"slug": "leap",
242+
"uuid": "7c8294ee-5924-4bf8-a72f-31d0e2d7d9a0",
243+
"core": false,
244+
"unlocked_by": "resistor-color",
245+
"difficulty": 1,
246+
"topics": [
247+
"booleans",
248+
"integers",
249+
"logic"
250+
]
251+
},
241252
{
242253
"slug": "reverse-string",
243254
"uuid": "e84c97eb-dbec-487c-b99f-ae9924e16293",
244255
"core": false,
245-
"unlocked_by": "leap",
256+
"unlocked_by": "resistor-color",
246257
"difficulty": 2,
247258
"topics": [
248259
"for",
@@ -254,7 +265,7 @@
254265
"slug": "triangle",
255266
"uuid": "ed3ca73a-a0f0-46b8-8013-8b6d20758c8f",
256267
"core": false,
257-
"unlocked_by": "leap",
268+
"unlocked_by": "resistor-color",
258269
"difficulty": 3,
259270
"topics": [
260271
"control_flow_conditionals",
@@ -267,7 +278,7 @@
267278
"slug": "collatz-conjecture",
268279
"uuid": "b8dacb3a-51d0-4da7-a6d2-aa29867e2b8c",
269280
"core": false,
270-
"unlocked_by": "leap",
281+
"unlocked_by": "resistor-color",
271282
"difficulty": 3,
272283
"topics": [
273284
"control_flow_conditionals",

exercises/resistor-color/.eslintrc

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"root": true,
3+
"parser": "babel-eslint",
4+
"parserOptions": {
5+
"ecmaVersion": 7,
6+
"sourceType": "module"
7+
},
8+
"env": {
9+
"es6": true,
10+
"node": true,
11+
"jest": true
12+
},
13+
"extends": [
14+
"eslint:recommended",
15+
"plugin:import/errors",
16+
"plugin:import/warnings"
17+
],
18+
"rules": {
19+
"linebreak-style": "off",
20+
21+
"import/extensions": "off",
22+
"import/no-default-export": "off",
23+
"import/no-unresolved": "off",
24+
"import/prefer-default-export": "off"
25+
}
26+
}

exercises/resistor-color/README.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Resistor Color
2+
3+
Resistors have color coded bands, where each color maps to a number. The first 2 bands of a resistor have a simple encoding scheme: each color maps to a single number.
4+
5+
These colors are encoded as follows:
6+
7+
- Black: 0
8+
- Brown: 1
9+
- Red: 2
10+
- Orange: 3
11+
- Yellow: 4
12+
- Green: 5
13+
- Blue: 6
14+
- Violet: 7
15+
- Grey: 8
16+
- White: 9
17+
18+
Mnemonics map the colors to the numbers, that, when stored as an array, happen to map to their index in the array: Better Be Right Or Your Great Big Values Go Wrong.
19+
20+
More information on the color encoding of resistors can be found in the [Electronic color code Wikipedia article](https://en.wikipedia.org/wiki/Electronic_color_code)
21+
22+
## Setup
23+
24+
Go through the setup instructions for Javascript to
25+
install the necessary dependencies:
26+
27+
[https://exercism.io/tracks/javascript/installation](https://exercism.io/tracks/javascript/installation)
28+
29+
## Requirements
30+
31+
Install assignment dependencies:
32+
33+
```bash
34+
$ npm install
35+
```
36+
37+
## Making the test suite pass
38+
39+
Execute the tests with:
40+
41+
```bash
42+
$ npm test
43+
```
44+
45+
In the test suites all tests but the first have been skipped.
46+
47+
Once you get a test passing, you can enable the next one by
48+
changing `xtest` to `test`.
49+
50+
## Submitting Incomplete Solutions
51+
52+
It's possible to submit an incomplete solution so you can see how others have completed the exercise.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
module.exports = {
2+
presets: [
3+
[
4+
'@babel/env',
5+
{
6+
targets: {
7+
node: 'current',
8+
},
9+
useBuiltIns: false,
10+
},
11+
12+
],
13+
],
14+
};
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
export const COLORS = [
2+
'black', 'brown', 'red', 'orange', 'yellow', 'green',
3+
'blue', 'violet', 'grey', 'white',
4+
];
5+
6+
export const colorCode = color => COLORS.indexOf(color)
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"name": "exercism-javascript",
3+
"version": "0.0.0",
4+
"description": "Exercism exercises in Javascript.",
5+
"author": "Katrina Owen",
6+
"private": true,
7+
"repository": {
8+
"type": "git",
9+
"url": "https://github.com/exercism/javascript"
10+
},
11+
"devDependencies": {
12+
"@babel/cli": "^7.2.3",
13+
"@babel/core": "^7.4.0",
14+
"@babel/preset-env": "^7.4.2",
15+
"babel-eslint": "^10.0.1",
16+
"babel-jest": "^24.5.0",
17+
"eslint": "^5.15.3",
18+
"eslint-plugin-import": "^2.16.0",
19+
"jest": "^24.5.0"
20+
},
21+
"jest": {
22+
"modulePathIgnorePatterns": [
23+
"package.json"
24+
]
25+
},
26+
"scripts": {
27+
"test": "jest --no-cache ./*",
28+
"watch": "jest --no-cache --watch ./*",
29+
"lint": "eslint .",
30+
"lint-test": "eslint . && jest --no-cache ./* "
31+
},
32+
"license": "MIT",
33+
"dependencies": {}
34+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { colorCode, COLORS } from './resistor-color'
2+
3+
describe('ResistorColor', () => {
4+
describe('Color codes', () => {
5+
test('Black', () => {
6+
expect(colorCode("black")).toEqual(0)
7+
})
8+
9+
xtest('White', () => {
10+
expect(colorCode("white")).toEqual(9)
11+
})
12+
13+
xtest('Orange', () => {
14+
expect(colorCode("orange")).toEqual(3)
15+
})
16+
})
17+
18+
xtest('Colors', () => {
19+
expect(COLORS).toEqual(["black","brown","red","orange","yellow","green","blue","violet","grey","white"])
20+
})
21+
})

0 commit comments

Comments
 (0)