TrickJarrett.com

Tuesday, December 7th, 2021

« Previous Day Next Day »

Years ago, I coded a very simple PHP tool for the easy making of a Secret Santa list. I put in people and email addresses, and it would pick who got who and send it to everyone.

Today, while doing something completely different and wholly unrelated to Christmas, coding, or anything. I suddenly realized the way I did it was overly complicated and dumb. Sigh.

I basically had it to random matching on each person of the front of the array, looping until it had randomly picked everyone in the array as givers and receivers.

I just realized that the easiest way for me to do this is to put everyone into an array, shuffle the array, and then just have the first person give to the second person, the second person give to the third person, the third to the fourth, and then the last person gives to the first.

Much simpler, cleaner, and faster.

12/7/2021 11:11 am | | Tags: programming, secret santa
« Previous Day Next Day »