Last updated
Was this helpful?
Last updated
Was this helpful?
Simple solution, doing a linear search.
Note that in Raku we don't have to worry about floating-point misrepresentations of decimals, because decimal fractions are stored as rationals.
If we expect to rescale many prices, a better approach would be to build a look-up array of 101 entries. Memory is cheap, and array indexing is blazing fast.
We can also build this same look-up array by parsing the table as formatted in the task description: