Sometimes the answer is not "42"
Good Friday, habra My friends and I have such a tradition - we get together and program together. We used to have such work, but now it’s just a tradition - code generation. We chose a simple task and drew solutions to who is what. The code will be closer to the end of the article, but do not rush to flip down, you must first explain what kind of code it is and how we got to it.
The task itself is to get the number 0x17 in the most sudden way.

Attention! This post offends the sense of beauty and the practice of programming in C. Read, accept and comment at your own risk.
Do you like magic numbers in code? It happens that you look at some code and see a = b ^ 7. Why exactly 7? What is this number, where did it come from, what does it mean? So many questions and so few answers if someone did not bother to comment. There are several ways to resolve this kind of uncertainty:
Why consider any other ways? Take the last one and go! But, as I said, there is a problem - there is not always an adequate way by calculations to show the path to the number. But the task was to get rid of the magic number, and not to do it logically. Moreover, we will bring the problem to the point of absurdity - we will obtain numbers in the most incomprehensible way.
The hardware-software complex in the form of a call to the rand () function decided that we will get rid of the magic number 0x17.
A group of pogromists including me, Viscount, and [REDACTED] set to work.
0x17 ways to get 0x17:
For those who doubt that the indicated task is completed correctly - a link to ideone .
Exercises aimed at the analysis of certain actions, I leave as my own degradation to the reader. But when questions arise, I am ready to answer them in the comments. I also urge everyone to demonstrate their ways ofshooting themselves in the leg with a rocket jump.
By the way, we are looking for a Python developer who knows how to program more clearly than I do. Join now!
The task itself is to get the number 0x17 in the most sudden way.

Attention! This post offends the sense of beauty and the practice of programming in C. Read, accept and comment at your own risk.
Do you like magic numbers in code? It happens that you look at some code and see a = b ^ 7. Why exactly 7? What is this number, where did it come from, what does it mean? So many questions and so few answers if someone did not bother to comment. There are several ways to resolve this kind of uncertainty:
- Leave a comment. But comments for wimps are not our way.
- Make a variable or macro with a speaking name. a = b ^ HEARTBEAT_MASK_BYTE. Already not bad, but it can be better, right?
- Show by calculations the path that led to the given number. Here! This is a great way. But not always applicable, as, for example, in the considered code. In it, 7 is a complete and independent element, which is not the result of any operations.
Why consider any other ways? Take the last one and go! But, as I said, there is a problem - there is not always an adequate way by calculations to show the path to the number. But the task was to get rid of the magic number, and not to do it logically. Moreover, we will bring the problem to the point of absurdity - we will obtain numbers in the most incomprehensible way.
The hardware-software complex in the form of a call to the rand () function decided that we will get rid of the magic number 0x17.
A group of pogromists including me, Viscount, and [REDACTED] set to work.
0x17 ways to get 0x17:
int Ox01 = ~-~-~-~-~-~-~-~-~-' ';
int Ox02 = ((!true)["true"]-(false)["FALSE"])>>true;
int Ox03 = 'X'/2/2^!*"";
int Ox04 = ('0'>>!*"")-!*"";
int Ox05 = (~'!'-~'~')>>!*"">>(2==1==0);
int Ox06 = ('|'||'|'|'|')["||||||||"]%*"error";
int Ox07 = '.'>>!false;
int Ox08 = '\\'>>('!'>>(1<<2));
int Ox09 = '/'-'/'/'/'>>'/'/'/';
int Ox0a = (*"")["yes"]^(*"")["no"];
int Ox0b = *"yes"^*"no";
int Ox0c = '0'/2-!*"";
int Ox0d = ((!'!'+'+')>>true)+(true<>('1'^'2');
int Ox14 = '^'>>('<'^'>');
int Ox15 = *"'"-(' '>>!0);
int Ox16 = '_'>>-~1;
int Ox17 = 010-001+010+010;
For those who doubt that the indicated task is completed correctly - a link to ideone .
Exercises aimed at the analysis of certain actions, I leave as my own degradation to the reader. But when questions arise, I am ready to answer them in the comments. I also urge everyone to demonstrate their ways of
By the way, we are looking for a Python developer who knows how to program more clearly than I do. Join now!