{"id":23544502,"url":"https://github.com/d3f0/mars_rover","last_synced_at":"2025-07-16T19:36:07.097Z","repository":{"id":139068484,"uuid":"537587977","full_name":"D3f0/mars_rover","owner":"D3f0","description":null,"archived":false,"fork":false,"pushed_at":"2022-09-18T12:50:55.000Z","size":905,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-15T08:45:13.565Z","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/D3f0.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":"2022-09-16T19:08:08.000Z","updated_at":"2022-09-17T20:16:48.000Z","dependencies_parsed_at":null,"dependency_job_id":"a555340d-08b2-41d3-b78b-b6c66f604d98","html_url":"https://github.com/D3f0/mars_rover","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/D3f0/mars_rover","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/D3f0%2Fmars_rover","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/D3f0%2Fmars_rover/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/D3f0%2Fmars_rover/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/D3f0%2Fmars_rover/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/D3f0","download_url":"https://codeload.github.com/D3f0/mars_rover/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/D3f0%2Fmars_rover/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265534895,"owners_count":23783910,"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":"2024-12-26T07:15:24.613Z","updated_at":"2025-07-16T19:36:07.091Z","avatar_url":"https://github.com/D3f0.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Mars Rover\n\n## Problem Statement\n\nA squad of robotic rovers are to be landed by NASA on a plateau on Mars. This\nplateau, which is flat and curiously rectangular, must be navigated by the\nrovers so that their on-board cameras can get a complete view of the surrounding\nterrain to send back to Earth. A rover's position and location are represented\nby a combination of x and y co-ordinates and a letter representing one of the\nfour cardinal compass directions. The plateau is divided up into a grid to\nsimplify navigation. An example position might be 0, 0, N, which means the rover\nis in the bottom left corner and facing North. In order to control a rover, NASA\nsends a simple string of letters. The possible letters are `L`, `R` and `M`. `L`\nand `R` makes the rover spin 90 degrees left or right respectively, without\nmoving from its current spot. 'M' means move forward one grid point, and\nmaintain the same heading. Assume that the square directly North from `(x, y)`\nis `(x, y+1)`.\n\n### Input\n\nThe first line of input is the upper-right coordinates of the plateau, the\nlower-left coordinates are assumed to be `0, 0`. The rest of the input is\ninformation pertaining to the rovers that have been deployed. Each rover has two\nlines of input. The first line gives the rover's position, and the second line\nis a series of instructions telling the rover how to explore the plateau. The\nposition is made up of two integers and a letter separated by spaces,\ncorresponding to the x and y co-ordinates and the rover's orientation. Each\nrover will be finished sequentially, which means that the second rover won't\nstart to move until the first one has finished moving. The output for each rover\nshould be its final co-ordinates and heading.\n\nConsider the following test input:\n\n```text\n5 5\n1 2 N\nLMLMLMLMM\n3 3 E\nMMRMMRMRRM\n```\n\nHere is the expected output:\n\n```text\n1 3 N\n5 1 E\n```\n\n## Proposed Solution\n\nIf the program find a rover out of bounds, it will abort.\n\n* Python 3.8+\n  * `argparse` CLI option parsing\n  * `re` regular expressions\n  * `dataclass` less verbose classes\n* Optional Dependencies (for Development and Testing)\n  * Pytest\n\n    Running test.\n  * Coverage\n\n    Checking coverage of tests\n  * IPython\n\n    Better interactive shell\n  * Pdb++\n\n    Drop in replacement for `pdb`, specially useful when debugging tests `py.test --pdb`\n\n  * Github Actions\n\n    * A Continuous Integration pipeline has been set up\n    to run the tests in Python 3.8, 3.9 and 3.10 [here](https://github.com/D3f0/mars_rover/actions/workflows/pytest.yaml). It also creates [Python wheels](https://realpython.com/python-wheels/) under the artifact tabs.\n    * A separate pipeline builds a Docker image that contains the\n      python program as [entrypoint](https://docs.docker.com/engine/reference/run/#entrypoint-default-command-to-execute-at-runtime)\n\n## How to run it\n\nThe project can be run with Python 3.8 and above. It doesn't require any external library.\nRunning the tests and packing it as a Python wheel require [poetry](https://python-poetry.org).\n\n### Makefile\n\nThis method doesn't require to install anything, just run `make run`. It will run the code\nin interactive mode. Note that given the limitations of passing arguments to `make` the file mode\nis not supported.\n\n### Command Line Interface\n\nOnce installed though pip, the script `mars_rover` should be available in your path.\nThis program can either run interactively `-i` or passing a file as input `-I`.\n\nThe wheel for pip installation is available in Github artifacts. Please note that\nthis is not PyPI and requires unzipping the file first, and the download is available\nonly for 90 days. Alternatively a Docker image has been published to Github Container\nRegistry.\n\n```bash\n# Running the command without arguments shows the usage\nusage: Mars Rover [-h] [-I INPUT_FILE] [-i] [-l LOG_LEVEL]\n\nThis software simulates the movements of a Mars Rover based on L(eft), R(ight) andM(ove forward) text characters. It\nsimulates the rovers sequentially. Use Ctrl+D to finalize the input.\n\noptional arguments:\n  -h, --help            show this help message and exit\n  -I INPUT_FILE, --input-file INPUT_FILE\n  -i, --stdin           Read input from stdin\n  -l LOG_LEVEL, --log-level LOG_LEVEL\n                        Set the logging level\n\n```\n\n#### Interactive mode\n\n*Note that an end of file is expected at the end, use `Ctrl+E` in Unix based OSs to produce it*\n\n```bash\n$ mars_rover -i\n10 10\n5 5 N\nMRMLMMRL\n6 8 N\n\n```\n\n#### Using an input file\n\n```bash\nmars_rover -I src/tests/case_01/input.txt\n```\n\n### Python interface\n\n*Note that this approach requires some interactive shell like IPython*\n\nInstall the Python wheel, and run it from the terminal as follows:\n\n```python\nfrom mars_rover.entities import Plateau, Rover\n\np = Plateau(5, 5)\nr = Rover((1, 1), \"N\")\nr.simulate(\"LLMRM\", p)\nprint(r)\n```\n\n### Installing the wheel\n\nPython wheels are the newest standard for Python distribution. Although this\nproject is not published in Python official package index PyPI, the CI pipeline\nproduces wheels as artifacts. To grab the latest build\n\n1. Go to Github Actions for the project [here](here)\n2. Locate the zip compressed wheel at the bottom of the page.\n    ![img](./docs/img/download_artifact.png)\n3. Download the file and unzip it.\n4. Install it with `python -m pip install path/to/mars_rover-0.1.0-py3-none-any.whl`\n\n\n\n## Running inside Docker\n\nIf Docker is available in your environment, this repository automatically pushes a docker image to Github Container Registry.\n\nTo run the program inside docker `-t` (tty allocation) and `-i` (interactive) flags must be provided.\n\n```bash\ndocker run --rm -ti ghcr.io/d3f0/mars_rover:latest -i\n```\n\n![docker execution](./docs/img/docker_execution.jpg)\n\n## Program Design\n\nThe program uses `argparse` to parse command line invocations. It works with streams,\nor file-like objects as input, so there's no interaction.\n\nThe input parsing is done with the `re` library for regular expressions. When an occurs\nthe shorthand `sys.exit()` is used to inform the user what went wrong.\n\n\n\n## Contributing to the Project\n\n### Using Github CodeSpaces\n\n1. Locate Open Code Spaces in Github web UI\n    ![Code Spaces](./docs/img/open_codespaces.png)\n2. Wait until the VSCode environment is operational\n   and run `poetry install` in the terminal. This will\n   leave the Python package `mars_rover` in editable state, any changes to the scripts will be reflected when running the `mars_rover` script in the path.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fd3f0%2Fmars_rover","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fd3f0%2Fmars_rover","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fd3f0%2Fmars_rover/lists"}