Skip to content

Instantly share code, notes, and snippets.

@johnelf
Last active December 4, 2018 02:35
Show Gist options
  • Save johnelf/d4a728942bfa33f793c903f33f395637 to your computer and use it in GitHub Desktop.
Save johnelf/d4a728942bfa33f793c903f33f395637 to your computer and use it in GitHub Desktop.
What to eat?
def what_to_have(list, count)
result = {}
(1..count).each do |n|
key = list.sample
if result[key]
result[key] = result[key] + 1
else
result[key] = 1
end
end
result.sort_by { |k, v| v }
end
resturants = ['香锅', '米饭炒菜', '凉皮肉夹馍', '饺子', '盖饭']
REPEAT_TIMES = 1000
what_to_have(resturants, REPEAT_TIMES).reverse.first
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment