I have approximately 100 tips that I need to display randomly on a site, different tip each day, and there is no access to a database. I have thought about putting the tips into array groups and associating each group with a day of the month, but that would not make the tips show up randomly. What is a relatively painless way to accomplish this task?
Share
Since you want to display only one tip a day, and you can’t store any state, you can do the following:
ith tip wherei = random.Next(numTips)If you also want to ensure each tip is displayed at least once before a tip is repeated:
Shuffle the elements with Fisher-Yates, using the not-so-random number generator you created. Or use LINQ:
ith tip modtips.Lengthwhereiis the number of days since Epoch.