This question already has an answer here:

To-Do: Come up with a Better Title


Specification:

This challenge is similar to , but with a twist. You goal is to output a finite string that resembles the following string of psuedo-random characters as closely as possible:

BABBBBAAABBAABBBBAABBBAABBBABBAABABABBBBABBBBBBAABABBAABABBBABBBABAAAAABAAAABBAAABAAABBBBAABBABBBAABBBAABAAAABAAAABABABBBBBAABAAABBABAABAABABABBAABAAABBBABBABABBABAABABABBAABBBAABABABBBABAAABAABBBBBAABBBABABAABAABBAABABBBAABBAABAAABABABBBBBAAAAABBBAAABABAABBAABAABAAAABABBBAABBABBBBBAABAAAAABABBBAAAAAABAAAABBABAABABBAAABBBBBBAABABBAAAAAABABBAAABBABBABBBBAAAAAABABBBBBABBBABBAABBABAABAAAAABBAABABBABAABABABBBAAAAAABBBBBABABBBBBAABAABBBAAABABBABBAAABBABBABABBAABBAABAABBBABBABABBABABABABABBBAAABBBBBBABAAAAAABBAABBAABBBAAAAAAABBBBABBBBAABAABAABBABBAAAAAABABBABAAAAABABABAABAABBBAABBABAAABABAAAAABAABABAABBABAABBABBABAABABBBBAAAAAABAAAAAAAAABAABAAAAAAAABABAABBBABAAABABBBBBAAABAAAABBBBBABBBAAAAABBBABBAAAABAABBBBAABBABABAAABAABAAAAABBABBBABBBBAABBABABBAABAAAABAABBABABBBAABABABABAABAAAAABBABBBABBABBAAABAAAABBABABBBABBABABBBBABAAABBBBAAAABBABAAABABBBBBABABBAABBABAAABBABAAAAAABBBAAAABBBAAABABAAAAABBBBABAAABBBAAAABABBBBAAAAABBBBAABAABABBABABBABAAAABBBBAAABAABAAABBBBBBABBABAABABAABBBBBBBBAABBBAABAABABAABBAAABABAABAABBBBBBABBA

The string is 1024 characters long, and consists only of uppercase A and B characters. You must write a program takes up less than or equal to 256 bytes. The above string was generated completely randomly.

This challenge is not code-golf! Since 256 bytes is far too few characters (even for golfing languages), you may output any finite string. Your score is Levenshtein Distance between the 1024 byte string, and the string your program outputs (where the lower score is the best.)


Examples:

Input, Output
1024 "A" characters, 500 Points
1024 "B" characters, 524 Points
1024 characters alternating between "A" and "B" ("A" first), 348 Points
1024 characters alternating between "A" and "B" ("B" first), 346 Points

Notes:

  • The output must be finite and deterministic.

  • Unfortunately, this challenge is limited to languages that can be scored in bytes.

  • You may not substitute A and B for other characters. If your language cannot output such characters, it may not compete.

  • If a language cannot compete, it is still welcome to post non-competing answers. Just make sure to explain how you are scoring the challenge.

  • The winner of this challenge is on a per-language basis, since would be unlikely that an answer from Brainf*** would ever beat one from Jelly.

marked as duplicate by Pavel, Picard, math junkie, Steadybox, TheNumberOne Mar 31 '17 at 23:25

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 2
    I hope you generated that string using a secure random source. If not, it's only a matter of time until somebody reverses the process... – F. George Mar 31 '17 at 20:21
  • @mEQ5aNLrK3lqs3kfSa5HbvsTWe0nIu It should be ;) – Julian Lachniet Mar 31 '17 at 20:22
  • 10
    "Since 256 bytes is far too few characters (even for golfing languages), you may output any finite string." Ehm. Your string only contains two different characters, which is one bit of information per character. That's 1024 bits or 128 bytes, leaving - even without any further compression - 128 bytes to construct the string from the raw information. That should even be enough in non-golfing languages. – Martin Ender Mar 31 '17 at 20:39
  • 7
    The core idea is very interesting, but this really would have benefited from some time in the sandbox, where I'm sure that would have been the first thing for people to point out to you, and where other users could have helped you construct a string that is actually hard to approximate without being frustrating. – Martin Ender Mar 31 '17 at 20:41
  • 1
    Proposal to kill current answers, and lower the maximum allowed distance. – Pavel Mar 31 '17 at 20:50

PHP, 246 printable bytes, distance 0

while($c=ord(base64_decode("vGec7K9+WXdBDEebnIQr5GkrI7WlZyuifOpMuZFfBxTJC5vkFwIaWPywLG3gX3ZpBlpXA+vk4tjazJ2tVcfoGZwHvJNgWgqTmiglNNpeBAEgFOi+IfcHYTzUSDd5rITXKpBu2Ia7Xo8NF9Zo0DhxQejheDyWtDxI/aU/zkpik/Y")[$i++]))echo strtr(sprintf("%08b",$c),10,BA);

or

while($c=base64_decode("vGec7K9+WXdBDEebnIQr5GkrI7WlZyuifOpMuZFfBxTJC5vkFwIaWPywLG3gX3ZpBlpXA+vk4tjazJ2tVcfoGZwHvJNgWgqTmiglNNpeBAEgFOi+IfcHYTzUSDd5rITXKpBu2Ia7Xo8NF9Zo0DhxQejheDyWtDxI/aU/zkpik/Y")[$i++])echo strtr(sprintf("%08b",ord($c)),10,BA);

Remarkable: gnuzip fails on the binary string. gzcompress adds 11 bytes and gzdeflate adds 5.

The fact that no 0x00 byte is in there saves 2 bytes on the first version;
no 0x30 saves 2 bytes on the second one.

  • 1
    gzcompress == 6 Bytes header + gzdeflate just so you know that gzcompress never helps ;) – Christoph Apr 4 '17 at 7:41

Pyth, distance 0

."AB¼gì¯~YwAG+äi+#µ¥g+¢|êL¹_ÉäXü°,mà_viZWëäâØÚÌ­UÇè¼`Z
(%4Ú^ è¾!÷a<ÔH7y¬×*nØ»^
ÖhÐ8qAèáx<´<Hý¥?ÎJbö"

The code is 135 Bytes long

JavaScript (ES6), distance 0

alert("¼gì¯~YwAG+äi+#µ¥g+¢|êL¹_ÉäXü°,mà_viZWëäâØÚÌ­UÇè¼`Z\n(%4Ú^ è¾!÷a<ÔH7y¬×*nØ»^\rÖhÐ8qAèáx<´<Hý¥?ÎJbö".replace(/[^]/g,c=>("0000000"+c.charCodeAt().toString(2)).slice(-8).replace(/./g,x=>"AB"[x])))

Contains lots of unprintables, so get the real code from this pastebin. The code is 232 bytes long.

Bubblegum, distance 0

The code is 187 bytes long:

00000000: 6591 8911 c340 0c02 6b83 fe7b ca63 8915  e....@..k..{.c..
00000010: 33ce 1f90 11b7 b66c 5b92 adfd 998f 91b4  3......l[.......
00000020: 13f6 b8c8 deb7 24cd e7e4 e872 5479 4c4d  ......$....rTyLM
00000030: 22e2 44b0 8900 7905 2c92 6ef1 68b1 48a2  ".D...y.,.n.h.H.
00000040: 2081 b554 9b23 df2c cde8 4d3f e43e 261c   ..T.#.,..M?.>&.
00000050: 0a0b 3331 1274 32cc 7c29 0a7b 14f6 6d7a  ..31.t2.|).{..mz
00000060: f3ba eab5 063c 8ca0 f1ec b284 0baa 51a8  .....<........Q.
00000070: 0cc9 ee7f 40f0 ade8 b821 cb27 bc1a a318  ....@....!.'....
00000080: e637 e50b 17cc 6db8 c070 3b50 c29d 08eb  .7....m..p;P....
00000090: b3e3 9d10 e0af cbe0 1b0d 5530 cc81 ba32  ..........U0...2
000000a0: 8b22 829b e186 d559 22e3 ac90 2bfc 60a1  .".....Y"...+.`.
000000b0: 4333 8ec2 8d3d 19c4 7dd5 17              C3...=..}..

Try it online.

brainfuck, distance 283, 45 bytes

-[+[>+<<]>+]>[>++>+<<-]>[>+.+.-.+..-.+.-.-<-]

Try it online!

brainfuck, distance 0 (non-competing)

Non-competing due to length (1548).

>+[+[<]>>+<+]>+.-.+....-...+..-..+....-..+...-..+...-.+..-..+.-.+.-.+....-.+......-..+.-.+..-..+.-.+...-.+...-.+.-.....+.-....+..-...+.-...+....-..+..-.+...-..+...-..+.-....+.-....+.-.+.-.+.....-..+.-...+..-.+.-..+.-..+.-.+.-.+..-..+.-...+...-.+..-.+.-.+..-.+.-..+.-.+.-.+..-..+...-..+.-.+.-.+...-.+.-...+.-..+.....-..+...-.+.-.+.-..+.-..+..-..+.-.+...-..+..-..+.-...+.-.+.-.+.....-.....+...-...+.-.+.-..+..-..+.-..+.-....+.-.+...-..+..-.+.....-..+.-.....+.-.+...-......+.-....+..-.+.-..+.-.+..-...+......-..+.-.+..-......+.-.+..-...+..-.+..-.+....-......+.-.+.....-.+...-.+..-..+..-.+.-..+.-.....+..-..+.-.+..-.+.-..+.-.+.-.+...-......+.....-.+.-.+.....-..+.-..+...-...+.-.+..-.+..-...+..-.+..-.+.-.+..-..+..-..+.-..+...-.+..-.+.-.+..-.+.-.+.-.+.-.+.-.+...-...+......-.+.-......+..-..+..-..+...-.......+....-.+....-..+.-..+.-..+..-.+..-......+.-.+..-.+.-.....+.-.+.-.+.-..+.-..+...-..+..-.+.-...+.-.+.-.....+.-..+.-.+.-..+..-.+.-..+..-.+..-.+.-..+.-.+....-......+.-.........+.-..+.-........+.-.+.-..+...-.+.-...+.-.+.....-...+.-....+.....-.+...-.....+...-.+..-....+.-..+....-..+..-.+.-.+.-...+.-..+.-.....+..-.+...-.+....-..+..-.+.-.+..-..+.-....+.-..+..-.+.-.+...-..+.-.+.-.+.-.+.-..+.-.....+..-.+...-.+..-.+..-...+.-....+..-.+.-.+...-.+..-.+.-.+....-.+.-...+....-....+..-.+.-...+.-.+.....-.+.-.+..-..+..-.+.-...+..-.+.-......+...-....+...-...+.-.+.-.....+....-.+.-...+...-....+.-.+....-.....+....-..+.-..+.-.+..-.+.-.+..-.+.-....+....-...+.-..+.-...+......-.+..-.+.-..+.-.+.-..+........-..+...-..+.-..+.-.+.-..+..-...+.-.+.-..+.-..+......-.+..-.

Try it online

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