Closed 0xNeshi closed 1 month ago
This one involves floating point math so I was on the fence about proposing it earlier. If the solution uses multiplication to avoid using floats at any point, that might work. However, that approach feels a bit convoluted for what generally is an easier exercise. Just because we can do it doesn't necessarily mean it's a great fit for the track. On the other hand, it can highlight some potential limitations with Cairo and how to work around them so there's some use there. We'll definitely want to provide an instructions-append highlighting the situation going into the exercise.
On the other hand, it can highlight some potential limitations with Cairo and how to work around them so there's some use there.
Exactly this :point_up: Given that one of the main current uses for Cairo is for smart contract development, where there is a need to handle decimals without the use of floating point numbers, I think this would be a great exercise to teach students how do exactly this.
We'll definitely want to provide an instructions-append highlighting the situation going into the exercise.
Agreed.
Updating the description.
@BNAndras I created a PR #290 for this without checking whether the issue was assigned, apologies. Will reassign to myself for clarity
No worries
Problem specification: https://github.com/exercism/problem-specifications/tree/main/exercises/space-age
TODO:
./bin/fetch-configlet && ./bin/configlet create --practice-exercise space-age
Even though this exercise requires the use of floating point numbers (which are not supported by Cairo), we should implement it in a way that works without them. This is usually achieved by the use of "basis points" - in short, the decimal part of the float number is represented by additional decimals being added to the Cairo integer, enabling calculations. Basically all numbers are multiplied by some multiple of the number 10, converting the float number into a regular (but expanded) integer. So
10.34
becomes10.34 * 100 = 1034
.