Good Friday to you, habra people. My friends and I have such a tradition - we get together and program together. We used to have this kind of work, but now it's just a tradition - codebredogeneration. We chose a simple task and drew decisions of who is in that much. The code will be closer to the end of the article, but do not rush to scroll down, you must first explain what this code is and how we came to it.
The task itself is to get the number 0x17 in the most unexpected way.
Attention! This post offends the sense of beauty and C programming practice. Read, perceive and comment at your own risk.
')
Do you like magic numbers in code? Here you look at some code and see a = b ^ 7. Why exactly 7? What is the 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 talking name. a = b ^ HEARTBEAT_MASK_BYTE. Already not bad, but you can do better, right?
- Show the calculation path that led to this 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 some other ways? Take the last and go! But, as I said, there is a problem - there is not always an adequate way to calculate the number path with calculations. But the task was to get rid of the magic number, and not to make it logical. Moreover, we will bring the problem to the point of absurdity - we will get the 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.
The mob team of me,
Viscount, and [REDACTED] set about creating.
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<<true); int Ox0e = (-~true^!false)*(true<<(-~true|!false))-!false; int Ox0f = '!'-'^'%*"*"; int Ox10 = -~*" L"^-~*"5Z"; int Ox11 = *"Totally" -* "not" +* "0x17" + true; int Ox12 = -~!*""*-~!*""*-~!*""*-~!*""*-~!*""+~!*""*-~!*""*-~!*""-true; int Ox13 = -compl(-compl true xor true)<<-compl true|'8'>>('1'^'2'); int Ox14 = '^'>>('<'^'>'); int Ox15 = *"'"-(' '>>!0); int Ox16 = '_'>>-~1; int Ox17 = 010-001+010+010;
For those who doubt that the specified 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 if you have questions, I am ready to answer them in the comments. In the same place, I urge everyone to demonstrate their ways of
shooting themselves in the leg to make a rosetjump.
By the way, we are looking for a
Python developer who can program more clearly than me. Join now!