Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pengux/ignite-coding-task
https://github.com/pengux/ignite-coding-task
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/pengux/ignite-coding-task
- Owner: pengux
- Created: 2023-03-22T20:00:39.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2023-03-23T08:41:52.000Z (almost 2 years ago)
- Last Synced: 2023-08-05T16:03:54.135Z (over 1 year ago)
- Language: Go
- Size: 54.7 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Alien Invasion Simulation
[Background](task_description.pdf)
## Assumptions
- City names cannot have whitespace in it
- Two cities that are connected to each other must have roads to each other in the opposite directions, e.g. `Foo north=Bar\nBar south=Foo`
- A city cannot have duplicates in the map input
- For each iteration, an alien can either move OR stay at the same city. This is to avoid the situation when there are 2 aliens left and each one is in a city that is direct connected to each other, thus making the simulation runs forever.
- 2 or more aliens could move to the same city and battle. All aliens will die and the city be destroyed as a result.## Design choices
- Input data for the map is accepted through STDIN and the number of aliens for the simulation is expected to be the first argument
- Only Simulation struct with its methods are public, all other types and methods are private
- Use of `golang.org/x/exp` for generic functions
- Use recursive depth-first search to check for the case where all aliens are isolated from each other.## Usage example
```sh
cat testdata/input.txt | go run ./main.go 10 > output.txt
cat output.txt
````## Fmt, lint, test and coverage
```sh
make fmt
make lint
make test
make test-coverprofile
make show-coverage
```## Can be improved
- Add a fuzz test for the `parseInput` function
- Try to increase test coverage