How to design a function that takes a date and gives out a number between 1-6, always the same for all dates

algorithms

As a part of an algorithm I'm making I need to make a function that takes the current date to a function and gives out a number between 1-6, and not the same number for two consecutive dates. And it should always return the same number for a given date.

A simple solution would be to make any Monday 1, Tuesday 2, Wednesday 3, etc, but since we only have 6 values just give Sunday 3 again. And then next Monday 1.

The problem with this algorithm is that it's really predictable. A good algorithm should be harder to guess for others.

Any tips on how to approach this?

Best Answer

A compromise between Bent and Doc Brown's approaches might be to take the Julian Date modulus of a multiple of 6 (eg. 36), then lookup the corresponding value (between 1 to 6) in a quasi-random list that satisfies the "consecutive constraint".

For 36, such a list might be:

 246531451362532614364125615343123456

which corresponds to the end word order in a Sestina (with the verses reversed).