Advertisement
Guest User

Untitled

a guest
Nov 16th, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. def figure_num_to_append(num, i, j):
  2. res_num = 0
  3. for k in range(num):
  4. if k in (i,j) or (num - res_num) in (i,j):
  5. break
  6. res_num += 1
  7. return res_num
  8.  
  9. def build_table(num):
  10. res_list = []
  11. for i in range(num + 1):
  12. tmp_list = []
  13. for j in range(num + 1):
  14. num_to_append = figure_num_to_append(num, i, j)
  15. tmp_list.append(num_to_append)
  16. res_list.append(tmp_list)
  17. return res_list
  18.  
  19. def stringify_table(table):
  20. res_str = ''
  21. for row in table:
  22. for cell in row:
  23. res_str += str(cell)
  24. res_str += '\n'
  25. return res_str
  26.  
  27.  
  28. def main():
  29. table = build_table(int(raw_input("Insert a number\n")))
  30. print stringify_table(table)
  31.  
  32. if __name__ == '__main__':
  33. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement