{"id":25445623,"url":"https://github.com/kisaa-fatima/cryptarthematic-puzzle-","last_synced_at":"2026-05-01T04:37:50.803Z","repository":{"id":248240106,"uuid":"828161149","full_name":"Kisaa-Fatima/Cryptarthematic-puzzle-","owner":"Kisaa-Fatima","description":"Cryptarithmetic puzzles are intriguing mathematical problems where numbers are represented by letters or symbols. The objective is to decipher the correspondence between these symbols and digits in a way that satisfies a given arithmetic equation.","archived":false,"fork":false,"pushed_at":"2024-07-13T10:00:46.000Z","size":10,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-16T05:09:15.426Z","etag":null,"topics":["dfs-algorithm","python","ucs","uniform-cost-search"],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","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/Kisaa-Fatima.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":"2024-07-13T09:52:50.000Z","updated_at":"2025-02-09T13:53:06.000Z","dependencies_parsed_at":"2024-07-13T11:08:40.725Z","dependency_job_id":null,"html_url":"https://github.com/Kisaa-Fatima/Cryptarthematic-puzzle-","commit_stats":null,"previous_names":["kisaa-fatima/cryptarthematic-puzzle-"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Kisaa-Fatima/Cryptarthematic-puzzle-","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kisaa-Fatima%2FCryptarthematic-puzzle-","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kisaa-Fatima%2FCryptarthematic-puzzle-/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kisaa-Fatima%2FCryptarthematic-puzzle-/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kisaa-Fatima%2FCryptarthematic-puzzle-/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Kisaa-Fatima","download_url":"https://codeload.github.com/Kisaa-Fatima/Cryptarthematic-puzzle-/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kisaa-Fatima%2FCryptarthematic-puzzle-/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32485297,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-30T13:12:12.517Z","status":"online","status_checked_at":"2026-05-01T02:00:05.856Z","response_time":64,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["dfs-algorithm","python","ucs","uniform-cost-search"],"created_at":"2025-02-17T16:31:55.624Z","updated_at":"2026-05-01T04:37:50.756Z","avatar_url":"https://github.com/Kisaa-Fatima.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Cryptarithmetic Puzzles Solver\n\nCryptarithmetic puzzles are intriguing mathematical problems where numbers are represented by letters or symbols. The objective is to decipher the correspondence between these symbols and digits in a way that satisfies a given arithmetic equation.\n\n## Overview\n\nThis repository contains two algorithms implemented to solve cryptarithmetic puzzles using Depth-First Search (DFS) and Uniform Cost Search (UCS). These algorithms are designed to find the unique digit-letter mapping to make the given equation valid.\n\n## Algorithms\n## 1. Depth-First Search (DFS) \n**Running Time Complexity** \n Worst Case: O(10^8) because there are 8 letters and 10 possible digits.\n**Space Complexity** \nWorst Case: O(N) where N is the number of unique letters.\n**Solution Approach**\n- Search Space Representation: Each level represents a letter and each branch represents a possible assignment of a digit to that letter.\n- Backtracking: Start with an empty assignment and explore all possible assignments, backtracking when a constraint is violated.\n- Recursive Exploration: At each step, choose an unassigned letter and try assigning each possible digit.\n**Code Steps** \n- is_valid_assignment function: Checks if the assignment of digits to letters is valid.\n- dfs function: Recursively explores all possible assignments of digits to letters.\n- Main Function solve_cryptarithmetic_dfs: Initializes variables and calls the dfs function to find a solution.\n- Print the Solution: The main function prints the solution returned by solve_cryptarithmetic_dfs.\n## 2. Uniform Cost Search (UCS)\n**Running Time Complexity**\nWorst Case: O(10^N) where N is the number of unique letters.\n**Space Complexity**\nWorst Case: O(10^N) where N is the number of unique letters.\n**Solution Approach**\n- Priority Queue: Start with an empty queue, using a priority queue to keep track of states to explore.\n- Cost-Based Expansion: At each step, expand the current state by assigning a digit to the next unassigned letter and calculating the cost.\n- Goal Check: If the assignment satisfies the cryptarithmetic equation, return the assignment.\n**Code Steps**\n- State Class: Represents a state in the search space.\n- is_valid_assignment Function: Checks if a given assignment of digits to letters is valid.\n- solve_cryptarithmetic_ucs Function: Implements the UCS algorithm to solve the cryptarithmetic puzzle.\n- Defining the solve Function: Calls solve_cryptarithmetic_ucs and wraps it with the timeit decorator to measure its execution time.\n- Printing the Result: Calls the solve function and prints the result.\n## Observations\n**Uniform Cost Search (UCS)**\nAdvantages: Guarantees optimal solution by prioritizing states with lower costs.\nDisadvantages: High time and space complexity, especially for puzzles with many unique letters.\n**Depth-First Search (DFS)**\nAdvantages: Explores deep branches before backtracking.\nDisadvantages: Does not guarantee an optimal solution, and issues with completeness and optimality.\n**Best Algorithm (Opinion)**\nA Search:* Balances between completeness, optimality, and efficiency by using heuristic information to guide the search effectively.\n## Results\n**DFS Algorithm**\n- Running Time Complexity: O(10^8)\n- Space Complexity: O(N)\n**UCS Algorithm**\n-Running Time Complexity: O(10^N)\n-Space Complexity: O(10^N)\n**Optimal Configuration**\n- DFS: Suitable for smaller problems with fewer unique letters.\n- UCS: More reliable for ensuring optimal solutions but may require significant resources for larger problems.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkisaa-fatima%2Fcryptarthematic-puzzle-","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkisaa-fatima%2Fcryptarthematic-puzzle-","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkisaa-fatima%2Fcryptarthematic-puzzle-/lists"}