Replies: 4 comments 9 replies
-
@hamarb123 I'm converting this question to a Discussion. |
Beta Was this translation helpful? Give feedback.
-
If I understand your question correctly, there is an algorithmic aspect to the answer, and a storage one.
|
Beta Was this translation helpful? Give feedback.
-
This might be a little off-topic, but I've done something similar with my Julia implementation that I plan to submit in a PR later on. Instead of storing only odd numbers, I generate a bit array of booleans with alternating true-false values by copying the byte 0x55 and truncating to the needed length, rather than going through the bitwise operations needed to set bits in said array. I think this could be considered a "pre-calculation" of sorts, which is why I also want to clarify whether this falls within the bounds of the "base" algorithm as an optimization on even numbers. The rest of the algorithm is exactly the same as the normal base algorithm in the original implementation, the only step changed was that the first step, removing even numbers, is "optimized" or "pre-calculated" out. So, only 2 is a "predetermined" prime. Would this be within the boundaries of a "base algorithm implementation"? |
Beta Was this translation helpful? Give feedback.
-
BTW, I have no issue with the omission of multiples of 2, which of course I do myself. My argument is that 2 is a special case anyway, being the only even prime. I am concerned that algorithms shouldn't use 8X the memory and then be compared to one another directly. So if solution_X uses bits and solution_Y uses bytes, I treat them separately. If an algorithm is fast enough to be a contender, it should use bit storage (either 1/2 or 1 bit) rather than 8 bits per candidate integer. If it's just a cool implementation and not a contender for fastest, then it can use bytes as sort of an "exhibition" implementation. I still think it's important to have a mix. For all I knew, using bytes could be slower because you blow the cache away much faster, so until we had one of each, it was all just theory. So both types are welcome, but to vie for the crown... (Just a random aside, not an official rule or anything!) |
Beta Was this translation helpful? Give feedback.
-
Hi, I've devised an algorithm that is quite fast for the language it is and the base algorithm.
I believe that it is the base algorithm and it follows the rules, but I'm not certain.
It uses 8-bits for each stored value, but instead of storing every value, it only stores for the odd numbers starting at 3. It doesn't have any predefined primes (except 2 like the standard c++ one), so it's not a wheel algorithm.
Is this allowed? Is it 8-bits or 4-bits or other?
I don't see why it wouldn't be, but I wanted to check before I got it ready for PR.
Beta Was this translation helpful? Give feedback.
All reactions