Skip to content

Instantly share code, notes, and snippets.

@havenwood
Created March 6, 2020 18:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save havenwood/48b5eacc187e44ad4f8b77bc590d1406 to your computer and use it in GitHub Desktop.
Save havenwood/48b5eacc187e44ad4f8b77bc590d1406 to your computer and use it in GitHub Desktop.
Some ideas for old_relik on #ruby IRC
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