Skip to content

Commit a6292a9

Browse files
committed
new exercise: resistor-color-duo
1 parent 6664f18 commit a6292a9

12 files changed

+10575
-0
lines changed

Diff for: config.json

+11
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,17 @@
2929
"text_formatting"
3030
]
3131
},
32+
{
33+
"slug": "resistor-color-duo",
34+
"uuid": "78645d36-12be-11ea-8d71-362b9e155667",
35+
"core": true,
36+
"unlocked_by": null,
37+
"difficulty": 2,
38+
"topics": [
39+
"strings",
40+
"arrays"
41+
]
42+
},
3243
{
3344
"slug": "leap",
3445
"uuid": "fb80f76c-42da-4f62-9f0f-8c85d984908b",

Diff for: exercises/resistor-color-duo/.eslintignore

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
bin/*
2+
dist/*
3+
docs/*
4+
node_modules/*
5+
production_node_modules/*
6+
test/fixtures/*
7+
tmp/*
8+
jest.config.js

Diff for: exercises/resistor-color-duo/.eslintrc

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
{
2+
"root": true,
3+
"parser": "@typescript-eslint/parser",
4+
"parserOptions": {
5+
"project": "./tsconfig.json",
6+
"ecmaFeatures": {
7+
"jsx": true
8+
},
9+
"ecmaVersion": 2018,
10+
"sourceType": "module"
11+
},
12+
"env": {
13+
"browser": true,
14+
"es6": true
15+
},
16+
"extends": [
17+
"eslint:recommended",
18+
"plugin:@typescript-eslint/eslint-recommended",
19+
"plugin:@typescript-eslint/recommended",
20+
],
21+
"globals": {
22+
"Atomics": "readonly",
23+
"SharedArrayBuffer": "readonly"
24+
},
25+
"plugins": [
26+
"@typescript-eslint"
27+
],
28+
"rules": {
29+
"@typescript-eslint/array-type": "off", // Styling not forced upon the student
30+
"@typescript-eslint/explicit-function-return-type": [
31+
"warn", {
32+
"allowExpressions": false,
33+
"allowTypedFunctionExpressions": true,
34+
"allowHigherOrderFunctions": true
35+
}
36+
], // Prevent bugs
37+
"@typescript-eslint/explicit-member-accessibility": "off", // Styling not forced upon the student
38+
"@typescript-eslint/indent": "off", // Styling not forced upon the student
39+
"@typescript-eslint/no-inferrable-types": [
40+
"error", {
41+
"ignoreParameters": true
42+
}
43+
],
44+
"@typescript-eslint/member-delimiter-style": "off", // Styling not forced upon the student
45+
"@typescript-eslint/no-non-null-assertion": "off",
46+
"@typescript-eslint/no-parameter-properties": [
47+
"warn", {
48+
"allows": [
49+
"private", "protected", "public",
50+
"private readonly", "protected readonly", "public readonly"
51+
]
52+
}
53+
], // only disallow readonly without an access modifier
54+
"@typescript-eslint/no-unused-vars": "off", // Covered by the tsc compiler (noUnusedLocals)
55+
"@typescript-eslint/no-use-before-define": [
56+
"error", {
57+
"functions": false,
58+
"typedefs": false
59+
}
60+
], // Prevent bugs, not styling
61+
"semi": "off", // Always disable base-rule
62+
"@typescript-eslint/semi": "off" // Styling not forced upon student
63+
}
64+
}

Diff for: exercises/resistor-color-duo/README.md

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
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+
8+
To get around this problem, manufacturers print color-coded bands onto the resistors to denote their resistance values. Each band has a position and a numeric value. For example, if they printed a brown band (value 1) followed by a green band (value 5), it would translate to the number 15.
9+
10+
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 color names as input and output a two digit number, even if the input is more than two colors!
11+
12+
The colors are mapped to the numbers from 0 to 9 in the sequence:
13+
Black - Brown - Red - Orange - Yellow - Green - Blue - Violet - Grey - White
14+
15+
From the example above:
16+
brown-green should return 15
17+
brown-green-violet should return 15 too, ignoring the third color.
18+
19+
## Setup
20+
21+
Go through the setup instructions for Javascript to
22+
install the necessary dependencies:
23+
24+
[https://exercism.io/tracks/javascript/installation](https://exercism.io/tracks/javascript/installation)
25+
26+
## Requirements
27+
28+
Install assignment dependencies:
29+
30+
```bash
31+
$ npm install
32+
```
33+
34+
## Making the test suite pass
35+
36+
Execute the tests with:
37+
38+
```bash
39+
$ npm test
40+
```
41+
42+
In the test suites all tests but the first have been skipped.
43+
44+
Once you get a test passing, you can enable the next one by
45+
changing `xtest` to `test`.
46+
47+
## Source
48+
49+
Maud de Vries, Erik Schierboom [https://github.com/exercism/problem-specifications/issues/1464](https://github.com/exercism/problem-specifications/issues/1464)
50+
51+
## Submitting Incomplete Solutions
52+
53+
It's possible to submit an incomplete solution so you can see how others have completed the exercise.

Diff for: exercises/resistor-color-duo/jest.config.js

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
module.exports = {
2+
verbose: true,
3+
projects: [
4+
'<rootDir>'
5+
],
6+
testMatch: [
7+
"**/__tests__/**/*.[jt]s?(x)",
8+
"**/test/**/*.[jt]s?(x)",
9+
"**/?(*.)+(spec|test).[jt]s?(x)"
10+
],
11+
testPathIgnorePatterns: [
12+
'/(?:production_)?node_modules/',
13+
'.d.ts$',
14+
'<rootDir>/test/fixtures',
15+
'<rootDir>/test/helpers',
16+
'__mocks__'
17+
],
18+
transform: {
19+
'^.+\\.[jt]sx?$': 'ts-jest',
20+
},
21+
};

0 commit comments

Comments
 (0)