sum up: I want to create an algorithm (or two) where the outcome is a list of numbers (1-7) where #2 is today, #1 is yesterday and #3.. is tomorrow and thereafter.
For example;
If today is Wednesday (3)
1. Monday = 7
2. Tuesday = 1
3. Wednesday = 2
4. Thursday = 3
5. Friday = 4and if today is Friday (5)
- Monday = 5
- Tuesday = 6
- Wednesday = 7
- Thursday = 1
- Friday = 2
Limitation:
The only numbers you can calculate with are
- The number of the week (i.e. Tuesday = 2, Friday = 5)
- 'Today', as a variable (i.e. if Today = Wednesday, Today = 3)
i.e.
NewNumber = 7 - (today + WeekDay)
Above probably doesn't makes sense, but for demonstration of variables only.
I'd agree with two algorithms, one for every day from today until end of week, and one for the past days (i.e. if today = Wednesday, #1 applies to wed-sun and #2 applies to mon-tue).
What would be the correct algorithm for this matter?
You can use modulus to "wrap" around the week.
In your notation:
$NewNumber = (1 + WeekDay - today) ~ \% ~ 7 + 1$
where $x ~ \% ~ 7$ ist the remainder when dividing $x$ by $7$.
You can also use
$NewNumber = (8 + WeekDay - today) ~ \% ~ 7 + 1$
which avoids remainders of negative numbers.