{"id":45521441,"url":"https://github.com/vspiliop/martian-robots","last_synced_at":"2026-02-22T23:00:05.589Z","repository":{"id":55535625,"uuid":"284487079","full_name":"vspiliop/martian-robots","owner":"vspiliop","description":"Coding exercise: The martian robots/ rovers problem in Java with a functional twist..","archived":false,"fork":false,"pushed_at":"2022-05-31T14:49:53.000Z","size":64,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-03-17T10:45:59.452Z","etag":null,"topics":["functional-programming","immutable-collections","immutable-objects","java","pure-function","vavr"],"latest_commit_sha":null,"homepage":"","language":"Java","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/vspiliop.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}},"created_at":"2020-08-02T15:19:36.000Z","updated_at":"2024-03-17T10:45:59.454Z","dependencies_parsed_at":"2022-08-15T02:40:59.973Z","dependency_job_id":null,"html_url":"https://github.com/vspiliop/martian-robots","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/vspiliop/martian-robots","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vspiliop%2Fmartian-robots","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vspiliop%2Fmartian-robots/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vspiliop%2Fmartian-robots/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vspiliop%2Fmartian-robots/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vspiliop","download_url":"https://codeload.github.com/vspiliop/martian-robots/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vspiliop%2Fmartian-robots/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29730201,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-22T20:09:16.275Z","status":"ssl_error","status_checked_at":"2026-02-22T20:09:13.750Z","response_time":110,"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":["functional-programming","immutable-collections","immutable-objects","java","pure-function","vavr"],"created_at":"2026-02-22T23:00:04.013Z","updated_at":"2026-02-22T23:00:05.572Z","avatar_url":"https://github.com/vspiliop.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Approach\n\nOO design but with a functional twist :-)\n\n - Keep method signatures clear: Refactored to use the `Either` and `Try` monads of `Vavr` to avoid throwing exceptions.\n - All possible errors are handled via `Either` composition.\n - Object Oriented design for the `Robot`, `MarsSurface`, `Orientation` and `Cartesian Coordinates`.\n - For `MarsSurface` a purely functional and immutable HashSet is used from `Vavr`. \n - `Robot`, `MarsSurface`, `Orientation` and `Cartesian Coordinates` are immutable and threadsafe.\n - Models an instruction as a `Function` that takes a `Robot` (or in case of an already failed execution of a previous instruction, an `IllegalArgumentException`) and returns a new `Robot` or an `IllegalArgumentException`, if the current executing command failed or a previous one did.\n - Specifically, an instruction is defined as `Function\u003cEither\u003cIllegalArgumentException, Robot\u003e, Either\u003cIllegalArgumentException, Robot\u003e\u003e`.\n - `InstructionChain` are chained such instructions via `andThen()`.\n\n## The Problem\n\nThe surface of Mars can be modelled by a rectangular grid around which robots are able to\nmove according to instructions provided from Earth. You are to write a program that\ndetermines each sequence of robot positions and reports the final position of the robot.\nA robot position consists of a grid coordinate (a pair of integers: x-coordinate followed by\ny-coordinate) and an orientation (N, S, E, W for north, south, east, and west).\nA robot instruction is a string of the letters “L”, “R”, and “F” which represent, respectively, the\ninstructions:\n - Left: the robot turns left 90 degrees and remains on the current grid point.\n - Right: the robot turns right 90 degrees and remains on the current grid point.\n - Forward: the robot moves forward one grid point in the direction of the current\norientation and maintains the same orientation.\n\nThe direction North corresponds to the direction from grid point (x, y) to grid point (x, y+1).\nThere is also a possibility that additional command types may be required in the future and\nprovision should be made for this.\n\nSince the grid is rectangular and bounded (...yes Mars is a strange planet), a robot that moves\n“off” an edge of the grid is lost forever. However, lost robots leave a robot “scent” that \nprohibits future robots from dropping off the world at the same grid point. The scent is left at\nthe last grid position the robot occupied before disappearing over the edge. An instruction to\nmove “off” the world from a grid point from which a robot has been previously lost is simply\nignored by the current robot.\n\n### The Input\n\nThe first line of input is the upper-right coordinates of the rectangular world, the lower-left\ncoordinates are assumed to be 0, 0.\n\nThe remaining input consists of a sequence of robot positions and instructions (two lines per\nrobot). A position consists of two integers specifying the initial coordinates of the robot and an\norientation (N, S, E, W), all separated by whitespace on one line. A robot instruction is a string\nof the letters “L”, “R”, and “F” on one line.\n\nEach robot is processed sequentially, i.e., finishes executing the robot instructions before the\nnext robot begins execution.\n\nThe maximum value for any coordinate is 50.\n\nAll instruction strings will be less than 100 characters in length.\n\n### The Output\n\nFor each robot position/instruction in the input, the output should indicate the final grid\nposition and orientation of the robot. If a robot falls off the edge of the grid the word “LOST”\nshould be printed after the position and orientation.\n\n### Sample Input\n\n````\n5 3\n1 1 E\nRFRFRFRF\n\n3 2 N\nFRRFLLFFRRFLL\n\n0 3 W\nLLFFFLFLFL\n````\n\n### Sample Output\n\n````\n1 1 E\n3 3 N LOST\n2 3 S\n````\n\n## If you run via IntelliJ (or any IDE)\n\nInstall Lombok plugin. This is not required if you use maven to build and test.\n\n## Build and run all unit tests\n\n - Install Java 11 or above\n - Install Maven\n - Run\n \n```\n mvn clean package\n```\n\n## Run custom input instructions and set custom expected output\n\n - Update `instructions_from_exercise_description` file to set any input instructions.\n - Update `expected_output_from_exercise_description` to set any expected results.\n - Run the specific unit test via maven\n \n```\nmvn -Dtest=ProcessingAStreamOfCommands test\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvspiliop%2Fmartian-robots","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvspiliop%2Fmartian-robots","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvspiliop%2Fmartian-robots/lists"}