Comments (3)
Thanks for this. I've opened a PR for what I consider to be an essential change.
I think it would be nice to have an "optimal" solution in the mentor notes here too, so we still have something to teach the people that get the minimal solution first time.
A few other suggestions:
- I think
initialize
be private too. luhn_sum % 10 == 0
- I like.zero?
here. I also likemodulo(10)
but that's more personal preference.
from website-copy.
Thanks for the PR and catching that! 🏅
I think
initialize
be private too.
initialize
is private by design, and it looks like by convention, it is positioned in the public interface, without actually being public.
(What I found: Normally, a subclass can override its parent's visibility, because Ruby adds a call to super
that makes the change possible. 🙃 My guess is that that magic has been taken out for initialize
.)
luhn_sum % 10 == 0
- I like.zero?
I felt it's too much depending on personal taste to add it to the notes. It's always debatable what should and shouldn't be in the notes, so this was just my judgment call. And if there wasn't much else to talk about in the notes, I probably would have mentioned it.
Also, it should have come up in earlier exercises, and we can't repeat everything that has been handled before. But still: just a judgment call.
I think it would be nice to have an "optimal" solution in the mentor notes here too
-
It is marked as a todo.
-
I have rarely seen a first submission that hit the MVS since I started mentoring Luhn. I mentored over 20 in the last month or so. (Which, from a Track Anatomy POV, I don't consider a good sign.)
-
I haven't found an optimal solution yet.
That's also because in my mind, I considered Luhn not to be the 'closing' of the mid-level exercises, but the start of the most advanced ones. And, a great opportunity to talk about mixins and such. -
The Notes are quite crowded already, and the optimal solution is probably a completely different strategy and outcome. I expect that in upcoming weeks, some of the notes can be moved 'down' to other/new core exercises, and that would make room for the new optimal solution.
Let's discuss that optimal solution first. Then worry about how to squeeze it into the Notes.
from website-copy.
I think that the approach given in the notes is somewhat flawed.
require 'scanf'
PAIRS = (0..9).zip([0, 2, 4, 6, 8, 1, 3, 5, 7, 9])
def luhn_sum(string)
string.delete(' ').reverse.scanf("%1d%1d") do | even, odd = 0 |
even + PAIRS[odd]
end.sum
end
It's not necessary to perform multiplication in the loop, and scanf
allows us to chunk and typecast the string in one go.
from website-copy.
Related Issues (20)
- Prevent people from accidentally comitting comments with unescaped %
- Typos: missing word in configlet description HOT 4
- Mentor Say there is an error in Scala two fer
- "We received the following error when we ran your code:" but no error is following HOT 2
- Irregular spelling ("Focusses" vs "Focuses") on About page.
- Mentor notes layout: Suggested comments should wrap, otherwise not readable HOT 5
- Accessibility : `Publish your code` Dialog not accessible by NVDA screen reader.
- Exercism swag site typo
- Incorrect language counts on login screen
- CLI walkthrough: installing Homebrew on Mac: instructions out of date?
- Typo on 'Get involve in the community' button on dashboard
- Add CLI install via Nix instruction
- Typo on Community page
- analysis of submitted exercise takes unusually long (_still processing_) HOT 2
- During signup: values page mentioned but not linked to
- 79850436079
- Rust/Gigasecond mentoring.md outdated
- Ну HOT 2
- Make complete exercises uncompleted HOT 1
- El_negro_willi #1: HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from website-copy.