-
-
Save havenwood/48b5eacc187e44ad4f8b77bc590d1406 to your computer and use it in GitHub Desktop.
Some ideas for old_relik on #ruby IRC
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def just_for_ideas(a, n) | |
last = a.pop | |
magnitude = last.digits.size.pred | |
limit = n.ceil -magnitude | |
amount = 10 ** magnitude | |
[*a, *last.step(by: amount, to: limit)] | |
end | |
example = [50, 100, 250, 500, 1000, 2000, 3000, 4000, 5000, 10000] | |
just_for_ideas(example, 21000) | |
#=> [50, 100, 250, 500, 1000, 2000, 3000, 4000, 5000, 10000, 20000, 30000] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment