mmishanchyk

Retake Exam - 16 December 2020 (problem3)

Jun 20th, 2021
805
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def current_row(n):
  2.     row = []
  3.     for i in range(n):
  4.         if i == 0 or i == n - 1:
  5.             row.append(1)
  6.         else:
  7.             c_row = current_row(n - 1)
  8.             row.append(c_row[i - 1] + c_row[i])
  9.     return row
  10.  
  11.  
  12. def get_magic_triangle(m):
  13.     result = []
  14.     for i in range(m):
  15.         result.append(current_row(i + 1))
  16.     return print(result)
  17.  
  18.  
  19. get_magic_triangle(5)
RAW Paste Data