I like this story a lot. My only suggestion would be to maybe somehow “explain” why a bit set is used (to save space or perhaps as a curiosity or whatever).
Great work! Looking forward to implementing this.
I like this story a lot. My only suggestion would be to maybe somehow “explain” why a bit set is used (to save space or perhaps as a curiosity or whatever).
Great work! Looking forward to implementing this.
With that example I get five sublists each with three elements for the longest continuous disjoint sublist, namely:
0 1 106
0 1 194
0 1 198
0 49 194
0 49 198
Do we want to catch all of those, or did I do a boo-boo ?
At first I wanted the length of the longest subarray of integers where no two elements have the same bit set to 1.
That’s what the tests and my example solution do.
| decimal | binary |
|---|---|
194 |
11000010 |
198 |
11000110 |
49 |
00110001 |
1 |
00000001 |
0 |
00000000 |
106 |
01101010 |
221 |
11011101 |
194 |
11000010 |
You can see that the three elements from 1 to 106 do not have the same bit set to 1. This subarray of length 3 is the longest subarray with that property.
In my story I switched 1 and 0 because I think marking the presence with 1 and the absence with 0 is more intuitive.
I will need to modify the tests and the example solution.
@siebenschlaefer are you still interested in moving forward with this exercise? I like it, and I think it would be a good addition.