diff --git a/data/pascal_triangle/pascal.py b/data/pascal_triangle/pascal.py new file mode 100644 index 0000000..014a8c1 --- /dev/null +++ b/data/pascal_triangle/pascal.py @@ -0,0 +1,22 @@ +n_rows = 7 + +data = [] +print("output: script\n-------------") +for i in range(1,n_rows+1,1): + a = [1]*i + if i >= 3: + for j in range(1,len(a)-1,1): + a[j] = data[-1][j-1] + data[-1][j] + data.append(a) + print(" ".join(str(k) for k in a)) + + +print("output: codex\n-------------") +pascal_triangle(n_rows) + + +# check +if pascal_triangle(n_rows) != None: + result = True +else: + result = False diff --git a/data/pascal_triangle/pascal.txt b/data/pascal_triangle/pascal.txt new file mode 100644 index 0000000..1c49354 --- /dev/null +++ b/data/pascal_triangle/pascal.txt @@ -0,0 +1,4 @@ +def pascal_triangle(n): + """ + This function returns the Pascal's triangle upto n rows. + """ diff --git a/data/pascal_triangle/pascal.yml b/data/pascal_triangle/pascal.yml new file mode 100644 index 0000000..d5084de --- /dev/null +++ b/data/pascal_triangle/pascal.yml @@ -0,0 +1,6 @@ +name: pascal +language: python +prompt: pascal.txt +label: pascal.py +context: python +test: pascal.py