Skip to content

Instantly share code, notes, and snippets.

@matthewjberger
Last active December 7, 2019 23:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matthewjberger/787fc6c878a98abea4ee59ef109dbc99 to your computer and use it in GitHub Desktop.
Save matthewjberger/787fc6c878a98abea4ee59ef109dbc99 to your computer and use it in GitHub Desktop.
Generating christmas gift pairings with Powershell!
$people = @("Matthew", "Nikky", "Lana", "Chris", "Tawny", "Briana")
$picked = [System.Collections.ArrayList]@()
$people | %{
$person = $_
$choices = $people | ?{ !$picked.Contains($_) -and $_ -ne $person}
$partner = Get-Random -InputObject $choices
$picked.Add($partner) | Out-Null
Write-Host "$person -> $partner"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment