Skip to content

Instantly share code, notes, and snippets.

@sadfuzzy
Last active August 29, 2015 14:08
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 sadfuzzy/3de18b12ed867d3a261d to your computer and use it in GitHub Desktop.
Save sadfuzzy/3de18b12ed867d3a261d to your computer and use it in GitHub Desktop.
Lunch List generator
class LunchList
NAMES = %i(DimaS DimaG Denis SergeyStat SergeyAdm Oleg Alena).shuffle
MIN_EATERS = 3
MAX_EATERS = 4
def generated_list
decisions = {}
NAMES.map do |name|
decisions[name] = rand(0..1).zero? ? 'wait' : 'go!'
end
eaters = decisions.values.count('go!')
return decisions.sort_by{ |v| v[1] } if (MIN_EATERS..MAX_EATERS).include?(eaters)
generated_list
end
def show
puts generated_list.map {|name, decision| "#{name} #{decision}"}
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment