Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # # Choose a Secret Santa for every name in the list. Obviously, a person cannot be their own Secret Santa.
- # #
- # # Output is obvious. Print out each person's secret Santa.
- #create 2 separate arrays because no method can be called from just one
- gifters = ["Luke Skywalker luke@theforce.net",
- "Leia Skywalker leia@therebellion.org",
- "Toula Portokalos toula@manhunter.org",
- "Gus Portokalos gus@weareallfruit.net",
- "Bruce Wayne bruce@imbatman.com",
- "Virgil Brigman virgil@rigworkersunion.org",
- "Lindsey Brigman lindsey@iseealiens.net"]
- takers = ["Luke Skywalker luke@theforce.net",
- "Leia Skywalker leia@therebellion.org",
- "Toula Portokalos toula@manhunter.org",
- "Gus Portokalos gus@weareallfruit.net",
- "Bruce Wayne bruce@imbatman.com",
- "Virgil Brigman virgil@rigworkersunion.org",
- "Lindsey Brigman lindsey@iseealiens.net"]
- #shift on this will return the first element of Luke and remove it from the array
- gift_buyer = gifters.shift()
- #assigning a different variable
- #utilizing .pop will take the last element and remove it from the array
- #.shuffle method will mix up the rest
- name_drawn = takers.shuffle!.pop
- # calling out the method above to output a specific action - long way
- if gift_buyer != name_drawn
- puts "#{gift_buyer} is #{name_drawn}'s secret santa"
- end
- # each if/else statement has an 'end' so i have to call a method on each if/else line
- gift_buyer2 = gifters.shift()
- name_drawn2 = takers.shuffle!.pop
- if gift_buyer2 != name_drawn2
- puts "#{gift_buyer2} is #{name_drawn2}'s secret santa"
- end
- gift_buyer3 = gifters.shift()
- name_drawn3 = takers.shuffle!.pop
- if gift_buyer3 != name_drawn3
- puts "#{gift_buyer3} is #{name_drawn3}'s secret santa"
- end
- gift_buyer4 = gifters.shift()
- name_drawn4 = takers.shuffle!.pop
- if gift_buyer4 != name_drawn4
- puts "#{gift_buyer4} is #{name_drawn4}'s secret santa"
- end
- gift_buyer5 = gifters.shift()
- name_drawn5 = takers.shuffle!.pop
- if gift_buyer5 != name_drawn5
- puts "#{gift_buyer5} is #{name_drawn5}'s secret santa"
- end
- gift_buyer6 = gifters.shift()
- name_drawn6 = takers.shuffle!.pop
- if gift_buyer6 != name_drawn6
- puts "#{gift_buyer6} is #{name_drawn6}'s secret santa"
- end
- gift_buyer7 = gifters.shift()
- name_drawn7 = takers.shuffle!.pop
- if gift_buyer7 != name_drawn7
- puts "#{gift_buyer7} is #{name_drawn7}'s secret santa"
- end
- # ??? I think a loop can be created or a class, which is where I got stuck :(
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement