From a5ad219e061f6f3867f628c1dadd9abf4f3869bd Mon Sep 17 00:00:00 2001 From: gamodyarajasooriya Date: Sat, 15 Mar 2025 10:13:23 +0000 Subject: [PATCH 1/6] My solution for the finding prime factors of integer values. --- src/01 Find Prime Factors/findingprimefactors.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 src/01 Find Prime Factors/findingprimefactors.py diff --git a/src/01 Find Prime Factors/findingprimefactors.py b/src/01 Find Prime Factors/findingprimefactors.py new file mode 100644 index 0000000..e69de29 From d47bafba1983bfc1680770231b444e996e6a3a4c Mon Sep 17 00:00:00 2001 From: gamodyarajasooriya Date: Sat, 15 Mar 2025 13:35:27 +0000 Subject: [PATCH 2/6] Succesfully cpmpleted challenge finding prime factors --- .../findingprimefactors.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/01 Find Prime Factors/findingprimefactors.py b/src/01 Find Prime Factors/findingprimefactors.py index e69de29..7afe94a 100644 --- a/src/01 Find Prime Factors/findingprimefactors.py +++ b/src/01 Find Prime Factors/findingprimefactors.py @@ -0,0 +1,17 @@ +def get_prime_factors(number): + factors=[] + factor=2 + while factor<=number: + if (number%factor==0): + factors.append(factor) + number=number/factor + else: + factor=factor+1 + return factors + + + +print(get_prime_factors(21)) +print(get_prime_factors(2300)) +print(get_prime_factors(347)) +print(get_prime_factors(0)) \ No newline at end of file From 22fb215867b9c076a8c682fc81a40cb33ca9c8d8 Mon Sep 17 00:00:00 2001 From: gamodyarajasooriya Date: Sun, 16 Mar 2025 14:20:32 +0000 Subject: [PATCH 3/6] Successfully completed the chaleenge with all requirements --- .vscode/settings.json | 1 - 1 file changed, 1 deletion(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 2369810..ca20f95 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -17,7 +17,6 @@ "files.autoSave": "afterDelay", "screencastMode.onlyKeyboardShortcuts": true, "terminal.integrated.fontSize": 18, - "workbench.activityBar.visible": true, "workbench.colorTheme": "Visual Studio Dark", "workbench.fontAliasing": "antialiased", "workbench.statusBar.visible": true From 4a93840169cd5acf2fa1e7e0e0bcbcdd88f8633f Mon Sep 17 00:00:00 2001 From: gamodyarajasooriya Date: Sun, 16 Mar 2025 15:11:07 +0000 Subject: [PATCH 4/6] My solution for identifying a palindrome --- .../identifyingpalindrome.py | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 src/02 Identify a Palindrome/identifyingpalindrome.py diff --git a/src/02 Identify a Palindrome/identifyingpalindrome.py b/src/02 Identify a Palindrome/identifyingpalindrome.py new file mode 100644 index 0000000..2716170 --- /dev/null +++ b/src/02 Identify a Palindrome/identifyingpalindrome.py @@ -0,0 +1,25 @@ +def palindrome(string): + text = "" + reversed_text = "" + + for char in string: + if char!=" ": + text+=char.lower() + + + + for char in reversed(string): + if char!=" ": + reversed_text+=char.lower() + + + return reversed_text==text + + + +print(palindrome("No lemon no melon")) +print(palindrome("race car")) +print(palindrome("hello")) + + + From fddba317af664107520ec5cc3a106d70191d247b Mon Sep 17 00:00:00 2001 From: Gamodya Rajasooriya Date: Sat, 28 Jun 2025 09:08:16 +0000 Subject: [PATCH 5/6] Sorting a string --- .vscode/settings.json | 8 ++++++-- src/03 Sort a String/mysolution.py | 9 +++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 src/03 Sort a String/mysolution.py diff --git a/.vscode/settings.json b/.vscode/settings.json index ca20f95..0aeb945 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -19,5 +19,9 @@ "terminal.integrated.fontSize": 18, "workbench.colorTheme": "Visual Studio Dark", "workbench.fontAliasing": "antialiased", - "workbench.statusBar.visible": true -} + "workbench.statusBar.visible": true, + "githubPullRequests.ignoredPullRequestBranches": [ + "main" + ], + "python.REPL.enableREPLSmartSend": false +} \ No newline at end of file diff --git a/src/03 Sort a String/mysolution.py b/src/03 Sort a String/mysolution.py new file mode 100644 index 0000000..7c0b0d2 --- /dev/null +++ b/src/03 Sort a String/mysolution.py @@ -0,0 +1,9 @@ +def sort_words(s): + words = s.split() + words.sort(key=str.lower) + return ' '.join(words) + + +result = sort_words('banana ORANGE apple') +print(result) + From 599c934f10469596a55c1b71ea3835a7ed60f974 Mon Sep 17 00:00:00 2001 From: Gamodya Rajasooriya Date: Sat, 28 Jun 2025 10:07:56 +0000 Subject: [PATCH 6/6] My solution for finding an item in a list --- src/04 Find All List Items/Find_a_list_item.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 src/04 Find All List Items/Find_a_list_item.py diff --git a/src/04 Find All List Items/Find_a_list_item.py b/src/04 Find All List Items/Find_a_list_item.py new file mode 100644 index 0000000..67dc9d7 --- /dev/null +++ b/src/04 Find All List Items/Find_a_list_item.py @@ -0,0 +1,16 @@ +def index_all(obj, item): + result = [] + + def search(sub_obj, path): + if isinstance(sub_obj, list): + for i, element in enumerate(sub_obj): + search(element, path + [i]) + else: + if sub_obj == item: + result.append(path) + + search(obj, []) + return result +example = [[[1, 2, 3], 2, [1, 3]], [1, 2, 3]] + +print(index_all(example, 1)) \ No newline at end of file