Skip to content

Instantly share code, notes, and snippets.

@coleww
Last active August 29, 2015 14:03
Show Gist options
  • Save coleww/cfaea55b92570ea9fced to your computer and use it in GitHub Desktop.
Save coleww/cfaea55b92570ea9fced to your computer and use it in GitHub Desktop.
using fibonacci in a web app
def set_amount
fibs = [0, 1]
self.amount = ([10, 7, 5, 3, 2, 1].map { |amt| [amt] * (fibs[0], fibs[1] = fibs[1], fibs[0] + fibs[1])[0]}.flatten).sample
end
#i really wish i could find a way to not have to declare the fibs array...
#this is for like a raffle type thing.
@coleww
Copy link
Author

coleww commented Jun 28, 2014

YOU LOVE THAT RAW ONE LINER
DONT YOU WISH YOU WORKED WITH ME?

@Stephenitis
Copy link

what the... do you want feedback?
explain the use case?

@mikeroher
Copy link

Why do you need to use fibonacci's sequence? Why can't you just generate a random array and sample it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment