4 ms·
How to implement a state machine in Python: def next_state(state): if state == 90000: return 0 return state + 1 But more seriously; on
by missblit 4y ago
How to implement a state machine in Python:
def next_state(state):
if state == 90000:
return 0
return state + 1
But more seriously; once I was asked to implement offsetof in an interview for an entry level C++ position. I didn't quite remember that this was impossible during the heat of the interview, but I did remember enough to not produce an incorrect solution that relies on undefined behavior. I didn't get that job.