In general I harmonized all 3 versions (my 2 and yours) and used names that best (to me) conceptually portrayed|explained their roles in the algorithm, and ended up using 95% of your naming conventions. @gap
is misleading, and @nn
better, by showing the form of the divisor for each digit (considered @dd
, but eh…). Basically, I wanted to use short|concise|clear names. The comments are more important than the names, like this_lo|next_lo
, which really didn’t need to be changed from n1|n2
in my original versions, because they’re only used once. Ultimately, I chose the names that made the most sense to me, and made me smile.
Tried .skip(count - keep).first(keep)
too, but it provided no performance|memory advantages I could detect, so I kept the shorter code. (Though good to know it’s doable.)
I also added the Ruby versions, which are about a 98% literal translation.
The bottom line is, this was a good learning exercise for me. I think all the versions now are much easier to comprehend, and illustrate different capabilities of Crystal|Ruby. And I’m finished with this task.