Commit graph

13 commits

Author SHA1 Message Date
Bruno BELANYI dc3408524b Make implementation follow assignment rules
Some checks failed
ci/woodpecker/push/check Pipeline failed
The assignment wants us to use exactly *one* O(log(N)) call. Hence the
single usage of `upper_bound`.

It also wants us to use a minimal amount of operations on `K` and `V`
values in the map. Finally it asks us to make the answer simple.
2024-08-24 20:24:42 +01:00
Bruno BELANYI bdccd17936 fixup! Add implementation 2024-08-24 19:29:09 +01:00
Bruno BELANYI 8165fc6f99 Add randomized test
This was especially helpful for my previous attempt at a solution, which
did was more complicated.

The original rules for this assignment are quite silly, I don't think
they really optimize anything, and make understanding the actual
algorithm more difficult than it should be.
2024-08-24 19:27:36 +01:00
Bruno BELANYI 67ed4d4d68 Make test failure more verbose
Outputting the state of the map and this history of operations makes
debugging easier.
2024-08-24 19:27:36 +01:00
Bruno BELANYI 301945884a Add initial tests
Those were the ones I used for the initial implementation.
2024-08-24 19:27:36 +01:00
Bruno BELANYI 9d90916307 Add implementation 2024-08-24 19:27:36 +01:00
Bruno BELANYI 1126ee30d8 Test against fake 'Model' implementation
This removes most of the redundant `for` loops that would appear in
hand-written unit tests, and could potentially open the door to
fuzz-testing/property-test the implementation for a more in-depth
test-suite.
2024-08-24 19:27:36 +01:00
Bruno BELANYI ce7cc4492c Explicitly test for canonicity
This will come in handy later, with more complex test cases.
2024-08-24 19:27:36 +01:00
Bruno BELANYI 5868b5d36c Introduce 'IntervalMapTest' fixture 2024-08-24 19:16:27 +01:00
Bruno BELANYI b23af215e8 Handle empty range insertion 2024-08-24 19:16:27 +01:00
Bruno BELANYI 9d2e062c38 Add test for minimal 'interval_map' type interface
Add `KeyInterface` (respectively `ValueInterface`). Those classes
provide the minimum documented interface for `K` (respectively `V`) in
`interval_map<K, V>`.
2024-08-24 19:16:27 +01:00
Bruno BELANYI e16ecf060b Add given code 2024-08-24 19:16:27 +01:00
Bruno BELANYI 3a182f3d0c Bootstrap project 2024-08-23 21:28:41 +01:00