Skip to content

Commit

Permalink
Merge branch 'decimal_to_binary' of github.com:MIT-Emerging-Talent/ET…
Browse files Browse the repository at this point in the history
…6-foundations-group-18 into decimal_to_binary
  • Loading branch information
HebaShaheen committed Jan 1, 2025
2 parents 7fafebf + 13ef565 commit 057c110
Show file tree
Hide file tree
Showing 20 changed files with 696 additions and 15 deletions.
6 changes: 3 additions & 3 deletions .github/ISSUE_TEMPLATE/help_wanted.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
---
name: help wanted
about: >
about: >
A template issue for when you're blocked on certain lines of code.
This template has many sections to get you thinking about your problem, you don't need to fill all of them.
This template has many sections to get you thinking about your problem,
you don't need to fill all of them.
labels: "help wanted"

---

<!--
Expand Down
3 changes: 2 additions & 1 deletion .github/ISSUE_TEMPLATE/meeting_agenda.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
---
name: meeting agenda
about: A template issue for planning meetings
title: "Agenda: __"
title: "Agenda: \_\_"
labels: agenda
---


<!-- Make your issue easy to find:
- milestone: any milestones you will be addressing
Expand Down
5 changes: 2 additions & 3 deletions .github/ISSUE_TEMPLATE/new_challenge.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
---
name: new challenge
about: >
A template issue for describing a new challenge on the project board.
about: >
A template issue for describing a new challenge on the project board.
Place this issue in the TODO column of your group's project board.
title: ''
---

<!--
Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/question.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
name: question
about: >
about: >
A template issue for topics you'd like to discuss or learn more about.
specific topics, general knowledge, it does not even need to be about code.
There are no bad questions!
Expand Down
17 changes: 17 additions & 0 deletions .github/workflows/ci-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,26 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: python version
run: python --version
shell: bash

- name: Check for test files
id: check_tests
run: |
test_files=$(find ./solutions/tests -type f -name "test_*.py")
if [ -n "$test_files" ]; then
echo "Found test files:"
echo "$test_files"
echo "has_tests=true" >> $GITHUB_OUTPUT
else
echo "No test files found matching pattern ./solutions/tests/test_*.py"
echo "has_tests=false" >> $GITHUB_OUTPUT
fi
shell: bash

- name: Python - Run Tests
if: steps.check_tests.outputs.has_tests == 'true'
run: python -m unittest
shell: bash
15 changes: 14 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -113,5 +113,18 @@
},

// Enable/disable update table of contents on save
"markdown.extension.toc.updateOnSave": false
"markdown.extension.toc.updateOnSave": false,

"[python]": {
"editor.defaultFormatter": "charliermarsh.ruff",
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.fixAll.ruff": "explicit",
"source.organizeImports.ruff": "explicit"
}
},
"cSpell.words": [
"Falaq",
"Youniss"
]
}
10 changes: 4 additions & 6 deletions collaboration/guide/0_repository_setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,16 @@ take the time to do this correctly at the beginning.

## Setup and Share a Repository

As a team you will choose the name for your team and select
someone from your team to be the repo owner. This person will fork this
repository and configure it for collaboration:
As a team you will choose the name for your team and select someone from your
team to be the repo owner. This person will fork this repository and configure
it for collaboration:

- Public face of your repository
- Change your
[repository description](https://stackoverflow.com/questions/7757751/how-do-you-change-a-repository-description-on-github)
- Add or remove topics from your repository
- Update your main README with your group name and an initial overview of your

project. (You can change this as much as you want.)

project. (You can change this as much as you want.)
- Under settings in your repository select:
- _Issues_
- _Projects_
Expand Down
43 changes: 43 additions & 0 deletions solutions/IsPrime.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
A module for finding if an integer is prime.
Module contents:
- IsPrime: finds if an integer is prime.
Created on XX XX XX
@author: Mohammed Elfadil
"""


def IsPrime(a: int) -> str:
"""Checks if an integer is prime.
Parameter:
a: int
Return -> str: whether a is prime or not
Raises:
AssertionError: if the argument is not an integer
>>> IsPrime(0)
not prime
>>> IsPrime(1)
not prime
>>> IsPrime(2)
prime
>>> IsPrime(4)
not prime
>>> IsPrime(7)
prime
>>> IsPrime(2.5)
invalid input
>>> IsPrime(-1)
not prime
"""
if not isinstance(a, int):
return "invalid input"
if a < 2:
return "not prime"
for i in range(2, a):
if a % i == 0:
return "not prime"
return "prime"
1 change: 1 addition & 0 deletions solutions/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

57 changes: 57 additions & 0 deletions solutions/cumulative_sum.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Module: cumulative_sum
Description:
This module provides a function to calculate the cumulative sum of
a list of numbers(integers\float). It is useful for applications requiring progressive
accumulation of values, such as financial calculations, data analysis,
or custom mathematical operations.
Module Contents:
- cumulative_sum(numbers: list) -> list:
Computes and returns a list of cumulative sums from the input list.
Author: Falaq Youniss
Date: 29/12/2024
"""


def cumulative_sum(numbers: list) -> list:
"""
Computes the cumulative sum of a list of numbers.
Args:
numbers (list): A list of numeric values (integers or floats).
Returns:
list: A list where each element is the cumulative sum up to that index.
Raises:
AssertionError:
- If the input is not a list.
- If the list contains non-numeric values.
- If the input is `None`.
>>> cumulative_sum([1, 2, 3, 4])
[1, 3, 6, 10]
>>> cumulative_sum([-1, -2, -3, -4])
[-1, -3, -6, -10]
>>> cumulative_sum([1.0, 2.0, 3.0, 4.0])
[1.0, 3.0, 6.0, 10.0]
"""
# Validate input
assert numbers is not None, "Input cannot be None."
assert isinstance(numbers, list), "Input must be a list of numeric values."
assert all(
isinstance(num, (int, float)) for num in numbers
), "All elements in the list must be numeric."
# Compute cumulative sums
cumulative_list = []
current_sum = 0
for num in numbers:
current_sum += num
cumulative_list.append(current_sum)

return cumulative_list
56 changes: 56 additions & 0 deletions solutions/factorial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
A module for Computing the factorial of a non-negative integer n.
Module contents:
- factorial: is the product of all positive integers less than or equal to n.
Created on XX XX XX
@author: Saad M. Ashour
"""


def factorial(n: int) -> int:
"""
Computes the factorial of a non-negative integer n.
The factorial of a non-negative integer n
is the product of all positive integers less than or equal to n.
Parameters:
n (int): A non-negative integer.
Returns:
int: The factorial of the input integer n.
Raises:
ValueError: If n is negative, as factorial is not defined for negative numbers.
TypeError: If n is not an integer, as factorials are only defined for integers.
Examples:
>>> factorial(0)
1
>>> factorial(1)
1
>>> factorial(5)
120
>>> factorial(3)
6
"""
# Validate input type and value
if not isinstance(n, int):
raise TypeError("Input must be an integer.")

if n < 0:
raise ValueError("Factorial is not defined for negative numbers.")

# Base case for recursion: 0! = 1
if n == 0 or n == 1:
return 1

# Recursive case: n! = n * (n-1)!
return n * factorial(n - 1)
40 changes: 40 additions & 0 deletions solutions/is_even.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on XX XX XX
A module for checking to see if an integer is even.
@author: Luyando .E. Chitindi
"""


def is_even(number: int) -> bool:
"""
This checks if an integer is even.
Parameters:
number: int, the number to check
Returns -> bool:
True if the number is even, false otherwise.
Raises:
AssertionError: if the input is not an integer
Example:
>>> is_even(4)
True
>>> is_even(3)
False
>>> is_even(0)
True
>>> is_even("hello")
Traceback (most recent call last):
...
AssertionError: Input must be an integer.
"""
assert isinstance(number, int), "Input must be an integer"
if number % 2 == 0:
return True
return False
38 changes: 38 additions & 0 deletions solutions/is_positive.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on XX XX XX
A module for checking if an integer is positive.
@author: Luyando .E. Chitindi
"""


def is_positive(number: int) -> bool:
"""
This checks if an integer is positive.
Parameters:
number: int, the number to check
Returns -> bool:
True if the number is positive, false otherwise.
Raises:
AssertionError: if the input is not an integer
Example:
>>> is_positive(4)
True
>>> is_positive(-3)
False
>>> is_positive(0)
False
>>> is_positive("hello")
Traceback (most recent call last):
...
AssertionError: Input must be an integer.
"""
assert isinstance(number, int), "Input must be an integer"
return number > 0
34 changes: 34 additions & 0 deletions solutions/mean.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
A module for finding the mean of a list of numbers.
Module contents:
- mean: finds the mean of a list of numbers.
Created on 29/12/2024
@author: Mohammed Elfadil
"""


def mean(a: list) -> float:
"""Finds the mean of a list of numbers.
Parameter:
a: list
Return -> float: the mean of the list
Raises:
AssertionError: if the argument is not a list
>>> mean([1, 2, 3, 4, 5])
3.0
>>> mean([10, 20, 30, 40, 50])
30.0
>>> mean([1.5, 2.5, 3.5])
2.5
>>>mean([2])
2.0
"""
# check if the argument is a list
assert isinstance(a, list), "invalid input"

# return the mean of the list by dividing the sum of the list by the length of the list
return sum(a) / len(a)
Loading

0 comments on commit 057c110

Please sign in to comment.