Hacker News new | ask | show | jobs
by bobbyi_settv 4342 days ago
Nick,

That helps but doesn't completely solve the state problem. Try adding these two lines to the end of the program:

    g()()()()()
    print g('al')

I think 'gal' should be printed here. Rule 7 says that's what your function should return given 'al', and the fact that we've called it in some other way before doesn't change the fact that it is required to return 'gal' given 'al'.

The solution I posted above handles this scenario (and, as a bonus, is thus threadsafe in case multiple people were doing g()()()('al') simultaneously).