Advertisement
Guest User

Untitled

a guest
Jun 16th, 2015
299
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.21 KB | None | 0 0
  1. # creates an array for giver:
  2. giver = ["Luke Skywalker luke@theforce.net",
  3. "Leia Skywalker leia@therebellion.org",
  4. "Toula Portokalos toula@manhunter.org",
  5. "Gus Portokalos gus@weareallfruit.net",
  6. "Bruce Wayne bruce@imbatman.com",
  7. "Virgil Brigman virgil@rigworkersunion.org",
  8. "Lindsey Brigman lindsey@iseealiens.net"]
  9.  
  10. # ceates a duplicate array:
  11. receiver = giver.dup
  12.  
  13. # takes the first person kicked out of the array 'givers' (Luke Skywalker) from the top
  14. # and assigns it to the variable 'secret santa' and removes it from the giver array
  15. secret_santa = giver.shift()
  16.  
  17. # '.pop' takes the last element in the receivers array; then shuffles the rest of the elements
  18. selected_name = receiver.shuffle!.pop
  19.  
  20. # makes sure the giver is not equal to the recipient then puts the first giver/receiver pair.
  21. if secret_santa != selected_name
  22. puts "#{secret_santa} is the Secret Santa of #{selected_name}"
  23. puts
  24. end
  25.  
  26. # selects the next element in the giver array
  27. secret_santa2 = giver.shift()
  28. selected_name2 = receiver.shuffle!.pop
  29. # makes sure the giver is not equal to the recipient then puts the second giver/receiver pair.
  30. if secret_santa2 != selected_name
  31. puts "#{secret_santa2} is the Secret Santa of #{selected_name2}"
  32. puts
  33. end
  34.  
  35. secret_santa3 = giver.shift()
  36. selected_name3 = receiver.shuffle!.pop # takes from the bottom
  37. if secret_santa3 != selected_name
  38. puts "#{secret_santa3} is the Secret Santa of #{selected_name3}"
  39. puts
  40. end
  41.  
  42. secret_santa4 = giver.shift()
  43. selected_name4 = receiver.shuffle!.pop # takes from the bottom
  44. if secret_santa4 != selected_name
  45. puts "#{secret_santa4} is the Secret Santa of #{selected_name4}"
  46. puts
  47. end
  48.  
  49. secret_santa5 = giver.shift()
  50. selected_name5 = receiver.shuffle!.pop # takes from the bottom
  51. if secret_santa5 != selected_name
  52. puts "#{secret_santa5} is the Secret Santa of #{selected_name5}"
  53. puts
  54. end
  55.  
  56. secret_santa6 = giver.shift()
  57. selected_name6 = receiver.shuffle!.pop # takes from the bottom
  58. if secret_santa6 != selected_name
  59. puts "#{secret_santa6} is the Secret Santa of #{selected_name6}"
  60. puts
  61. end
  62.  
  63. secret_santa7 = giver.shift()
  64. selected_name7 = receiver.shuffle!.pop # takes from the bottom
  65. if secret_santa7 != selected_name
  66. puts "#{secret_santa7} is the Secret Santa of #{selected_name7}"
  67. puts
  68. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement