Advertisement
Albinutte

Untitled

Mar 6th, 2016
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.58 KB | None | 0 0
  1. def CakewalkSimulator(steps, direction):
  2.     s = abs(steps)
  3.     if direction == 'right':
  4.         res = list(range(1, s + 1))
  5.     if direction == 'down':
  6.         res = [[i + 1] for i in range(s)]
  7.     if direction == 'downright':
  8.         res = [[i + 1 if i == j else 0 for j in range(s)] for i in range(s)]
  9.     if direction == 'downleft':
  10.         res = [[i + 1 if i == s - j - 1 else 0 for j in range(s)] for i in range(s)]
  11.     if steps < 0:
  12.         res.reverse()
  13.         if isinstance(res[0], list):
  14.             res = [list(reversed(r)) for r in res]
  15.     print res
  16.     return res
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement