4
\$\begingroup\$

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.

DLosc
40.5k6 gold badges87 silver badges142 bronze badges
asked Jan 26, 2022 at 12:58
\$\endgroup\$
14
  • 5
    \$\begingroup\$ The binary is the rar file itself, not the extracted contents, right? \$\endgroup\$ Commented Jan 26, 2022 at 13:16
  • 8
    \$\begingroup\$ What makes this challenge interesting? A compressed file will look almost purely random, so there doesn't seem to be a strategy to avoid byte values \$\endgroup\$ Commented Jan 26, 2022 at 13:23
  • 6
    \$\begingroup\$ Any reason why you have a rar with exe? Why not just the raw 65,024 bytes? \$\endgroup\$ Commented Jan 26, 2022 at 14:13
  • 8
    \$\begingroup\$ @l4m2 Responding to my request for clarification with a quote from the question which I can read in front of me doesn't help. I can already read that, and it wasn't clear enough to answer my query. I think I have worked out what you meant by looking at the file sizes of the rar and the exe (the extracted exe is 65024 bytes, but the rar is 64848), but I'm still not sure. Can you please explicitly clarify the question? \$\endgroup\$ Commented Jan 26, 2022 at 14:39
  • 5
    \$\begingroup\$ I'd also like to point out that VirusTotal flags the 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 an exe, but I still don't suggest running it. \$\endgroup\$ Commented Jan 26, 2022 at 14:43

7 Answers 7

6
\$\begingroup\$

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
answered Jan 26, 2022 at 15:12
\$\endgroup\$
4
\$\begingroup\$

Pyth, (削除) 55 (削除ここまで) 51 bytes

<3s*L1586"iýy±å7˱â7a£Õ§3mh79B!OÈ­wc7wÝ%'÷î3awo÷c­#

Try it online!

 "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.)

answered Jan 27, 2022 at 2:33
\$\endgroup\$
2
  • \$\begingroup\$ I feel like the requirement of the environment variable should cost bytes. \$\endgroup\$ Commented 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\$ Commented Jan 27, 2022 at 19:43
3
\$\begingroup\$

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.)

answered Jan 26, 2022 at 14:54
\$\endgroup\$
2
\$\begingroup\$

JavaScript (ES10), 131 bytes

Returns an array of bytes.

_=>[..."hx53ptn9mgv1xij4xcw506nhi1cxi7w116o3kntsesafc5xwy4w15u6bo7ulphwt"].flatMap(v=>Array(1016).fill(n-=parseInt(v,36)-17),n=187)

Try it online!

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.

answered Jan 27, 2022 at 1:35
\$\endgroup\$
1
\$\begingroup\$

JavaScript (Node.js), 74 bytes SBCS

_=>"­[-!^7q7hŒƒŽÏ3á»±™{3Ž3îg}GÅc¬ïn×ばつO~v#1›1⁄2+:[¦w".repeat(1414).slice(20)

Try it online!

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

answered Jan 27, 2022 at 15:53
\$\endgroup\$
2
  • \$\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\$ Commented Jan 27, 2022 at 16:14
  • \$\begingroup\$ @ovs Using printable ascii, the minimum loop length is 76 \$\endgroup\$ Commented Jan 27, 2022 at 17:28
1
\$\begingroup\$

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!

answered Jan 27, 2022 at 1:53
\$\endgroup\$
1
  • \$\begingroup\$ εŽ4´и} to Ž4´δи for -1. \$\endgroup\$ Commented Jan 27, 2022 at 9:03
0
\$\begingroup\$

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)";
}
emanresu A
46k5 gold badges110 silver badges254 bronze badges
answered Apr 4, 2022 at 7:25
\$\endgroup\$
0

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.