{"id":23879211,"url":"https://github.com/tsembp/epl232-hw3","last_synced_at":"2026-04-22T05:33:14.206Z","repository":{"id":261211014,"uuid":"883615748","full_name":"tsembp/EPL232-HW3","owner":"tsembp","description":"Automated Latin Square Game - Panagiotis Tsembekis \u0026 Rafael Tsekouronas","archived":false,"fork":false,"pushed_at":"2024-11-30T08:20:34.000Z","size":1227,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-03T22:34:49.669Z","etag":null,"topics":["backtracking-algorithm","c","dynamic-memory-allocation","latinsquare","memory-management"],"latest_commit_sha":null,"homepage":"","language":"CSS","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/tsembp.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-11-05T09:28:01.000Z","updated_at":"2024-12-24T17:52:37.000Z","dependencies_parsed_at":"2025-01-03T22:44:35.875Z","dependency_job_id":null,"html_url":"https://github.com/tsembp/EPL232-HW3","commit_stats":null,"previous_names":["tsembp/epl232-hw3"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tsembp%2FEPL232-HW3","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tsembp%2FEPL232-HW3/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tsembp%2FEPL232-HW3/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tsembp%2FEPL232-HW3/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tsembp","download_url":"https://codeload.github.com/tsembp/EPL232-HW3/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240245903,"owners_count":19771033,"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":["backtracking-algorithm","c","dynamic-memory-allocation","latinsquare","memory-management"],"created_at":"2025-01-03T22:34:29.741Z","updated_at":"2026-04-22T05:33:09.158Z","avatar_url":"https://github.com/tsembp.png","language":"CSS","funding_links":[],"categories":[],"sub_categories":[],"readme":"@mainpage\n# EPL232 - Assignment 3 - Latin Square Solver 🧩\n\n## 📝 Overview\nA collaborative project by Panagiotis Tsembekis (UC1070326) and Rafael Tsekouronas (UC1070153).\n\nThis project implements a backtracking algorithm using a stack to solve the Latin Square puzzle. A Latin Square is an \\( n \\times n \\) grid where each row and column contains the numbers from 1 to \\( n \\) exactly once. The program reads an initial puzzle configuration from a file, solves it, and outputs the solution step-by-step.\n\n---\n\n## 🛠️ Features\n- Backtracking algorithm for puzzle solving.\n- Dynamically allocated 2D arrays for grid representation.\n- Stack-based backtracking to explore possible solutions.\n- Handles puzzles of various sizes as specified in the input file.\n- Reports all memory usage and leaks using `valgrind`.\n- Modular structure with separate `.c` and `.h` files for:\n  - Stack management.\n  - File handling.\n  - Solver logic.\n- Clear and informative error messages and outputs.\n- Handling of invalid .txt files passed in arguments for initial tableau.\n\n---\n\n## 🏗️ File Structure\n### Source Files\n- **`file.c` / `file.h`**: Handles reading the puzzle from a file and memory management of dynamic arrays.\n- **`stack.c` / `stack.h`**: Manages the stack operations (push, pop, and memory deallocation).\n- **`solver.c` / `solver.h`**: Implements the backtracking algorithm to solve the Latin Square.\n- **`latinSolver.c`**: Contains the main function and integrates the modules.\n\n### Input Files (Testers)\n- **`lsq2.txt`**: Another example input file for a 4x4 Latin Square.\n  ```text\n  4\n  0 0 0 -4\n  0 -2 0 0\n  0 0 0 0\n  0 0 0 -2\n  ```\n- **`lsq3.txt`**: Example input file for a 4x4 Latin Square with some cells pre-filled.\n  ```text\n  7\n  0 0 0 -4 0 -6 0\n  0 -2 0 0 -1 -7 0\n  0 -1 0 0 0 -3 0\n  0 0 0 -2 0 0 0\n  -6 -4 0 0 0 0 -1\n  0 0 0 0 0 0 0\n  -1 0 0 0 -5 0 -7\n  ```\n\n### Output\n- The program prints the step-by-step solution to the console, including:\n  - Current grid state for each step.\n  - Push and pop operations on the stack.\n  - Number of total `push` and `pop` operations performed when the puzzle is solved.\n\n---\n\n## 🏃 Compilation and Execution\n### Compilation\nTo compile the program, use the provided `Makefile`:\n```bash\nmake\n```\n\n### Execution\nRun the solver with an input file:\n```bash\n./latinSolver \u003cinput_file.txt\u003e\n```\nExample:\n```bash\n./latinSolver lsq1.txt\n```\n\n---\n\n## 🎞️ Memory Management\nAll dynamically allocated memory is freed before program termination. Use `valgrind` to verify memory safety:\n```bash\nvalgrind --leak-check=full ./latinSolver \u003cinput_file\u003e\n```\n\n---\n\n## 📄 Doxygen Documentation\nDoxygen comments are included throughout the source files. To generate documentation:\n1. Run the following command:\n   ```bash\n   doxygen Doxyfile\n   ```\n2. Open the `html/index.html` file in your browser for detailed documentation.\n\n---\n\n## Example Outputs\n### Input (`lsq1.txt`):\n```text\n4\n0 -2 0 -4\n-2 -3 0 0\n0 0 -1 -2\n0 0 0 -3\n```\n### Output:\n```text\nPUSH: STEP 1\n+-----+-----+-----+-----+\n|  1  | (2) |  0  | (4) |\n+-----+-----+-----+-----+\n...\n\nCongrats! Puzzle solved!\nPUSH NUM: 9\nPOP NUM: 0\n```\n\n---\n\n## Testing\nTest the solver with provided input files (`lsq2.txt` and `lsq3.txt`) or create your own. Ensure the input format matches:\n1. The first line specifies the size \\( n \\) of the grid.\n2. Subsequent lines contain \\( n \\) integers per line, separated by spaces.\n\n---\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftsembp%2Fepl232-hw3","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftsembp%2Fepl232-hw3","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftsembp%2Fepl232-hw3/lists"}