https://github.com/programmerdan/magrathea2
Magrathea 2.0 -- Our planet building friends have downsized to building mountain ranges. code-golf submission for a question of this name.
https://github.com/programmerdan/magrathea2
Last synced: about 1 year ago
JSON representation
Magrathea 2.0 -- Our planet building friends have downsized to building mountain ranges. code-golf submission for a question of this name.
- Host: GitHub
- URL: https://github.com/programmerdan/magrathea2
- Owner: ProgrammerDan
- License: unlicense
- Created: 2014-03-02T05:23:28.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2014-03-02T05:28:01.000Z (over 12 years ago)
- Last Synced: 2025-02-09T14:24:04.354Z (over 1 year ago)
- Language: Java
- Size: 137 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
Magrathea 2.0
=============
This is a solution to the code-golf problem [Magrathea 2.0](http://codegolf.stackexchange.com/questions/22192/magrathea-2-0-building-mountains). Feel free to fork and improve.
A few usage notes:
**Input**
The input should follow this format (from code-golf problem):
A string of dots and digits providing the basis for the mountain chain. Each string is exactly as long as necessary to support the mountains and each peak is given by a digit instead of a dot, indicating the height of the peak.
Example:
..3..2.
**Output**
An ascii version of the mountain chain.
* Each digit in the input represents exactly one peak (^) at exactly the height indicated by the digit (i.e. 9 is the highest height).
* There must not be additional peaks in the output (i.e. at places where there is a dot in the input).
* Mountains are of triangular shape, i.e. slopes are created using / and \ characters.
* Passes where two mountains overlap are shaped using the character v.
There are a few other requirements in the code-golf problem, that I follow but contribute nothing to understanding.
**Execution**
You use any of the `.java` files in this repository. `Magrathea.java` is standalone, and can be run without any additional inputs. It was my testing harness for development and min-ification. `Magrathea2.java` is a human-readable form of the final submission. Execute it by passing in a valid input sequence as described in the input section. Finally, `M.java` is the code-golf min-ified version of the code. Execute it the same as `Magrathea2.java` by passing it a valid input sequence.
**Closing notes**
This solution weighs in at 407 characters. I'm sure I could do better with some more thought, but this was a lark and I'm pretty pleased with what I was able to do.