Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/fforbeck/spreadsheet
Spreasheet Programming Challenge
https://github.com/fforbeck/spreadsheet
functional-programming java8 object-oriented-programming programming-challenge
Last synced: 18 days ago
JSON representation
Spreasheet Programming Challenge
- Host: GitHub
- URL: https://github.com/fforbeck/spreadsheet
- Owner: fforbeck
- Created: 2017-10-21T21:56:16.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-10-23T21:21:46.000Z (over 7 years ago)
- Last Synced: 2024-12-31T03:12:30.614Z (24 days ago)
- Topics: functional-programming, java8, object-oriented-programming, programming-challenge
- Language: Java
- Homepage:
- Size: 23.4 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Programming Challenge
A spreadsheet consists of a two-dimensional array of cells, labeled `A1`, `A2`, etc. Rows are
identified using letters, columns by numbers.
Each cell contains either a sign integer (its value) or an expression. Expressions contain integers,
cell references, and the operators `+`, `-`, `*`, `/` with the usual rules of evaluation – note that the
input is RPN and should be evaluated in stack order.## Description
Write a program in vanilla Java 8 to read a spreadsheet from `stdin`, evaluate the values of all the
cells, and write the output to `stdout`. Your program should detect cyclic dependencies in the input data,
report these in a sensible manner, and exit with a non-zero exit code.The spreadsheet input is defined as follows:
- Line 1 - the width `N` of the spreadsheet
- Line 2 - the height `M` of the spreadsheet
- `N*M` lines each containing an expression which is the value of the corresponding cell
(cells enumerated in the order `A1, A2, ..., A{N}, B1, ...`).You can assume that there are no more than 26 rows (`A-Z`) in the spreadsheet; however there
can be any number of columns (`1-N`).Your program must output its data in the same format, but each cell should be reduced to a single
floating-point value (`String.format(“%.5f”, val)`).## Test vector
![input-output](input-output.png)
## Additional requirements
Final solution should only use the standard Java library and be hosted on Github. Gradle script
should simplify build process and the main usage scenario should be:
- > gradle -q run < input.txt > output.txt
The `-q` flag must be added in order to write only the solution in the output.txt,
otherwise it will include the gradle compilation statuses.--