Skip to content

Challenge submission#1

Open
rafaelbeckel wants to merge 21 commits intostakingrewards:backendfrom
rafaelbeckel:backend
Open

Challenge submission#1
rafaelbeckel wants to merge 21 commits intostakingrewards:backendfrom
rafaelbeckel:backend

Conversation

@rafaelbeckel
Copy link
Copy Markdown

@rafaelbeckel rafaelbeckel commented Jan 13, 2023

This is my final submission. I'll write more details as a comment or edit this description later.

The solution is working and fully functional.

How to run it:

From Docker

❯ docker build -t cell .
docker run cell

From MacOS with Apple Silicon (M1 or M2)

cd dist/macos-arm64
❯ ./cell transactions.csv
...
!fee           | !cost_threshold |             |                         | 
0.09           | 10000           |             |                         | 
...
!cost_too_high |                 |             |                         | 
true           |                 |             |                         | 

❯ ./cell transactions_false.csv
...
!fee           | !cost_threshold |             |                         | 
0.09           | 51000           |             |                         | 
...
!cost_too_high |                 |             |                         | 
false          |                 |             |                         | 

❯ ./cell transactions_invalid.csv
Error: invalid column count on line 7. Expected 5 but found 4

From Rust

❯ cargo run -- transactions.csv
...

Running all test cases (40)

❯ cargo test

Rafael Beckel and others added 20 commits December 24, 2022 19:03
Merry Christmas! I started this today and decided to use Rust, because I've been reading about it for a while but haven't built a program yet. This will be my first try.
At this point, we have a basic table that holds cells objects in a hash map.
No calculations of formulas yet, we just print the raw cell contents in stdout.

The idea is that the map keys will hold a String reference of the cell,
as "A1", "B2", etc. This will make it easy to search them and iterate,
so they can reference each other quite trivially.

Each cell will hold a lexer and a parser (to be implemented), so the
strings will be converted to an internal syntax tree and calculated.
Rust compiler makes it impossible to create circular references or data races, which introduces a big challenge on building data structures that are common in other languages. Because of the ownership model, referencing a shared pointer requires the knowledge of all types of Rust smart pointers, the subtle differences between them, and when each one is suitable. In the end, it was a RefCell wrapped in a Reference Counter, a case that should be avoided if possible, which I tried hard to achieve, but our program is one of such cases where a RefCell is required because we manage shared references to data that can be changed at runtime.
removes thiserror lib and the custom errors file in favor of ad-hoc errors with anyhow
The evaluator is done. I'll finish up cleaning up the tests tomorrow.
it fails with the main challenge, though, because of stack overflow. I'll debug it and allocate the necessary parts to the heap
I finally fixed the Stack Overflow and implemented all the test cases. The result goes beyond the challenge and implements ranges, lte and pretty formatting as well. It took a while, but I'm proud of it.
Comment thread Cargo.toml Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant