{"id":27215317,"url":"https://github.com/hulomjosuan21/codingproblems","last_synced_at":"2025-04-10T04:14:52.560Z","repository":{"id":281879003,"uuid":"946660619","full_name":"hulomjosuan21/codingProblems","owner":"hulomjosuan21","description":null,"archived":false,"fork":false,"pushed_at":"2025-03-23T13:28:32.000Z","size":180,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-10T04:14:49.605Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hulomjosuan21.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-03-11T13:37:32.000Z","updated_at":"2025-03-23T13:28:35.000Z","dependencies_parsed_at":null,"dependency_job_id":"858bc7a9-9db6-41d0-b1a1-395cfc1c8f12","html_url":"https://github.com/hulomjosuan21/codingProblems","commit_stats":null,"previous_names":["hulomjosuan21/coding_problems_practice","hulomjosuan21/codingproblems"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hulomjosuan21%2FcodingProblems","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hulomjosuan21%2FcodingProblems/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hulomjosuan21%2FcodingProblems/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hulomjosuan21%2FcodingProblems/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hulomjosuan21","download_url":"https://codeload.github.com/hulomjosuan21/codingProblems/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248154999,"owners_count":21056543,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-04-10T04:14:52.063Z","updated_at":"2025-04-10T04:14:52.544Z","avatar_url":"https://github.com/hulomjosuan21.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Prime Number Checker \nA prime number is a natural number greater than 1 that has only two factors: 1 and itself. The goal is to implement a function `is_prime_number(n)` that checks whether a given number `n` is prime. The function should return `True` if the number is prime and `False` otherwise.  \n\n```python\nimport math\n\ndef is_prime_number(n):\n    is_prime = True\n    if n \u003c= 1:\n        is_prime = False\n    elif n in (2, 3):\n        pass\n    elif n % 2 == 0:\n        is_prime = False\n    else:\n        for i in range(3, math.isqrt(n) + 1, 2):\n            if n % i == 0:\n                is_prime = False\n                break\n\n    return is_prime\n\nresult = \"Prime\" if is_prime_number(8) else \"Not Prime\"\nprint(result)  # Output: Not Prime\n```\n## Find Minimum and Maximum  \nGiven a list of numbers, implement a function `find_min_max(arr)` that returns a tuple containing the minimum and maximum values in the list. The function iterates through the list, updating the minimum and maximum values accordingly.  \n\n```python\ndef find_min_max(arr):\n    _min, _max = arr[0], arr[0]\n\n    for e in arr:\n        if e \u003c _min:\n            _min = e\n        if e \u003e _max:\n            _max = e\n\n    return _min, _max\n\nprint(findMinMax([1,2,3])) # Output: \"(1,3)\"\n```\nReverse a String  \nImplement a function `reverse_string(text)` that takes a string as input and returns the reversed version of it. The function iterates through the string in reverse order and constructs a new reversed string.  \n\n```python\ndef reverse_string(text):\n    temp = ''\n    # temp = text[::-1]\n\n    for i in range(len(text) - 1, -1, -1):\n        temp += text[i]\n\n    return temp\n\nprint(reverse_string(\"Josuan\"))  # Output: \"nausoJ\"\n```\n## Compute Factorial of a Number  \nImplement a function `compute_factorial_of_number(n)` that calculates the factorial of a given non-negative integer `n`. The factorial of a number `n` is the product of all positive integers from `1` to `n`.  \n\n```python\ndef compute_factorial_of_number(n):\n    if n in (0, 1):\n        return 1\n\n    result = 1\n    for i in range(2, n + 1):\n        result *= i\n\n    return result\n\nprint(compute_factorial_of_number(5))  # Output: 120\n```\n## Find Greatest Common Divisor (GCD)  \nImplement a function `find_GCD(a, b)` that calculates the greatest common divisor (GCD) of two integers `a` and `b` using the Euclidean algorithm. The GCD is the largest positive integer that divides both numbers without leaving a remainder.  \n\n```python\ndef find_GCD(a, b):\n    while b != 0:\n        a, b = b, a % b\n    return abs(a)\n\nprint(find_GCD(48, 18))  # Output: 6\n```\n## Check if a Number is a Palindrome  \nImplement a function `is_number_palindrome(n)` that checks whether a given number `n` is a palindrome. A palindrome is a number that reads the same forward and backward.  \n\n```python\ndef is_number_palindrome(n):\n    str_n = str(n)\n\n    reversed_str = ''\n    for i in range(len(str_n) - 1, -1, -1):\n        reversed_str += str_n[i]\n\n    return True if str_n == reversed_str else False\n\nprint(is_number_palindrome(102))  # Output: False\n```\n## Find the Nth Fibonacci Number  \nImplement a function `find_nth_fibonacci_number(n)` that returns the `n`th Fibonacci number. The Fibonacci sequence starts with `0` and `1`, and each subsequent number is the sum of the previous two.  \n\n```python\ndef find_nth_fibonacci_number(n):\n    if n in (0, 1):\n        return n\n\n    prev = 0\n    curr = 1\n\n    for _ in range(2, n + 1):\n        _next = prev + curr\n        prev = curr\n        curr = _next\n\n    return curr\n\nprint(find_nth_fibonacci_number(6))  # Output: 8\n```\n## Find the Missing Number  \nImplement a function `find_missing_number(arr)` that finds the missing number in a sequence of `n` consecutive integers starting from `1`. The function calculates the expected sum of numbers from `1` to `n` using the formula `n * (n + 1) / 2` and compares it to the actual sum of the given list to determine the missing number.  \n\n```python\ndef find_missing_number(arr):\n    n = len(arr) + 1\n    expected_sum = n * (n + 1) // 2\n\n    actual_sum = sum(arr)\n\n    return expected_sum - actual_sum\n\nprint(find_missing_number([1,2,3,4,5,7,8]))  # Output: 6\n```\n## Bubble Sort Algorithm  \nImplement a function `bubble_sort(arr)` that sorts a list of numbers in ascending order using the Bubble Sort algorithm. The algorithm repeatedly swaps adjacent elements if they are in the wrong order until the entire list is sorted.  \n\n```python\ndef bubble_sort(arr):\n    n = len(arr)\n\n    for i in range(n):\n        for j in range(n - i - 1):\n            if arr[j] \u003e arr[j + 1]:\n                arr[j], arr[j + 1] = arr[j + 1], arr[j]\n\n    return arr\n\nprint(bubble_sort([1,3,2,5,4]))  # Output: [1, 2, 3, 4, 5]\n```\n## Merge Two Sorted Arrays  \nImplement a function `mergeTwoSortedArray(arr1, arr2)` that merges two sorted arrays into a single sorted array. The function iterates through both arrays, comparing elements and appending the smaller one to the result. Any remaining elements are added at the end.  \n\n```python\ndef merge_two_sorted_array(arr1, arr2):\n    i, j = 0, 0\n\n    merged_arr = []\n\n    while i \u003c len(arr1) and j \u003c len(arr2):\n        if arr1[i] \u003c arr2[j]:\n            merged_arr.append(arr1[i])\n            i += 1\n        else:\n            merged_arr.append(arr2[j])\n            j += 1\n\n    while i \u003c len(arr1):\n        merged_arr.append(arr1[i])\n        i += 1\n\n    while j \u003c len(arr2):\n        merged_arr.append(arr2[j])\n        j += 1\n\n    return merged_arr\n\nprint(mergeTwoSortedArray([1,3,5],[2,4,6]))  # Output: [1, 2, 3, 4, 5, 6]\n```\n## Insertion Sort Algorithm  \nImplement a function `insertion_sort(arr)` that sorts a list of numbers in ascending order using the Insertion Sort algorithm. The algorithm builds a sorted sequence one element at a time by shifting larger elements to the right and inserting the current element into its correct position.  \n\n```python\ndef insertion_sort(arr):\n    n = len(arr)\n    for i in range(1, n):\n        temp = arr[i]\n        j = i - 1\n\n        while j \u003e= 0 and arr[j] \u003e temp:\n            arr[j + 1] = arr[j]\n            j -= 1\n\n        arr[j + 1] = temp\n\n    return arr\n\nprint(insertion_sort([1,3,2,5,4]))  # Output: [1, 2, 3, 4, 5]\n```\n## Get All Consonants  \nImplement a function `get_consonants()` that prints all consonants from the English alphabet. The function excludes vowels (`a, e, i, o, u`) and prints the remaining letters in lowercase.  \n\n```python\ndef get_consonants():\n    import string\n\n    vowels = \"aeiou\"\n\n    consonants = [letter for letter in string.ascii_lowercase if letter not in vowels]\n\n    print(\"\".join(consonants))\n\nget_consonants()  # Output: \"bcdfghjklmnpqrstvwxyz\"\n```\n## Count Character Frequency in a String  \nImplement a function `count_frequency_char_in_str(string)` that counts the frequency of each character in a given string. The function iterates through the string and keeps track of occurrences using a dictionary.  \n\n```python\ndef count_frequency_char_in_str(string):\n    counts = {}\n\n    for c in string:\n        if c in counts:\n            counts[c] += 1\n        else:\n            counts[c] = 1\n\n    return counts\n\nprint(count_frequency_char_in_str(\"jjjoosuan\"))  \n# Output: {'j': 3, 'o': 2, 's': 1, 'u': 1, 'a': 1, 'n': 1}\n```\n## Find First Non-Repeating Character  \nImplement a function `find_first_non_repeating_char(string)` that finds the first character in a given string that does not repeat. The function uses a dictionary to count occurrences and then identifies the first character with a count of `1`.  \n\n```python\ndef find_first_non_repeating_char(string):\n    char_count = {}\n\n    for c in string:\n        if c in char_count:\n            char_count[c] += 1\n        else:\n            char_count[c] = 1\n\n    s = ''\n\n    for k, v in char_count.items():\n        if v == 1:\n            s = k\n            break\n\n    return s\n\nprint(find_first_non_repeating_char(\"jjqmsjssaqqq\"))  # Output: \"m\"\n```\n## Find Median of Two Sorted Arrays  \nImplement a function `get_median_of_two_sorted_array(arr1, arr2)` that finds the median of two sorted arrays. The function merges both arrays into a single sorted array and returns the median value.  \n\n```python\ndef get_median_of_two_sorted_array(arr1, arr2):\n    merged_arr = sorted(arr1 + arr2)\n    n = len(merged_arr)\n\n    if n % 2 == 0:\n        mid1 = n // 2 - 1\n        mid2 = n // 2\n        return (merged_arr[mid1] + merged_arr[mid2]) / 2\n    else:\n        return merged_arr[n // 2]\n\nprint(get_median_of_two_sorted_array([1, 3, 5], [2, 4, 6]))  # Output: 3.5\n```\n## Two Sum Problem  \nImplement a function `two_sum_problem(arr, target)` that finds the indices of two numbers in an array that add up to a given target. The function iterates through the array and returns the first pair of indices whose sum equals the target.  \n\n```python\ndef two_sum_problem(arr, target):\n    n = len(arr)\n    x, y = -1, -1\n    for i in range(n):\n        for j in range(i + 1, n):\n            if arr[i] + arr[j] == target:\n                x, y = i, j\n                break\n        if x != -1:\n            break\n\n    return [x, y]\n\nprint(two_sum_problem([2, 7, 11, 15], 9))  # Output: [0, 1]\n```\n## Check If a String is a Palindrome  \nImplement a function `check_if_palindrome(string)` that checks whether a given string is a palindrome. A palindrome is a word, phrase, or sequence that reads the same forward and backward.  \n\n```python\ndef check_if_palindrome(string):\n    i, j = 0, len(string) - 1\n    while i \u003c j:\n        if string[i] != string[j]:\n            return False\n        i += 1\n        j -= 1\n    return True\n\nprint(check_if_palindrome(\"level\"))  # Output: True\nprint(check_if_palindrome(\"hello\"))  # Output: False\n```\n## Digital Decipher\n```python\ndef digital_decipher(s, key):\n    ascii_val = [ord(i) for i in s]\n\n    result = ''\n    for n in ascii_val:\n        result += chr(n-key)\n\n    return result\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhulomjosuan21%2Fcodingproblems","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhulomjosuan21%2Fcodingproblems","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhulomjosuan21%2Fcodingproblems/lists"}