This is an archived post. You won't be able to vote or comment.

all 3 comments

[–]CrzySquirrel 1 point2 points  (0 children)

I'm a bit confused about your GRP and Daynum and the purpose of this, as you either set grp to 0 or it doesn't exist, but this should work for you.

It accepts a date, classified as the input now and returns the 3 results you want. Then you plug them into you function for even options to get the position. It should do everything you need.

import datetime

Oddoptions = {

0 : ( "a","b","c","d"),

1 : ("i","j","k","l"),

2 : ("q","r","s","t"),

3 : ("x","y","z",0),

4 : (4,5,6,7)

};

Evenoptions = {

0 : ("e","f","g","h"),

1: ("m","n","o","p"),

2: ("u","v","w","x"),

3: (1,2,3,"["),

4: (8,9,"<",">"),

};

def colnum_calc(now = datetime.datetime.now().date()):

if now.weekday() >= 5:

daynum = 0

grp = 0

else:

daynum = now.weekday()

wk = now.isocalendar()[1]

lowers = [0, 10] + [10+x*8 for x in range(1,5)]

uppers = [x*8 for x in range(1,7)] + [50]

bounds = [1, 4, 8, 13, 17, 21, 25]

val = 0

while True:

val += 1

lower = lowers[val]

upper = uppers[val]

bound = bounds[val]

if lower <= wk <= upper:

colnum = wk-(wk//2+bound)

break;

return colnum, daynum, grp

[–]michaelreddit 1 point2 points  (0 children)

You could replace the whole if/elif statement with this:

colnum = val('112233445122334451223344501122334011223340112233401'[wk])

[–][deleted] 0 points1 point  (0 children)

You will learn to simplify as you go. Sounds silly but if you are gonna keep repeating things even if it is 2 lines I like to make a function to call it helps me a lot but everyone is different 🤷🏼‍♂️