Skip to content

Commit

Permalink
Add resistor-color-duo exercise
Browse files Browse the repository at this point in the history
  • Loading branch information
BNAndras committed Apr 21, 2024
1 parent 9293864 commit 17c1f67
Show file tree
Hide file tree
Showing 7 changed files with 282 additions and 34 deletions.
152 changes: 118 additions & 34 deletions config.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,20 @@
"average_run_time": 2
},
"files": {
"solution": ["%{kebab_slug}.el"],
"test": ["%{kebab_slug}-test.el"],
"example": ["example.el"],
"exemplar": [".meta/exemplar.el"]
"solution": [
"%{kebab_slug}.el"
],
"test": [
"%{kebab_slug}-test.el"
],
"example": [
"example.el"
],
"exemplar": [
".meta/exemplar.el"
]
},
"exercises": {
"concept": [],
"practice": [
{
"slug": "hello-world",
Expand All @@ -34,7 +41,9 @@
"practices": [],
"prerequisites": [],
"difficulty": 1,
"topics": ["strings"]
"topics": [
"strings"
]
},
{
"slug": "two-fer",
Expand All @@ -43,7 +52,9 @@
"practices": [],
"prerequisites": [],
"difficulty": 1,
"topics": ["strings"]
"topics": [
"strings"
]
},
{
"slug": "leap",
Expand All @@ -52,7 +63,12 @@
"practices": [],
"prerequisites": [],
"difficulty": 1,
"topics": ["control_flow_conditionals", "equality", "integers", "logic"]
"topics": [
"control_flow_conditionals",
"equality",
"integers",
"logic"
]
},
{
"slug": "anagram",
Expand All @@ -61,7 +77,19 @@
"practices": [],
"prerequisites": [],
"difficulty": 2,
"topics": ["equality", "filtering", "strings"]
"topics": [
"equality",
"filtering",
"strings"
]
},
{
"slug": "resistor-color-duo",
"name": "Resistor Color Duo",
"uuid": "1c55189e-2c58-48b4-92f1-9a05a9b9c6d6",
"practices": [],
"prerequisites": [],
"difficulty": 2
},
{
"slug": "roman-numerals",
Expand Down Expand Up @@ -100,7 +128,11 @@
"practices": [],
"prerequisites": [],
"difficulty": 1,
"topics": ["control_flow_conditionals", "strings", "transforming"]
"topics": [
"control_flow_conditionals",
"strings",
"transforming"
]
},
{
"slug": "bob",
Expand All @@ -109,7 +141,11 @@
"practices": [],
"prerequisites": [],
"difficulty": 1,
"topics": ["control_flow_conditionals", "parsing", "strings"]
"topics": [
"control_flow_conditionals",
"parsing",
"strings"
]
},
{
"slug": "word-count",
Expand All @@ -132,7 +168,10 @@
"practices": [],
"prerequisites": [],
"difficulty": 1,
"topics": ["strings", "transforming"]
"topics": [
"strings",
"transforming"
]
},
{
"slug": "allergies",
Expand All @@ -155,7 +194,9 @@
"practices": [],
"prerequisites": [],
"difficulty": 1,
"topics": ["math"]
"topics": [
"math"
]
},
{
"slug": "binary",
Expand All @@ -164,7 +205,6 @@
"practices": [],
"prerequisites": [],
"difficulty": 1,
"topics": null,
"status": "deprecated"
},
{
Expand Down Expand Up @@ -202,7 +242,11 @@
"practices": [],
"prerequisites": [],
"difficulty": 1,
"topics": ["control_flow_loops", "maps", "transforming"]
"topics": [
"control_flow_loops",
"maps",
"transforming"
]
},
{
"slug": "gigasecond",
Expand All @@ -211,7 +255,13 @@
"practices": [],
"prerequisites": [],
"difficulty": 1,
"topics": ["date", "integers", "time", "transforming", "variables"]
"topics": [
"date",
"integers",
"time",
"transforming",
"variables"
]
},
{
"slug": "grains",
Expand All @@ -220,7 +270,10 @@
"practices": [],
"prerequisites": [],
"difficulty": 1,
"topics": ["integers", "variables"]
"topics": [
"integers",
"variables"
]
},
{
"slug": "nucleotide-count",
Expand All @@ -229,7 +282,12 @@
"practices": [],
"prerequisites": [],
"difficulty": 1,
"topics": ["control_flow_loops", "maps", "sorting", "strings"]
"topics": [
"control_flow_loops",
"maps",
"sorting",
"strings"
]
},
{
"slug": "pangram",
Expand All @@ -238,7 +296,10 @@
"practices": [],
"prerequisites": [],
"difficulty": 1,
"topics": ["control_flow_loops", "strings"]
"topics": [
"control_flow_loops",
"strings"
]
},
{
"slug": "perfect-numbers",
Expand All @@ -247,7 +308,10 @@
"practices": [],
"prerequisites": [],
"difficulty": 1,
"topics": ["math", "number_theory"]
"topics": [
"math",
"number_theory"
]
},
{
"slug": "raindrops",
Expand All @@ -256,7 +320,11 @@
"practices": [],
"prerequisites": [],
"difficulty": 1,
"topics": ["control_flow_conditionals", "filtering", "integers"]
"topics": [
"control_flow_conditionals",
"filtering",
"integers"
]
},
{
"slug": "trinary",
Expand All @@ -265,7 +333,9 @@
"practices": [],
"prerequisites": [],
"difficulty": 1,
"topics": ["math"]
"topics": [
"math"
]
},
{
"slug": "atbash-cipher",
Expand All @@ -288,7 +358,11 @@
"practices": [],
"prerequisites": [],
"difficulty": 2,
"topics": ["cryptograpy", "strings", "transforming"]
"topics": [
"cryptograpy",
"strings",
"transforming"
]
},
{
"slug": "phone-number",
Expand All @@ -297,7 +371,11 @@
"practices": [],
"prerequisites": [],
"difficulty": 2,
"topics": ["interfaces", "parsing", "strings"]
"topics": [
"interfaces",
"parsing",
"strings"
]
},
{
"slug": "robot-name",
Expand All @@ -306,16 +384,19 @@
"practices": [],
"prerequisites": [],
"difficulty": 2,
"topics": ["randomness", "strings", "variables"]
"topics": [
"randomness",
"strings",
"variables"
]
},
{
"slug": "run-length-encoding",
"name": "Run-Length Encoding",
"uuid": "9e8f98f0-6fff-4389-a9a2-9ae43edefa21",
"practices": [],
"prerequisites": [],
"difficulty": 2,
"topics": null
"difficulty": 2
},
{
"slug": "luhn",
Expand All @@ -324,7 +405,11 @@
"practices": [],
"prerequisites": [],
"difficulty": 3,
"topics": ["checksums", "list_operations", "strings"]
"topics": [
"checksums",
"list_operations",
"strings"
]
},
{
"slug": "list-ops",
Expand Down Expand Up @@ -440,7 +525,6 @@
}
]
},
"concepts": [],
"key_features": [
{
"title": "Simple syntax",
Expand Down Expand Up @@ -474,14 +558,14 @@
}
],
"tags": [
"paradigm/functional",
"typing/dynamic",
"typing/strong",
"execution_mode/interpreted",
"platform/windows",
"platform/mac",
"paradigm/functional",
"platform/linux",
"platform/mac",
"platform/windows",
"runtime/language_specific",
"typing/dynamic",
"typing/strong",
"used_for/scripts"
]
}
33 changes: 33 additions & 0 deletions exercises/practice/resistor-color-duo/.docs/instructions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Instructions

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.

The first 2 bands of a resistor have a simple encoding scheme: each color maps to a single 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.

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 band colors are encoded as follows:

- Black: 0
- Brown: 1
- Red: 2
- Orange: 3
- Yellow: 4
- Green: 5
- Blue: 6
- Violet: 7
- Grey: 8
- White: 9

From the example above:
brown-green should return 15
brown-green-violet should return 15 too, ignoring the third color.
19 changes: 19 additions & 0 deletions exercises/practice/resistor-color-duo/.meta/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"authors": [
"BNAndras"
],
"files": {
"solution": [
"resistor-color-duo.el"
],
"test": [
"resistor-color-duo-test.el"
],
"example": [
"example.el"
]
},
"blurb": "Convert color codes, as used on resistors, to a numeric value.",
"source": "Maud de Vries, Erik Schierboom",
"source_url": "https://github.com/exercism/problem-specifications/issues/1464"
}
Loading

0 comments on commit 17c1f67

Please sign in to comment.