-
-
Notifications
You must be signed in to change notification settings - Fork 398
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New practice exercise resistor-color-duo
#800
New practice exercise resistor-color-duo
#800
Conversation
Thank you for contributing to Based on the files changed in this PR, it would be good to pay attention to the following details when reviewing the PR:
Automated comment created by PR Commenter 🤖. |
"prerequisites": [ | ||
"atoms", | ||
"lists", | ||
"pattern-matching", | ||
"maps" | ||
], | ||
"practices": [ | ||
"maps" | ||
], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting. With those prerequisites, resistor-color-duo
would be unlocked before resistor-color
because resistor-color
has an implementation with a list and Enum.find_index(@colors, &(&1 == color))
, so it requires enum
, and enum
comes after all those prerequisites.
We cannot edit resistor-color
to NOT use enum
because it needs to return all the colors in order, and map keys aren't ordered.
I don't know if that's a problem, but it defies my expectations. I would think that resistor-color
is easier than resistor-color-duo
, and that resistor-color-duo
is easier than resistor-color-trio
🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But this one has maps
, does that come after lists
and enum
or is it a different branch?
I could use a list implementation to make them all consistent. To be honest I didn't notice resistor-color
existed haha.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lists
and maps
are required by enum
.
I think using a list for this exercise would make it less idiomatic. I guess we need to accept it like it is :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
map keys aren't ordered.
100% agree with this statement, it is a common fallacy for students to believe that map keys are ordered just because they appear so in small maps.
Not sure if this is a problem though. This is somewhat similar to the "Instruments of Texas" theme that we reuse in the concept exercises as Maud had designed these exercises as teaching exercises. Each one just teaches something different.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Someone going through all three exercises in a row is likely to reuse the same implementation though. Either with maps or lists. I probably would have written resistor-color
with maps as well since lookup is O(1)
rather than O(n)
.
@doc """ | ||
Calculate a resistance value from two colors | ||
""" | ||
@spec value(colors :: [atom]) :: integer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like that the colors are atoms. What do you think about editing resistor-color
to also use atoms for the colors? Now they're strings.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Leave it to me. Maybe we should make the trio all a little bit more consistent on other things as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll merge. |
|
New one. Quite simple.
Big brother
resistor-color-trio
coming up next.