Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
dict + lambda (python way =) solution in Clear category for Follow Instructions by kdim
def follow(instructions):
go = {
'f': lambda x, y: (x, y + 1),
'b': lambda x, y: (x, y - 1),
'l': lambda x, y: (x - 1, y),
'r': lambda x, y: (x + 1, y)
}
a = (0,0)
for step in instructions:
a = go[step](*a)
return a
Jan. 27, 2021