Skip to content

Commit

Permalink
new exercise: resistor-color-duo
Browse files Browse the repository at this point in the history
  • Loading branch information
msomji committed Nov 29, 2019
1 parent 6664f18 commit a6292a9
Show file tree
Hide file tree
Showing 12 changed files with 10,575 additions and 0 deletions.
11 changes: 11 additions & 0 deletions config.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,17 @@
"text_formatting"
]
},
{
"slug": "resistor-color-duo",
"uuid": "78645d36-12be-11ea-8d71-362b9e155667",
"core": true,
"unlocked_by": null,
"difficulty": 2,
"topics": [
"strings",
"arrays"
]
},
{
"slug": "leap",
"uuid": "fb80f76c-42da-4f62-9f0f-8c85d984908b",
Expand Down
8 changes: 8 additions & 0 deletions exercises/resistor-color-duo/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
bin/*
dist/*
docs/*
node_modules/*
production_node_modules/*
test/fixtures/*
tmp/*
jest.config.js
64 changes: 64 additions & 0 deletions exercises/resistor-color-duo/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
{
"root": true,
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": "./tsconfig.json",
"ecmaFeatures": {
"jsx": true
},
"ecmaVersion": 2018,
"sourceType": "module"
},
"env": {
"browser": true,
"es6": true
},
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
],
"globals": {
"Atomics": "readonly",
"SharedArrayBuffer": "readonly"
},
"plugins": [
"@typescript-eslint"
],
"rules": {
"@typescript-eslint/array-type": "off", // Styling not forced upon the student
"@typescript-eslint/explicit-function-return-type": [
"warn", {
"allowExpressions": false,
"allowTypedFunctionExpressions": true,
"allowHigherOrderFunctions": true
}
], // Prevent bugs
"@typescript-eslint/explicit-member-accessibility": "off", // Styling not forced upon the student
"@typescript-eslint/indent": "off", // Styling not forced upon the student
"@typescript-eslint/no-inferrable-types": [
"error", {
"ignoreParameters": true
}
],
"@typescript-eslint/member-delimiter-style": "off", // Styling not forced upon the student
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/no-parameter-properties": [
"warn", {
"allows": [
"private", "protected", "public",
"private readonly", "protected readonly", "public readonly"
]
}
], // only disallow readonly without an access modifier
"@typescript-eslint/no-unused-vars": "off", // Covered by the tsc compiler (noUnusedLocals)
"@typescript-eslint/no-use-before-define": [
"error", {
"functions": false,
"typedefs": false
}
], // Prevent bugs, not styling
"semi": "off", // Always disable base-rule
"@typescript-eslint/semi": "off" // Styling not forced upon student
}
}
53 changes: 53 additions & 0 deletions exercises/resistor-color-duo/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Resistor Color Duo

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:

* Each resistor has a resistance value.
* Resistors are small - so small in fact that if you printed the resistance value on them, it would be hard to read.

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.

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!

The colors are mapped to the numbers from 0 to 9 in the sequence:
Black - Brown - Red - Orange - Yellow - Green - Blue - Violet - Grey - White

From the example above:
brown-green should return 15
brown-green-violet should return 15 too, ignoring the third color.

## Setup

Go through the setup instructions for Javascript to
install the necessary dependencies:

[https://exercism.io/tracks/javascript/installation](https://exercism.io/tracks/javascript/installation)

## Requirements

Install assignment dependencies:

```bash
$ npm install
```

## Making the test suite pass

Execute the tests with:

```bash
$ npm test
```

In the test suites all tests but the first have been skipped.

Once you get a test passing, you can enable the next one by
changing `xtest` to `test`.

## Source

Maud de Vries, Erik Schierboom [https://github.com/exercism/problem-specifications/issues/1464](https://github.com/exercism/problem-specifications/issues/1464)

## Submitting Incomplete Solutions

It's possible to submit an incomplete solution so you can see how others have completed the exercise.
21 changes: 21 additions & 0 deletions exercises/resistor-color-duo/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
module.exports = {
verbose: true,
projects: [
'<rootDir>'
],
testMatch: [
"**/__tests__/**/*.[jt]s?(x)",
"**/test/**/*.[jt]s?(x)",
"**/?(*.)+(spec|test).[jt]s?(x)"
],
testPathIgnorePatterns: [
'/(?:production_)?node_modules/',
'.d.ts$',
'<rootDir>/test/fixtures',
'<rootDir>/test/helpers',
'__mocks__'
],
transform: {
'^.+\\.[jt]sx?$': 'ts-jest',
},
};
Loading

0 comments on commit a6292a9

Please sign in to comment.