Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit f63a556

Browse files
author
programmiri
committed
Add exercise resistor-color-duo
1 parent f918b0d commit f63a556

File tree

6 files changed

+4353
-0
lines changed

6 files changed

+4353
-0
lines changed

‎resistor-color-duo/.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+
}

‎resistor-color-duo/README.md‎

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# Resistor Color Duo
2+
3+
If you want to build something using a Raspberry Pi, you'll probably use _resistors_. For this exercise, you need to know two things about them:
4+
5+
* Each resistor has a resistance value.
6+
* Resistors are small - so small in fact that if you printed the resistance value on them, it would be hard to read.
7+
To get around this problem, manufacturers print color-coded bands onto the resistors to denote their resistance values. Each band acts as a digit of a number. For example, if they printed a brown band (value 1) followed by a green band (value 5), it would translate to the number 15.
8+
9+
In this exercise, you are going to create a helpful program so that you don't have to remember the values of the bands. The program will take two colors as input, and output the correct number.
10+
11+
The band colors are encoded as follows:
12+
13+
- Black: 0
14+
- Brown: 1
15+
- Red: 2
16+
- Orange: 3
17+
- Yellow: 4
18+
- Green: 5
19+
- Blue: 6
20+
- Violet: 7
21+
- Grey: 8
22+
- White: 9
23+
24+
## Setup
25+
26+
Go through the setup instructions for Javascript to install the necessary
27+
dependencies:
28+
29+
[https://exercism.io/tracks/javascript/installation](https://exercism.io/tracks/javascript/installation)
30+
31+
## Requirements
32+
33+
Install assignment dependencies:
34+
35+
```bash
36+
$ npm install
37+
```
38+
39+
## Making the test suite pass
40+
41+
Execute the tests with:
42+
43+
```bash
44+
$ npm test
45+
```
46+
47+
In the test suites all tests but the first have been skipped.
48+
49+
Once you get a test passing, you can enable the next one by changing `xtest` to
50+
`test`.
51+
52+
## Source
53+
54+
Maud de Vries, Erik Schierboom [https://github.com/exercism/problem-specifications/issues/1464](https://github.com/exercism/problem-specifications/issues/1464)
55+
56+
## Submitting Incomplete Solutions
57+
58+
It's possible to submit an incomplete solution so you can see how others have
59+
completed the exercise.

‎resistor-color-duo/babel.config.js‎

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+
};

‎resistor-color-duo/package.json‎

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: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { value } from './resistor-color-duo.js';
2+
3+
describe('Resistor Colors', () => {
4+
test('Brown and black', () => {
5+
expect(value(['brown', 'black'])).toEqual(10);
6+
});
7+
8+
xtest('Blue and grey', () => {
9+
expect(value(['blue', 'grey'])).toEqual(68);
10+
});
11+
12+
xtest('Yellow and violet', () => {
13+
expect(value(['yellow', 'violet'])).toEqual(47);
14+
});
15+
16+
xtest('Orange and orange', () => {
17+
expect(value(['orange', 'orange'])).toEqual(33);
18+
});
19+
});

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /