Advertisement
Guest User

Untitled

a guest
Nov 24th, 2014
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. $people = array();
  2. for($i=0; $i < 15; $i++)
  3. {
  4. $people[] = chr(65 + $i);
  5. }
  6. shuffle($people);
  7.  
  8. $unmatched = array('AG', 'HJ', 'BF', 'CI');
  9.  
  10. $rotated_people = $people;
  11. array_push($rotated_people, array_shift($rotated_people));
  12. $queue = array(
  13. $people,
  14. $rotated_people,
  15. );
  16.  
  17. for ($i=0; $i<15; $i++) {
  18. $give = $queue[0][$i];
  19. $get = $queue[1][$i];
  20. if ( ! in_array([$give . $get, $get . $give], $unmatched) && $give != $get )
  21. {
  22. echo $give . ' gives present to ' . $get . "<br/>";
  23. }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement