The Naughty Algorithm


/ Published in: Other
Save to your folder(s)



Copy this code and paste it in your HTML
  1. # loop through all of humanity
  2. humanity.each do |human|
  3.  
  4. # select out a set of presents for this human
  5. presents = santas_bag.select do |gift|
  6. good_enough = list.is_good_enough_for_this_gift?(human, gift)
  7. if (!good_enough) # better check twice
  8. good_enough = list.is_good_enough_for_this_gift?(human, gift)
  9. return good_enough
  10. end
  11.  
  12. santa.leave presents
  13. end

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.