Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def CakewalkSimulator(steps, direction):
- s = abs(steps)
- if direction == 'right':
- res = list(range(1, s + 1))
- if direction == 'down':
- res = [[i + 1] for i in range(s)]
- if direction == 'downright':
- res = [[i + 1 if i == j else 0 for j in range(s)] for i in range(s)]
- if direction == 'downleft':
- res = [[i + 1 if i == s - j - 1 else 0 for j in range(s)] for i in range(s)]
- if steps < 0:
- res.reverse()
- if isinstance(res[0], list):
- res = [list(reversed(r)) for r in res]
- print res
- return res
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement