I stumbled upon this code on Quora.
#include<stdio.h>
main(){
int $[]
={0x69, 0154,107,
'e',0x79,0157, 117,'v',0x6a}
,_,__;_=__^__;__=_;while(_<(-
(~(1<<3))+3)){(_==1<<1||_==
-(~(1<<3))||_==11)?putchar
(*($+(1>>1))):putchar(*(
__++ +$)),(_==1>>1||
_==1<<2||_==(1<<3
)-1)?putchar
(' '):1;
_++;
}
}
The program's output is i like you viji
. It's touching, but cryptic. So I formatted it with indent to get a better idea.
main ()
{
int $[] = { 0x69, 0154, 107,
'e', 0x79, 0157, 117, 'v', 0x6a
}
, _, __;
_ = __ ^ __;
__ = _;
while (_ < (-(~(1 << 3)) + 3))
{
(_ == 1 << 1 || _ ==
-(~(1 << 3)) || _ == 11) ? putchar
(*($ + (1 >> 1))) : putchar (*(__++ + $)), (_ == 1 >> 1 ||
_ == 1 << 2 || _ == (1 << 3) - 1) ? putchar
(' ') : 1;
_++;
}
}
Now it's not so touching, but still a little cryptic.
So, can anybody explain how this code manages to print i like you viji
?
UPDATE:
gave better names to variables $
, _
and __
and expanded ternary operators:
int a[] = { 0x69, 0154, 107, 'e', 0x79, 0157, 117, 'v', 0x6a }, x, y;
x = y ^ y;
y = x;
while (x < (-(~(1 << 3)) + 3))
{
if (x == 1 << 1 || x == -(~(1 << 3)) || x == 11)
putchar (*(a + (1 >> 1)));
else
{
putchar (*(y++ + a));
if (x == 1 >> 1 || x == 1 << 2 || x == (1 << 3) - 1)
putchar (' ');
else
1;
}
x++;
}
What does Red Heart emoji ❤️ mean? The red heart emoji is used in warm emotional contexts. It can be used to express gratitude, love, happiness, hope, or even flirtatiousness.
The main difference in appearance relates to whether the elaborated hearts are shown in pink, or red. There's also design choices where some platforms show ❤️ Red Heart with a gloss and ♥️ Heart Suit as a matte heart, while others show every emoji in matte.
What does ❤️🔥 Heart on Fire emoji mean? The Heart on Fire emoji ❤️🔥 depicts a flaming heart. It can be used to represent passionate love (“burning love”) or intense liking of something.
A heart symbol emoji, used in card games for the hearts suit. In emoji form, this is most commonly used for love, affectiction, romance and positive intentions. Sometimes shown in a slightly darker shade of red than ❤️ Red Heart.
Rewriting the code gives:
int arr1[] = { 'i', 'l', 'k', 'e', 'y', 'o', 'u', 'v', 'j'};
int i0, i1; // Moved to new line instead of using ,
i0 = 0; // i0 = i1 ^ i1;
i1 = i0;
while (i0 < 12) // All strange constant like (1<<3) recalculated
{
if (i0 == 2 || i0 == 9 || i0 == 11) // "? :" replaced by if
{
putchar(*arr1);
}
else
{
putchar (*(arr1 + i1));
++i1;
if (i0 == 0 || i0 == 4 || i0 == 7)
{
putchar(' ');
}
}
i0++;
}
1) Reformat the lines, remove unnecessary spaces, insert spaces for readability
main()
{
int $[] = {0x69, 0154,107, 'e',0x79,0157, 117,'v',0x6a} , _, __;
_ = __^__;
__ = _;
while(_ < (-(~(1<<3))+3))
{
(_ == 1<<1 || _ == -(~(1<<3)) || _ == 11) ?
putchar(*($ + (1>>1))) :
putchar(*(__++ +$)), (_ == 1 >> 1 || _ == 1<<2 || _ == (1<<3)-1) ?
putchar(' ') : 1;
_++;
}
}
2) Rename variable, i.e $ to arr1, _ to i0 and __ to i1
main()
{
int arr1[] = {0x69, 0154,107, 'e',0x79,0157, 117,'v',0x6a} , i0, i1;
i0 = i1^i1;
i1 = i0;
while(i0 < (-(~(1<<3))+3))
{
(i0==1<<1 || i0== -(~(1<<3)) || i0 == 11) ?
putchar(*(arr1+(1>>1))) :
putchar(*(i1++ +arr1)), (i0 == 1 >> 1 || i0 == 1<<2 || i0 == (1<<3)-1) ?
putchar(' ') : 1;
i0++;
}
}
3) Use if-statement instead of ?: This includes breaking the comma-line into two line.
main()
{
int arr1[] = {0x69, 0154,107, 'e',0x79,0157, 117,'v',0x6a} , i0, i1;
i0=i1^i1;
i1=i0;
while(i0 < (-(~(1<<3))+3))
{
if (i0 == 1<<1 ||i0== -(~(1<<3)) || i0 == 11)
{
putchar(*(arr1+(1>>1)));
}
else
{
putchar(*(i1++ +arr1));
if (i0 == 1 >> 1 || i0 == 1<<2 || i0 == (1<<3)-1)
{
putchar(' ');
}
else
{
1; // This does nothing so it can be removed
}
}
i0++;
}
}
4) Recalculate number-constant to better values Examples
0x69 is the same as 'i'
1 << 1 is the same as 2
-(~(1<<3)) is the same as 9
i1 ^ i1 is the same as 0
1>>1 is the same as 0
main()
{
int arr1[] = { 'i', 'l', 'k', 'e', 'y', 'o', 'u', 'v', 'j'} , i0, i1;
i0 = 0;
i1 = i0;
while(i0 < 12)
{
if (i0 == 2 || i0 == 9 || i0 == 11)
{
putchar(*(arr1));
}
else
{
putchar(*(i1++ +arr1));
if (i0 == 0 || i0 == 4 || i0 == 7)
{
putchar(' ');
}
}
i0++;
}
}
5) Some minor final clean up
main()
{
int arr1[] = { 'i', 'l', 'k', 'e', 'y', 'o', 'u', 'v', 'j'}; // Move i0 and
// i1 to nextt line
int i0, i1;
i0 = 0;
i1 = i0;
while(i0 < 12)
{
if (i0 == 2 || i0 == 9 || i0 == 11)
{
putchar(*arr1);
}
else
{
putchar(*(arr1 + i1)); // Splitted into two lines
++i1;
if (i0 == 0 || i0 == 4 || i0 == 7)
{
putchar(' ');
}
}
i0++;
}
}
Now the code is pretty easy to read.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With