{"id":24087307,"url":"https://github.com/abdulrahim-ramadan/hackerrank-tests","last_synced_at":"2026-02-13T23:09:36.221Z","repository":{"id":251613285,"uuid":"837912536","full_name":"abdulrahim-ramadan/HackerRank-Tests","owner":"abdulrahim-ramadan","description":"This repository contains solutions to coding challenges as part of the Python certification test from HackerRank. These challenges are designed to test proficiency in Python programming through real-world problem-solving scenarios.","archived":false,"fork":false,"pushed_at":"2024-12-04T00:58:39.000Z","size":20,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-05T19:04:20.034Z","etag":null,"topics":["certification","hackerrank","python3","test"],"latest_commit_sha":null,"homepage":"","language":null,"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/abdulrahim-ramadan.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,"zenodo":null}},"created_at":"2024-08-04T12:18:02.000Z","updated_at":"2025-03-08T18:02:25.000Z","dependencies_parsed_at":"2025-05-05T18:48:47.207Z","dependency_job_id":"9d68f597-3ccc-4438-b1dc-e8676d034e35","html_url":"https://github.com/abdulrahim-ramadan/HackerRank-Tests","commit_stats":null,"previous_names":["abdulrahim-ramadan/hackerrank-tests-"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/abdulrahim-ramadan/HackerRank-Tests","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abdulrahim-ramadan%2FHackerRank-Tests","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abdulrahim-ramadan%2FHackerRank-Tests/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abdulrahim-ramadan%2FHackerRank-Tests/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abdulrahim-ramadan%2FHackerRank-Tests/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/abdulrahim-ramadan","download_url":"https://codeload.github.com/abdulrahim-ramadan/HackerRank-Tests/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abdulrahim-ramadan%2FHackerRank-Tests/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29422550,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-13T22:20:51.549Z","status":"ssl_error","status_checked_at":"2026-02-13T22:20:49.838Z","response_time":78,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["certification","hackerrank","python3","test"],"created_at":"2025-01-10T03:03:41.929Z","updated_at":"2026-02-13T23:09:36.187Z","avatar_url":"https://github.com/abdulrahim-ramadan.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"### Python Certification Test Solutions\n\nWelcome to my repository showcasing solutions for the HackerRank Python certification test. These solutions demonstrate my proficiency in Python programming and problem-solving skills.\n\n**Certification:** [HackerRank Certificate](https://www.hackerrank.com/certificates/857fc25f5ac2)\n\n\n## Challenges\n\n### 1. Vending Machine\n\nCreate a `VendingMachine` class to simulate a vending machine where users can buy items, and the machine tracks items and money transactions.\n\n**Class: VendingMachine**\n\n- **`__init__(self, num_items, item_price)`**\n  - **Parameters:**\n    - `num_items` (int): Initial number of items.\n    - `item_price` (float): Price per item.\n  - **Description:**\n    - Initializes the vending machine with the number of items and price.\n\n- **`buy(self, req_items, money)`**\n  - **Parameters:**\n    - `req_items` (int): Number of items to buy.\n    - `money` (float): Amount of money inserted.\n  - **Returns:**\n    - Remaining change if successful.\n    - `\"not enough items in the machine\"` if there are insufficient items.\n    - `\"not enough coins\"` if the money is insufficient.\n  - **Description:**\n    - Processes the purchase of items and handles money transactions.\n\n**Example Implementation:**\n\n```python\nclass VendingMachine:\n    def __init__(self, num_items, item_price):\n        self.num_items = num_items\n        self.item_price = item_price\n    \n    def buy(self, req_items, money):\n        total_cost = req_items * self.item_price\n        \n        if req_items \u003e self.num_items:\n            return \"not enough items in the machine\"\n        if money \u003c total_cost:\n            return \"not enough coins\"\n        \n        self.num_items -= req_items\n        return round(money - total_cost, 2)\n```\n\n---\n\n### 2. Shape Classes with Area Method\n\nImplement two classes: `Rectangle` and `Circle`, which compute their areas.\n\n**Rectangle Class:**\n\n- **`__init__(self, length, width)`**\n  - **Parameters:**\n    - `length` (int): Length of the rectangle.\n    - `width` (int): Width of the rectangle.\n  - **Description:**\n    - Initializes the rectangle with length and width.\n\n- **`area(self)`**\n  - **Returns:**\n    - Area of the rectangle.\n  - **Description:**\n    - Calculates the area of the rectangle.\n\n**Circle Class:**\n\n- **`__init__(self, radius)`**\n  - **Parameters:**\n    - `radius` (int): Radius of the circle.\n  - **Description:**\n    - Initializes the circle with radius.\n\n- **`area(self)`**\n  - **Returns:**\n    - Area of the circle using π.\n  - **Description:**\n    - Calculates the area of the circle.\n\n**Implementation:**\n\n```python\nimport math\n\nclass Rectangle:\n    def __init__(self, length, width):\n        self.length = length\n        self.width = width\n    \n    def area(self):\n        return self.length * self.width\n\nclass Circle:\n    def __init__(self, radius):\n        self.radius = radius\n    \n    def area(self):\n        return math.pi * self.radius ** 2\n\nif __name__ == \"__main__\":\n    import sys\n    input = sys.stdin.read\n    data = input().split()\n    \n    num_queries = int(data[0])\n    results = []\n    \n    index = 1\n    for _ in range(num_queries):\n        shape_type = data[index]\n        if shape_type == 'rectangle':\n            length = int(data[index + 1])\n            width = int(data[index + 2])\n            rect = Rectangle(length, width)\n            results.append(f\"{rect.area():.2f}\")\n            index += 3\n        elif shape_type == 'circle':\n            radius = int(data[index + 1])\n            circ = Circle(radius)\n            results.append(f\"{circ.area():.2f}\")\n            index += 2\n    \n    for result in results:\n        print(result)\n```\n\n---\n\n### 3. String Transformation\n\nTransform a sentence based on specific rules for each word:\n- The first character remains unchanged.\n- For each subsequent character, compare it to the preceding character:\n  - If the preceding character comes earlier in the alphabet, transform the current character to uppercase.\n  - If the current character comes earlier in the alphabet, transform it to lowercase.\n  - If the characters are the same, leave the current character unchanged.\n\n**Function Description:**\n\n**`transformSentence(sentence: str) -\u003e str`**\n\n- **Parameters:**\n  - `sentence` (str): The input sentence.\n- **Returns:**\n  - Transformed sentence as a string.\n\n**Implementation:**\n\n```python\nimport os\n\ndef transformSentence(sentence):\n    # Split the sentence into words\n    words = sentence.split()\n    transformed_words = []\n    \n    # Process each word in the sentence\n    for word in words:\n        if not word:\n            transformed_words.append('')\n            continue\n        \n        # Start with the first character unchanged\n        transformed_word = word[0]\n        \n        # Process the rest of the characters\n        for i in range(1, len(word)):\n            prev_char = word[i - 1]\n            current_char = word[i]\n            \n            # Compare characters in a case-insensitive manner\n            if prev_char.lower() \u003c current_char.lower():\n                transformed_word += current_char.upper()\n            elif prev_char.lower() \u003e current_char.lower():\n                transformed_word += current_char.lower()\n            else:\n                transformed_word += current_char\n        \n        # Append the transformed word to the list\n        transformed_words.append(transformed_word)\n    \n    # Join the transformed words with spaces and return the final sentence\n    return ' '.join(transformed_words)\n\nif __name__ == '__main__':\n    # Read the input from standard input\n    sentence = input().strip()  # Remove any leading/trailing whitespace\n    \n    # Get the transformed sentence\n    result = transformSentence(sentence)\n    \n    # Write the result to standard output (or a file in the competition environment)\n    print(result)\n\n```\n\n---\n\n## Disclaimer\n\nThese solutions are personal implementations for the HackerRank Python Certification challenges. They are intended to showcase problem-solving skills and coding abilities. Please use these solutions for educational purposes and contribute your own unique solutions to the learning community.\n\nAll content related to the challenges is © HackerRank. For more challenges and to improve your coding skills, visit [HackerRank](https://www.hackerrank.com/).\n\n## License\n\nThis project is licensed under the [MIT License](LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabdulrahim-ramadan%2Fhackerrank-tests","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fabdulrahim-ramadan%2Fhackerrank-tests","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabdulrahim-ramadan%2Fhackerrank-tests/lists"}