Skip to content

Adding a fourth canonical exercise to the 'resistor color' series - #2682

Open
Cool-Katt wants to merge 6 commits into
exercism:mainfrom
Cool-Katt:main
Open

Cool-Katt wants to merge 6 commits into
exercism:mainfrom
Cool-Katt:main

Conversation

@Cool-Katt

Copy link
Copy Markdown
Contributor

No description provided.

@Cool-Katt
Cool-Katt requested a review from a team as a code owner September 8, 2026 11:24
@Cool-Katt

Copy link
Copy Markdown
Contributor Author

Okay, so
This is a port of the fourth exercise in the 'resistor colours' series, taken pretty much as is from the Python track.
Discussion can be found here


After many attempts, every check except for the links passes. I don't think I can do much about the links in this PR and it's out of scope so it should be fine™️

Comment thread exercises/resistor-color-tolerance/description.md
Comment thread exercises/resistor-color-tolerance/canonical-data.json
Comment thread exercises/resistor-color-expert/metadata.toml Outdated
Comment thread exercises/resistor-color-tolerance/metadata.toml Outdated
So an input `list` of `["orange", "orange", "blue", "red"]` should return:

"33 megaohms ±2%"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you mention the decimals used

@glennj

glennj commented Sep 16, 2026

Copy link
Copy Markdown
Contributor

Resistors are nightmare fuel for the colourblind.

The program will take 1, 4, or 5 colors as input and output the correct value in ohms.
The color bands are encoded as follows:

- black: 0

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we switch to a table for the colors (here and tolerance)?

@kotp kotp left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving, but provided suggestion that could be put in place, in agreement with @IsaacG .

Comment on lines +7 to +16
- black: 0
- brown: 1
- red: 2
- orange: 3
- yellow: 4
- green: 5
- blue: 6
- violet: 7
- grey: 8
- white: 9

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- black: 0
- brown: 1
- red: 2
- orange: 3
- yellow: 4
- green: 5
- blue: 6
- violet: 7
- grey: 8
- white: 9
| Color | Value |
|-------------|-------|
| Black | 0 |
| Brown | 1 |
| Red | 2 |
| Orange | 3 |
| Yellow | 4 |
| Green | 5 |
| Blue | 6 |
| Violet | 7 |
| Gray | 8 |
| White | 9 |
|-------------|-------|

For convenience, in case you want to use this.

I did not leave it in a more "codey" flavor, since it is the information not the formatting that is important here (the dash and colon looks like adherence to some formal syntax for some languages data structures).

Comment on lines +26 to +33
- grey - 0.05%
- violet - 0.1%
- blue - 0.25%
- green - 0.5%
- brown - 1%
- red - 2%
- gold - 5%
- silver - 10%

@kotp kotp Sep 16, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- grey - 0.05%
- violet - 0.1%
- blue - 0.25%
- green - 0.5%
- brown - 1%
- red - 2%
- gold - 5%
- silver - 10%
| Color | Tolerance |
|--------|----------:|
| Grey | ±0.05% |
| Violet | ±0.10% |
| Blue | ±0.25% |
| Green | ±0.50% |
| Brown | ±1.00% |
| Red | ±2.00% |
| Gold | ±5.00% |
| Silver | ±10.00% |
|--------|-----------|

@glennj glennj Sep 16, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or if you want to right-align the Tolerances:

| Color       | Tolerance |
| ----------- | --------: |
| Grey        | 0.05%     |
| Silver      | 10%       |
Color Tolerance
Grey 0.05%
Silver 10%

Formatting content within your table

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We probably need to include the ± symbol here, since IIRC, the tests check for it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. If anyone wants to amend, feel free, since I'm away from a computer for a while.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be able to click on "Apply suggestion" if it is looking OK now.

title = "Resistor Color Tolerance"
blurb = "Convert color codes as used on resistors with different bands to a human-readable label."
source = "Ported for the Python Track"
source = "Ported from the Python Track"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since Meatball was the genesis of this exercise on the Python track, we should give him author credit here. (Sorry - I missed this the first time around)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you have a link to the original conversation then, or should it be just 'credit to Meatball'

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
source = "Ported from the Python Track"
source = "Meatball"

or

Suggested change
source = "Ported from the Python Track"
source = "@meatball133"

+cc @meatball133 for input :)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For relative-distance, we just used vaeng without an @ and the source URL was the problem specs PR. From that context, it was clear vaeng was an Exercism / GitHub user. However, we probably shouldn't link to this PR (given it's by Cool-Katt not meatball) but the original exercise PR on the Python track OR an Exercism profile. vaeng is not an English word so it likely wouldn't be read as such while meatball is. "@Meatball" makes it clearer it's likely an online handle on Exercism or elsewhere.

@zeektvbox01-hub zeektvbox01-hub left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try to add a mention of decimal values

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants