import/*By_Iyad_Hamid*/std;//>./IH_404.cpp
int main(){auto(p )=+std ::putchar;
;; int(i )=0,o =+ 49, l=10, a=35
,b =+32; for (int c: std:: /*/
in 2024! /*/ string (+ R"(11 111
11 I1 1p141= Ia dT
24= ii RX28=i i1X 28
mpj1Xp@i pj18 p@1Mi1 8Q41Mi18 Q41M
iR8Q41Ma d4Q4 1o1p1a 81111111 )"))
if(c-=o; c>=0 )for (;++i%+7 ||i%
o<1&&!p( +l);c =c >>1)p(c&1 ?a:b
);/*(c) Fair*/ std::print (""
"Page.not.found\n");/*w/C++23*/return{0};}
How was it made?
The image is stored as a bitmask within the string in the middle of the code. For each character in the string, 6 bits are encoded.
The actual C++ program is equivalent to the following:
#include <cstdio>
#include <string>
#include <print>
int main() {
// each 6-character chunk is one line
std::string encoded_string = R"(
1111111 I11p141 =IadT24 =iiRX28
=ii1X28 mpj1Xp@ ipj18p@ 1Mi18Q4
1Mi18Q4 1MiR8Q4 1Mad4Q4 1o1p1a8
1111111
)";
int char_count = 0;
for (char c : encoded_string) {
// ignore whitespace characters, only characters from '1' to '1'+64
if (c < '1')
continue;
// shift back to bit-string
c -= '1';
// loop through each bit
for (int b = 0; b < 6; ++b) {
// check if the b-th bit is 1
if ((c >> b) & 0b1 == 0b1)
std::putchar('#');
else
std::putchar(' ');
}
// board is 6*6 wide, enter newline after 6 encoded characters
if (char_count == 6) {
std::putchar('\n');
char_count = 0;
}
else
++char_count;
}
return 0;
}
The actual values were calculated and inserted by the following python script.
from itertools import batched
code = R"""
import/*By_Iyad_Hamid*/std;//>./IH_404.cpp
int main(){auto(p )=+std ::putchar;
;; int(i )=0,o =+ 49, l=10, a=35
,b =+32; for (int c: std:: /*/
in 2024! /*/ string (+ R"($$ $$$
$$ $$ $$$$$$ $$ $$
$$$ $$ $$$$$$ $$$ $$
$$$$$$$$ $$$$ $$$$$$ $$$$$$$$ $$$$
$$$$$$$$ $$$$ $$$$$$ $$$$$$$$ )"))
if(c-=o; c>=0 )for (;++i%+7 ||i%
o<1&&!p( +l);c =c >>1)p(c&1 ?a:b
);/*(c) Fair*/ std::print (""
"Page.not.found\n");/*w/C++23*/return{0};}
"""
num_bits = 6
char_offset = '1' # ascii range is from this to + 2^num_bits
code_enc_str = ''
for line in code.splitlines():
line = ''.join('1' if i == ' ' else '0' for i in line)
line_enc_str = ''
for char in batched(line, num_bits):
char_bit_str = ''.join(char[::-1]) # reverse bits for endianess (little -> big)
char_num = int(char_bit_str, 2) # bits gets rereversed here
line_enc_str += chr(ord(char_offset) + char_num)
code_enc_str += line_enc_str
code = list(code)
# preforms a[f(:)] = b
def filterIterableAssign(a, b, f):
filter_view = filter(lambda it: f(it[1]), enumerate(a))
for (i,_),v in zip(filter_view, b):
a[i] = v
filterIterableAssign(code, code_enc_str, lambda x: x == '$')
print(''.join(code))