I recently stumbled upon this screenshot while researching social media on the train. Of course, it was followed by a cascade of spiteful comments, criticizing this fresh programmer鈥檚 attempt to solve a classical problem in computer science. The modulus operation. Now, in a world where AI is replacing programmers by the minute, taking their jobs and revolutionizing the way we think about code, maybe we should be more open to the thoughts of the fresh new blood of the industry? In fact, the above code is a perfect example of a time-memory tradeoff. You鈥檙e trading off your time and at the same time, the computers memory and time as well! Truly a marvelous algorithm! So I went to work to explore this idea of checking if a number is odd or even by only using comparisons to see how well it works in a real world scenario. Since I鈥檓 a great believer in performant code I decided to implement this in the C programming language as it鈥檚 by far the fastest language on the planet to this day (thanks to the visionary genius Dennis Richie). So I started composing /* Copyright 2023. All unauthorized distribution of this source code will be persecuted to the fullest extent of the law*/ #include <stdio.h> #include <stdint.h> #include <stdlib.h> int main(int argc, char* argv[]) { uint8_t number = atoi(argv[1]); // No problems here if (number == 0) printf("even\n"); if (number == 1) printf("odd\n"); if (number == 2) printf("even\n"); if (number == 3) printf("odd\n"); if (number == 4) printf("even\n"); if (number == 5) printf("odd\n"); if (number == 6) printf("even\n"); if (number == 7) printf("odd\n"); if (number == 8) printf("even\n"); if (number == 9) printf("odd\n"); if (number == 10) printf("even\n"); } Beautiful! Lets compile the code, disabling optimizations with /Od to make sure that the pesky compiler doesn鈥檛 interfere with our algorithm. After compiling we can do a quick test of the program we get some positive results: PS > cl.exe /Od program.c PS > .\program.exe 0 even PS > ...
First seen: 2025-12-12 10:42
Last seen: 2025-12-13 01:50