Last active
December 4, 2018 02:35
-
-
Save johnelf/d4a728942bfa33f793c903f33f395637 to your computer and use it in GitHub Desktop.
What to eat?
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 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