-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from Manobal-Singh-Bagady/patterns
Add code for Pattern 11, Pattern 12, Pattern 13, and Pattern 14
- Loading branch information
Showing
4 changed files
with
256 additions
and
0 deletions.
There are no files selected for viewing
72 changes: 72 additions & 0 deletions
72
CODE/Step1-Learn the basics/Lec2-Build Up Logical thinking/Pattern11.ipynb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"# Pattern 11\n", | ||
"\n", | ||
"- pattern:\n", | ||
"\n", | ||
" ```text \n", | ||
" n=3\n", | ||
" 1\n", | ||
" 0 1\n", | ||
" 1 0 1\n", | ||
" ```" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 3, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"1 \n", | ||
"0 1 \n", | ||
"1 0 1 \n", | ||
"0 1 0 1 \n", | ||
"1 0 1 0 1 \n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"# Pattern 11\n", | ||
"def nBinaryTriangle(n: int) -> None:\n", | ||
" for i in range(n):\n", | ||
" str = 1 if i%2==0 else 0\n", | ||
" for j in range(i+1):\n", | ||
" print(str, end=' ')\n", | ||
" str^=1\n", | ||
" print()\n", | ||
"\n", | ||
"\n", | ||
"nBinaryTriangle(5)" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.12.2" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |
74 changes: 74 additions & 0 deletions
74
CODE/Step1-Learn the basics/Lec2-Build Up Logical thinking/Pattern12.ipynb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"# Pattern 12\n", | ||
"\n", | ||
"- pattern:\n", | ||
"\n", | ||
" ```text\n", | ||
" 1 1\n", | ||
" 1 2 2 1\n", | ||
" 1 2 3 3 2 1\n", | ||
" ```" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 16, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"1 1 \n", | ||
"1 2 2 1 \n", | ||
"1 2 3 3 2 1 \n", | ||
"1 2 3 4 4 3 2 1 \n", | ||
"1 2 3 4 5 5 4 3 2 1 \n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"# Pattern 12\n", | ||
"def numberCrown(n: int) -> None:\n", | ||
" spaces = 4*(n-1)\n", | ||
" for i in range(1,n+1):\n", | ||
" for j in range(1,i+1):\n", | ||
" print(j, end=' ')\n", | ||
" print(' '*spaces, end='')\n", | ||
" spaces -= 4\n", | ||
" for j in range(i,0,-1):\n", | ||
" print(j, end=' ')\n", | ||
" print()\n", | ||
"\n", | ||
"\n", | ||
"numberCrown(5)" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.12.2" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |
72 changes: 72 additions & 0 deletions
72
CODE/Step1-Learn the basics/Lec2-Build Up Logical thinking/Pattern13.ipynb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"# Pattern 13\n", | ||
"\n", | ||
"- pattern:\n", | ||
"\n", | ||
" ```text \n", | ||
" n=3\n", | ||
" 1\n", | ||
" 2 3\n", | ||
" 4 5 6\n", | ||
" ```" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 3, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"1 \n", | ||
"2 3 \n", | ||
"4 5 6 \n", | ||
"7 8 9 10 \n", | ||
"11 12 13 14 15 \n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"# Pattern 13\n", | ||
"def nNumberTriangle(n: int) -> None:\n", | ||
" num = 1\n", | ||
" for i in range(n):\n", | ||
" for _ in range(i+1):\n", | ||
" print(num, end=' ')\n", | ||
" num+=1\n", | ||
" print()\n", | ||
"\n", | ||
"\n", | ||
"nNumberTriangle(5)" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.12.2" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |
38 changes: 38 additions & 0 deletions
38
CODE/Step1-Learn the basics/Lec2-Build Up Logical thinking/Pattern14.ipynb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"# Pattern 14\n", | ||
"\n", | ||
"- pattern:\n", | ||
"\n", | ||
" ```text \n", | ||
" n=3\n", | ||
" 1\n", | ||
" 0 1\n", | ||
" 1 0 1\n", | ||
" ```" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": { | ||
"vscode": { | ||
"languageId": "plaintext" | ||
} | ||
}, | ||
"outputs": [], | ||
"source": [] | ||
} | ||
], | ||
"metadata": { | ||
"language_info": { | ||
"name": "python" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |