This rar
file, when decompressed, gives a 65024-byte exe
file. Requiring you to output the contents of that file would be absolutely no fun.
But you aren't required to do that. Actually, you're to do something opposite: Output a binary of the same length (65024 bytes), such that no byte equals the byte at same position in the source exe
file.
This is code-golf, shortest code wins.
7 Answers 7
BQN, 81 bytesSBCS
•Out 65024↑1042/"#?ZY>Rg*778c0?74h3g)G?mm5963!1[!1OC+VUb)7]#Z-%&N/D^sUrJaVwc}%! "
Try it online! This is written for CBQN, I removed the •Out
to run it online.
If you split the binary into chunks of 1042, in each chunk at least one printable different from "
is missing. Search program:
pa ← @- ̃'"'⊸≠⊸/' '+↕95
b ← @- ̃•FBytes "fr08v101.exe"
m ← ⊑⌽1000+/{⊑∧ ́¬∧ ̋pa∊⌜< ̆↑‿x⥊b} ̈ 1000+↕1000
•Show m
•Show @+⊑⟜pa ̈ ⊑∘/ ̆⍉¬pa∊⌜< ̆↑‿m⥊b
Pyth, (削除) 55 (削除ここまで) 51 bytes
<3s*L1586"iýy±å7˱â7a£Õ§3mh79B!OÈwc7wÝ%'÷î3awo÷c#
"iýy±å7˱â7a£Õ§3mh79B!OÈwc7wÝ%'÷î3awo÷c# 41-character string literal
*L1586 repeat each character 1586 times
s concatenate
<3 remove the last 3 characters
output with a trailing newline
(Use the PYTHONIOENCODING=latin1
environment variable for correct binary output.)
-
\$\begingroup\$ I feel like the requirement of the environment variable should cost bytes. \$\endgroup\$Makonede– Makonede2022年01月27日 19:08:28 +00:00Commented Jan 27, 2022 at 19:08
-
\$\begingroup\$ @Makonede The environment variable is not required; it just changes the output format to bytes for more convenient verification. The output without it is still correct, just in a different format (65024 UTF-8 characters), exactly like l4m2’s own JavaScript answer and similarly to the answers that return an array of 65024 integers. \$\endgroup\$Anders Kaseorg– Anders Kaseorg2022年01月27日 19:43:35 +00:00Commented Jan 27, 2022 at 19:43
Charcoal, 339 bytes
×ばつTμ[j...|U◨{U8→o4D›⮌⪫ιaYh⎇E"6oρ⌊mMOk...÷›GF⭆B↨⬤U↙⊕✳...Hd¶5‖O$¬÷G≕6TχSυ⟧⌈◨~a3j'▷↘3⊖À70r]e⎇−≔s&g>▶r↔⊗0ηχκη↔S1hLΦ⍘⦄⪪⊕«⪪⊙M»nPOgbO\XKÀ›'◨‽⬤κ➙›\p;▶⸿4P÷χ>Ie...Eσ/N⟲B÷«〜υ⟧χ9✂‽G6⦄7τH¿Þ2⊘ΦW4rO&×ばつσIB⍘↔_%ηA⸿/?⊙/J¡lβ"K▷¬✂6τB%G▶%+%zÀτ(&7\`g7C↙¤⦄ïG↖0⪫ςj]nQ#W¶JeM)⬤χ9c←@7S5w⌊#U;N⌕·NSN1?Σ@s↖$T(5xd«Fαh▶o⌊0l⮌d⮌oH"=d=▷À0j¤q⊙⦃Oε↥∧ψ�¬&≧↷cy/⊞4GE»¦≔✳κ¦'6↘S⎚ü]2Q"¶
Try it online! Link is to verbose version of code. Explanation: Charcoal is very good at printing lots of -
signs. The compressed strings represents all the runs of non--
-signs in the file. Each run of -
s is separated by a newline, thus ensuring that no character of the output matches a character in the file.
UT
Turn off Charcoal's default rectangular output, since we don't want space padding.
I⪪...¶
Split the compressed string 1041\n97...104\n2031
on newlines (they are the golfiest separators), and cast the numbers to integer, which causes Charcoal to output them as that number of -
signs.
A "port" of @ovs's answer is only 90 bytes:
⭆""jVXW⬤tO#^S0➙↷⊟Li§K′′1·βc/o±d74%;{ESM»ΠiρξDςΦcSEenÞ−.7¡ê;q¬⟧l%Π0NoΣ′′≔X=·6d ́Z»〜⪪V⎚+⪪Àk×ばつι512
Try it online! Link is to verbose version of code. Explanation: Simply repeats each character in the compressed string 512 times (I used this instead of @ovs' 1042 because it's a factor of 65024 and larger factors end up covering all of printable ASCII). Conveniently all the characters needed are in Charcoal's "symbols" area which allows the string to be compressed from 127 to 84 bytes. (It's not possible to do this with all letters (either upper or lower case) or all digits.)
JavaScript (ES10), 131 bytes
Returns an array of bytes.
_=>[..."hx53ptn9mgv1xij4xcw506nhi1cxi7w116o3kntsesafc5xwy4w15u6bo7ulphwt"].flatMap(v=>Array(1016).fill(n-=parseInt(v,36)-17),n=187)
How?
This encodes 64 bytes \$b_0\$ to \$b_{63}\$ that are repeated 1016 times each and do not appear in the corresponding chunk of the original file:
187,171,183,197,189,177,171,179,174,175,161,177,161,160,158,171,
155,160,145,157,174,185,179,179,178,194,199,183,182,192,177,193,
209,220,213,227,224,218,206,195,198,187,194,196,201,213,197,182,
165,178,163,179,191,178,189,195,188,198,185,181,173,173,158,146
The values were chosen in such a way that \$|b_k-b_{k-1}|<18\$ for each \$k>0\$, which allows to store the delta values in base 36.
JavaScript (Node.js), 74 bytes SBCS
_=>"[-!^7q7hÏ3á»±{33îg}GÅc¬ïn×ばつO~v#11⁄2+:[¦w".repeat(1414).slice(20)
I'm not sure if this happen for random enough file, or why you use aaaabbbbccccdddd
rather than abcdabcdabcdabcd
even for languages with better support for the latter solution
-
\$\begingroup\$ I haven't tried the
abcdabcd...
pattern for my answer, but it only has a longer lookup string because I limited myself to printable ascii. If I'd use the full byte range, I could use a length 41 string, which is shorter than the one used here. I guess in Javascript repeating each character is a lot longer, so your approach is probably better. \$\endgroup\$ovs– ovs2022年01月27日 16:14:27 +00:00Commented Jan 27, 2022 at 16:14 -
\$\begingroup\$ @ovs Using printable ascii, the minimum loop length is 76 \$\endgroup\$l4m2– l4m22022年01月27日 17:28:55 +00:00Commented Jan 27, 2022 at 17:28
05AB1E, (削除) 260 (削除ここまで) (削除) 70 (削除ここまで) 69 bytes
-1 thanks to Kevin Cruijssen.
•Ý=£ë—ÛāR5Bf·1⁄2" ̈ß¡ ̃v`6BÌÝΩ\∞?ΓтJ&тƒFćO#'œ|Ć‹RÞ1⁄4Á,нìçD|•Ƶ?вŽ4 ́δи ̃Ž3ć(£
Try it online! Outputs as a list of byte values. Alternative link for text output.
Explanation
Similarly to other answers here, this answer uses equal-sized chunks (except the last chunk), each consisting of the same byte throughout the entire chunk (but different bytes throughout the entire output). To get an optimal score, maximizing the chunk size is important – or rather, minimizing the number of chunks.
To do this, I iterated through chunk sizes, starting from \1ドル{,}000\$ and going up. With each iteration, I checked if every byte value was present at least once in at least one chunk.
This happened at \1ドル{,}200\$ bytes per chunk. This meant that each chunk but the last can be up to \1ドル{,}199\$ bytes, with the last chunk being \278ドル\$ bytes. This means there are \54ドル\$ full chunks plus the small chunk at the end, making a total of \55ドル\$ chunks.
Let's verify this: ×ばつ1{,}199+278=65{,}024\$.
Finally, for each chunk, we find the smallest byte that doesn't exist there and repeat it for the length of that chunk, and we're done!
-
\$\begingroup\$
εŽ4´и}
toŽ4´δи
for -1. \$\endgroup\$Kevin Cruijssen– Kevin Cruijssen2022年01月27日 09:03:03 +00:00Commented Jan 27, 2022 at 9:03
PHP (276 chars)
for($d=[-17,-532,-95,-515,-79,463,95,-392,-27,148,$i=-1,808,53,61,15,-665,-5,419,-29,211,46,399,95,569,11,-2,101,-588,11,418,-43,-70,-48,-1887,105,918,-63,-1655,-97,-317,-104,-116,-74,513,53,885,-97,605,150,593,20,-295];++$i<52;)echo str_repeat(chr(150-$d[$i]),2500-$d[++$i]);
Try it Online (using an URL shortener to store the .exe file)
If GMP is available it's 206 chars long :
for($d=str_split(($i=0).gmp_init('1FmB6eDs41MlblmT1hchbcMok3RFjcIJ7OHt8hphdLMPDPgigsPrqHXfc3QEFotYuvL9zfZ3y7ZYkD7nnoSCgAzgJhHEVnl9R6mB5cshIudtpnunsccV',62),4);$i<52;)echo str_repeat(chr($d[$i++]),$d[$i++]);
How is generated this sequence of str_repeat ?
Just by the output of strcspn.
<?php
$data = file_get_contents('raw_file');
$file_length = strlen($data);
$ptr = 0;
while ($ptr < $file_length) {
$max_dist = $max_ord = 0;
for ($i = 0; $i < 256; ++$i) {
$char = chr($i);
$dist = strcspn($data, $char, $ptr);
if ($dist > $max_dist) {
$max_dist = $dist;
$max_ord = $i;
}
}
$ptr += $max_dist;
echo ".str_repeat(chr($max_ord), $max_dist)";
}
Explore related questions
See similar questions with these tags.
rar
file itself, not the extracted contents, right? \$\endgroup\$rar
and theexe
(the extractedexe
is 65024 bytes, but therar
is 64848), but I'm still not sure. Can you please explicitly clarify the question? \$\endgroup\$exe
as possible malware. I think this is just a false positive because the file is so compressed that it looks like encryption, which is potentially suspicious for anexe
, but I still don't suggest running it. \$\endgroup\$