Skip to content

Rebasing #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Oct 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .github/workflows/auto_close_empty_issues.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# GitHub Action that uses close-issue auto-close empty issues after they are opened.
# If the issue body text is empty the Action auto-closes it and sends a notification.
# Otherwise if the issue body is not empty, it does nothing and the issue remains open.
# https://github.com/marketplace/actions/close-issue

name: auto_close_empty_issues
on:
issues:
types: [opened]
jobs:
check-issue-body-not-empty:
runs-on: ubuntu-latest
steps:
- if: github.event.issue.body == 0
name: Close Issue
uses: peter-evans/close-issue@v1
with:
comment: |
Issue body must contain content.
Auto-closing this issue.
3 changes: 2 additions & 1 deletion DIRECTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,8 @@
* Problem 11
* [Sol1](https://github.com/TheAlgorithms/Python/blob/master/project_euler/problem_11/sol1.py)
* [Sol2](https://github.com/TheAlgorithms/Python/blob/master/project_euler/problem_11/sol2.py)
* Problem 112
* [Sol1](https://github.com/TheAlgorithms/Python/blob/master/project_euler/problem_112/sol1.py)
* Problem 12
* [Sol1](https://github.com/TheAlgorithms/Python/blob/master/project_euler/problem_12/sol1.py)
* [Sol2](https://github.com/TheAlgorithms/Python/blob/master/project_euler/problem_12/sol2.py)
Expand Down Expand Up @@ -691,7 +693,6 @@
* [External Sort](https://github.com/TheAlgorithms/Python/blob/master/sorts/external_sort.py)
* [Gnome Sort](https://github.com/TheAlgorithms/Python/blob/master/sorts/gnome_sort.py)
* [Heap Sort](https://github.com/TheAlgorithms/Python/blob/master/sorts/heap_sort.py)
* [I Sort](https://github.com/TheAlgorithms/Python/blob/master/sorts/i_sort.py)
* [Insertion Sort](https://github.com/TheAlgorithms/Python/blob/master/sorts/insertion_sort.py)
* [Iterative Merge Sort](https://github.com/TheAlgorithms/Python/blob/master/sorts/iterative_merge_sort.py)
* [Merge Insertion Sort](https://github.com/TheAlgorithms/Python/blob/master/sorts/merge_insertion_sort.py)
Expand Down
25 changes: 25 additions & 0 deletions maths/area.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,30 @@ def area_circle(radius: float) -> float:
return pi * radius ** 2


def area_rhombus(diagonal_1: float, diagonal_2: float) -> float:
"""
Calculate the area of a rhombus

>>> area_rhombus(10, 20)
100.0
>>> area_rhombus(-1, -2)
Traceback (most recent call last):
...
ValueError: area_rhombus() only accepts non-negative values
>>> area_rhombus(1, -2)
Traceback (most recent call last):
...
ValueError: area_rhombus() only accepts non-negative values
>>> area_rhombus(-1, 2)
Traceback (most recent call last):
...
ValueError: area_rhombus() only accepts non-negative values
"""
if diagonal_1 < 0 or diagonal_2 < 0:
raise ValueError("area_rhombus() only accepts non-negative values")
return 1 / 2 * diagonal_1 * diagonal_2


def main():
print("Areas of various geometric shapes: \n")
print(f"Rectangle: {area_rectangle(10, 20)}")
Expand All @@ -197,6 +221,7 @@ def main():
print("\nSurface Areas of various geometric shapes: \n")
print(f"Cube: {surface_area_cube(20)}")
print(f"Sphere: {surface_area_sphere(20)}")
print(f"Rhombus: {area_rhombus(10, 20)}")


if __name__ == "__main__":
Expand Down