Secret Santa Picker using R

Here’s a quick post on making a secret santa picker using R. The code eliminates a person from picking themselves, otherwise it’s no frills.

#set the variable for the number of people
npeople=5

fam=matrix(ncol=1, nrow=npeople, NA)
fam[1,1]="name1"
fam[2,1]="name2"
fam[3,1]="name3"
fam[4,1]="name4"
fam[5,1]="name5"


fam2=matrix(ncol=1, nrow=npeople, NA)
names=c("name1","name2","name3","name4","name5")
for (i in 1:npeople){
  #pick the first name
  if (i==1){
    xx2=sample(names, (npeople-i+1), replace=FALSE)
  } else
    xx2=sample(xx2, (npeople-i+1), replace=FALSE)
  
  if (xx2[1]!=fam[i,1]){
    fam2[i,1]=xx2[1]
  } else{
    fam2[i,1]=xx2[2]}
    
  
  #set up the new matrix with one less name
  used=which(xx2==fam2[i])
  xx2[used]="zzzzz"
  xx2=sort(xx2)[1:(npeople-i)]
}

#add "has" to the matrix
has=matrix(ncol=1,nrow=npeople, "has")

#build the final matrices
final=cbind(fam,has,fam2)	
#the final results
final

[,1] [,2] [,3]
[1,] “name1” “has” “name4”
[2,] “name2” “has” “name3”
[3,] “name3” “has” “name5”
[4,] “name4” “has” “name2”
[5,] “name5” “has” “name1”

Unbroken – A Visual Guide via Google Earth

I recently finished reading Unbroken by Laura Hillenbrand. It was an immensely powerful story of the human spirit and will to survive and flourish. The only thing I felt was lacking in the book was a visual guide (i.e., map) of Louie’s crazy trip around the Pacific. Therefore I made this Google Earth kmz file which has pins for many of the significant locations in the book once Louie is sent to Honolulu. The kmz file can be viewed in Google Maps by clicking the link, with the option to download if interested (see link below). Here’s a list of the locations included:

KMZ Download (via google drive)

Honolulu
Midway Islands
Wake Atoll
Canton Island
Makin – Gilbert Islands
Tarawa – Gilbert Islands
Funafuti
Nauru
Palmyra Atoll
Flight path of the Green Hornet
Lost at Sea – Louie, Phil and Mac’s drifting journey
Wotje Atoll
Kwajalein Atoll – Execution Island
Ofuna Camp (very approximate)
Omori POW Camp
Naoetsu POW Camp