Jan-15-2024, 07:46 PM
If using 0 and 1 to represent closed / open doors it's simple to toggle value using XOR (bitwise exclusive OR). Something along those lines (just an idea, haven't tested it):
# 1 means door open, 0 mean doors closed # create list of 100 doors open doors = [1] * 100 # toggle every second value for i in range(1, 100, 2): doors[i] ^= True # toggle nth value with nth step for n in range(2, 101): for i in range(n, 100, n): doors[i] ^= True print(doors) print(sum(doors))
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy
Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.
Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.