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.

\$\endgroup\$
14
  • 5
    \$\begingroup\$ The binary is the rar file itself, not the extracted contents, right? \$\endgroup\$
    – pxeger
    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\$
    – Luis Mendo
    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\$ 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\$
    – pxeger
    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\$
    – pxeger
    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∊⌜<˘↑‿𝕩⥊b}¨ 1000+↕1000
•Show m
•Show @+⊑⟜pa¨ ⊑∘/˘⍉¬pa∊⌜<˘↑‿m⥊b
\$\endgroup\$
4
\$\begingroup\$

Pyth, 55 51 bytes

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

Try it online!

         "iýy±å7˱â7a£Õ§³mh79B!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.)

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

Charcoal, 339 bytes

UTI⪪”}⊞➙×Tμ[j…|U◨{U⁸→º4D›⮌⪫ιaYh⎇E"6ºρ⌊mMOk…÷›GF⭆B↨⬤U↙⊕✳…Hd¶5‖O$¬÷G≕6TχSυ⟧⌈◨~a3j'▷↘3⊖À⁷0r]e⎇⁻≔s&g>▶r↔⊗⁰ηχκη↔S1hLΦ⍘⦄⪪⊕«⪪⊙M»nPOgbO\XKÀ›'◨‽⬤κ➙›\p;▶⸿⁴P÷χ>Ie…Eσ/N⟲B÷«~υ⟧χ9✂‽G⁶⦄⁷τH¿Þ₂⊘ΦW4rO&v×σIB⍘↔_﹪ηA⸿/?⊙/J¡lβ“K▷¬✂6τB﹪G▶﹪⁺%zÀτ(&7\`g⁷C↙¤⦄ïG↖0⪫ςj]nQ#W¶JeM)⬤χ9c←@⁷S5w⌊#U;N⌕·NSN1?Σ@s↖$T(⁵xd«Fαh▶º⌊0l⮌d⮌oH"=d=▷À⁰j¤q⊙⦃Oε↥∧ψ�¬&≧↷cy/⊞⁴GE»¦≔✳κ¦'⁶↘S⎚ü]₂Q”¶

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·β℅±d74%;{ESM»ΠⅈρξDςΦcSEenÞ⁻.⁷¡ê;q¬⟧l﹪Π0№Σ″≔X⁼·⁶d´Z»~⪪V⎚+⪪ÀkO”×ι⁵¹²

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

\$\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.

\$\endgroup\$
1
\$\begingroup\$

JavaScript (Node.js), 74 bytes SBCS

_=>"­[-!^7q7hŒƒŽÏ³á»±™{3޳îg}GÅc¬ïn·×O~v#¹›½+:[¦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

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

05AB1E, 260 70 69 bytes

-1 thanks to Kevin Cruijssen.

•Ý=£ë—ÛāR5Bf·½"¨ß¡˜v`₆BÌÝΩ\∞?ΓтJ&тƒFćO#'œ|Ć‹RÞ¼Á,нìç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: \$54×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!

\$\endgroup\$
1
  • \$\begingroup\$ εŽ4´и} to Ž4´δи for -1. \$\endgroup\$ 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)";
}
\$\endgroup\$
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.