| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 52cf668 commit 5df8aec
25 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,34 +1,24 @@ | |||
| 1 | - # GitHub Action that uses Black to reformat the Python code in an incoming pull request. | ||
| 2 | - # If all Python code in the pull request is complient with Black then this Action does nothing. | ||
| 3 | - # Othewrwise, Black is run and its changes are committed back to the incoming pull request. | ||
| 1 | + # GitHub Action that uses Black to reformat Python code (if needed) when doing a git push. | ||
| 2 | + # If all Python code in the repo is complient with Black then this Action does nothing. | ||
| 3 | + # Otherwise, Black is run and its changes are committed to the repo. | ||
| 4 | 4 | # https://github.com/cclauss/autoblack | |
| 5 | 5 | ||
| 6 | - name: autoblack | ||
| 7 | - on: [pull_request] | ||
| 6 | + name: autoblack_push | ||
| 7 | + on: [push] | ||
| 8 | 8 | jobs: | |
| 9 | 9 | build: | |
| 10 | 10 | runs-on: ubuntu-latest | |
| 11 | - strategy: | ||
| 12 | - max-parallel: 1 | ||
| 13 | - matrix: | ||
| 14 | - python-version: [3.7] | ||
| 15 | 11 | steps: | |
| 16 | 12 | - uses: actions/checkout@v1 | |
| 17 | - - name: Set up Python ${{ matrix.python-version }} | ||
| 18 | - uses: actions/setup-python@v1 | ||
| 19 | - with: | ||
| 20 | - python-version: ${{ matrix.python-version }} | ||
| 21 | - - name: Install psf/black | ||
| 22 | - run: pip install black | ||
| 23 | - - name: Run black --check . | ||
| 24 | - run: black --check . | ||
| 25 | - - name: If needed, commit black changes to the pull request | ||
| 13 | + - uses: actions/setup-python@v1 | ||
| 14 | + - run: pip install black | ||
| 15 | + - run: black --check . | ||
| 16 | + - name: If needed, commit black changes to a new pull request | ||
| 26 | 17 | if: failure() | |
| 27 | 18 | run: | | |
| 28 | 19 | black . | |
| 29 | - git config --global user.name 'autoblack' | ||
| 30 | - git config --global user.email 'cclauss@users.noreply.github.com' | ||
| 20 | + git config --global user.name github-actions | ||
| 21 | + git config --global user.email '${GITHUB_ACTOR}@users.noreply.github.com' | ||
| 31 | 22 | git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY | |
| 32 | - git checkout $GITHUB_HEAD_REF | ||
| 33 | - git commit -am "fixup: Format Python code with psf/black" | ||
| 34 | - git push | ||
| 23 | + git commit -am "fixup! Format Python code with psf/black push" | ||
| 24 | + git push --force origin HEAD:$GITHUB_REF | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -41,19 +41,21 @@ def miller_rabin(n, allow_probable=False): | |||
| 41 | 41 | "A return value of True indicates a probable prime." | |
| 42 | 42 | ) | |
| 43 | 43 | # array bounds provided by analysis | |
| 44 | - bounds = [2_047, | ||
| 45 | - 1_373_653, | ||
| 46 | - 25_326_001, | ||
| 47 | - 3_215_031_751, | ||
| 48 | - 2_152_302_898_747, | ||
| 49 | - 3_474_749_660_383, | ||
| 50 | - 341_550_071_728_321, | ||
| 51 | - 1, | ||
| 52 | - 3_825_123_056_546_413_051, | ||
| 53 | - 1, | ||
| 54 | - 1, | ||
| 55 | - 318_665_857_834_031_151_167_461, | ||
| 56 | - 3_317_044_064_679_887_385_961_981] | ||
| 44 | + bounds = [ | ||
| 45 | + 2_047, | ||
| 46 | + 1_373_653, | ||
| 47 | + 25_326_001, | ||
| 48 | + 3_215_031_751, | ||
| 49 | + 2_152_302_898_747, | ||
| 50 | + 3_474_749_660_383, | ||
| 51 | + 341_550_071_728_321, | ||
| 52 | + 1, | ||
| 53 | + 3_825_123_056_546_413_051, | ||
| 54 | + 1, | ||
| 55 | + 1, | ||
| 56 | + 318_665_857_834_031_151_167_461, | ||
| 57 | + 3_317_044_064_679_887_385_961_981, | ||
| 58 | + ] | ||
| 57 | 59 | ||
| 58 | 60 | primes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41] | |
| 59 | 61 | for idx, _p in enumerate(bounds, 1): | |
@@ -131,5 +133,5 @@ def test_miller_rabin(): | |||
| 131 | 133 | # upper limit for probabilistic test | |
| 132 | 134 | ||
| 133 | 135 | ||
| 134 | - if __name__ == '__main__': | ||
| 136 | + if __name__ == "__main__": | ||
| 135 | 137 | test_miller_rabin() | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,8 +1,8 @@ | |||
| 1 | 1 | def find_primitive(n): | |
| 2 | 2 | for r in range(1, n): | |
| 3 | 3 | li = [] | |
| 4 | - for x in range(n-1): | ||
| 5 | - val = pow(r,x,n) | ||
| 4 | + for x in range(n - 1): | ||
| 5 | + val = pow(r, x, n) | ||
| 6 | 6 | if val in li: | |
| 7 | 7 | break | |
| 8 | 8 | li.append(val) | |
@@ -11,16 +11,15 @@ def find_primitive(n): | |||
| 11 | 11 | ||
| 12 | 12 | ||
| 13 | 13 | if __name__ == "__main__": | |
| 14 | - q = int(input('Enter a prime number q: ')) | ||
| 14 | + q = int(input("Enter a prime number q: ")) | ||
| 15 | 15 | a = find_primitive(q) | |
| 16 | - a_private = int(input('Enter private key of A: ')) | ||
| 16 | + a_private = int(input("Enter private key of A: ")) | ||
| 17 | 17 | a_public = pow(a, a_private, q) | |
| 18 | - b_private = int(input('Enter private key of B: ')) | ||
| 18 | + b_private = int(input("Enter private key of B: ")) | ||
| 19 | 19 | b_public = pow(a, b_private, q) | |
| 20 | 20 | ||
| 21 | 21 | a_secret = pow(b_public, a_private, q) | |
| 22 | 22 | b_secret = pow(a_public, b_private, q) | |
| 23 | 23 | ||
| 24 | - print('The key value generated by A is: ', a_secret) | ||
| 25 | - print('The key value generated by B is: ', b_secret) | ||
| 26 | - | ||
| 24 | + print("The key value generated by A is: ", a_secret) | ||
| 25 | + print("The key value generated by B is: ", b_secret) | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -22,7 +22,7 @@ def display(tree): # In Order traversal of the tree | |||
| 22 | 22 | ||
| 23 | 23 | ||
| 24 | 24 | def depth_of_tree( | |
| 25 | - tree | ||
| 25 | + tree, | ||
| 26 | 26 | ): # This is the recursive function to find the depth of binary tree. | |
| 27 | 27 | if tree is None: | |
| 28 | 28 | return 0 | |
@@ -36,7 +36,7 @@ def depth_of_tree( | |||
| 36 | 36 | ||
| 37 | 37 | ||
| 38 | 38 | def is_full_binary_tree( | |
| 39 | - tree | ||
| 39 | + tree, | ||
| 40 | 40 | ): # This functions returns that is it full binary tree or not? | |
| 41 | 41 | if tree is None: | |
| 42 | 42 | return True | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -172,7 +172,6 @@ def main(): | |||
| 172 | 172 | args = input() | |
| 173 | 173 | ||
| 174 | 174 | print("good by!") | |
| 175 | - | ||
| 176 | 175 | ||
| 177 | 176 | ||
| 178 | 177 | if __name__ == "__main__": | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -77,9 +77,10 @@ def sift_down(self, idx, array): | |||
| 77 | 77 | ||
| 78 | 78 | if smallest != idx: | |
| 79 | 79 | array[idx], array[smallest] = array[smallest], array[idx] | |
| 80 | - self.idx_of_element[array[idx]], self.idx_of_element[ | ||
| 81 | - array[smallest] | ||
| 82 | - ] = ( | ||
| 80 | + ( | ||
| 81 | + self.idx_of_element[array[idx]], | ||
| 82 | + self.idx_of_element[array[smallest]], | ||
| 83 | + ) = ( | ||
| 83 | 84 | self.idx_of_element[array[smallest]], | |
| 84 | 85 | self.idx_of_element[array[idx]], | |
| 85 | 86 | ) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -23,9 +23,7 @@ def insertHead(self, x): | |||
| 23 | 23 | def deleteHead(self): | |
| 24 | 24 | temp = self.head | |
| 25 | 25 | self.head = self.head.next # oldHead <--> 2ndElement(head) | |
| 26 | - self.head.previous = ( | ||
| 27 | - None | ||
| 28 | - ) # oldHead --> 2ndElement(head) nothing pointing at it so the old head will be removed | ||
| 26 | + self.head.previous = None # oldHead --> 2ndElement(head) nothing pointing at it so the old head will be removed | ||
| 29 | 27 | if self.head is None: | |
| 30 | 28 | self.tail = None # if empty linked list | |
| 31 | 29 | return temp | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,6 +1,7 @@ | |||
| 1 | 1 | # Recursive Prorgam to create a Linked List from a sequence and | |
| 2 | 2 | # print a string representation of it. | |
| 3 | 3 | ||
| 4 | + | ||
| 4 | 5 | class Node: | |
| 5 | 6 | def __init__(self, data=None): | |
| 6 | 7 | self.data = data | |
@@ -17,7 +18,6 @@ def __repr__(self): | |||
| 17 | 18 | return string_rep | |
| 18 | 19 | ||
| 19 | 20 | ||
| 20 | - | ||
| 21 | 21 | def make_linked_list(elements_list): | |
| 22 | 22 | """Creates a Linked List from the elements of the given sequence | |
| 23 | 23 | (list/tuple) and returns the head of the Linked List.""" | |
@@ -36,8 +36,7 @@ def make_linked_list(elements_list): | |||
| 36 | 36 | return head | |
| 37 | 37 | ||
| 38 | 38 | ||
| 39 | - | ||
| 40 | - list_data = [1,3,5,32,44,12,43] | ||
| 39 | + list_data = [1, 3, 5, 32, 44, 12, 43] | ||
| 41 | 40 | print(f"List: {list_data}") | |
| 42 | 41 | print("Creating Linked List from List.") | |
| 43 | 42 | linked_list = make_linked_list(list_data) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,5 +1,6 @@ | |||
| 1 | 1 | # Program to print the elements of a linked list in reverse | |
| 2 | 2 | ||
| 3 | + | ||
| 3 | 4 | class Node: | |
| 4 | 5 | def __init__(self, data=None): | |
| 5 | 6 | self.data = data | |
@@ -16,7 +17,6 @@ def __repr__(self): | |||
| 16 | 17 | return string_rep | |
| 17 | 18 | ||
| 18 | 19 | ||
| 19 | - | ||
| 20 | 20 | def make_linked_list(elements_list): | |
| 21 | 21 | """Creates a Linked List from the elements of the given sequence | |
| 22 | 22 | (list/tuple) and returns the head of the Linked List.""" | |
@@ -34,6 +34,7 @@ def make_linked_list(elements_list): | |||
| 34 | 34 | current = current.next | |
| 35 | 35 | return head | |
| 36 | 36 | ||
| 37 | + | ||
| 37 | 38 | def print_reverse(head_node): | |
| 38 | 39 | """Prints the elements of the given Linked List in reverse order""" | |
| 39 | 40 | ||
@@ -46,8 +47,7 @@ def print_reverse(head_node): | |||
| 46 | 47 | print(head_node.data) | |
| 47 | 48 | ||
| 48 | 49 | ||
| 49 | - | ||
| 50 | - list_data = [14,52,14,12,43] | ||
| 50 | + list_data = [14, 52, 14, 12, 43] | ||
| 51 | 51 | linked_list = make_linked_list(list_data) | |
| 52 | 52 | print("Linked List:") | |
| 53 | 53 | print(linked_list) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -48,8 +48,9 @@ def longest_subsequence(array: List[int]) -> List[int]: # This function is recu | |||
| 48 | 48 | return temp_array | |
| 49 | 49 | else: | |
| 50 | 50 | return longest_subseq | |
| 51 | - | ||
| 51 | + | ||
| 52 | 52 | ||
| 53 | 53 | if __name__ == "__main__": | |
| 54 | 54 | import doctest | |
| 55 | + | ||
| 55 | 56 | doctest.testmod() | |
| Back | FazBrowse Home | New Git URL |
0 commit comments