Skip to content

Commit

Permalink
Merge branch 'main' into least-common-multiple
Browse files Browse the repository at this point in the history
  • Loading branch information
kefahalshaer authored Jan 13, 2025
2 parents c8e6c13 + 3c27da4 commit 00510a9
Show file tree
Hide file tree
Showing 6 changed files with 291 additions and 1 deletion.
6 changes: 6 additions & 0 deletions collaboration/learning_goals.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,9 @@ to write solid and detailed unit tests.
- Improve my programming skills in Python, especially in writing unit test programs
- Mastering Code Review, making PRs, and the other GitHub teams' tasks.
- Improve my communication with the team.

### *Tamir El-Waleed*

- Improve my testing skills, in addition to mastering basic Git & Github behavior.
- Create a complete project from scratch, building my portfolio in the process.

41 changes: 40 additions & 1 deletion collaboration/retrospective.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,59 @@

## Stop Doing

- Missing meetings.
- Absence of effective communication.
- Non-compliance with deadlines.
- Not adhering to group norms strictly.

## Continue Doing

- Collaborative work.
- Access to support whenever needed.
- Open to learn and to ask.
- Consistency with work.
- Good and organized planning.

## Start Doing

- Use the GitHub discussion section more frequently.
- Peer programming.
- Detailed documentation of work and activities.
- Create a detailed project timeline.
- Assign tasks and roles at the outset of the project.
- Keep meetings shorter and on a fixed agreed-upon day.
- Understand everyone’s strengths and weaknesses, then build a common ground.

## Lessons Learned

- GitHub workflow.
- Project management.
- VScode workflow.
- Navigating issues related to Python, GitHub, and VSCode.
- Flexibility.
- Clear communication is the key for asynchronous collaboration.

______________________________________________________________________

## Strategy vs. Board

### What parts of your plan went as expected?

- Communication with the team.
- Collaborating on GitHub.
- The majority of team members were able to meet the project's main requirements
before the final deadline.
- All team members were cautious with the repository.

### What parts of your plan did not work out?

- **Internal deadline:** Some team members missed it.
- **Time management and availability:** Coordinating meetings with all team members
was quite challenging.

### Did you need to add things that weren't in your strategy?

### Or remove extra steps?
- Include an alternative communication medium.
- Ensure that everyone is on the same page and understands the workflow.
- Utilize a task management tool such as **_Asana_** or **_Trello_** for more insights
and details into the progress of each team member.
56 changes: 56 additions & 0 deletions solutions/maximum_length.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
A module to find the maximum length of the
concatenation of a subsequence of arr that has unique characters.
Return the maximum possible length of s
Module contents:
- maxLength: Function to get the Maximum Length of a Concatenated String with Unique Characters
- backtrack: Helper function to perform backtracking
Created on 2024-01-12
Author: Kefah Albashityalshaer
"""


def max_length(arr: list) -> int:
"""
Function to get the Maximum Length of a Concatenated String with Unique Characters
Takes a list of strings and returns the max length of concatenated string with unique characters
Parameters:
arr: list of stings elements to process
Returns -> int: the maximum length
Examples:
>>> max_length(["un","iq","ue"])
4
>>> max_length(["cha","r","act","ers"])
6
>>> max_length(["abcdefghijklmnopqrstuvwxyz"])
26
>>> max_length(["a", "bb", "ccc"])
1
>>> max_length([])
0
"""
assert isinstance(arr, list), "input should be a list of strings"

# Helper function to perform backtracking
def backtrack(index, current_string):
# If the current string has duplicate characters, return 0
if len(current_string) != len(set(current_string)):
return 0

# Calculate the maximum length by trying to add each subsequent string
max_length = len(current_string)
for i in range(index, len(arr)):
max_length = max(max_length, backtrack(i + 1, current_string + arr[i]))
return max_length

# Start the backtracking from index 0 and an empty string
return backtrack(0, "")
44 changes: 44 additions & 0 deletions solutions/min_integer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
A module for obtaining min integer from a list.
Module contents:
- min_integer: Returns minimum integer from a list of integers
Created on 2025-01-09
Author: Tamir Elwaleeed
"""


def min_integer(my_list: list) -> int:
"""Returns the min integer in a list of integers
If the list is empty, the function returns None
Parameters:
my_list: list, the list to find the min from
Returns -> int: the min integer from the list
Raises:
AssertionError: if input is not a list
Examples:
>>> min_integer([1, 2, 3, 4, 5])
1
>>> min_integer([-1, -4, -5])
-5
>>> min_integer([])
None
"""
assert isinstance(my_list, list), "input must be a list"

if len(my_list) == 0:
return None
result = my_list[0]
i = 1
while i < len(my_list):
if my_list[i] < result:
result = my_list[i]
i += 1
return result
70 changes: 70 additions & 0 deletions solutions/tests/test_maximum_length.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Test module for maximum_length function.
Test categories:
- Standard cases: list of strings that may have unique or overlapping characters
- Edge cases: empty lists, strings with identical bounds or duplicate characters, substrings with repetitive letters
- Defensive tests: invalid inputs, assertions, or `TypeError` exceptions
Created on 2024-01-12
Author: Kefah Albashityalshaer
"""

import unittest

from ..maximum_length import max_length


class TestMaxLengthFunction(unittest.TestCase):
# Standard test cases
def test_basic_cases(self):
self.assertEqual(
max_length(["un", "iq", "ue"]), 4
) # "uniq" forms a concatenated string of length 4
self.assertEqual(
max_length(["cha", "r", "act", "ers"]), 6
) # The longest concatenated string is "acters" (length 6)
self.assertEqual(
max_length(["abcdefghijklmnopqrstuvwxyz"]), 26
) # The string contains all unique lowercase letters (length 26)

# Edge Cases
def test_empty_list(self):
self.assertEqual(
max_length([]), 0
) # No strings to concatenate, so the result is 0

def test_single_element(self):
self.assertEqual(max_length(["a"]), 1)
self.assertEqual(max_length(["abcdef"]), 6)

def test_no_unique_concatenation(self):
self.assertEqual(max_length(["a", "bb", "ccc"]), 1)

def test_repeated_characters(self):
self.assertEqual(max_length(["abc", "def", "abc"]), 6)

def test_large_input(self):
arr = ["ab", "cd", "ef", "gh", "ij", "kl", "mnop"]
self.assertEqual(max_length(arr), 16) # Longest possible combination

# Defensive tests
def test_invalid_input(self):
with self.assertRaises(
AssertionError,
msg="Input should raise an AssertionError for non-list input.",
):
max_length("not a list")

def test_non_string_input(self):
with self.assertRaises(TypeError):
max_length(["abc", 123, "def"])

def test_empty_strings(self):
self.assertEqual(max_length(["", "abc", "de"]), 5)


if __name__ == "__main__":
unittest.main()
75 changes: 75 additions & 0 deletions solutions/tests/test_min_integer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Test module for min_integer function.
Test categories:
- Standard cases: typical lists with different lengths
- Edge cases: empty lists, single elements, strings
- Defensive tests: wrong input types, assertions
Created on 2025-01-09
Author: Tamir Elwaleeed
"""

import unittest
from ..min_integer import min_integer


class TestMinInteger(unittest.TestCase):
"""Define unittests for min_integer([..])."""

def test_ordered_list(self):
"""Test an ordered list of integers."""
ordered = [1, 2, 3, 4]
self.assertEqual(min_integer(ordered), 1)

def test_unordered_list(self):
"""Test an unordered list of integers."""
unordered = [1, 2, 4, 3]
self.assertEqual(min_integer(unordered), 1)

def test_min_at_beginning(self):
"""Test a list with a beginning min value."""
min_at_beginning = [1, 4, 3, 2]
self.assertEqual(min_integer(min_at_beginning), 1)

def test_empty_list(self):
"""Test an empty list."""
empty = []
self.assertEqual(min_integer(empty), None)

def test_one_element_list(self):
"""Test a list with a single element."""
one_element = [7]
self.assertEqual(min_integer(one_element), 7)

def test_floats(self):
"""Test a list of floats."""
floats = [1.53, 6.33, -9.123, 15.2, 6.0]
self.assertEqual(min_integer(floats), -9.123)

def test_ints_and_floats(self):
"""Test a list of ints and floats."""
ints_and_floats = [1.53, 15.5, -9, 15, 6]
self.assertEqual(min_integer(ints_and_floats), -9)

def test_string(self):
"""Test a string."""
string = "Brennan"
with self.assertRaises(AssertionError):
min_integer(string)

def test_list_of_strings(self):
"""Test a list of strings."""
strings = ["Brennan", "is", "my", "name"]
self.assertEqual(min_integer(strings), "Brennan")

def test_empty_string(self):
"""Test an empty string."""
with self.assertRaises(AssertionError):
min_integer("")


if __name__ == "__main__":
unittest.main()

0 comments on commit 00510a9

Please sign in to comment.