Stream: beginners

Topic: Exercism Space Age


view this post on Zulip Kilian Vounckx (Sep 07 2024 at 11:25):

I am going through the exercism track. When doing the Space Age exercise, I get the correct result with some rounding errors, but because the tests check for exact equality, it doesn't pass. I know the exercise uses Dec instead of floating points, so it should be exact in theory, but different methods of finding the solution will still give different results.

Also the solution is rounded to two digits after the decimal point, but roc does not (yet) have a function to conveniently round to something other than integers. So I had to multiply by 100, round, and divide again which wasn't that nice of an experience

view this post on Zulip Anton (Sep 07 2024 at 12:02):

Seems like the easiest fix would be to change the test to check for a small difference with the target value instead of an exact match.

view this post on Zulip Kilian Vounckx (Sep 07 2024 at 12:09):

True, especially since Num.isApproxEq exists anyway

view this post on Zulip Isaac Van Doren (Sep 07 2024 at 12:11):

@Kilian Vounckx could you make an issue on the exercism/roc repo?

view this post on Zulip Kilian Vounckx (Sep 07 2024 at 12:14):

done

view this post on Zulip Isaac Van Doren (Sep 07 2024 at 12:18):

Thanks!

view this post on Zulip Isaac Van Doren (Sep 07 2024 at 20:46):

Just opened a PR to update this https://github.com/exercism/roc/pull/80


Last updated: Jul 06 2025 at 12:14 UTC