From dba1893472fa47704385f1b3b8b02f4f44447291 Mon Sep 17 00:00:00 2001 From: Abhishek Date: Fri, 12 Apr 2024 12:51:09 +0530 Subject: [PATCH 1/3] diamond --- practice/diamond/diamond.py | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/practice/diamond/diamond.py b/practice/diamond/diamond.py index 14f2850..4b6bb0e 100644 --- a/practice/diamond/diamond.py +++ b/practice/diamond/diamond.py @@ -1,2 +1,25 @@ def rows(letter): - pass + rows = [] + size = 2 * (ord(letter) - ord('A')) + 1 # size of the diamond + + for i in range(size): # iterate over the rows + row = ' ' * abs(size // 2 - i) # spaces before the first letter + row += chr(ord('A') + min(i, size - i - 1)) # first letter + + if i != 0 and i != size - 1: # middle row + row += ' ' * (2 * min(i, size - i - 1) - 1) # spaces between the letters + row += chr(ord('A') + min(i, size - i - 1)) # second letter + + row += ' ' * abs(size // 2 - i) # spaces after the second letter + rows.append(row) # add the row to the list + + return rows + +pass + +# My Understanding of the pattern ---> +# It starts with the letter 'A' at the top and goes up to the input letter, then back down to 'A'. +# Each row of the diamond has two same letters, except for the first and last rows which have one letter +# The letters are separated by spaces, and the number of spaces between the letters increases by two with each row +# from the top to the middle, then decreases by two with each row from the middle to the bottom. + From 0010c72efb5232792a93a57f31730daad62c4f7f Mon Sep 17 00:00:00 2001 From: Abhishek Date: Mon, 22 Apr 2024 02:23:45 +0530 Subject: [PATCH 2/3] run impacted tests only --- .github/workflows/python-app.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/python-app.yml b/.github/workflows/python-app.yml index 48d1bde..a4e04c8 100644 --- a/.github/workflows/python-app.yml +++ b/.github/workflows/python-app.yml @@ -30,7 +30,8 @@ jobs: if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - name: Test with pytest run: | - pytest --continue-on-collection-errors + git fetch --no-tags --prune --depth=1 origin +refs/heads/*:refs/remotes/origin/* + git diff origin/main HEAD --name-only -- practice | xargs dirname | sort | uniq | xargs pytest - name: Lint with flake8 run: | # stop the build if there are Python syntax errors or undefined names From b574ec3d40398053eeb0368bda769f84575997a9 Mon Sep 17 00:00:00 2001 From: Abhishek Date: Mon, 22 Apr 2024 02:37:40 +0530 Subject: [PATCH 3/3] resolved conflicts --- .github/workflows/python-app.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/python-app.yml b/.github/workflows/python-app.yml index a4e04c8..e1ba390 100644 --- a/.github/workflows/python-app.yml +++ b/.github/workflows/python-app.yml @@ -30,11 +30,11 @@ jobs: if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - name: Test with pytest run: | - git fetch --no-tags --prune --depth=1 origin +refs/heads/*:refs/remotes/origin/* - git diff origin/main HEAD --name-only -- practice | xargs dirname | sort | uniq | xargs pytest + git fetch --no-tags --prune --depth=1 origin +refs/heads/*:refs/remotes/origin/* + git diff origin/main HEAD --name-only -- practice | xargs dirname | sort | uniq | xargs pytest - name: Lint with flake8 run: | # stop the build if there are Python syntax errors or undefined names flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide - flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics + flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics \ No newline at end of file